-- cgit 1.2.3-korg From 2a93b9ddf308b6bdd135be182c1b3fa779891840 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 18 Jul 2017 19:40:01 -0400 Subject: Populate seed code Add seed code for sli/core repository Issue: CCSDK-6 Change-Id: Iaeb54c6135a94a6ffec0c7fd96505d72d18aeb00 Signed-off-by: Dan Timoney --- .gitignore | 44 + LICENSE.txt | 22 + README.md | 7 + dblib/.gitignore | 34 + dblib/README.md | 6 + dblib/features/pom.xml | 138 +++ dblib/features/src/main/resources/features.xml | 18 + dblib/installer/pom.xml | 143 +++ .../src/assembly/assemble_installer_zip.xml | 39 + .../src/assembly/assemble_mvnrepo_zip.xml | 29 + .../src/main/resources/scripts/install-feature.sh | 19 + dblib/pom.xml | 114 ++ dblib/provider/pom.xml | 82 ++ .../sdnc/sli/resource/dblib/CachedDataSource.java | 616 ++++++++++ .../resource/dblib/CachedDataSourceFactory.java | 45 + .../sdnc/sli/resource/dblib/DBConfigException.java | 47 + .../sli/resource/dblib/DBLIBResourceActivator.java | 130 +++ .../sdnc/sli/resource/dblib/DBLibConnection.java | 390 +++++++ .../sdnc/sli/resource/dblib/DBLibException.java | 39 + .../sdnc/sli/resource/dblib/DBResourceManager.java | 862 ++++++++++++++ .../sli/resource/dblib/DBResourceObserver.java | 27 + .../sdnc/sli/resource/dblib/DataAccessor.java | 33 + .../sli/resource/dblib/DataSourceComparator.java | 33 + .../sdnc/sli/resource/dblib/DbLibService.java | 46 + .../dblib/DblibConfigurationException.java | 45 + .../dblib/NoAvailableConnectionsException.java | 36 + .../dblib/TerminatingCachedDataSource.java | 82 ++ .../resource/dblib/config/BaseDBConfiguration.java | 104 ++ .../sli/resource/dblib/config/DbConfigPool.java | 56 + .../resource/dblib/config/JDBCConfiguration.java | 31 + .../factory/AbstractDBResourceManagerFactory.java | 39 + .../factory/AbstractResourceManagerFactory.java | 104 ++ .../resource/dblib/factory/DBConfigFactory.java | 100 ++ .../dblib/factory/FactoryNotDefinedException.java | 37 + .../dblib/jdbc/JdbcDBCachedDataSource.java | 249 ++++ .../dblib/jdbc/JdbcDbResourceManagerFactory.java | 186 +++ .../resource/dblib/jdbc/MySQLCachedDataSource.java | 217 ++++ .../sdnc/sli/resource/dblib/pm/PollingWorker.java | 217 ++++ .../sli/resource/dblib/pm/SQLExecutionMonitor.java | 237 ++++ .../dblib/pm/SQLExecutionMonitorObserver.java | 37 + dblib/provider/src/main/resources/dblib.properties | 13 + example-settings.xml | 163 +++ filters/.gitignore | 34 + filters/.sonar/checkstyle.xml | 1 + filters/.sonar/pmd.xml | 67 ++ filters/README | 14 + filters/features/pom.xml | 101 ++ filters/features/src/main/resources/features.xml | 32 + filters/installer/pom.xml | 138 +++ .../src/assembly/assemble_installer_zip.xml | 61 + .../src/assembly/assemble_mvnrepo_zip.xml | 49 + .../src/main/resources/scripts/install-feature.sh | 40 + filters/pom.xml | 81 ++ filters/provider/pom.xml | 94 ++ .../java/org/openecomp/sdnc/filters/Activator.java | 63 ++ .../java/org/openecomp/sdnc/filters/LogFilter.java | 222 ++++ .../filters/RequestResponseDbLoggingFilter.java | 297 +++++ .../sdnc/filters/RequestResponseLoggingFilter.java | 289 +++++ jenkins-settings.xml | 168 +++ pom.xml | 183 +++ sli/.gitignore | 38 + sli/common/pom.xml | 150 +++ .../antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 | 66 ++ .../org/openecomp/sdnc/sli/BreakNodeException.java | 46 + .../openecomp/sdnc/sli/ConfigurationException.java | 45 + .../sdnc/sli/DuplicateValueException.java | 45 + .../java/org/openecomp/sdnc/sli/MessageWriter.java | 302 +++++ .../java/org/openecomp/sdnc/sli/MetricLogger.java | 301 +++++ .../org/openecomp/sdnc/sli/SvcLogicAdaptor.java | 42 + .../java/org/openecomp/sdnc/sli/SvcLogicAtom.java | 174 +++ .../sdnc/sli/SvcLogicBinaryExpression.java | 149 +++ .../org/openecomp/sdnc/sli/SvcLogicContext.java | 248 ++++ .../org/openecomp/sdnc/sli/SvcLogicDblibStore.java | 533 +++++++++ .../org/openecomp/sdnc/sli/SvcLogicException.java | 46 + .../openecomp/sdnc/sli/SvcLogicExprListener.java | 316 ++++++ .../sdnc/sli/SvcLogicExprParserErrorListener.java | 44 + .../org/openecomp/sdnc/sli/SvcLogicExpression.java | 51 + .../sdnc/sli/SvcLogicExpressionFactory.java | 99 ++ .../openecomp/sdnc/sli/SvcLogicFunctionCall.java | 80 ++ .../java/org/openecomp/sdnc/sli/SvcLogicGraph.java | 184 +++ .../org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java | 34 + .../org/openecomp/sdnc/sli/SvcLogicJdbcStore.java | 895 +++++++++++++++ .../java/org/openecomp/sdnc/sli/SvcLogicNode.java | 456 ++++++++ .../org/openecomp/sdnc/sli/SvcLogicParser.java | 598 ++++++++++ .../sdnc/sli/SvcLogicParserException.java | 43 + .../org/openecomp/sdnc/sli/SvcLogicRecorder.java | 30 + .../org/openecomp/sdnc/sli/SvcLogicResource.java | 53 + .../java/org/openecomp/sdnc/sli/SvcLogicStore.java | 37 + .../openecomp/sdnc/sli/SvcLogicStoreFactory.java | 96 ++ .../openecomp/sdnc/sli/SvcLogicVariableTerm.java | 77 ++ sli/common/src/main/resources/crAseNetwork.sql | 82 ++ sli/common/src/main/resources/svclogic.xsd | 334 ++++++ sli/common/src/main/yang/ase-network.yang | 179 +++ sli/common/src/main/yang/ase-type.yang | 561 +++++++++ sli/common/src/main/yang/ase.yang | 558 +++++++++ .../openecomp/sdnc/sli/SvcLogicContextTest.java | 69 ++ .../sdnc/sli/SvcLogicExpressionParserTest.java | 69 ++ .../org/openecomp/sdnc/sli/SvcLogicParserTest.java | 163 +++ .../test/resources/EvcActivateSvcLogic_v100.xml | 70 ++ .../src/test/resources/EvcPortSvcLogic_v100.xml | 263 +++++ .../test/resources/ReleasePortSvcLogic_v101.xml | 89 ++ .../src/test/resources/bad_neutron_logic_v11.xml | 61 + sli/common/src/test/resources/expression.tests | 19 + sli/common/src/test/resources/mergetest.xml | 54 + .../src/test/resources/neutron_logic_v10.xml | 56 + sli/common/src/test/resources/nonsense.xml | 24 + sli/common/src/test/resources/parser-bad.tests | 3 + sli/common/src/test/resources/parser-good.tests | 2 + .../src/test/resources/simplelogger.properties | 24 + sli/common/src/test/resources/svclogic.properties | 26 + sli/common/src/test/resources/svclogic.sh | 32 + sli/common/src/test/resources/svclogic.xsd | 323 ++++++ sli/features/pom.xml | 137 +++ sli/features/src/main/resources/features.xml | 39 + sli/installer/pom.xml | 149 +++ .../src/assembly/assemble_installer_zip.xml | 59 + .../src/assembly/assemble_mvnrepo_zip.xml | 49 + .../src/main/resources/scripts/install-feature.sh | 40 + sli/pom.xml | 65 ++ sli/provider/pom.xml | 96 ++ .../sdnc/sli/provider/BlockNodeExecutor.java | 75 ++ .../sdnc/sli/provider/BreakNodeExecutor.java | 42 + .../sdnc/sli/provider/CallNodeExecutor.java | 165 +++ .../sdnc/sli/provider/ConfigureNodeExecutor.java | 248 ++++ .../sdnc/sli/provider/DeleteNodeExecutor.java | 101 ++ .../sdnc/sli/provider/ExecuteNodeExecutor.java | 161 +++ .../sdnc/sli/provider/ExistsNodeExecutor.java | 105 ++ .../sdnc/sli/provider/ForNodeExecutor.java | 109 ++ .../sdnc/sli/provider/GetResourceNodeExecutor.java | 134 +++ .../sdnc/sli/provider/IsAvailableNodeExecutor.java | 103 ++ .../openecomp/sdnc/sli/provider/MdsalHelper.java | 1186 ++++++++++++++++++++ .../sdnc/sli/provider/NotifyNodeExecutor.java | 102 ++ .../sdnc/sli/provider/RecordNodeExecutor.java | 119 ++ .../sdnc/sli/provider/ReleaseNodeExecutor.java | 100 ++ .../sdnc/sli/provider/ReserveNodeExecutor.java | 114 ++ .../sdnc/sli/provider/ReturnNodeExecutor.java | 78 ++ .../sdnc/sli/provider/SaveNodeExecutor.java | 142 +++ .../sdnc/sli/provider/SetNodeExecutor.java | 189 ++++ .../sdnc/sli/provider/SvcLogicActivator.java | 225 ++++ .../sdnc/sli/provider/SvcLogicAdaptorFactory.java | 86 ++ .../sli/provider/SvcLogicExpressionResolver.java | 605 ++++++++++ .../sdnc/sli/provider/SvcLogicNodeExecutor.java | 110 ++ .../sdnc/sli/provider/SvcLogicService.java | 76 ++ .../sdnc/sli/provider/SvcLogicServiceImpl.java | 273 +++++ .../sdnc/sli/provider/SwitchNodeExecutor.java | 63 ++ .../sdnc/sli/provider/UpdateNodeExecutor.java | 136 +++ .../sdnc/sli/provider/WhileNodeExecutor.java | 75 ++ .../org/openecomp/sdnc/sli/provider/BadPlugin.java | 56 + .../sdnc/sli/provider/ExecuteNodeExecutorTest.java | 57 + .../sdnc/sli/provider/LunchSelectorPlugin.java | 78 ++ .../sdnc/sli/provider/MdsalHelperTest.java | 43 + .../sdnc/sli/provider/MdsalHelperTesterUtil.java | 37 + .../openecomp/sdnc/sli/provider/PluginTest.java | 106 ++ .../provider/SvcLogicExpressionResolverTest.java | 123 ++ .../sli/provider/SvcLogicGraphExecutorTest.java | 212 ++++ .../sdnc/sli/provider/VoidDummyPlugin.java | 38 + sli/provider/src/test/resources/executor.tests | 2 + sli/provider/src/test/resources/expression.tests | 24 + .../src/test/resources/l3sdn_logic_v10.xml | 74 ++ .../src/test/resources/simplelogger.properties | 22 + .../src/test/resources/svclogic.properties | 26 + sli/recording/pom.xml | 77 ++ .../openecomp/sdnc/sli/recording/FileRecorder.java | 117 ++ .../sdnc/sli/recording/RecordingActivator.java | 75 ++ .../sdnc/sli/recording/Slf4jRecorder.java | 130 +++ .../src/main/resources/svclogic.properties | 26 + sliPluginUtils/.gitignore | 34 + sliPluginUtils/.sonar/checkstyle.xml | 1 + sliPluginUtils/.sonar/pmd.xml | 67 ++ sliPluginUtils/features/pom.xml | 127 +++ .../features/src/main/resources/features.xml | 39 + sliPluginUtils/installer/pom.xml | 138 +++ .../src/assembly/assemble_installer_zip.xml | 59 + .../src/assembly/assemble_mvnrepo_zip.xml | 49 + .../src/main/resources/scripts/install-feature.sh | 40 + sliPluginUtils/pom.xml | 41 + sliPluginUtils/provider/pom.xml | 85 ++ .../openecomp/sdnc/sli/SliPluginUtils/DME2.java | 111 ++ .../sdnc/sli/SliPluginUtils/SliPluginUtils.java | 754 +++++++++++++ .../SliPluginUtils/SliPluginUtilsActivator.java | 95 ++ .../sdnc/sli/SliPluginUtils/SliStringUtils.java | 396 +++++++ .../sli/SliPluginUtils/SvcLogicContextList.java | 210 ++++ .../sli/SliPluginUtils/SvcLogicContextObject.java | 28 + .../SliPluginUtils/commondatastructures/YesNo.java | 51 + .../commondatastructures/package-info.java | 28 + .../sli/SliPluginUtils/CheckParametersTest.java | 116 ++ .../sdnc/sli/SliPluginUtils/Dme2Test.java | 109 ++ .../SliPluginUtils_StaticFunctionsTest.java | 250 +++++ .../SliPluginUtils/SliPluginUtils_ctxSortList.java | 96 ++ .../SliPluginUtils_ctxSortListTest.java | 97 ++ .../sli/SliPluginUtils/SliStringUtilsTest.java | 244 ++++ .../SliPluginUtils/SvcLogicContextListTest.java | 307 +++++ sliapi/.gitignore | 34 + sliapi/README.txt | 35 + sliapi/features/pom.xml | 134 +++ sliapi/features/src/main/resources/features.xml | 39 + sliapi/installer/pom.xml | 137 +++ .../src/assembly/assemble_installer_zip.xml | 59 + .../src/assembly/assemble_mvnrepo_zip.xml | 55 + .../src/main/resources/scripts/install-feature.sh | 40 + sliapi/model/pom.xml | 79 ++ sliapi/model/src/main/yang/sliapi.yang | 111 ++ sliapi/pom.xml | 61 + sliapi/provider/pom.xml | 144 +++ .../impl/rev140523/SliapiProviderModule.java | 59 + .../rev140523/SliapiProviderModuleFactory.java | 34 + .../org/openecomp/sdnc/sliapi/SliapiHelper.java | 40 + .../org/openecomp/sdnc/sliapi/sliapiProvider.java | 557 +++++++++ .../src/main/resources/initial/sliapi-provider.xml | 72 ++ .../src/main/yang/sliapi-provider-impl.yang | 61 + src/site/apt/nodes.apt | 953 ++++++++++++++++ src/site/site.xml | 31 + version.properties | 15 + 213 files changed, 28390 insertions(+) create mode 100755 .gitignore create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100755 dblib/.gitignore create mode 100755 dblib/README.md create mode 100755 dblib/features/pom.xml create mode 100755 dblib/features/src/main/resources/features.xml create mode 100755 dblib/installer/pom.xml create mode 100755 dblib/installer/src/assembly/assemble_installer_zip.xml create mode 100755 dblib/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 dblib/installer/src/main/resources/scripts/install-feature.sh create mode 100755 dblib/pom.xml create mode 100755 dblib/provider/pom.xml create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSource.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBConfigException.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLIBResourceActivator.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibConnection.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibException.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceObserver.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataAccessor.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataSourceComparator.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DbLibService.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DblibConfigurationException.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/NoAvailableConnectionsException.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/TerminatingCachedDataSource.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/BaseDBConfiguration.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/JDBCConfiguration.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/FactoryNotDefinedException.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDbResourceManagerFactory.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/MySQLCachedDataSource.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/PollingWorker.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitor.java create mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitorObserver.java create mode 100755 dblib/provider/src/main/resources/dblib.properties create mode 100644 example-settings.xml create mode 100755 filters/.gitignore create mode 100755 filters/.sonar/checkstyle.xml create mode 100755 filters/.sonar/pmd.xml create mode 100755 filters/README create mode 100755 filters/features/pom.xml create mode 100644 filters/features/src/main/resources/features.xml create mode 100755 filters/installer/pom.xml create mode 100644 filters/installer/src/assembly/assemble_installer_zip.xml create mode 100644 filters/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 filters/installer/src/main/resources/scripts/install-feature.sh create mode 100644 filters/pom.xml create mode 100755 filters/provider/pom.xml create mode 100644 filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java create mode 100644 filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java create mode 100644 filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java create mode 100644 filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java create mode 100644 jenkins-settings.xml create mode 100755 pom.xml create mode 100755 sli/.gitignore create mode 100755 sli/common/pom.xml create mode 100755 sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java create mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java create mode 100644 sli/common/src/main/resources/crAseNetwork.sql create mode 100755 sli/common/src/main/resources/svclogic.xsd create mode 100755 sli/common/src/main/yang/ase-network.yang create mode 100755 sli/common/src/main/yang/ase-type.yang create mode 100755 sli/common/src/main/yang/ase.yang create mode 100644 sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java create mode 100644 sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java create mode 100644 sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java create mode 100644 sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml create mode 100644 sli/common/src/test/resources/EvcPortSvcLogic_v100.xml create mode 100644 sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml create mode 100644 sli/common/src/test/resources/bad_neutron_logic_v11.xml create mode 100755 sli/common/src/test/resources/expression.tests create mode 100644 sli/common/src/test/resources/mergetest.xml create mode 100644 sli/common/src/test/resources/neutron_logic_v10.xml create mode 100644 sli/common/src/test/resources/nonsense.xml create mode 100755 sli/common/src/test/resources/parser-bad.tests create mode 100755 sli/common/src/test/resources/parser-good.tests create mode 100644 sli/common/src/test/resources/simplelogger.properties create mode 100644 sli/common/src/test/resources/svclogic.properties create mode 100644 sli/common/src/test/resources/svclogic.sh create mode 100755 sli/common/src/test/resources/svclogic.xsd create mode 100755 sli/features/pom.xml create mode 100644 sli/features/src/main/resources/features.xml create mode 100755 sli/installer/pom.xml create mode 100644 sli/installer/src/assembly/assemble_installer_zip.xml create mode 100644 sli/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 sli/installer/src/main/resources/scripts/install-feature.sh create mode 100755 sli/pom.xml create mode 100755 sli/provider/pom.xml create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BlockNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BreakNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ForNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/MdsalHelper.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReturnNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicAdaptorFactory.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicServiceImpl.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java create mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java create mode 100755 sli/provider/src/test/resources/executor.tests create mode 100755 sli/provider/src/test/resources/expression.tests create mode 100644 sli/provider/src/test/resources/l3sdn_logic_v10.xml create mode 100644 sli/provider/src/test/resources/simplelogger.properties create mode 100644 sli/provider/src/test/resources/svclogic.properties create mode 100755 sli/recording/pom.xml create mode 100644 sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/FileRecorder.java create mode 100644 sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/RecordingActivator.java create mode 100644 sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/Slf4jRecorder.java create mode 100644 sli/recording/src/main/resources/svclogic.properties create mode 100755 sliPluginUtils/.gitignore create mode 100755 sliPluginUtils/.sonar/checkstyle.xml create mode 100755 sliPluginUtils/.sonar/pmd.xml create mode 100755 sliPluginUtils/features/pom.xml create mode 100644 sliPluginUtils/features/src/main/resources/features.xml create mode 100755 sliPluginUtils/installer/pom.xml create mode 100644 sliPluginUtils/installer/src/assembly/assemble_installer_zip.xml create mode 100644 sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh create mode 100755 sliPluginUtils/pom.xml create mode 100755 sliPluginUtils/provider/pom.xml create mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/DME2.java create mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils.java create mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtilsActivator.java create mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtils.java create mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextList.java create mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextObject.java create mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/YesNo.java create mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/package-info.java create mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/CheckParametersTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/Dme2Test.java create mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_StaticFunctionsTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortList.java create mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortListTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtilsTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextListTest.java create mode 100755 sliapi/.gitignore create mode 100755 sliapi/README.txt create mode 100755 sliapi/features/pom.xml create mode 100644 sliapi/features/src/main/resources/features.xml create mode 100755 sliapi/installer/pom.xml create mode 100644 sliapi/installer/src/assembly/assemble_installer_zip.xml create mode 100644 sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 sliapi/installer/src/main/resources/scripts/install-feature.sh create mode 100755 sliapi/model/pom.xml create mode 100755 sliapi/model/src/main/yang/sliapi.yang create mode 100755 sliapi/pom.xml create mode 100755 sliapi/provider/pom.xml create mode 100644 sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/sliapi/provider/impl/rev140523/SliapiProviderModule.java create mode 100644 sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java create mode 100644 sliapi/provider/src/main/java/org/openecomp/sdnc/sliapi/SliapiHelper.java create mode 100644 sliapi/provider/src/main/java/org/openecomp/sdnc/sliapi/sliapiProvider.java create mode 100644 sliapi/provider/src/main/resources/initial/sliapi-provider.xml create mode 100755 sliapi/provider/src/main/yang/sliapi-provider-impl.yang create mode 100644 src/site/apt/nodes.apt create mode 100644 src/site/site.xml create mode 100644 version.properties diff --git a/.gitignore b/.gitignore new file mode 100755 index 000000000..f9801b8c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +.checkstyle +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## antlr4 generated files ## +ExprGrammarBaseListener.java +ExprGrammarLexer.java +ExprGrammarListener.java +ExprGrammarParser.java +ExprGrammar.tokens +ExprGrammarLexer.tokens + +# BlackDuck generated file +sdnc-core_bdio.jsonld +blackDuckHubProjectName.txt +blackDuckHubProjectVersionName.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..3ea5081a0 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ diff --git a/README.md b/README.md new file mode 100644 index 000000000..50134aea4 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +This source repository contains the code for the core SDN Controller components. +To compile this code: + +1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the OpenECOMP repositories and OpenDaylight repositories. See example-settings.xml for an example. + +2. To compile, run "mvn clean install". + diff --git a/dblib/.gitignore b/dblib/.gitignore new file mode 100755 index 000000000..b73caf31e --- /dev/null +++ b/dblib/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/dblib/README.md b/dblib/README.md new file mode 100755 index 000000000..98e8f0c6f --- /dev/null +++ b/dblib/README.md @@ -0,0 +1,6 @@ +DBLIB Utility +--------------------- + +DBLIB utility is designed as a high availability connection manager. +It is configured to use multiple databases, and based on the configured rules +always provide the connection to te active database. diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml new file mode 100755 index 000000000..6c174b1c8 --- /dev/null +++ b/dblib/features/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + + dblib + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + dblib-features + DBLIB Adaptor - Features + + jar + + + + + + org.openecomp.sdnc.core + dblib-provider + ${project.version} + + + + commons-lang + commons-lang + 2.6 + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + + + org.opendaylight.odlparent + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/dblib/features/src/main/resources/features.xml b/dblib/features/src/main/resources/features.xml new file mode 100755 index 000000000..0c3e8fe38 --- /dev/null +++ b/dblib/features/src/main/resources/features.xml @@ -0,0 +1,18 @@ + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + + odl-mdsal-broker + wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=com.mysql.*&overwrite=merge + mvn:org.openecomp.sdnc.core/dblib-provider/${project.version} + mvn:mysql/mysql-connector-java/${mysql.connector.version} + + + diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml new file mode 100755 index 000000000..9da6a459f --- /dev/null +++ b/dblib/installer/pom.xml @@ -0,0 +1,143 @@ + + + 4.0.0 + + dblib + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + dblib-installer + DBLIB Adaptor - Karaf Installer + pom + + + sdnc-dblib + sdnc-dblib + mvn:org.openecomp.sdnc.core/dblib-features/${project.version}/xml/features + false + + + + + + org.openecomp.sdnc.core + dblib-features + ${project.version} + features + xml + + + * + * + + + + + + org.openecomp.sdnc.core + dblib-provider + ${project.version} + + + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.openecomp.sdnc,org.apache.tomcat + sli-common,sli-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/dblib/installer/src/assembly/assemble_installer_zip.xml b/dblib/installer/src/assembly/assemble_installer_zip.xml new file mode 100755 index 000000000..a6a22a9ba --- /dev/null +++ b/dblib/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,39 @@ + + + + bin + + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/dblib/installer/src/assembly/assemble_mvnrepo_zip.xml b/dblib/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100755 index 000000000..d96c9f402 --- /dev/null +++ b/dblib/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,29 @@ + + + + bin + + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/dblib/installer/src/main/resources/scripts/install-feature.sh b/dblib/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..16b5be8c4 --- /dev/null +++ b/dblib/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/dblib/pom.xml b/dblib/pom.xml new file mode 100755 index 000000000..78af665af --- /dev/null +++ b/dblib/pom.xml @@ -0,0 +1,114 @@ + + + + org.openecomp.sdnc.core + sdnc-core + 0.0.1-SNAPSHOT + + + + 4.0.0 + pom + org.openecomp.sdnc.core + dblib + + + DBLIB Adaptor + The DBLIB adaptor allows service logic to access persistent data in a local sql database + + 0.0.1-SNAPSHOT + + + + + + org.codehaus.mojo + + license-maven-plugin + + 1.9 + + + + apache_v2 + + 2016 + + AT&T + + openecomp + + + + src/main/java + + + + + + *.png + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compile.plugin.version} + + ${java.version.source} + ${java.version.target} + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10 + + + + aggregate + + aggregate + + site + + + + + + maven-source-plugin + 2.1.1 + + + bundle-sources + package + + + jar-no-fork + + + test-jar-no-fork + + + + + + + + + + AT&T + + + provider + features + installer + + diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml new file mode 100755 index 000000000..b5acc7e14 --- /dev/null +++ b/dblib/provider/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + org.openecomp.sdnc.core + dblib + 0.0.1-SNAPSHOT + + dblib-provider + 0.0.1-SNAPSHOT + bundle + DBLIB Adaptor - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + 4.11 + test + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + mysql + mysql-connector-java + ${mysql.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.openecomp.sdnc.sli.resource.dblib + org.openecomp.sdnc.sli.resource.dblib.DBLIBResourceActivator + org.openecomp.sdnc.sli.resource.dblib;version=${project.version} + + * + true + + + + + + + + + diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSource.java new file mode 100644 index 000000000..58a0aeb11 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSource.java @@ -0,0 +1,616 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.io.Closeable; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.sql.Blob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Observer; + +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetProvider; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitor; +import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitorObserver; +import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitor.TestObject; +import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; + + +/** + * @version $Revision: 1.13 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ + +public abstract class CachedDataSource implements DataSource, SQLExecutionMonitorObserver +{ + private static Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); + + protected static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; + + protected long CONN_REQ_TIMEOUT = 30L; + protected long DATA_REQ_TIMEOUT = 100L; + + private final SQLExecutionMonitor monitor; + protected DataSource ds = null; + protected String connectionName = null; + protected boolean initialized = false; + + private long interval = 1000; + private long initialDelay = 5000; + private long expectedCompletionTime = 50L; + private boolean canTakeOffLine = true; + private long unprocessedFailoverThreshold = 3L; + + private long nextErrorReportTime = 0L; + + private String globalHostName = null; + + + public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException + { + configure(jdbcElem); + monitor = new SQLExecutionMonitor(this); + } + + protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; + /* (non-Javadoc) + * @see javax.sql.DataSource#getConnection() + */ + public Connection getConnection() throws SQLException + { + return ds.getConnection(); + } + + public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable + { + TestObject testObject = null; + testObject = monitor.registerRequest(); + + Connection connection = null; + try { + connection = this.getConnection(); + if(connection == null ) { + throw new SQLException("Connection invalid"); + } + if(LOGGER.isDebugEnabled()) + LOGGER.debug("Obtained connection <" + connectionName + ">: "+connection.toString()); + return executePreparedStatement(connection, statement, arguments, true); + } finally { + try { + if(connection != null && !connection.isClosed()) { + connection.close(); + } + } catch(Throwable exc) { + // the exception not monitored + } finally { + connection = null; + } + + monitor.deregisterReguest(testObject); + } + } + + public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable + { + TestObject testObject = null; + testObject = monitor.registerRequest(); + + Connection connection = null; + try { + connection = this.getConnection(); + if(connection == null ) { + throw new SQLException("Connection invalid"); + } + if(LOGGER.isDebugEnabled()) + LOGGER.debug("Obtained connection <" + connectionName + ">: "+connection.toString()); + return executeUpdatePreparedStatement(connection, statement, arguments, true); + } finally { + try { + if(connection != null && !connection.isClosed()) { + connection.close(); + } + } catch(Throwable exc) { + // the exception not monitored + } finally { + connection = null; + } + + monitor.deregisterReguest(testObject); + } + } + + CachedRowSet executePreparedStatement(Connection conn, String statement, ArrayList arguments, boolean close) throws SQLException, Throwable + { + long time = System.currentTimeMillis(); + + CachedRowSet data = null; + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL Statement: "+ statement); + if(arguments != null && !arguments.isEmpty()) { + LOGGER.debug("Argunments: "+ Arrays.toString(arguments.toArray())); + } + } + + ResultSet rs = null; + try { + data = RowSetProvider.newFactory().createCachedRowSet(); + PreparedStatement ps = conn.prepareStatement(statement); + if(arguments != null) + { + for(int i = 0, max = arguments.size(); i < max; i++){ + ps.setObject(i+1, arguments.get(i)); + } + } + rs = ps.executeQuery(); + data.populate(rs); + // Point the rowset Cursor to the start + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL SUCCESS. rows returned: " + data.size()+ ", time(ms): "+ (System.currentTimeMillis() - time)); } + } catch(SQLException exc){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); + } + try { conn.rollback(); } catch(Throwable thr){} + if(arguments != null && !arguments.isEmpty()) { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); + } else { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); + } + throw exc; + } catch(Throwable exc){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); + } + if(arguments != null && !arguments.isEmpty()) { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); + } else { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); + } + throw exc; // new SQLException(exc); + } finally { + + try { + if(rs != null){ + rs.close(); + rs = null; + } + } catch(Exception exc){ + + } + try { + if(conn != null && close){ + conn.close(); + conn = null; + } + } catch(Exception exc){ + + } + } + + return data; + } + + boolean executeUpdatePreparedStatement(Connection conn, String statement, ArrayList arguments, boolean close) throws SQLException, Throwable { + long time = System.currentTimeMillis(); + + CachedRowSet data = null; + + int rs = -1; + try { + data = RowSetProvider.newFactory().createCachedRowSet(); + PreparedStatement ps = conn.prepareStatement(statement); + if(arguments != null) + { + for(int i = 0, max = arguments.size(); i < max; i++){ + if(arguments.get(i) instanceof Blob) { + ps.setBlob(i+1, (Blob)arguments.get(i)); + } else if(arguments.get(i) instanceof Timestamp) { + ps.setTimestamp(i+1, (Timestamp)arguments.get(i)); + } else if(arguments.get(i) instanceof Integer) { + ps.setInt(i+1, (Integer)arguments.get(i)); + } else if(arguments.get(i) instanceof Long) { + ps.setLong(i+1, (Long)arguments.get(i)); + } else if(arguments.get(i) instanceof Date) { + ps.setDate(i+1, (Date)arguments.get(i)); + } else { + ps.setObject(i+1, arguments.get(i)); + } + } + } + rs = ps.executeUpdate(); + // Point the rowset Cursor to the start + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL SUCCESS. rows returned: " + data.size()+ ", time(ms): "+ (System.currentTimeMillis() - time)); + } + } catch(SQLException exc){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); + } + try { conn.rollback(); } catch(Throwable thr){} + if(arguments != null && !arguments.isEmpty()) { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); + } else { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); + } + throw exc; + } catch(Throwable exc){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); + } + if(arguments != null && !arguments.isEmpty()) { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); + } else { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); + } + throw exc; // new SQLException(exc); + } finally { + try { + if(conn != null && close){ + conn.close(); + conn = null; + } + } catch(Exception exc){ + + } + } + + return true; + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) + */ + public Connection getConnection(String username, String password) + throws SQLException + { + return ds.getConnection(username, password); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getLogWriter() + */ + public PrintWriter getLogWriter() throws SQLException + { + return ds.getLogWriter(); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getLoginTimeout() + */ + public int getLoginTimeout() throws SQLException + { + return ds.getLoginTimeout(); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) + */ + public void setLogWriter(PrintWriter out) throws SQLException + { + ds.setLogWriter(out); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#setLoginTimeout(int) + */ + public void setLoginTimeout(int seconds) throws SQLException + { + ds.setLoginTimeout(seconds); + } + + + public final String getDbConnectionName(){ + return connectionName; + } + + protected final void setDbConnectionName(String name) { + this.connectionName = name; + } + + public void cleanUp(){ + if(ds != null && ds instanceof Closeable) { + try { + ((Closeable)ds).close(); + } catch (IOException e) { + LOGGER.warn(e.getMessage()); + } + } + ds = null; + monitor.deleteObservers(); + monitor.cleanup(); + } + + public boolean isInitialized() { + return initialized; + } + + protected boolean testConnection(){ + return testConnection(false); + } + + protected boolean testConnection(boolean error_level){ + Connection conn = null; + ResultSet rs = null; + Statement stmt = null; + try + { + Boolean readOnly = null; + String hostname = null; + conn = this.getConnection(); + stmt = conn.createStatement(); + rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); //("SELECT 1 FROM DUAL"); //"select BANNER from SYS.V_$VERSION" + while(rs.next()) + { + readOnly = rs.getBoolean(1); + hostname = rs.getString(2); + + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL DataSource <"+getDbConnectionName() + "> connected to " + hostname + ", read-only is " + readOnly + ", tested successfully "); + } + } + + } catch (Throwable exc) { + if(error_level) { + LOGGER.error("SQL DataSource <" + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } else { + LOGGER.info("SQL DataSource <" + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } + return false; + } finally { + if(rs != null) { + try { + rs.close(); + rs = null; + } catch (SQLException e) { + } + } + if(stmt != null) { + try { + stmt.close(); + stmt = null; + } catch (SQLException e) { + } + } + if(conn !=null){ + try { + conn.close(); + conn = null; + } catch (SQLException e) { + } + } + } + return true; + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + public T unwrap(Class iface) throws SQLException { + return null; + } + + @SuppressWarnings("deprecation") + public void setConnectionCachingEnabled(boolean state) + { +// if(ds != null && ds instanceof OracleDataSource) +// try { +// ((OracleDataSource)ds).setConnectionCachingEnabled(true); +// } catch (SQLException exc) { +// LOGGER.warn("", exc); +// } + } + + public void addObserver(Observer observer) { + monitor.addObserver(observer); + } + + public void deleteObserver(Observer observer) { + monitor.deleteObserver(observer); + } + + public long getInterval() { + return interval; + } + + public long getInitialDelay() { + return initialDelay; + } + + public void setInterval(long value) { + interval = value; + } + + public void setInitialDelay(long value) { + initialDelay = value; + } + + public long getExpectedCompletionTime() { + return expectedCompletionTime; + } + + public void setExpectedCompletionTime(long value) { + expectedCompletionTime = value; + } + + public long getUnprocessedFailoverThreshold() { + return unprocessedFailoverThreshold; + } + + public void setUnprocessedFailoverThreshold(long value) { + this.unprocessedFailoverThreshold = value; + } + + public boolean canTakeOffLine() { + return canTakeOffLine; + } + + public void blockImmediateOffLine() { + canTakeOffLine = false; + final Thread offLineTimer = new Thread() + { + public void run(){ + try { + Thread.sleep(30000L); + }catch(Throwable exc){ + + }finally{ + canTakeOffLine = true; + } + } + }; + offLineTimer.setDaemon(true); + offLineTimer.start(); + } + + /** + * @return the monitor + */ + final SQLExecutionMonitor getMonitor() { + return monitor; + } + + protected boolean isSlave() throws PoolExhaustedException, MySQLNonTransientConnectionException { + CachedRowSet rs = null; + boolean isSlave = true; + String hostname = "UNDETERMINED"; + try { + boolean localSlave = true; + rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList()); + while(rs.next()) { + localSlave = rs.getBoolean(1); + hostname = rs.getString(2); + } + isSlave = localSlave; + } catch(PoolExhaustedException | MySQLNonTransientConnectionException peexc){ + throw peexc; + } catch (SQLException e) { + LOGGER.error("", e); + isSlave = true; + } catch (Throwable e) { + LOGGER.error("", e); + isSlave = true; + } + if(isSlave){ + LOGGER.debug("SQL SLAVE : "+connectionName + " on server " + hostname); + } else { + LOGGER.debug("SQL MASTER : "+connectionName + " on server " + hostname); + } + return isSlave; + } + + public boolean isFabric() { + return false; + } + + protected boolean lockTable(Connection conn, String tableName) { + boolean retValue = false; + Statement lock = null; + try { + if(tableName != null) { + if(LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); + if("SVC_LOGIC".equals(tableName)) { + Exception e = new Exception(); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + LOGGER.debug(sw.toString()); + } + } + lock = conn.createStatement(); + lock.execute("LOCK TABLES " + tableName + " WRITE"); + retValue = true; + } + } catch(Exception exc){ + LOGGER.error("", exc); + retValue = false; + } finally { + try { + lock.close(); + } catch(Exception exc) { + + } + } + return retValue; + } + + protected boolean unlockTable(Connection conn) { + boolean retValue = false; + Statement lock = null; + try { + if(LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'UNLOCK TABLES' on connection " + conn.toString()); + } + lock = conn.createStatement(); + retValue = lock.execute("UNLOCK TABLES"); + } catch(Exception exc){ + LOGGER.error("", exc); + retValue = false; + } finally { + try { + lock.close(); + } catch(Exception exc) { + + } + } + return retValue; + } + + public void getPoolInfo(boolean allocation) { + + } + + public long getNextErrorReportTime() { + return nextErrorReportTime; + } + + public void setNextErrorReportTime(long nextTime) { + this.nextErrorReportTime = nextTime; + } + + public void setGlobalHostName(String hostname) { + this.globalHostName = hostname; + } + + public String getGlobalHostName() { + return globalHostName; + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java new file mode 100644 index 000000000..3e51ed942 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + + +import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.jdbc.JdbcDBCachedDataSource; +import org.openecomp.sdnc.sli.resource.dblib.jdbc.MySQLCachedDataSource; + +/** + * @version $Revision: 1.1 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class CachedDataSourceFactory { + + public static CachedDataSource createDataSource(BaseDBConfiguration config) { + if(config instanceof JDBCConfiguration) + return JdbcDBCachedDataSource.createInstance(config); + + return (CachedDataSource)null; + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBConfigException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBConfigException.java new file mode 100644 index 000000000..b324e6a2c --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBConfigException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + + +/** + * @version $Revision: 1.1 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class DBConfigException extends RuntimeException +{ + /** + * + */ + private static final long serialVersionUID = 4752405152537680257L; + + public DBConfigException(Exception e) + { + super(e.toString()); + } + + public DBConfigException(String msg) + { + super(msg); + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLIBResourceActivator.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLIBResourceActivator.java new file mode 100644 index 000000000..150a9a82f --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLIBResourceActivator.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.io.File; +import java.net.URL; +import java.util.Properties; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DBLIBResourceActivator implements BundleActivator { + + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final String DBLIB_PROP_PATH = "/dblib.properties"; + + private ServiceRegistration registration = null; + + private static final Logger LOG = LoggerFactory.getLogger(DBLIBResourceActivator.class); + + @Override + public void start(BundleContext ctx) throws Exception { + LOG.info("entering DBLIBResourceActivator.start"); + + DbLibService jdbcDataSource = null; + // Read properties + Properties props = new Properties(); + + File file = null; + URL propURL = null; + String propDir = System.getenv(SDNC_CONFIG_DIR); + if ((propDir == null) || (propDir.length() == 0)) { + propDir = "/opt/sdnc/data/properties"; + } + file = new File(propDir + DBLIB_PROP_PATH); + if(file.exists()) { + propURL = file.toURI().toURL(); + LOG.info("Using property file (1): " + file.toString()); + } else { + propURL = ctx.getBundle().getResource("dblib.properties"); + URL tmp = null; + if (propURL == null) { + file = new File(DBLIB_PROP_PATH); + tmp = this.getClass().getResource(DBLIB_PROP_PATH); +// if(!file.exists()) { + if(tmp == null) { + throw new DblibConfigurationException("Missing configuration properties resource(3) : " + DBLIB_PROP_PATH); + } else { + propURL = tmp; //file.toURI().toURL(); + LOG.info("Using property file (4): " + file.toString()); + } + } else { + LOG.info("Using property file (2): " + propURL.toString()); + } + } + + + try { + props.load(propURL.openStream()); + } catch (Exception e) { + throw new DblibConfigurationException("Could not load properties at URL " + propURL.toString(), e); + + } + + + + try { + jdbcDataSource = DBResourceManager.create(props); + } catch (Exception exc) { + throw new DblibConfigurationException("Could not get initialize database", exc); + } + + String regName = jdbcDataSource.getClass().getName(); + + LOG.info("Registering DBResourceManager service "+regName); + registration = ctx.registerService(new String[] { regName, DbLibService.class.getName(), "javax.sql.DataSource" }, jdbcDataSource, null); + } + + @Override + public void stop(BundleContext ctx) throws Exception { + LOG.info("entering DBLIBResourceActivator.stop"); + if (registration != null) + { + try { + ServiceReference sref = ctx.getServiceReference(DbLibService.class.getName()); + + if (sref == null) { + LOG.warn("Could not find service reference for DBLIB service (" + DbLibService.class.getName() + ")"); + } else { + DBResourceManager dblibSvc = (DBResourceManager) ctx.getService(sref); + if (dblibSvc == null) { + LOG.warn("Could not find service reference for DBLIB service (" + DbLibService.class.getName() + ")"); + } else { + dblibSvc.cleanUp(); + } + } + } catch(Throwable exc) { + LOG.warn("Cleanup", exc); + } + + registration.unregister(); + registration = null; + LOG.debug("Deregistering DBResourceManager service"); + } + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibConnection.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibConnection.java new file mode 100644 index 000000000..5c1f51040 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibConnection.java @@ -0,0 +1,390 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.sql.Array; +import java.sql.Blob; +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.NClob; +import java.sql.PreparedStatement; +import java.sql.SQLClientInfoException; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Struct; +import java.util.ArrayList; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +import javax.sql.rowset.CachedRowSet; + +import org.apache.tomcat.jdbc.pool.PooledConnection; +import org.apache.tomcat.jdbc.pool.ProxyConnection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DBLibConnection implements Connection { + + private static Logger LOGGER = LoggerFactory.getLogger(DBLibConnection.class); + + private final Connection connection; + private final CachedDataSource dataSource; + private boolean locked = false; + private String tableName = null; + + public DBLibConnection(Connection con, CachedDataSource dataSource){ + this.connection = con; + this.dataSource = dataSource; + locked = false; + dataSource.getPoolInfo(true); + } + + public boolean lockTable(String tablename) { + this.tableName = tablename; + return locked = dataSource.lockTable(connection, tableName); + } + + public void resetInactivityTimer() { + Class iface = PooledConnection.class; + try { + PooledConnection pc = connection.unwrap(iface); + pc.setTimestamp(System.currentTimeMillis()); + } catch (SQLException e) { + LOGGER.warn("Failed resetting timeout timer", e); + } + } + + public boolean unlock() { + dataSource.unlockTable(connection); + return locked = false; + } + + public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable + { + ArrayList newList=new ArrayList(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + resetInactivityTimer(); + return dataSource.executeUpdatePreparedStatement(connection, statement, newList, false); + } + + public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable + { + ArrayList newList=new ArrayList(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + resetInactivityTimer(); + return dataSource.executePreparedStatement(connection, statement, newList, false); + } + + @Override + public T unwrap(Class iface) throws SQLException { + return connection.unwrap(iface); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return connection.isWrapperFor(iface); + } + + @Override + public Statement createStatement() throws SQLException { + return connection.createStatement(); + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + return connection.prepareStatement(sql); + } + + @Override + public CallableStatement prepareCall(String sql) throws SQLException { + return connection.prepareCall(sql); + } + + @Override + public String nativeSQL(String sql) throws SQLException { + return connection.nativeSQL(sql); + } + + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + connection.setAutoCommit(autoCommit); + } + + @Override + public boolean getAutoCommit() throws SQLException { + return connection.getAutoCommit(); + } + + @Override + public void commit() throws SQLException { + connection.commit(); + } + + @Override + public void rollback() throws SQLException { + connection.rollback(); + } + + @Override + public void close() throws SQLException { + if(this.locked) { + try { + this.unlock(); + } catch(Throwable th) { + LOGGER.error("Failed unlocking",th); + } + } + if(connection != null && !connection.isClosed()) { + connection.close(); + } + dataSource.getPoolInfo(false); + } + + @Override + public boolean isClosed() throws SQLException { + return connection.isClosed(); + } + + @Override + public DatabaseMetaData getMetaData() throws SQLException { + return connection.getMetaData(); + } + + @Override + public void setReadOnly(boolean readOnly) throws SQLException { + connection.setReadOnly(readOnly); + } + + @Override + public boolean isReadOnly() throws SQLException { + return connection.isReadOnly(); + } + + @Override + public void setCatalog(String catalog) throws SQLException { + connection.setCatalog(catalog); + } + + @Override + public String getCatalog() throws SQLException { + return connection.getCatalog(); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + connection.setTransactionIsolation(level); + } + + @Override + public int getTransactionIsolation() throws SQLException { + return connection.getTransactionIsolation(); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return connection.getWarnings(); + } + + @Override + public void clearWarnings() throws SQLException { + connection.clearWarnings(); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { + return connection.createStatement(resultSetType, resultSetConcurrency); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + return connection.prepareStatement(sql, resultSetType, resultSetConcurrency); + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { + return connection.prepareCall(sql, resultSetType, resultSetConcurrency); + } + + @Override + public Map> getTypeMap() throws SQLException { + return connection.getTypeMap(); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + connection.setTypeMap(map); + } + + @Override + public void setHoldability(int holdability) throws SQLException { + connection.setHoldability(holdability); + } + + @Override + public int getHoldability() throws SQLException { + return connection.getHoldability(); + } + + @Override + public Savepoint setSavepoint() throws SQLException { + return connection.setSavepoint(); + } + + @Override + public Savepoint setSavepoint(String name) throws SQLException { + return connection.setSavepoint(name); + } + + @Override + public void rollback(Savepoint savepoint) throws SQLException { + connection.rollback(savepoint); + } + + @Override + public void releaseSavepoint(Savepoint savepoint) throws SQLException { + connection.releaseSavepoint(savepoint); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) + throws SQLException { + return connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return connection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { + return connection.prepareStatement(sql, autoGeneratedKeys); + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + return connection.prepareStatement(sql, columnIndexes); + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { + return connection.prepareStatement(sql, columnNames); + } + + @Override + public Clob createClob() throws SQLException { + return connection.createClob(); + } + + @Override + public Blob createBlob() throws SQLException { + return connection.createBlob(); + } + + @Override + public NClob createNClob() throws SQLException { + return connection.createNClob(); + } + + @Override + public SQLXML createSQLXML() throws SQLException { + return connection.createSQLXML(); + } + + @Override + public boolean isValid(int timeout) throws SQLException { + return connection.isValid(timeout); + } + + @Override + public void setClientInfo(String name, String value) throws SQLClientInfoException { + connection.setClientInfo(name, value); + } + + @Override + public void setClientInfo(Properties properties) throws SQLClientInfoException { + connection.setClientInfo(properties); + } + + @Override + public String getClientInfo(String name) throws SQLException { + return connection.getClientInfo(name); + } + + @Override + public Properties getClientInfo() throws SQLException { + return connection.getClientInfo(); + } + + @Override + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + return connection.createArrayOf(typeName, elements); + } + + @Override + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { + return connection.createStruct(typeName, attributes); + } + + @Override + public void setSchema(String schema) throws SQLException { + connection.setSchema(schema); + } + + @Override + public String getSchema() throws SQLException { + return connection.getSchema(); + } + + @Override + public void abort(Executor executor) throws SQLException { + connection.abort(executor); + } + + @Override + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + connection.setNetworkTimeout(executor, milliseconds); + } + + @Override + public int getNetworkTimeout() throws SQLException { + return connection.getNetworkTimeout(); + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibException.java new file mode 100644 index 000000000..cc80741dc --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibException.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.sql.SQLException; + +/** + * An exception time for handling DBLIB specific error handling. + */ +public class DBLibException extends SQLException { + + /** + * + */ + private static final long serialVersionUID = -5345059355083984696L; + + public DBLibException(String message){ + super(message); + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java new file mode 100644 index 000000000..5cf2953b7 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java @@ -0,0 +1,862 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLDataException; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.sql.SQLSyntaxErrorException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Observable; +import java.util.PriorityQueue; +import java.util.Properties; +import java.util.Queue; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; + +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; +import org.openecomp.sdnc.sli.resource.dblib.factory.AbstractDBResourceManagerFactory; +import org.openecomp.sdnc.sli.resource.dblib.factory.AbstractResourceManagerFactory; +import org.openecomp.sdnc.sli.resource.dblib.factory.DBConfigFactory; +import org.openecomp.sdnc.sli.resource.dblib.pm.PollingWorker; +import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitor; +import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @version $Revision: 1.15 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class DBResourceManager implements DataSource, DataAccessor, DBResourceObserver, DbLibService { + private static Logger LOGGER = LoggerFactory.getLogger(DBResourceManager.class); + + transient boolean terminating = false; + transient protected long retryInterval = 10000L; + transient boolean recoveryMode = true; + + protected final AtomicBoolean dsSelector = new AtomicBoolean(); + +// Queue dsQueue = new ConcurrentLinkedQueue(); + Queue dsQueue = new PriorityQueue(4, new Comparator(){ + + @Override + public int compare(CachedDataSource left, CachedDataSource right) { + try { + if(!left.isSlave()) + return -1; + if(!right.isSlave()) + return 1; + + } catch (Throwable e) { + LOGGER.warn("", e); + } + return 0; + } + + }); + protected final Set broken = Collections.synchronizedSet(new HashSet()); + protected final Object monitor = new Object(); + protected final Properties configProps; + protected final Thread worker; + + protected final long terminationTimeOut; + protected final boolean monitorDbResponse; + protected final long monitoringInterval; + protected final long monitoringInitialDelay; + protected final long expectedCompletionTime; + protected final long unprocessedFailoverThreshold; + + public DBResourceManager(Properties props){ + this.configProps = props; + + // get retry interval value + retryInterval = getLongFromProperties(props, "org.openecomp.dblib.connection.retry", 10000L); + + // get recovery mode flag + recoveryMode = getBooleanFromProperties(props, "org.openecomp.dblib.connection.recovery", true); + if(!recoveryMode) + { + recoveryMode = false; + LOGGER.info("Recovery Mode disabled"); + } + // get time out value for thread cleanup + terminationTimeOut = getLongFromProperties(props, "org.openecomp.dblib.termination.timeout", 300000L); + // get properties for monitoring + monitorDbResponse = getBooleanFromProperties(props, "org.openecomp.dblib.connection.monitor", false); + monitoringInterval = getLongFromProperties(props, "org.openecomp.dblib.connection.monitor.interval", 1000L); + monitoringInitialDelay = getLongFromProperties(props, "org.openecomp.dblib.connection.monitor.startdelay", 5000L); + expectedCompletionTime = getLongFromProperties(props, "org.openecomp.dblib.connection.monitor.expectedcompletiontime", 5000L); + unprocessedFailoverThreshold = getLongFromProperties(props, "org.openecomp.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); + + // initialize performance monitor + PollingWorker.createInistance(props); + + // initialize recovery thread + worker = new RecoveryMgr(); + worker.setName("DBResourcemanagerWatchThread"); + worker.setDaemon(true); + worker.start(); + } + + private void config(Properties ctx) throws Exception { + + DbConfigPool dbConfig = DBConfigFactory.createConfig(this.configProps); + + try { + AbstractResourceManagerFactory factory = AbstractDBResourceManagerFactory.getFactory(dbConfig.getType()); + if(LOGGER.isInfoEnabled()){ + LOGGER.info("Default DB config is : " + dbConfig.getType()); + LOGGER.info("Using factory : " + factory.getClass().getName()); + } + CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, this); + if(cachedDS == null || cachedDS.length == 0) { + LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); + throw new Exception("Failed to initialize DB Library. No data source was created."); + } + + for(int i=0; i 1){ + handleGetConnectionException(dataSource, new Exception(data.toString())); + } + } + } + } + } + + public void testForceRecovery() + { + CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + handleGetConnectionException(active, new Exception("test")); + } + + class RecoveryMgr extends Thread { + + public void run() { + while(!terminating) + { + try { + Thread.sleep(retryInterval); + } catch (InterruptedException e1) { } + CachedDataSource brokenSource = null; + try { + if (!broken.isEmpty()) { + CachedDataSource[] sourceArray = broken.toArray(new CachedDataSource[0]); + for (int i = 0; i < sourceArray.length; i++) + { + brokenSource = sourceArray[i]; + if (brokenSource instanceof TerminatingCachedDataSource) + break; + if (resetConnectionPool(brokenSource)) { + broken.remove(brokenSource); + brokenSource.blockImmediateOffLine(); + dsQueue.add(brokenSource); + LOGGER.info("DataSource <" + + brokenSource.getDbConnectionName() + + "> recovered."); + } + brokenSource = null; + } + } + } catch (Exception exc) { + LOGGER.warn(exc.getMessage()); + if(brokenSource != null){ + try { + if(!broken.contains(brokenSource)) + broken.add(brokenSource); + brokenSource = null; + } catch (Exception e1) { } + } + } + } + LOGGER.info("DBResourceManager.RecoveryMgr <"+this.toString() +"> terminated." ); + } + + private boolean resetConnectionPool(CachedDataSource dataSource){ + try { + return dataSource.testConnection(); + } catch (Exception exc) { + LOGGER.info("DataSource <" + dataSource.getDbConnectionName() + "> resetCache failed with error: "+ exc.getMessage()); + return false; + } + } + } + + /* (non-Javadoc) + * @see org.openecomp.sdnc.sli.resource.dblib.DbLibService#getData(java.lang.String, java.util.ArrayList, java.lang.String) + */ + @Override + public CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) throws SQLException { + ArrayList newList=new ArrayList(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + if(recoveryMode) + return requestDataWithRecovery(statement, newList, preferredDS); + else + return requestDataNoRecovery(statement, newList, preferredDS); + } + + private CachedRowSet requestDataWithRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + Throwable lastException = null; + CachedDataSource active = null; + + // test if there are any connection pools available + LinkedList sources = new LinkedList(this.dsQueue); + if(sources.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); + } + if(preferredDS != null && !sources.peek().getDbConnectionName().equals(preferredDS)) { + Collections.reverse(sources); + } + + + // loop through available data sources to retrieve data. + while(!sources.isEmpty()) + { + active = sources.peek(); + + long time = System.currentTimeMillis(); + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + master = null; + } + } + sources.remove(active); + return active.getData(statement, arguments); + } catch(SQLDataException exc){ + throw exc; + } catch(SQLSyntaxErrorException exc){ + throw exc; + } catch(SQLIntegrityConstraintViolationException exc){ + throw exc; + } catch(Throwable exc){ + lastException = exc; + String message = exc.getMessage(); + if(message == null) { + if(exc.getCause() != null) { + message = exc.getCause().getMessage(); + } + if(message == null) + message = exc.getClass().getName(); + } + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + handleGetConnectionException(active, exc); + } finally { + if(LOGGER.isDebugEnabled()){ + time = (System.currentTimeMillis() - time); + LOGGER.debug("getData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + if(lastException instanceof SQLException){ + throw (SQLException)lastException; + } + // repackage the exception + // you are here because either you run out of available data sources + // or the last exception was not of SQLException type. + // repackage the exception + if(lastException == null) { + throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); + } else { + SQLException exception = new DBLibException(lastException.getMessage()); + exception.setStackTrace(lastException.getStackTrace()); + if(lastException.getCause() instanceof SQLException) { + throw (SQLException)lastException.getCause(); + } + throw exception; + } + } + + private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + if(dsQueue.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); + } + CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + long time = System.currentTimeMillis(); + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) + active = master; + } + return active.getData(statement, arguments); +// } catch(SQLDataException exc){ +// throw exc; + } catch(Throwable exc){ + String message = exc.getMessage(); + if(message == null) + message = exc.getClass().getName(); + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + if(exc instanceof SQLException) + throw (SQLException)exc; + else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } finally { + if(LOGGER.isDebugEnabled()){ + time = (System.currentTimeMillis() - time); + LOGGER.debug(">> getData : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + + + /* (non-Javadoc) + * @see org.openecomp.sdnc.sli.resource.dblib.DbLibService#writeData(java.lang.String, java.util.ArrayList, java.lang.String) + */ + @Override + public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException + { + ArrayList newList=new ArrayList(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + + return writeDataNoRecovery(statement, newList, preferredDS); + } + + CachedDataSource findMaster() throws PoolExhaustedException, MySQLNonTransientConnectionException { + CachedDataSource master = null; + CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); + for(int i=0; i arguments, String preferredDS) throws SQLException { + if(dsQueue.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); + } + + boolean initialRequest = true; + boolean retryAllowed = true; + CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + long time = System.currentTimeMillis(); + while(initialRequest) { + initialRequest = false; + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } + + return active.writeData(statement, arguments); + } catch(Throwable exc){ + String message = exc.getMessage(); + if(message == null) + message = exc.getClass().getName(); + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + if(exc instanceof SQLException) { + SQLException sqlExc = SQLException.class.cast(exc); + // handle read-only exception + if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { + LOGGER.warn("retrying due to: " + sqlExc.getMessage()); + dsQueue.remove(active); + dsQueue.add(active); + if(retryAllowed){ + retryAllowed = false; + initialRequest = true; + continue; + } + } + throw (SQLException)exc; + } else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } finally { + if(LOGGER.isDebugEnabled()){ + time = (System.currentTimeMillis() - time); + LOGGER.debug("writeData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + return true; + } + + private void setDataSource(CachedDataSource dataSource) { + if(dataSource.testConnection(true)){ + this.dsQueue.add(dataSource); + } else { + this.broken.add(dataSource); + } + } + + public Connection getConnection() throws SQLException { + Throwable lastException = null; + CachedDataSource active = null; + + if(dsQueue.isEmpty()){ + throw new DBLibException("No active DB connection pools are available in GetConnection call."); + } + + try { + active = dsQueue.peek(); + CachedDataSource tmpActive = findMaster(); + if(tmpActive != null) { + active = tmpActive; + } + return new DBLibConnection(active.getConnection(), active); + } catch(javax.sql.rowset.spi.SyncFactoryException exc){ + LOGGER.debug("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); + LOGGER.warn("CLASSPATH issue. Allowing retry", exc); + lastException = exc; + } catch(PoolExhaustedException exc) { + throw new NoAvailableConnectionsException(exc); + } catch(MySQLNonTransientConnectionException exc){ + throw new NoAvailableConnectionsException(exc); + } catch(Exception exc){ + lastException = exc; + if(recoveryMode){ + handleGetConnectionException(active, exc); + } else { + if(exc instanceof MySQLNonTransientConnectionException) { + throw new NoAvailableConnectionsException(exc); + } if(exc instanceof SQLException) { + throw (SQLException)exc; + } else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } + } catch (Throwable trwb) { + DBLibException excptn = new DBLibException(trwb.getMessage()); + excptn.setStackTrace(trwb.getStackTrace()); + throw excptn; + } finally { + if(LOGGER.isDebugEnabled()){ + displayState(); + } + } + + if(lastException instanceof SQLException){ + throw (SQLException)lastException; + } + // repackage the exception + if(lastException == null) { + throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); + } else { + SQLException exception = new DBLibException(lastException.getMessage()); + exception.setStackTrace(lastException.getStackTrace()); + if(lastException.getCause() instanceof SQLException) { +// exception.setNextException((SQLException)lastException.getCause()); + throw (SQLException)lastException.getCause(); + } + throw exception; + } + } + + public Connection getConnection(String username, String password) + throws SQLException { + CachedDataSource active = null; + + if(dsQueue.isEmpty()){ + throw new DBLibException("No active DB connection pools are available in GetConnection call."); + } + + + try { + active = dsQueue.peek(); + CachedDataSource tmpActive = findMaster(); + if(tmpActive != null) { + active = tmpActive; + } + return active.getConnection(username, password); + } catch(Throwable exc){ + if(recoveryMode){ + handleGetConnectionException(active, exc); + } else { + if(exc instanceof SQLException) + throw (SQLException)exc; + else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } + + } + + throw new DBLibException("No connections available in DBResourceManager in GetConnection call."); + } + + private void handleGetConnectionException(CachedDataSource source, Throwable exc) { + try { + if(!source.canTakeOffLine()) + { + LOGGER.error("Could not switch due to blocking"); + return; + } + + boolean removed = dsQueue.remove(source); + if(!broken.contains(source)) + { + if(broken.add(source)) + { + LOGGER.warn("DB Recovery: DataSource <" + source.getDbConnectionName() + "> put in the recovery mode. Reason : " + exc.getMessage()); + } else { + LOGGER.warn("Error putting DataSource <" +source.getDbConnectionName()+ "> in recovery mode."); + } + } else { + LOGGER.info("DB Recovery: DataSource <" + source.getDbConnectionName() + "> already in recovery queue"); + } + if(removed) + { + if(!dsQueue.isEmpty()) + { + LOGGER.warn("DB DataSource <" + dsQueue.peek().getDbConnectionName() + "> became active"); + } + } + } catch (Exception e) { + LOGGER.error("", e); + } + } + + public void cleanUp() { + for(Iterator it=dsQueue.iterator();it.hasNext();){ + CachedDataSource cds = (CachedDataSource)it.next(); + it.remove(); + cds.cleanUp(); + } + + try { + this.terminating = true; + if(broken != null) + { + try { + broken.add( new TerminatingCachedDataSource(null)); + } catch(Exception exc){ + LOGGER.error("Waiting for Worker to stop", exc); + } + } + worker.join(terminationTimeOut); + LOGGER.info("DBResourceManager.RecoveryMgr <"+worker.toString() +"> termination was successful: " + worker.getState()); + } catch(Exception exc){ + LOGGER.error("Waiting for Worker thread to terminate ", exc); + } + } + + public static DBResourceManager create(Properties props) throws Exception { + DBResourceManager dbmanager = new DBResourceManager(props); + dbmanager.config(props); + return dbmanager; + } + + public PrintWriter getLogWriter() throws SQLException { + return ((CachedDataSource)this.dsQueue.peek()).getLogWriter(); + } + + public int getLoginTimeout() throws SQLException { + return ((CachedDataSource)this.dsQueue.peek()).getLoginTimeout(); + } + + public void setLogWriter(PrintWriter out) throws SQLException { + ((CachedDataSource)this.dsQueue.peek()).setLogWriter(out); + } + + public void setLoginTimeout(int seconds) throws SQLException { + ((CachedDataSource)this.dsQueue.peek()).setLoginTimeout(seconds); + } + + public void displayState(){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); + CachedDataSource current = (CachedDataSource)dsQueue.peek(); + if(current != null) { + LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); + } + } + } + + /* (non-Javadoc) + * @see org.openecomp.sdnc.sli.resource.dblib.DbLibService#isActive() + */ + @Override + public boolean isActive() { + return this.dsQueue.size()>0; + } + + public String getActiveStatus(){ + return "Connected: " + dsQueue.size()+"\tIn-recovery: "+broken.size(); + } + + public String getDBStatus(boolean htmlFormat) { + StringBuilder buffer = new StringBuilder(); + + ArrayList list = new ArrayList(); + list.addAll(dsQueue); + list.addAll(broken); + if (htmlFormat) + { + buffer.append("") + .append("Name:").append(""); + for (int i = 0; i < list.size(); i++) { + buffer.append(""); + buffer.append(((CachedDataSource) list.get(i)).getDbConnectionName()).append(""); + } + buffer.append(""); + + buffer.append("State:"); + for (int i = 0; i < list.size(); i++) { + if (broken.contains(list.get(i))) { + buffer.append("in recovery"); + } + if (dsQueue.contains(list.get(i))) { + if (dsQueue.peek() == list.get(i)) + buffer.append("active"); + else + buffer.append("standby"); + } + } + buffer.append(""); + + } else { + for (int i = 0; i < list.size(); i++) { + buffer.append("Name: ").append(((CachedDataSource) list.get(i)).getDbConnectionName()); + buffer.append("\tState: "); + if (broken.contains(list.get(i))) { + buffer.append("in recovery"); + } else + if (dsQueue.contains(list.get(i))) { + if (dsQueue.peek() == list.get(i)) + buffer.append("active"); + else + buffer.append("standby"); + } + + buffer.append("\n"); + + } + } + return buffer.toString(); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + public T unwrap(Class iface) throws SQLException { + return null; + } + + /** + * @return the monitorDbResponse + */ + public final boolean isMonitorDbResponse() { + return recoveryMode && monitorDbResponse; + } + + public void test(){ + CachedDataSource obj = dsQueue.peek(); + Exception ption = new Exception(); + try { + for(int i=0; i<5; i++) + { + handleGetConnectionException(obj, ption); + } + } catch(Throwable exc){ + LOGGER.warn("", exc); + } + } + + public String getPreferredDSName(){ + if(isActive()){ + return getPreferredDataSourceName(dsSelector); + } + return ""; + } + + public String getPreferredDataSourceName(AtomicBoolean flipper) { + + LinkedList snapshot = new LinkedList(dsQueue); + if(snapshot.size() > 1){ + CachedDataSource first = snapshot.getFirst(); + CachedDataSource last = snapshot.getLast(); + + int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount(); + if(delta < 0) { + flipper.set(false); + } else if(delta > 0) { + flipper.set(true); + } else { + // check the last value and return !last + flipper.getAndSet(!flipper.get()); + } + + if (flipper.get()) + Collections.reverse(snapshot); + } + return snapshot.peek().getDbConnectionName(); + } + + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + return null; + } + + public String getMasterName() { + if(isActive()){ + return getMasterDataSourceName(dsSelector); + } + return ""; + } + + + private String getMasterDataSourceName(AtomicBoolean flipper) { + + LinkedList snapshot = new LinkedList(dsQueue); + if(snapshot.size() > 1){ + CachedDataSource first = snapshot.getFirst(); + CachedDataSource last = snapshot.getLast(); + + int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount(); + if(delta < 0) { + flipper.set(false); + } else if(delta > 0) { + flipper.set(true); + } else { + // check the last value and return !last + flipper.getAndSet(!flipper.get()); + } + + if (flipper.get()) + Collections.reverse(snapshot); + } + return snapshot.peek().getDbConnectionName(); + } + + class RemindTask extends TimerTask { + public void run() { + CachedDataSource ds = dsQueue.peek(); + if(ds != null) + ds.getPoolInfo(false); + } + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceObserver.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceObserver.java new file mode 100644 index 000000000..e06779f35 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceObserver.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.util.Observer; + +public interface DBResourceObserver extends Observer { + public boolean isMonitorDbResponse(); +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataAccessor.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataAccessor.java new file mode 100644 index 000000000..cd054a51d --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataAccessor.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.sql.SQLException; +import java.util.ArrayList; + +import javax.sql.rowset.CachedRowSet; + +public interface DataAccessor { + + public abstract CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) + throws SQLException; + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataSourceComparator.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataSourceComparator.java new file mode 100644 index 000000000..37d625136 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataSourceComparator.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.util.Comparator; + +public interface DataSourceComparator extends Comparator { + + public abstract CachedDataSource getLastUsed(); + + public abstract void setLastUsed(CachedDataSource lastUsed); + + public abstract int compare(CachedDataSource ds1, CachedDataSource ds2); + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DbLibService.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DbLibService.java new file mode 100644 index 000000000..25edd1f07 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DbLibService.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.sql.SQLException; +import java.util.ArrayList; + +import javax.sql.rowset.CachedRowSet; + +public interface DbLibService { + + /* (non-Javadoc) + * @see DataAccessor#getData(java.lang.String, java.util.ArrayList) + */ + public abstract CachedRowSet getData(String statement, + ArrayList arguments, String preferredDS) + throws SQLException; + + /* (non-Javadoc) + * @see DataAccessor#writeData(java.lang.String, java.util.ArrayList) + */ + public abstract boolean writeData(String statement, + ArrayList arguments, String preferredDS) + throws SQLException; + + public abstract boolean isActive(); + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DblibConfigurationException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DblibConfigurationException.java new file mode 100644 index 000000000..17700a5ee --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DblibConfigurationException.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + + +public class DblibConfigurationException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public DblibConfigurationException() + { + super(); + } + + public DblibConfigurationException(String msg) + { + super(msg); + } + + public DblibConfigurationException(String msg, Throwable t) + { + super(msg, t); + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/NoAvailableConnectionsException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/NoAvailableConnectionsException.java new file mode 100644 index 000000000..16895b4d5 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/NoAvailableConnectionsException.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.sql.SQLException; + +public class NoAvailableConnectionsException extends SQLException { + + /** + * + */ + private static final long serialVersionUID = -6259205931674413018L; + + public NoAvailableConnectionsException(Exception exc) { + super(exc); + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/TerminatingCachedDataSource.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/TerminatingCachedDataSource.java new file mode 100644 index 000000000..234bbed0c --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/TerminatingCachedDataSource.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib; + +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; + +import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitorObserver; + + +public class TerminatingCachedDataSource extends CachedDataSource implements SQLExecutionMonitorObserver { + + public TerminatingCachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { + super(jdbcElem); + } + + protected void configure(BaseDBConfiguration jdbcElem) throws DBConfigException { + // no action + } + + public long getInterval() { + return 1000; + } + + public long getInitialDelay() { + return 1000; + } + + public long getExpectedCompletionTime() { + return 50; + } + + public void setExpectedCompletionTime(long value) { + + } + + public void setInterval(long value) { + + } + + public void setInitialDelay(long value) { + + } + + public long getUnprocessedFailoverThreshold() { + return 3; + } + + public void setUnprocessedFailoverThreshold(long value) { + + } + + public int compareTo(CachedDataSource ods) + { + return 0; + } + + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/BaseDBConfiguration.java new file mode 100644 index 000000000..976b1cf2d --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/BaseDBConfiguration.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.config; + +import java.util.Properties; + +public abstract class BaseDBConfiguration { + public static final String DATABASE_TYPE = "org.openecomp.sdnc.sli.dbtype"; + public static final String DATABASE_URL = "org.openecomp.sdnc.sli.jdbc.url"; + public static final String DATABASE_NAME = "org.openecomp.sdnc.sli.jdbc.database"; + public static final String CONNECTION_NAME = "org.openecomp.sdnc.sli.jdbc.connection.name"; + public static final String DATABASE_USER = "org.openecomp.sdnc.sli.jdbc.user"; + public static final String DATABASE_PSSWD = "org.openecomp.sdnc.sli.jdbc.password"; + public static final String CONNECTION_TIMEOUT="org.openecomp.sdnc.sli.jdbc.connection.timeout"; + public static final String REQUEST_TIMEOUT = "org.openecomp.sdnc.sli.jdbc.request.timeout"; + public static final String MIN_LIMIT = "org.openecomp.sdnc.sli.jdbc.limit.min"; + public static final String MAX_LIMIT = "org.openecomp.sdnc.sli.jdbc.limit.max"; + public static final String INIT_LIMIT = "org.openecomp.sdnc.sli.jdbc.limit.init"; + public static final String DATABASE_HOSTS = "org.openecomp.sdnc.sli.jdbc.hosts"; + + + protected final Properties props; + + public BaseDBConfiguration(Properties properties) { + this.props = properties; + } + + public int getConnTimeout() { + try { + String value = props.getProperty(CONNECTION_TIMEOUT); + return Integer.parseInt(value); + } catch(Exception exc) { + return -1; + } + } + + public int getRequestTimeout() { + try { + String value = props.getProperty(REQUEST_TIMEOUT); + if(value == null) + return -1; + return Integer.parseInt(value); + } catch(Exception exc) { + return -1; + } + } + + public String getDbConnectionName() { + return props.getProperty(CONNECTION_NAME); + } + + public String getDatabaseName() { + return props.getProperty(DATABASE_NAME); + } + + public String getDbUserId() { + return props.getProperty(DATABASE_USER); + } + + public String getDbPasswd() { + return props.getProperty(DATABASE_PSSWD); + } + + public int getDbMinLimit() { + String value = props.getProperty(MIN_LIMIT); + return Integer.parseInt(value); + } + + public int getDbMaxLimit() { + String value = props.getProperty(MAX_LIMIT); + return Integer.parseInt(value); + } + + public int getDbInitialLimit() { + String value = props.getProperty(INIT_LIMIT); + return Integer.parseInt(value); + } + + public String getDbUrl() { + return props.getProperty(DATABASE_URL); + } + + public String getServerGroup() { + return null; + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java new file mode 100644 index 000000000..117f9321d --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.config; + +import java.util.ArrayList; +import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DbConfigPool { + private static Logger LOGGER = LoggerFactory.getLogger(DbConfigPool.class); + + private final String type; + + private ArrayList configurations = new ArrayList(); + + public DbConfigPool(Properties properties) { + LOGGER.debug("Initializing DbConfigType"); + type = properties.getProperty(BaseDBConfiguration.DATABASE_TYPE, "JDBC").toUpperCase(); + } + + public int getTimeout() { + // TODO Auto-generated method stub + return 0; + } + + public String getType() { + return type; + } + + public JDBCConfiguration[] getJDBCbSourceArray() { + return configurations.toArray(new JDBCConfiguration[configurations.size()]); + } + + public void addConfiguration(BaseDBConfiguration config) { + configurations.add(config); + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/JDBCConfiguration.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/JDBCConfiguration.java new file mode 100644 index 000000000..cb6ea3e5c --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/JDBCConfiguration.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.config; + +import java.util.Properties; + +public class JDBCConfiguration extends BaseDBConfiguration { + + public JDBCConfiguration(Properties xmlElem) { + super(xmlElem); + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java new file mode 100644 index 000000000..f4291a7dd --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.factory; + +import org.openecomp.sdnc.sli.resource.dblib.jdbc.JdbcDbResourceManagerFactory; + +/** + * @version $Revision: 1.1 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class AbstractDBResourceManagerFactory { + + public static AbstractResourceManagerFactory getFactory(String type) throws FactoryNotDefinedException { + + // JDBC + return JdbcDbResourceManagerFactory.createIntstance(); + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java new file mode 100644 index 000000000..0f58a3f03 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.factory; + + +import java.sql.SQLException; +import java.util.Set; +import java.util.concurrent.Callable; + +import org.openecomp.sdnc.sli.resource.dblib.CachedDataSource; +import org.openecomp.sdnc.sli.resource.dblib.CachedDataSourceFactory; +import org.openecomp.sdnc.sli.resource.dblib.DBConfigException; +import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager; +import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; +import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @version $Revision: 1.6 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public abstract class AbstractResourceManagerFactory { + private static Logger LOGGER = LoggerFactory.getLogger(AbstractResourceManagerFactory.class); + + public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager) throws Exception; + public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager dbResourceManager, String sourceName) throws SQLException ; + + + public static AbstractResourceManagerFactory createIntstance() throws FactoryNotDefinedException { + throw new FactoryNotDefinedException("Factory method 'createIntstance' needs to be overriden in DBResourceManagerFactory"); + } + + public class DBInitTask implements Callable + { + private BaseDBConfiguration config = null; + private Set activeTasks; + + public DBInitTask(JDBCConfiguration jdbcconfig, Set tasks) { + this.config = jdbcconfig; + this.activeTasks = tasks; + } + + public CachedDataSource call() throws Exception { + CachedDataSource ds = null; + try { + ds = CachedDataSourceFactory.createDataSource(config); + return ds; + } finally { + synchronized(activeTasks) { + activeTasks.remove(this); + if (activeTasks.isEmpty()) { + final Runnable closure = new Runnable() { + + public void run() { + try { + Thread.sleep(300); + } catch (Exception e) { + } + synchronized(activeTasks) { + activeTasks.notifyAll(); + } + } + }; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Completed CachedDataSource.Call and notifyAll from " + ds.getDbConnectionName()); + } + Thread worker = new Thread(closure); + worker.setDaemon(true); + worker.start(); + } else { + if (LOGGER.isDebugEnabled()) { + if (ds != null) { + LOGGER.debug("Completed CachedDataSource.Call from " + ds.getDbConnectionName()); + } + } + } + } + } + } + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java new file mode 100644 index 000000000..8aadcae6b --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.factory; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Properties; + +import org.slf4j.LoggerFactory; + +import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; +import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; + +/** + * @version $Revision: 1.1 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki 01/17/08 Initial version + */ +public class DBConfigFactory { + + public static DbConfigPool createConfig(Properties resource) { + return getConfigparams(resource); + } + + static DbConfigPool getConfigparams(Properties properties){ + DbConfigPool xmlConfig = new DbConfigPool(properties); + ArrayList propertySets = new ArrayList(); + + if("JDBC".equalsIgnoreCase(xmlConfig.getType())) { + String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS); + if(hosts == null || hosts.isEmpty()) { + propertySets.add(properties); + } else { + String[] newhost = hosts.split(","); + for(int i=0; i< newhost.length; i++) { + Properties localset = new Properties(); + localset.putAll(properties); + String url = localset.getProperty(BaseDBConfiguration.DATABASE_URL); + if(url.contains("DBHOST")) + url = url.replace("DBHOST", newhost[i]); + if(url.contains("dbhost")) + url = url.replace("dbhost", newhost[i]); + localset.setProperty(BaseDBConfiguration.DATABASE_URL, url); + localset.setProperty(BaseDBConfiguration.CONNECTION_NAME, newhost[i]); + propertySets.add(localset); + } + } + } else { + propertySets.add(properties); + } + try { + Iterator it = propertySets.iterator(); + while(it.hasNext()) { + BaseDBConfiguration config = parse(it.next()); + xmlConfig.addConfiguration(config); + } + + } catch (Exception e) { + LoggerFactory.getLogger(DBConfigFactory.class).warn("",e); + } + + return xmlConfig; + } + + public static BaseDBConfiguration parse(Properties props) throws Exception { + + String type = props.getProperty(BaseDBConfiguration.DATABASE_TYPE); + + BaseDBConfiguration config = null; + + if("JDBC".equalsIgnoreCase(type)) { + config = new JDBCConfiguration(props); + } + + return config; + + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/FactoryNotDefinedException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/FactoryNotDefinedException.java new file mode 100644 index 000000000..e38cd3519 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/FactoryNotDefinedException.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.factory; + + +/** + * @version 1.3 + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki 01/16/08 Initial version + */ +public class FactoryNotDefinedException extends Exception { + + public FactoryNotDefinedException(String message) { + super(message); + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java new file mode 100644 index 000000000..90c76f637 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java @@ -0,0 +1,249 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.jdbc; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLFeatureNotSupportedException; + +import org.apache.tomcat.jdbc.pool.DataSource; +import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.openecomp.sdnc.sli.resource.dblib.CachedDataSource; +import org.openecomp.sdnc.sli.resource.dblib.DBConfigException; +import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; +import com.mysql.jdbc.Driver; + + +/** + * @version $Revision: 1.7 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ + +public class JdbcDBCachedDataSource extends CachedDataSource +{ + private String dbUserId; + private String dbPasswd; + private String dbUrl; + + private int minLimit; + private int maxLimit; + private int initialLimit; + + private static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; + + private static Logger LOGGER = LoggerFactory.getLogger(JdbcDBCachedDataSource.class); + + /** + * @param jdbcElem + */ + public JdbcDBCachedDataSource(BaseDBConfiguration jdbcElem) + { + super(jdbcElem); + } + + @Override + protected void configure(BaseDBConfiguration xmlElem) throws DBConfigException + { + BaseDBConfiguration jdbcConfig = (BaseDBConfiguration)xmlElem; + if(jdbcConfig.getConnTimeout() > 0){ + this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); + } + if(jdbcConfig.getRequestTimeout() > 0){ + this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); + } + + // set connection pool name + String dbConnectionName = jdbcConfig.getDbConnectionName(); + super.setDbConnectionName(dbConnectionName); + // Configure the JDBC connection + dbUserId = jdbcConfig.getDbUserId(); + if (dbUserId == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + dbPasswd = jdbcConfig.getDbPasswd(); + if (dbPasswd == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + /* + dbDriver = jdbcConfig.getDbDriver(); + if (dbDriver == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new ScpTblUpdateError(errorMsg); + } + */ + + minLimit = jdbcConfig.getDbMinLimit(); +// if (minLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + maxLimit = jdbcConfig.getDbMaxLimit(); +// if (maxLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + initialLimit = jdbcConfig.getDbInitialLimit(); +// if (initialLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + + dbUrl = jdbcConfig.getDbUrl(); + if(dbUrl == null){ + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + try { + Driver dr = new com.mysql.jdbc.Driver(); + Class clazz = Class.forName("com.mysql.jdbc.Driver") ; + + PoolProperties p = new PoolProperties(); + p.setDriverClassName("com.mysql.jdbc.Driver"); + p.setUrl(dbUrl); + p.setUsername(dbUserId); + p.setPassword(dbPasswd); + p.setJmxEnabled(true); + p.setTestWhileIdle(false); + p.setTestOnBorrow(true); + p.setValidationQuery("SELECT 1"); + p.setTestOnReturn(false); + p.setValidationInterval(30000); + p.setTimeBetweenEvictionRunsMillis(30000); + p.setInitialSize(initialLimit); + p.setMaxActive(maxLimit); + p.setMaxIdle(maxLimit); + p.setMaxWait(10000); + p.setRemoveAbandonedTimeout(60); + p.setMinEvictableIdleTimeMillis(30000); + p.setMinIdle(minLimit); + p.setLogAbandoned(true); + p.setRemoveAbandoned(true); + p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" + + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"); + + DataSource dataSource = new DataSource(p); + + synchronized(this) + { + this.ds = dataSource; + Connection con = null; + PreparedStatement st = null; + ResultSet rs = null; + + try { + con = dataSource.getConnection(); + st = con.prepareStatement("Select 1 FROM DUAL"); + rs = st.executeQuery(); + } catch(Exception exc) { + LOGGER.error(exc.getMessage()); + } finally { + if(rs != null) rs.close(); + if(st != null) st.close(); + if(con != null) con.close(); + } + + initialized = true; + LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); + } + +// } catch (SQLException exc) { +// initialized = false; +// StringBuffer sb = new StringBuffer(); +// sb.append("Failed to initialize MySQLDataSource<"); +// sb.append(dbConnectionName).append(">. Reason: "); +// sb.append(exc.getMessage()); +// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +//// throw new DBConfigException(e.getMessage()); + } catch (Exception exc) { + initialized = false; + StringBuffer sb = new StringBuffer(); + sb.append("Failed to initialize MySQLCachedDataSource <"); + sb.append(dbConnectionName).append(">. Reason: "); + sb.append(exc.getMessage()); + LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +// throw new DBConfigException(e.getMessage()); + } + } + + public final String getDbUrl() + { + return dbUrl; + } + + public final String getDbUserId() + { + return dbUserId; + } + + public final String getDbPasswd() + { + return dbPasswd; + } + + public static JdbcDBCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { + return new JdbcDBCachedDataSource(config); + } + + public String toString(){ + return getDbConnectionName(); + } + + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } + + public void cleanUp(){ + DataSource dataSource = (DataSource)ds; + dataSource.getPool().purge(); + int active = dataSource.getActive(); + int size = dataSource.getSize(); + dataSource.close(true); + super.cleanUp(); + } + +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDbResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDbResourceManagerFactory.java new file mode 100644 index 000000000..84399dfd9 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDbResourceManagerFactory.java @@ -0,0 +1,186 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.jdbc; + + +import java.sql.SQLException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; + +import org.openecomp.sdnc.sli.resource.dblib.CachedDataSource; +import org.openecomp.sdnc.sli.resource.dblib.CachedDataSourceFactory; +import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager; +import org.openecomp.sdnc.sli.resource.dblib.DataSourceComparator; +import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; +import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; +import org.openecomp.sdnc.sli.resource.dblib.factory.AbstractResourceManagerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @version $Revision: 1.6 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class JdbcDbResourceManagerFactory extends AbstractResourceManagerFactory { + private static Logger LOGGER = LoggerFactory.getLogger(JdbcDbResourceManagerFactory.class ); + private JdbcDbResourceManagerFactory(){ + + } + + class MyFutureTask extends FutureTask + { + + public MyFutureTask(Callable result) { + super(result); + } + + } + + public CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager, String sourceName) throws SQLException + { + // here create the data sources objects + JDBCConfiguration[] list = dbConfig.getJDBCbSourceArray(); + CachedDataSource[] cachedDS = new CachedDataSource[1]; + + for(int i=0, max=list.length; i tasks = new HashSet(); + if(LOGGER.isDebugEnabled()) { + LOGGER.debug("Creating " + list.length + " datasources."); + } + + for(int i=0, max=list.length; i 0){ + this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); + } + if(jdbcConfig.getRequestTimeout() > 0){ + this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); + } + + // set connection pool name + String dbConnectionName = jdbcConfig.getDbConnectionName(); + super.setDbConnectionName(dbConnectionName); + // Configure the JDBC connection + dbUserId = jdbcConfig.getDbUserId(); + if (dbUserId == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + dbPasswd = jdbcConfig.getDbPasswd(); + if (dbPasswd == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + /* + dbDriver = jdbcConfig.getDbDriver(); + if (dbDriver == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new ScpTblUpdateError(errorMsg); + } + */ + + minLimit = Integer.toString(jdbcConfig.getDbMinLimit()); + if (minLimit == null) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + maxLimit = Integer.toString(jdbcConfig.getDbMaxLimit()); + if (maxLimit == null) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + initialLimit = Integer.toString(jdbcConfig.getDbInitialLimit()); + if (initialLimit == null) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + dbUrl = jdbcConfig.getDbUrl(); + if(dbUrl == null){ + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + try { + + MysqlDataSource dataSource = new MysqlDataSource(); + dataSource.setUser(dbUserId); + dataSource.setPassword(dbPasswd); + dataSource.setURL(dbUrl); +// dataSource.setInitialSize(5); +// dataSource.setMaxTotal(60); +// dataSource.setMaxActive(100); +// dataSource.setMaxWait(10000); +// dataSource.setMaxIdle(10); + + Properties connAttr = new Properties(); + + connAttr.setProperty("MinLimit", minLimit); + connAttr.setProperty("MaxLimit", maxLimit); + connAttr.setProperty("InitialLimit", initialLimit); + connAttr.setProperty("TRANSACTION_ISOLATION","SERIALIZABLE"); + connAttr.setProperty("CONNECTION_TAG", dbConnectionName.toUpperCase()+"_CONNECTION"); + connAttr.setProperty("InactivityTimeout", "900"); + connAttr.setProperty("AbandonedConnectionTimeout", "600"); + connAttr.setProperty("PropertyCheckInterval", "60"); + connAttr.setProperty("ValidateConnection", "true"); + + + synchronized(this) + { + this.ds = dataSource; + + initialized = true; + LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); + } + +// } catch (SQLException exc) { +// initialized = false; +// StringBuffer sb = new StringBuffer(); +// sb.append("Failed to initialize MySQLDataSource<"); +// sb.append(dbConnectionName).append(">. Reason: "); +// sb.append(exc.getMessage()); +// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +//// throw new DBConfigException(e.getMessage()); + } catch (Exception exc) { + initialized = false; + StringBuffer sb = new StringBuffer(); + sb.append("Failed to initialize MySQLCachedDataSource <"); + sb.append(dbConnectionName).append(">. Reason: "); + sb.append(exc.getMessage()); + LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +// throw new DBConfigException(e.getMessage()); + } + } + + public final String getDbUrl() + { + return dbUrl; + } + + public final String getDbUserId() + { + return dbUserId; + } + + public final String getDbPasswd() + { + return dbPasswd; + } + + public static MySQLCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { + return new MySQLCachedDataSource(config); + } + + public String toString(){ + return getDbConnectionName(); + } + + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/PollingWorker.java new file mode 100644 index 000000000..de87fa7e8 --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/PollingWorker.java @@ -0,0 +1,217 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.pm; + +import java.util.Iterator; +import java.util.Properties; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.TreeSet; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.atomic.AtomicLong; + +public class PollingWorker implements Runnable { + + private Logger LOGGER = LoggerFactory.getLogger(PollingWorker.class); + + private static PollingWorker self = null; + + private LinkedBlockingQueue tasks = new LinkedBlockingQueue(100); + private long interval = 1000L; + private Thread worker = null; + private AtomicLong[] counters = null; + private int[] bucketUnit = null; + private static boolean enabled = false; + private Timer timer = null; + + public static void post(long starttime){ + PollingWorker temp = self; + if(temp != null && enabled) { + temp.register(new TestSample(starttime)); + } + } + + public static void createInistance(Properties props){ + self = new PollingWorker(props); + } + + private PollingWorker(Properties ctxprops){ + if(ctxprops==null || ctxprops.getProperty("org.openecomp.sdnc.dblib.pm") == null){ + enabled = false; + } else { + if("true".equalsIgnoreCase((String)ctxprops.getProperty("org.openecomp.sdnc.dblib.pm"))){ + enabled = true; + } else { + enabled = false; + } + } + + interval = Long.parseLong(( ctxprops == null || ctxprops.getProperty("org.openecomp.sdnc.dblib.pm.interval") == null) ? "60" : (String)ctxprops.getProperty("org.openecomp.sdnc.dblib.pm.interval")); + // '0' bucket is to count exceptions + String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.openecomp.sdnc.dblib.pm.sampling")==null) ? "0,2,5,10,20,50,100" : (String)ctxprops.getProperty("org.openecomp.sdnc.dblib.pm.sampling")).split(","); + + if(enabled){ + bucketUnit = new int[sampling.length]; + for(int i=0, max = bucketUnit.length; i x.starttime) + return -1; + if(endtime > x.endtime) + return -1; + return 0; + } + return 1; + } + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitor.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitor.java new file mode 100644 index 000000000..c58c9db7d --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitor.java @@ -0,0 +1,237 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.pm; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collections; +import java.util.Observable; +import java.util.Observer; +import java.util.SortedSet; +import java.util.Timer; +import java.util.TimerTask; +import java.util.TreeSet; +import java.util.concurrent.atomic.AtomicLong; + +import org.openecomp.sdnc.sli.resource.dblib.DBResourceObserver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SQLExecutionMonitor extends Observable +{ + private static Logger LOGGER = LoggerFactory.getLogger(SQLExecutionMonitor.class); + + final static long MILISECOND = 1000000L; + final static long SECOND = 1000L*MILISECOND; + + private final Timer timer; + // collection + private final SortedSet innerSet; + private SQLExecutionMonitorObserver parent = null; + private final AtomicLong completionCounter; + private boolean activeState = false; + private final long interval; + private final long initialDelay; + private final long EXPECTED_TIME_TO_COMPLETE; + private final long UNPROCESSED_FAILOVER_THRESHOLD; + + private final class MonitoringTask extends TimerTask + { + + public void run() + { + try { + TestObject testObj = new TestObject(); + testObj.setStartTime(testObj.getStartTime() - EXPECTED_TIME_TO_COMPLETE); + + // take a snapshot of the current task list + TestObject[] array = innerSet.toArray(new TestObject[0]); + SortedSet copyCurrent = new TreeSet(Arrays.asList(array)); + // get the list of the tasks that are older than the specified + // interval. + SortedSet unprocessed = copyCurrent.headSet(testObj); + + long succesfulCount = completionCounter.get(); + int unprocessedCount = unprocessed.size(); + + if (!unprocessed.isEmpty() && unprocessedCount > UNPROCESSED_FAILOVER_THRESHOLD && succesfulCount == 0) + { + // switch the Connection Pool to passive + setChanged(); + notifyObservers("Open JDBC requests=" + unprocessedCount+" in "+SQLExecutionMonitor.this.parent.getDbConnectionName()); + } + } catch (Exception exc) { + LOGGER.error("", exc); + } finally { + completionCounter.set(0L); + } + } + } + + public static class TestObject implements Comparable, Serializable + { + + private static final long serialVersionUID = 1L; + private long starttime; + private long randId; + + public TestObject() + { + starttime = System.nanoTime(); + } + + public long getStartTime() + { + return starttime; + } + + public void setStartTime(long newTime) + { + starttime = newTime; + } + + public int compareTo(TestObject o) + { + if( this == o) + return 0; + if(this.starttime > o.getStartTime()) + return 1; + if(this.starttime < o.getStartTime()) + return -1; + + if(this.hashCode() > o.hashCode()) + return 1; + if(this.hashCode() < o.hashCode()) + return -1; + + return 0; + } + + public String toString() + { + return Long.toString(starttime)+"#"+ this.hashCode(); + } + + public boolean equals(Object obj) + { + if (this == obj) + return true; + + return (obj instanceof TestObject + && starttime == ((TestObject) obj).getStartTime() + && hashCode() == ((TestObject) obj).hashCode()); + } + } + + public SQLExecutionMonitor(SQLExecutionMonitorObserver parent) + { + this.parent = parent; + completionCounter = new AtomicLong(0L); + interval = parent.getInterval(); + initialDelay = parent.getInitialDelay(); + this.UNPROCESSED_FAILOVER_THRESHOLD = parent.getUnprocessedFailoverThreshold(); + this.EXPECTED_TIME_TO_COMPLETE = parent.getExpectedCompletionTime()*MILISECOND; + + innerSet = Collections.synchronizedSortedSet(new TreeSet()); + timer = new Timer(); + } + + public void cleanup() + { + timer.cancel(); + } + + // registerRequest + public TestObject registerRequest() + { + if(activeState) + { + TestObject test = new TestObject(); + if(innerSet.add(test)) + return test; + } + return null; + } + + // deregisterSuccessfulReguest + public boolean deregisterReguest(TestObject test) + { + if(test == null) + return false; + // remove from the collection + if(innerSet.remove(test) && activeState) + { + completionCounter.incrementAndGet(); + return true; + } + return false; + } + + public void terminate() { + timer.cancel(); + } + + /** + * @return the parent + */ + public final Object getParent() { + return parent; + } + + public void addObserver(Observer observer) + { + if(observer instanceof DBResourceObserver) + { + DBResourceObserver dbObserver = (DBResourceObserver)observer; + if(dbObserver.isMonitorDbResponse()) + { + if(countObservers() == 0) + { + TimerTask remindTask = new MonitoringTask(); + timer.schedule(remindTask, initialDelay, interval); + activeState = true; + } + } + } + super.addObserver(observer); + } + + public void deleteObserver(Observer observer) + { + super.deleteObserver(observer); + if(observer instanceof DBResourceObserver) + { + DBResourceObserver dbObserver = (DBResourceObserver)observer; + if(dbObserver.isMonitorDbResponse()) + { + if(countObservers() == 0) + { + timer.cancel(); + activeState = false; + } + } + } + } + + public final int getPorcessedConnectionsCount() { + return innerSet.size(); + } +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitorObserver.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitorObserver.java new file mode 100644 index 000000000..1f329750b --- /dev/null +++ b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitorObserver.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * openecomp + * ================================================================================ + * Copyright (C) 2016 - 2017 AT&T + * ================================================================================ + * 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.openecomp.sdnc.sli.resource.dblib.pm; + +public interface SQLExecutionMonitorObserver { + public String getDbConnectionName(); + + public long getInterval(); + public void setInterval(long value); + + public long getInitialDelay(); + public void setInitialDelay(long value); + + public long getExpectedCompletionTime(); + public void setExpectedCompletionTime(long value); + + public long getUnprocessedFailoverThreshold(); + public void setUnprocessedFailoverThreshold(long value); +} diff --git a/dblib/provider/src/main/resources/dblib.properties b/dblib/provider/src/main/resources/dblib.properties new file mode 100755 index 000000000..ac295c78d --- /dev/null +++ b/dblib/provider/src/main/resources/dblib.properties @@ -0,0 +1,13 @@ +org.openecomp.sdnc.sli.dbtype=jdbc +org.openecomp.sdnc.sli.jdbc.hosts=sdnctldb01,sdnctldb02 +org.openecomp.sdnc.sli.jdbc.url=jdbc:mysql://DBHOST:3306/sdnctl +org.openecomp.sdnc.sli.jdbc.database=sdnctl +org.openecomp.sdnc.sli.jdbc.user={user for sdnctl} +org.openecomp.sdnc.sli.jdbc.password={password for sdnctl} +org.openecomp.sdnc.sli.jdbc.connection.name=sdnctldb01 + +org.openecomp.sdnc.sli.jdbc.connection.timeout=50 +org.openecomp.sdnc.sli.jdbc.request.timeout=100 +org.openecomp.sdnc.sli.jdbc.limit.init=10 +org.openecomp.sdnc.sli.jdbc.limit.min=10 +org.openecomp.sdnc.sli.jdbc.limit.max=20 diff --git a/example-settings.xml b/example-settings.xml new file mode 100644 index 000000000..bfd6b9f4a --- /dev/null +++ b/example-settings.xml @@ -0,0 +1,163 @@ + + + + + + + + openecomp-release + + + openecomp-release + openecomp-release + https://nexus.onap.org/content/repositories/releases/ + + true + never + + + false + + + + + + openecomp-release + openecomp-release + https://nexus.onap.org/content/repositories/releases/ + + true + never + + + false + + + + + + + openecomp-snapshots + + + openecomp-snapshot + openecomp-snapshot + https://nexus.onap.org/content/repositories/snapshots/ + + false + + + true + + + + + + openecomp-snapshot + openecomp-snapshot + https://nexus.onap.org/content/repositories/snapshots/ + + false + + + true + + + + + + opendaylight-release + + + opendaylight-mirror + opendaylight-mirror + https://nexus.opendaylight.org/content/repositories/public/ + + true + never + + + false + + + + + + opendaylight-mirror + opendaylight-mirror + https://nexus.opendaylight.org/content/repositories/public/ + + true + never + + + false + + + + + + + opendaylight-snapshots + + + opendaylight-snapshot + opendaylight-snapshot + https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + false + + + true + + + + + + opendaylight-snapshot + opendaylight-snapshot + https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + false + + + true + + + + + + + + openecomp-release + openecomp-snapshots + opendaylight-release + opendaylight-snapshots + + + + + nexus + USERNAME + PASSWORD + + + openecomp-release + USERNAME + PASSWORD + + + openecomp-snapshot + USERNAME + PASSWORD + + + diff --git a/filters/.gitignore b/filters/.gitignore new file mode 100755 index 000000000..b73caf31e --- /dev/null +++ b/filters/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/filters/.sonar/checkstyle.xml b/filters/.sonar/checkstyle.xml new file mode 100755 index 000000000..3fa231535 --- /dev/null +++ b/filters/.sonar/checkstyle.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/filters/.sonar/pmd.xml b/filters/.sonar/pmd.xml new file mode 100755 index 000000000..80343b3bd --- /dev/null +++ b/filters/.sonar/pmd.xml @@ -0,0 +1,67 @@ + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 2 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 5 + + + 2 + + + 3 + + + 3 + + + diff --git a/filters/README b/filters/README new file mode 100755 index 000000000..9d69d638d --- /dev/null +++ b/filters/README @@ -0,0 +1,14 @@ + +/restconf filters are enabled by specifying filter chain in + /opt/opendaylight/current/etc/org.opendaylight.aaa.filterchain.cfg +and enabling bundle class loading + >bundle:dynamic-import org.openecomp.sdnc.filters-provider + +loggers: + org.openecomp.sdnc.filters.audit + org.openecomp.sdnc.filters.metric + org.openecomp.sdnc.filters.request.response + + + + diff --git a/filters/features/pom.xml b/filters/features/pom.xml new file mode 100755 index 000000000..1e3875deb --- /dev/null +++ b/filters/features/pom.xml @@ -0,0 +1,101 @@ + + + 4.0.0 + + filters + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + filters-features + Filters - Features + + jar + + + + + + org.openecomp.sdnc.core + filters-provider + ${project.version} + + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/filters/features/src/main/resources/features.xml b/filters/features/src/main/resources/features.xml new file mode 100644 index 000000000..1c58e6490 --- /dev/null +++ b/filters/features/src/main/resources/features.xml @@ -0,0 +1,32 @@ + + + + + + + + mvn:org.openecomp.sdnc.core/filters-provider/${project.version} + + + diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml new file mode 100755 index 000000000..579c0e9a5 --- /dev/null +++ b/filters/installer/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + + org.openecomp.sdnc.core + filters + 0.0.1-SNAPSHOT + + filters-installer + Filters - Karaf Installer + pom + + + sdnc-filters + sdnc-filters + mvn:org.openecomp.sdnc.core/filters-features/${project.version}/xml/features + false + + + + + + org.openecomp.sdnc.core + filters-features + ${project.version} + features + xml + + + * + * + + + + + + org.openecomp.sdnc.core + filters-provider + ${project.version} + + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.openecomp.sdnc + sli-common,sli-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/filters/installer/src/assembly/assemble_installer_zip.xml b/filters/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..3a5c5f654 --- /dev/null +++ b/filters/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,61 @@ + + + + + + + bin + + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/filters/installer/src/assembly/assemble_mvnrepo_zip.xml b/filters/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..a9fca4d04 --- /dev/null +++ b/filters/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + bin + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/filters/installer/src/main/resources/scripts/install-feature.sh b/filters/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..93236c5be --- /dev/null +++ b/filters/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +### +# ============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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/filters/pom.xml b/filters/pom.xml new file mode 100644 index 000000000..b075be985 --- /dev/null +++ b/filters/pom.xml @@ -0,0 +1,81 @@ + + + + + org.openecomp.sdnc.core + sdnc-core + 0.0.1-SNAPSHOT + + + 4.0.0 + pom + org.openecomp.sdnc.core + filters + + + Filters + Servlet filter to implement ECOMP logging spec + + 0.0.1-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compile.plugin.version} + + ${java.version.source} + ${java.version.target} + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10 + + + + aggregate + + aggregate + + site + + + + + + + maven-source-plugin + 2.1.1 + + + bundle-sources + package + + + jar-no-fork + + + test-jar-no-fork + + + + + + + + + + OpenECOMP + + + provider + features + installer + + diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml new file mode 100755 index 000000000..a7b6daec1 --- /dev/null +++ b/filters/provider/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + + org.openecomp.sdnc.core + filters + 0.0.1-SNAPSHOT + + filters-provider + bundle + Filters - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + 4.11 + test + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + commons-codec + commons-codec + ${commons.codec.version} + + + org.openecomp.sdnc.core + sli-common + ${project.version} + + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.openecomp.sdnc.filters + org.openecomp.sdnc.filters.Activator + org.openecomp.sdnc.filters + org.openecomp.sdnc.filters + javax.servlet.*,java.io.*,org.osgi.framework.*,org.slf4j.*,org.apache.commons.codec.binary.* + + true + + + + + + + + + diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java new file mode 100644 index 000000000..d21b30992 --- /dev/null +++ b/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java @@ -0,0 +1,63 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.filters; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class Activator implements BundleActivator { + + private ServiceRegistration registration = null; + + private static final Logger LOG = LoggerFactory.getLogger(Activator.class); + + @Override + public void start(BundleContext ctx) throws Exception { + + + + Object impl = new String(); + String regName = impl.getClass().getName(); + + if (registration == null) + { + LOG.debug("Registering Filters service "+regName); + registration = ctx.registerService(regName, impl, null); + } + + } + + @Override + public void stop(BundleContext ctx) throws Exception { + + if (registration != null) + { + registration.unregister(); + registration = null; + } + } + +} diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java new file mode 100644 index 000000000..809cfb287 --- /dev/null +++ b/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java @@ -0,0 +1,222 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.filters; + +import java.io.IOException; +import java.util.UUID; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.codec.binary.Base64; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + + + +/** + * Logs IN request according ECOMP Logging Guidelines at https://tspace.web.att.com/viewer/app/lcfiles/ae5f7751-39da-4c6b-8a83-5836c8c815e1/content + */ +public class LogFilter implements Filter { + + //X-ECOMP is shared between audit and metric + public static final String BEGIN_TIMESTAMP = "AUDIT-BeginTimestamp"; + public static final String END_TIMESTAMP = "AUDIT-EndTimestamp"; + public static final String REQUEST_ID = "X-ECOMP-RequestID"; + public static final String SERVICE_INSTANCE = "X-ECOMP-ServiceInstanceID"; + public static final String THREAD_ID ="X-ECOMP-ThreadId"; //optional + public static final String PHYSICAL_SERVER_NAME="X-ECOMP-PhysicalServerName"; //optional + public static final String SERVICE_NAME="X-ECOMP-ServiceName"; + public static final String PARTNER_NAME="X-ECOMP-PartnerName"; + public static final String STATUS_CODE="AUDIT-StatusCode"; + public static final String RESP_CODE="AUDIT-ResponseCode"; + public static final String RESP_DESC="AUDIT-ResponseDescription"; + public static final String INSTANCE_UUID="AUDIT-InstanceUUID"; + public static final String CATEGORY="AUDIT-INFO"; + public static final String SEVERITY ="AUDIT-Severity"; //optional + public static final String SERVER_IP="AUDIT-ServerIP"; //by chef node['ip'] + public static final String ELAPSED_TIME="AUDIT-ElapsedTime"; + public static final String SERVER_HOST="AUDIT-Server";//by chef node['fqdn'] + public static final String CLIENT_IP="AUDIT-ClientIPaddress"; + public static final String CLASS="AUDIT-Classname"; //optional + public static final String UNUSED="AUDIT-Unused"; //empty + public static final String PROCESS_KEY="AUDIT-ProcessKey"; //optional + public static final String CUST_1="AUDIT-CustomField1";//optional + public static final String CUST_2="AUDIT-CustomField2"; //optional + public static final String CUST_3="AUDIT-CustomField3"; //optional + public static final String CUST_4="AUDIT-CustomField4"; //optional + public static final String DETAIL_MESSAGE="AUDIT-DetailMessage";//optional + + + private static final Logger log = LoggerFactory.getLogger(LogFilter.class); + private static final Logger AUDIT = LoggerFactory.getLogger("org.openecomp.sdnc.filters.audit"); + @Override + public void destroy() { + } + + @Override + public void doFilter(final ServletRequest request, final ServletResponse response, + final FilterChain filterChain) throws IOException, ServletException { + + long startTime = System.currentTimeMillis(); + try { + + if ( request != null && request instanceof HttpServletRequest ) { + pre((HttpServletRequest)request); + } + filterChain.doFilter(request, response); + + + } finally { + + if (request != null && request instanceof HttpServletRequest ) { + post((HttpServletRequest)request,(HttpServletResponse)response,startTime); + } + MDC.clear(); + } + + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + + + private void pre(HttpServletRequest request) { + + UUID uuid = UUID.randomUUID(); + // check if uuid is in header X-ECOMP-RequestID + + String ecompUUID = request.getHeader(REQUEST_ID); + + if (ecompUUID != null && ecompUUID.length() > 0) { + try { + uuid = UUID.fromString(ecompUUID); + log.info("UUID is ECOMP UUID " + uuid.toString()); + } catch (Exception ex){ + log.warn("Failed to convert ECOMP UUID to java.util.UUID format:" + ecompUUID,ex); + } + } + MDC.put(REQUEST_ID, uuid.toString()); + + String userName="unknown"; + + /* below returning org.opendaylight.aaa.shiro.realm.TokenAuthRealm$ODLPrincipal@745dfcfe + if ( request.getUserPrincipal() != null) { + userName = request.getUserPrincipal().getName(); + } + */ + // going directly after Authorization header + if (request.getHeader("Authorization") != null) { + String authzHeader = request.getHeader("Authorization"); + String usernameAndPassword = new String(Base64.decodeBase64(authzHeader.substring(6).getBytes())); + + int userNameIndex = usernameAndPassword.indexOf(":"); + String username = usernameAndPassword.substring(0, userNameIndex); + userName = username; + + } + + + MDC.put(PARTNER_NAME, userName); + //just to initilaze for metric logger (outbound calls) + MDC.put("X-ECOMP-TargetEntity",""); + MDC.put("X-ECOMP-TargetServiceName",""); + + MDC.put(SERVICE_NAME,request.getRequestURL().toString()); + MDC.put(SERVICE_INSTANCE,""); + + } + + + private void post(HttpServletRequest request,HttpServletResponse response,long startTime) { + + //AUDIT.info("{}|{}|{}{}",request.getRemoteHost(),request.getMethod(),request.getRequestURL().toString(),request.getQueryString()); + //AUDIT.info(request.getRemoteHost() + D + request.getMethod() + D + request.getRequestURL().toString() + D + request.getQueryString()); + //METRIC.info(request.getMethod() + D + response.getStatus() + D + request.getRequestURL().toString() + D + (System.currentTimeMillis() - startTime) + " ms"); + MDC.put(BEGIN_TIMESTAMP,asIso8601(startTime)); + MDC.put(END_TIMESTAMP,asIso8601(System.currentTimeMillis())); + //MDC.put(REQUEST_ID,"already done above"); + MDC.put(SERVICE_NAME,request.getRequestURL().toString()); + int idx = request.getPathInfo().toString().lastIndexOf(":"); + String instance = ""; + if ( idx != -1 ) { + instance = request.getPathInfo().substring(idx+1); + } + MDC.put(SERVICE_INSTANCE,instance); + MDC.put(THREAD_ID,""); + MDC.put(PHYSICAL_SERVER_NAME,""); + //MDC.put(PARTNER_NAME,"already done above"); + if ( response.getStatus() >= 400 ) { + MDC.put(STATUS_CODE,"ERROR"); + } else { + MDC.put(STATUS_CODE,"COMPLETE"); + } + + MDC.put(RESP_CODE,"" + response.getStatus()); + MDC.put(RESP_DESC,""); + MDC.put(INSTANCE_UUID,""); + MDC.put(CATEGORY,""); + MDC.put(SEVERITY,""); + //MDC.put(SERVER_IP,""); //by chef + MDC.put(ELAPSED_TIME,"" + (System.currentTimeMillis() - startTime)); + //MDC.put(SERVER_HOST,""); //by chef + MDC.put(CLIENT_IP,request.getRemoteHost()); + MDC.put(CLASS,""); + MDC.put(UNUSED,""); + MDC.put(PROCESS_KEY,""); + MDC.put(CUST_1,""); + MDC.put(CUST_2,""); + MDC.put(CUST_3,""); + MDC.put(CUST_4,""); + MDC.put(DETAIL_MESSAGE,request.getMethod()); + + AUDIT.info(""); + } + + private String asIso8601(Date date) { + TimeZone tz = TimeZone.getTimeZone("UTC"); + DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'hh:mm:ss:SS'+00:00'"); + df.setTimeZone(tz); + return df.format(date); + } + + private String asIso8601(long tsInMillis) { + return asIso8601(new Date(tsInMillis)); + } + + +} diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java new file mode 100644 index 000000000..183301be5 --- /dev/null +++ b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java @@ -0,0 +1,297 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.filters; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.zip.GZIPInputStream; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.openecomp.sdnc.sli.MessageWriter; + +public class RequestResponseDbLoggingFilter implements Filter { + + private static Logger log = LoggerFactory.getLogger(RequestResponseDbLoggingFilter.class); + + public static final String REQUEST_ID = "X-ECOMP-RequestID"; + + private static class ByteArrayServletStream extends ServletOutputStream { + + ByteArrayOutputStream baos; + + ByteArrayServletStream(ByteArrayOutputStream baos) { + this.baos = baos; + } + + @Override + public void write(int param) throws IOException { + baos.write(param); + } + } + + private static class ByteArrayPrintWriter { + + private ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + private PrintWriter pw = new PrintWriter(baos); + + private ServletOutputStream sos = new ByteArrayServletStream(baos); + + public PrintWriter getWriter() { + return pw; + } + + public ServletOutputStream getStream() { + return sos; + } + + byte[] toByteArray() { + return baos.toByteArray(); + } + } + + private class BufferedServletInputStream extends ServletInputStream { + + ByteArrayInputStream bais; + + public BufferedServletInputStream(ByteArrayInputStream bais) { + this.bais = bais; + } + + @Override + public int available() { + return bais.available(); + } + + @Override + public int read() { + return bais.read(); + } + + @Override + public int read(byte[] buf, int off, int len) { + return bais.read(buf, off, len); + } + + } + + private class BufferedRequestWrapper extends HttpServletRequestWrapper { + + ByteArrayInputStream bais; + + ByteArrayOutputStream baos; + + BufferedServletInputStream bsis; + + byte[] buffer; + + public BufferedRequestWrapper(HttpServletRequest req) throws IOException { + super(req); + + InputStream is = req.getInputStream(); + baos = new ByteArrayOutputStream(); + byte buf[] = new byte[1024]; + int letti; + while ((letti = is.read(buf)) > 0) { + baos.write(buf, 0, letti); + } + buffer = baos.toByteArray(); + + } + + @Override + public ServletInputStream getInputStream() { + try { + bais = new ByteArrayInputStream(buffer); + bsis = new BufferedServletInputStream(bais); + } catch (Exception ex) { + ex.printStackTrace(); + } + + return bsis; + } + + public byte[] getBuffer() { + return buffer; + } + + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + @Override + public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain) + throws IOException, ServletException { + + if (request == null || !(request instanceof HttpServletRequest)) { + filterChain.doFilter(request, response); + return; + } + + long t1 = System.currentTimeMillis(); + + final HttpServletRequest httpRequest = (HttpServletRequest) request; + BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); + + String requestId = httpRequest.getHeader(REQUEST_ID); + if (requestId == null || requestId.trim().length() == 0) { + log.warn("Could not write request in DB: " + REQUEST_ID + " is missing in the HTTP headers."); + return; + } + + String requestHost = request.getRemoteHost(); + if (requestHost == null) + requestHost = request.getRemoteAddr(); + + String requestStr = new String(bufferedRequest.getBuffer()); + + MessageWriter.saveIncomingRequest(requestId, null, requestHost, requestStr); + + long t2 = System.currentTimeMillis(); + + log.info("Request saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1)); + + final HttpServletResponse httpResponse = (HttpServletResponse) response; + + final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(); + HttpServletResponse wrappedResp = new HttpServletResponseWrapper(httpResponse) { + + @Override + public PrintWriter getWriter() { + return pw.getWriter(); + } + + @Override + public ServletOutputStream getOutputStream() { + return pw.getStream(); + } + }; + + try { + + filterChain.doFilter(bufferedRequest, wrappedResp); + + } finally { + + if (request != null && request instanceof HttpServletRequest) { + + t1 = System.currentTimeMillis(); + + byte[] bytes = pw.toByteArray(); + response.getOutputStream().write(bytes); + response.getOutputStream().flush(); + + String responseStr = null; + if ("gzip".equals(httpResponse.getHeader("Content-Encoding"))) { + responseStr = decompressGZIPByteArray(bytes); + } else { + responseStr = new String(bytes); + } + + MessageWriter.saveIncomingResponse(requestId, httpResponse.getStatus(), responseStr); + + t2 = System.currentTimeMillis(); + + log.info("Response saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1)); + } + } + + } + + @Override + public void destroy() { + } + + private String decompressGZIPByteArray(byte[] bytes) { + + BufferedReader in = null; + InputStreamReader inR = null; + ByteArrayInputStream byteS = null; + GZIPInputStream gzS = null; + StringBuilder str = new StringBuilder(); + try { + byteS = new ByteArrayInputStream(bytes); + gzS = new GZIPInputStream(byteS); + inR = new InputStreamReader(gzS); + in = new BufferedReader(inR); + + if (in != null) { + + String content; + + while ((content = in.readLine()) != null) { + str.append(content); + } + } + + } catch (Exception e) { + log.error("Failed get read GZIPInputStream", e); + } finally { + + if (byteS != null) + try { + byteS.close(); + } catch (IOException e1) { + log.error("Failed to close ByteStream", e1); + } + if (gzS != null) + try { + gzS.close(); + } catch (IOException e2) { + log.error("Failed to close GZStream", e2); + } + if (inR != null) + try { + inR.close(); + } catch (IOException e3) { + log.error("Failed to close InputReader", e3); + } + if (in != null) + try { + in.close(); + } catch (IOException e) { + log.error("Failed to close BufferedReader", e); + } + } + return str.toString(); + } +} diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java new file mode 100644 index 000000000..b15932f09 --- /dev/null +++ b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java @@ -0,0 +1,289 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.filters; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.Enumeration; +import java.util.zip.GZIPInputStream; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; + +public class RequestResponseLoggingFilter implements Filter { + + private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("org.openecomp.sdnc.filters.request.response"); + + private static class ByteArrayServletStream extends ServletOutputStream { + + ByteArrayOutputStream baos; + + ByteArrayServletStream(ByteArrayOutputStream baos) { + this.baos = baos; + } + + @Override + public void write(int param) throws IOException { + baos.write(param); + } + } + + private static class ByteArrayPrintWriter { + + private ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + private PrintWriter pw = new PrintWriter(baos); + + private ServletOutputStream sos = new ByteArrayServletStream(baos); + + public PrintWriter getWriter() { + return pw; + } + + public ServletOutputStream getStream() { + return sos; + } + + byte[] toByteArray() { + return baos.toByteArray(); + } + } + + private class BufferedServletInputStream extends ServletInputStream { + + ByteArrayInputStream bais; + + public BufferedServletInputStream(ByteArrayInputStream bais) { + this.bais = bais; + } + + @Override + public int available() { + return bais.available(); + } + + @Override + public int read() { + return bais.read(); + } + + @Override + public int read(byte[] buf, int off, int len) { + return bais.read(buf, off, len); + } + + } + + private class BufferedRequestWrapper extends HttpServletRequestWrapper { + + ByteArrayInputStream bais; + + ByteArrayOutputStream baos; + + BufferedServletInputStream bsis; + + byte[] buffer; + + public BufferedRequestWrapper(HttpServletRequest req) throws IOException { + super(req); + + InputStream is = req.getInputStream(); + baos = new ByteArrayOutputStream(); + byte buf[] = new byte[1024]; + int letti; + while ((letti = is.read(buf)) > 0) { + baos.write(buf, 0, letti); + } + buffer = baos.toByteArray(); + + } + + @Override + public ServletInputStream getInputStream() { + try { + bais = new ByteArrayInputStream(buffer); + bsis = new BufferedServletInputStream(bais); + } catch (Exception ex) { + ex.printStackTrace(); + } + + return bsis; + } + + public byte[] getBuffer() { + return buffer; + } + + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + + final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; + BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); + + StringBuilder requestHeaders = new StringBuilder("REQUEST|"); + requestHeaders.append(httpRequest.getMethod()); + requestHeaders.append(":"); + requestHeaders.append(httpRequest.getRequestURL().toString()); + requestHeaders.append("|"); + String header; + for (Enumeration e = httpRequest.getHeaderNames(); e.hasMoreElements();) { + header = e.nextElement(); + requestHeaders.append(header); + requestHeaders.append(":"); + requestHeaders.append(httpRequest.getHeader(header)); + requestHeaders.append(";"); + + } + log.info(requestHeaders.toString()); + + log.info("REQUEST BODY|" + new String(bufferedRequest.getBuffer())); + + final HttpServletResponse response = (HttpServletResponse) servletResponse; + + final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(); + HttpServletResponse wrappedResp = new HttpServletResponseWrapper(response) { + @Override + public PrintWriter getWriter() { + return pw.getWriter(); + } + + @Override + public ServletOutputStream getOutputStream() { + return pw.getStream(); + } + + }; + + try { + + filterChain.doFilter(bufferedRequest, wrappedResp); + + }catch (Exception e){ + log.error("Chain Exception",e); + throw e; + } finally { + byte[] bytes = pw.toByteArray(); + response.getOutputStream().write(bytes); + response.getOutputStream().flush(); + + StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|"); + + for (String headerName : response.getHeaderNames()) { + responseHeaders.append(headerName); + responseHeaders.append(":"); + responseHeaders.append(response.getHeader(headerName)); + responseHeaders.append(";"); + + } + log.info(responseHeaders.toString()); + + if ("gzip".equals(response.getHeader("Content-Encoding"))) { + + log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes)); + + } else { + + log.info("RESPONSE BODY|" + new String(bytes)); + } + } + } + + @Override + public void destroy() { + } + + private String decompressGZIPByteArray(byte[] bytes) { + + BufferedReader in = null; + InputStreamReader inR = null; + ByteArrayInputStream byteS = null; + GZIPInputStream gzS = null; + StringBuilder str = new StringBuilder(); + try { + byteS = new ByteArrayInputStream(bytes); + gzS = new GZIPInputStream(byteS); + inR = new InputStreamReader(gzS); + in = new BufferedReader(inR); + + if (in != null) { + + String content; + + while ((content = in.readLine()) != null) { + str.append(content); + } + } + + } catch (Exception e) { + log.error("Failed get read GZIPInputStream", e); + } finally { + + if (byteS != null) + try { + byteS.close(); + } catch (IOException e1) { + log.error("Failed to close ByteStream", e1); + } + if (gzS != null) + try { + gzS.close(); + } catch (IOException e2) { + log.error("Failed to close GZStream", e2); + } + if (inR != null) + try { + inR.close(); + } catch (IOException e3) { + log.error("Failed to close InputReader", e3); + } + if (in != null) + try { + in.close(); + } catch (IOException e) { + log.error("Failed to close BufferedReader", e); + } + } + return str.toString(); + } +} diff --git a/jenkins-settings.xml b/jenkins-settings.xml new file mode 100644 index 000000000..344994f85 --- /dev/null +++ b/jenkins-settings.xml @@ -0,0 +1,168 @@ + + + + + + + + openecomp-release + + + openecomp-release + openecomp-release + https://ecomp-nexus:8443/repository/maven-releases/ + + true + never + + + false + + + + + + openecomp-release + openecomp-release + https://ecomp-nexus:8443/repository/maven-releases/ + + true + never + + + false + + + + + + + openecomp-snapshots + + + openecomp-snapshot + openecomp-snapshot + https://ecomp-nexus:8443/repository/maven-snapshots/ + + false + + + true + + + + + + openecomp-snapshot + openecomp-snapshot + https://ecomp-nexus:8443/repository/maven-snapshots/ + + false + + + true + + + + + + opendaylight-release + + + opendaylight-mirror + opendaylight-mirror + https://nexus.opendaylight.org/content/repositories/public/ + + true + never + + + false + + + + + + opendaylight-mirror + opendaylight-mirror + https://nexus.opendaylight.org/content/repositories/public/ + + true + never + + + false + + + + + + + opendaylight-snapshots + + + opendaylight-snapshot + opendaylight-snapshot + https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + false + + + true + + + + + + opendaylight-snapshot + opendaylight-snapshot + https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + + false + + + true + + + + + + + + openecomp-release + openecomp-snapshots + opendaylight-release + opendaylight-snapshots + + + + + nexus + ${ecomp.nexus.user} + ${ecomp.nexus.password} + + + openecomp-release + ${ecomp.nexus.user} + ${ecomp.nexus.password} + + + openecomp-snapshot + ${ecomp.nexus.user} + ${ecomp.nexus.password} + + + sdnc-javadoc + ${ecomp.nexus.user} + ${ecomp.nexus.password} + + + diff --git a/pom.xml b/pom.xml new file mode 100755 index 000000000..bb0df7e78 --- /dev/null +++ b/pom.xml @@ -0,0 +1,183 @@ + + + + 4.0.0 + pom + org.openecomp.sdnc.core + sdnc-core + + SDN-C Core Components + https://wiki.onap.org + The SDN-C core components contains the SLI, dblib and root pom + + + org.onap.ccsdk.parent + odlparent-boron-sr3 + 0.0.1-SNAPSHOT + + + + JIRA + http://jira.onap.org/ + + + + + scm:git:ssh://git@${onap.git.host}/sdnc-code.git + scm:git:ssh://${onap.git.host}:${onap.git.port}/${onap.git.project}/sdnc-core.git + ${onap.git.protocol}://${onap.git.host}/projects/${onap.git.project}/repos/sdnc-core/browse + sdnc-core-1.1.0 + + + + Jenkins + https://jenkins.onap.org/ + + + + + + ecomp-site + dav:https://${onap.nexus.host}/content/sites/site/org/onap/sdnc/core/${project.artifactId}/${project.version} + + + + + + + blackduck + + + blackduck-scan + + + + + + com.blackducksoftware.integration + hub-maven-plugin + 1.4.0 + false + + ${project.name} + ${project.basedir} + + + + create-bdio-file + package + + createHubOutput + + + + + + + + + + + + + + + + + + + + + org.codehaus.mojo + + license-maven-plugin + + 1.10 + + + + false + + ============LICENSE_START======================================================= + + ============LICENSE_END========================================================= + + ================================================================================ + + apache_v2 + + 2017 + + AT&T Intellectual Property. All rights + reserved. + + openECOMP : SDN-C + + true + + true + + true + + true + + + + + + + + first + + + + update-file-header + + + + process-sources + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.17 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + https://${onap.nexus.host} + ${onap.nexus.staging.profile-id} + ${onap.nexus.staging.server-id} + + + + + + + + dblib + sli + filters + sliPluginUtils + sliapi + + + OpenECOMP + + 0.0.1-SNAPSHOT + + + diff --git a/sli/.gitignore b/sli/.gitignore new file mode 100755 index 000000000..3632ac676 --- /dev/null +++ b/sli/.gitignore @@ -0,0 +1,38 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## antlr4 generated files ## +ExprGrammarBaseListener.java +ExprGrammarLexer.java +ExprGrammarListener.java +ExprGrammarParser.java +ExprGrammar.tokens +ExprGrammarLexer.tokens diff --git a/sli/common/pom.xml b/sli/common/pom.xml new file mode 100755 index 000000000..ce98b947c --- /dev/null +++ b/sli/common/pom.xml @@ -0,0 +1,150 @@ + + 4.0.0 + + sli + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + sli-common + bundle + + SLI - Common Classes + The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter + + + + junit + junit + 3.8.1 + test + + + org.antlr + antlr4 + ${antlr.version} + jar + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + 1.7.5 + compile + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + + + org.opendaylight.mdsal + yang-binding + ${odl.mdsal.yang.binding.version} + + + org.opendaylight.yangtools + yang-common + ${odl.yangtools.version} + + + org.opendaylight.mdsal.model + ietf-inet-types + ${odl.ietf-inet-types.version} + + + org.opendaylight.mdsal.model + ietf-yang-types + ${odl.ietf-yang-types.version} + + + org.opendaylight.controller + sal-core-api + ${odl.mdsal.version} + + + org.opendaylight.yangtools + yang-data-impl + ${odl.yangtools.version} + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + mysql + mysql-connector-java + ${mysql.connector.version} + jar + compile + + + org.openecomp.sdnc.core + dblib-provider + ${sdnctl.dblib.version} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + **/*.xsd + + + org.openecomp.sdnc.sli.SvcLogicParser + org.openecomp.sdnc.sli + true + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.openecomp.sdnc.sli;version=${project.version} + * + *;scope=compile;artifactId=commons-lang|commons-lang3 + true + + + + + org.antlr + antlr4-maven-plugin + ${antlr.version} + + + + ${project.basedir}/src/main/java/ + + antlr + + antlr4 + + + + + + + + diff --git a/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 b/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 new file mode 100755 index 000000000..51f401690 --- /dev/null +++ b/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 @@ -0,0 +1,66 @@ +grammar ExprGrammar; + +options { + language = Java; +} + + +COMPAREOP : '==' | '!=' | '>' | '<' | '>=' | '<='; + +RELOP : 'and' | 'or'; + +ADDOP : '+' | '-'; + +MULTOP : '/' | '*'; + +NUMBER : ('0'..'9')+; + +STRING : '\'' ~[\']* '\''; + +IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*; + +// CONTEXT_VAR : '$' IDENTIFIER; + +WS: [ \n\t\r]+ -> skip; + +constant : NUMBER | STRING ; + +variableLead : ('$')? variableTerm ; + +variableTerm : IDENTIFIER ('[' expr ']')? ; + +variable : variableLead ('.' variableTerm)* ('.')?; + +// variable : CONTEXT_VAR ( '[' expr ']' )? ('.' IDENTIFIER )? ; + +atom : constant | variable; + + +expr : atom + | parenExpr + | multExpr + | addExpr + | compareExpr + | relExpr + | funcExpr; + +parenExpr : '(' expr ')'; + +term : atom | parenExpr | funcExpr; + +multExpr : term (MULTOP term)*; + +addExpr : multExpr (ADDOP multExpr)*; + +compareExpr : addExpr COMPAREOP addExpr; + +relExpr : compareExpr (RELOP expr)*; + +funcExpr : IDENTIFIER '(' expr (',' expr)* ')'; + + + + + + + diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java new file mode 100644 index 000000000..3e355baad --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java @@ -0,0 +1,46 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +public class BreakNodeException extends SvcLogicException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public BreakNodeException() + { + super(); + } + + public BreakNodeException(String message) + { + super(message); + } + + public BreakNodeException(String message, Throwable t) + { + super(message, t); + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java new file mode 100644 index 000000000..fa1308f0e --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java @@ -0,0 +1,45 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +public class ConfigurationException extends SvcLogicException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public ConfigurationException() + { + super(); + } + + public ConfigurationException(String msg) + { + super(msg); + } + + public ConfigurationException(String msg, Throwable t) + { + super(msg, t); + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java new file mode 100644 index 000000000..beb22b0b8 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java @@ -0,0 +1,45 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +public class DuplicateValueException extends SvcLogicException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public DuplicateValueException() + { + super(); + } + + public DuplicateValueException(String message) + { + super(message); + } + + public DuplicateValueException(String message, Throwable t) + { + super(message, t); + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java new file mode 100644 index 000000000..5e5b621b0 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java @@ -0,0 +1,302 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.File; +import java.io.FileInputStream; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Properties; + +import javax.sql.rowset.CachedRowSet; + +import org.openecomp.sdnc.sli.resource.dblib.DbLibService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class MessageWriter { + + private static final Logger LOG = LoggerFactory.getLogger(MessageWriter.class); + + private static final String DBLIB_SERVICE = "org.openecomp.sdnc.sli.resource.dblib.DBResourceManager"; + private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final String INCOMING_PROPERTY_NAME = "org.openecomp.sdnc.sli.MessageWriter.writeIncomingRequests"; + private static final String OUTGOING_PROPERTY_NAME = "org.openecomp.sdnc.sli.MessageWriter.writeOutgoingRequests"; + + private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + + private static DbLibService dbLibService = null; + + private static boolean incomingEnabled = false; + private static boolean outgoingEnabled = false; + + private static boolean initialized = false; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static void init() { + if (initialized) + return; + + initialized = true; + + // Read properties + Properties props = new Properties(); + String propPath = System.getenv(SVCLOGIC_PROP_VAR); + + if (propPath == null) { + String propDir = System.getenv(SDNC_CONFIG_DIR); + if (propDir == null) { + propDir = "/opt/sdnc/data/properties"; + } + propPath = propDir + "/svclogic.properties"; + LOG.warn("Environment variable " + SVCLOGIC_PROP_VAR + " unset - defaulting to " + propPath); + } + + File propFile = new File(propPath); + + if (!propFile.exists()) { + LOG.warn("Property file does not exist: " + propPath); + } + + try { + props.load(new FileInputStream(propFile)); + } catch (Exception e) { + LOG.warn("Error loading property file: " + propPath, e); + } + + incomingEnabled = Boolean.valueOf(props.getProperty(INCOMING_PROPERTY_NAME, "false")); + outgoingEnabled = Boolean.valueOf(props.getProperty(OUTGOING_PROPERTY_NAME, "false")); + + LOG.info(INCOMING_PROPERTY_NAME + ": " + incomingEnabled); + LOG.info(OUTGOING_PROPERTY_NAME + ": " + outgoingEnabled); + + if (dbLibService != null) + return; + + BundleContext bctx = FrameworkUtil.getBundle(MessageWriter.class).getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(DBLIB_SERVICE); + + if (sref == null) { + LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")"); + } else { + dbLibService = (DbLibService) bctx.getService(sref); + if (dbLibService == null) { + LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")"); + } + } + } + + public static void saveOutgoingRequest( + String requestId, + String serviceInstanceId, + String targetUrl, + String request) { + try { + init(); + + if (!outgoingEnabled) + return; + + if (serviceInstanceId == null || serviceInstanceId.trim().length() == 0) + serviceInstanceId = "NA"; + + int seqnum = getLastSequenceNumber("OUTGOING_MESSAGE", requestId) + 1; + String now = df.format(new Date()); + + String sql = "INSERT INTO OUTGOING_MESSAGE (\n" + + " request_id, sequence_number, service_instance_id, target_url, request, start_time)\n" + + "VALUES (?, ?, ?, ?, ?, ?)"; + + ArrayList data = new ArrayList<>(); + data.add(requestId); + data.add(String.valueOf(seqnum)); + data.add(serviceInstanceId); + data.add(targetUrl); + data.add(request); + data.add(now); + + dbLibService.writeData(sql, data, null); + + } catch (Exception e) { + LOG.warn("Failed to save outgoing request for request-id: " + requestId, e); + } + } + + public static void saveOutgoingResponse(String requestId, int httpResponseCode, String response) { + try { + init(); + + if (!outgoingEnabled) + return; + + int seqnum = getLastSequenceNumber("OUTGOING_MESSAGE", requestId); + if (seqnum == 0) { + LOG.warn("Failed to save outgoing response for request-id: " + requestId + + ": Request record not found in OUTGOING_MESSAGE"); + return; + } + + String now = df.format(new Date()); + + String sql = "UPDATE OUTGOING_MESSAGE SET http_response_code = ?, response = ?,\n" + + " duration = timestampdiff(MICROSECOND, start_time, ?) / 1000\n" + + "WHERE request_id = ? AND sequence_number = ?"; + + ArrayList data = new ArrayList<>(); + data.add(String.valueOf(httpResponseCode)); + data.add(response); + data.add(now); + data.add(requestId); + data.add(String.valueOf(seqnum)); + + dbLibService.writeData(sql, data, null); + + } catch (Exception e) { + LOG.warn("Failed to save outgoing response for request-id: " + requestId, e); + } + } + + public static void saveIncomingRequest( + String requestId, + String serviceInstanceId, + String requestHost, + String request) { + try { + init(); + + if (!incomingEnabled) + return; + + if (serviceInstanceId == null || serviceInstanceId.trim().length() == 0) + serviceInstanceId = "NA"; + + int seqnum = getLastSequenceNumber("INCOMING_MESSAGE", requestId) + 1; + String now = df.format(new Date()); + + String sql = "INSERT INTO INCOMING_MESSAGE (\n" + + " request_id, sequence_number, service_instance_id, request_host, request, start_time)\n" + + "VALUES (?, ?, ?, ?, ?, ?)"; + + ArrayList data = new ArrayList<>(); + data.add(requestId); + data.add(String.valueOf(seqnum)); + data.add(serviceInstanceId); + data.add(requestHost); + data.add(request); + data.add(now); + + dbLibService.writeData(sql, data, null); + + } catch (Exception e) { + LOG.warn("Failed to save incoming request for request-id: " + requestId, e); + } + } + + public static void saveIncomingResponse(String requestId, int httpResponseCode, String response) { + try { + init(); + + if (!incomingEnabled) + return; + + int seqnum = getLastSequenceNumber("INCOMING_MESSAGE", requestId); + if (seqnum == 0) { + LOG.warn("Failed to save response for request-id: " + requestId + + ": Request record not found in INCOMING_MESSAGE"); + return; + } + + String now = df.format(new Date()); + + String sql = "UPDATE INCOMING_MESSAGE SET http_response_code = ?, response = ?,\n" + + " duration = timestampdiff(MICROSECOND, start_time, ?) / 1000\n" + + "WHERE request_id = ? AND sequence_number = ?"; + + ArrayList data = new ArrayList<>(); + data.add(String.valueOf(httpResponseCode)); + data.add(response); + data.add(now); + data.add(requestId); + data.add(String.valueOf(seqnum)); + + dbLibService.writeData(sql, data, null); + + } catch (Exception e) { + LOG.warn("Failed to save response for request-id: " + requestId, e); + } + } + + public static String getServiceInstanceId(String requestId) throws SQLException { + init(); + + String sql = "SELECT service_instance_id FROM OUTGOING_MESSAGE WHERE request_id = '" + requestId + + "' ORDER BY sequence_number DESC"; + + CachedRowSet rs = null; + try { + rs = dbLibService.getData(sql, null, null); + if (rs.next()) { + return rs.getString("service_instance_id"); + } + } finally { + if (rs != null) { + try { + rs.close(); + } catch (Exception e) { + LOG.warn("Failed to close CachedRowSet", e); + } + } + } + return null; + } + + private static int getLastSequenceNumber(String tableName, String requestId) throws SQLException { + String sql = "SELECT sequence_number FROM " + tableName + " WHERE request_id = '" + requestId + + "' ORDER BY sequence_number DESC"; + + CachedRowSet rs = null; + try { + rs = dbLibService.getData(sql, null, null); + if (rs.next()) { + return rs.getInt("sequence_number"); + } + } finally { + if (rs != null) { + try { + rs.close(); + } catch (Exception e) { + LOG.warn("Failed to close CachedRowSet", e); + } + } + } + return 0; + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java new file mode 100644 index 000000000..14b1f008b --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java @@ -0,0 +1,301 @@ +/*- + * ============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========================================================= + */ + +/** + * + */ +package org.openecomp.sdnc.sli; + +import java.net.InetAddress; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +/** + * @author dt5972 + * + */ +public class MetricLogger { + + private static final Logger KARAF = LoggerFactory.getLogger(MetricLogger.class); + private static final Logger METRIC = LoggerFactory.getLogger("org.openecomp.sdnc.filters.metric"); + + public static final String BEGIN_TIMESTAMP = "X-ECOMP-BeginTimestamp"; + public static final String END_TIMESTAMP = "X-ECOMP-EndTimestamp"; + public static final String REQUEST_ID = "X-ECOMP-RequestID"; + public static final String SERVICE_INSTANCE_ID = "X-ECOMP-ServiceInstanceID"; + public static final String SERVICE_NAME = "X-ECOMP-ServiceName"; + public static final String PARTNER_NAME = "X-ECOMP-PartnerName"; + public static final String TARGET_ENTITY = "X-ECOMP-TargetEntity"; + public static final String TARGET_SERVICE_NAME = "X-ECOMP-TargetServiceName"; + public static final String STATUS_CODE = "X-ECOMP-StatusCode"; + public static final String RESPONSE_CODE = "X-ECOMP-ResponseCode"; + public static final String RESPONSE_DESCRIPTION = "X-ECOMP-ResponseDescription"; + public static final String INSTANCE_UUID = "X-ECOMP-InstanceUUID"; + public static final String CATEGORY_LOG_LEVEL = "X-ECOMP-CategoryLogLevel"; + public static final String SEVERITY = "X-ECOMP-Severity"; + public static final String SERVER_IP_ADDRESS = "X-ECOMP-ServerIpAddress"; + public static final String ELAPSED_TIME = "X-ECOMP-ElapsedTime"; + public static final String SERVER = "X-ECOMP-Server"; + public static final String CLIENT_IP = "X-ECOMP-ClientIp"; + public static final String CLASS_NAME = "X-ECOMP-ClassName"; + public static final String TARGET_VIRTUAL_ENTITY = "X-ECOMP-TargetVirtualEntity"; + + private long beginTimestamp; + private String lastMsg = null; + + public MetricLogger() { + beginTimestamp = System.currentTimeMillis(); + + try { + InetAddress localhost = InetAddress.getLocalHost(); + setServerIpAddress(localhost.getHostAddress()); + setServer(localhost.getCanonicalHostName()); + } catch (Exception e) { + KARAF.error("Could not get localhost", e); + } + + } + + + public String getBeginTimestamp() { + return MDC.get(BEGIN_TIMESTAMP); + } + + private void setBeginTimestamp(long beginTimestamp) { + this.beginTimestamp = beginTimestamp; + MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(beginTimestamp)); + } + + public String getEndTimestamp() { + return MDC.get(END_TIMESTAMP); + } + + private void setEndTimestamp(long endTimestamp) { + // Set MDC with formatted time stamp + MDC.put(END_TIMESTAMP, MetricLogger.asIso8601(endTimestamp)); + + // Set elapsed time + setElapsedTime(endTimestamp - beginTimestamp); + + } + + public String getRequestID() { + return MDC.get(REQUEST_ID); + } + + + public String getServiceInstanceID() { + return MDC.get(SERVICE_INSTANCE_ID); + } + + private void setServiceInstanceID(String svcInstanceId) { + MDC.put(SERVICE_INSTANCE_ID, svcInstanceId); + } + + public String getServiceName() { + return MDC.get(SERVICE_NAME); + } + + private void setServiceName(String svcName) { + MDC.put(SERVICE_NAME, svcName); + } + + public String getPartnerName() { + return MDC.get(PARTNER_NAME); + } + + private void setPartnerName(String partnerName) { + MDC.put(PARTNER_NAME, partnerName); + } + + public String getTargetEntity() { + return MDC.get(TARGET_ENTITY); + } + + private void setTargetEntity(String targetEntity) { + MDC.put(TARGET_ENTITY, targetEntity); + } + + public String getTargetServiceName() { + return MDC.get(TARGET_SERVICE_NAME); + } + + private void setTargetServiceName(String targetServiceName) { + MDC.put(TARGET_SERVICE_NAME, targetServiceName); + } + + public String getStatusCode() { + return MDC.get(STATUS_CODE); + } + + private void setStatusCode(String statusCode) { + MDC.put(STATUS_CODE, statusCode); + } + + public String getResponseCode() { + return MDC.get(RESPONSE_CODE); + } + + private void setResponseCode(String responseCode) { + MDC.put(RESPONSE_CODE, responseCode); + } + + public String getResponseDescription() { + return MDC.get(RESPONSE_DESCRIPTION); + } + + private void setResponseDescription(String responseDesc) { + MDC.put(RESPONSE_DESCRIPTION, responseDesc); + } + + public String getInstanceUUID() { + return MDC.get(INSTANCE_UUID); + } + + private void setInstanceUUID(String instanceUUID) { + MDC.put(INSTANCE_UUID, instanceUUID); + } + + public String getCategoryLogLevel() { + return MDC.get(CATEGORY_LOG_LEVEL); + } + + private void setCategoryLogLevel(String categoryLogLevel) { + MDC.put(CATEGORY_LOG_LEVEL, categoryLogLevel); + } + + public String getSeverity() { + return MDC.get(SEVERITY); + } + + private void setSeverity(String severity) { + MDC.put(SEVERITY, severity); + } + + public String getServerIpAddress() { + return MDC.get(SERVER_IP_ADDRESS); + } + + private void setServerIpAddress(String serverIpAddress) { + MDC.put(SERVER_IP_ADDRESS, serverIpAddress); + } + + public String getElapsedTime() { + return MDC.get(ELAPSED_TIME); + } + + private void setElapsedTime(long elapsedTime) { + MDC.put(ELAPSED_TIME, ""+elapsedTime); + } + + public String getServer() { + return MDC.get(SERVER); + } + + private void setServer(String server) { + MDC.put(SERVER, server); + } + + public String getClientIp() { + return MDC.get(CLIENT_IP); + } + + private void setClientIp(String clientIp) { + MDC.put(CLIENT_IP, clientIp); + } + + public String getClassName() { + return MDC.get(CLASS_NAME); + } + + private void setClassName(String className) { + MDC.put(CLASS_NAME, className); + } + + public String getTargetVirtualEntity() { + return MDC.get(TARGET_VIRTUAL_ENTITY); + } + + private void setTargetVirtualEntity(String targetVirtualEntity) { + MDC.put(TARGET_VIRTUAL_ENTITY, targetVirtualEntity); + } + + public static String asIso8601(Date date) { + TimeZone tz = TimeZone.getTimeZone("UTC"); + DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); + df.setTimeZone(tz); + return df.format(date); + } + + public static String asIso8601(long tsInMillis) { + return MetricLogger.asIso8601(new Date(tsInMillis)); + } + + public void logRequest(String svcInstanceId, String svcName, String partnerName, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) { + + setBeginTimestamp(System.currentTimeMillis()); + + if (svcInstanceId != null) { + setServiceInstanceID(svcInstanceId); + } + + if (svcName != null) { + setServiceName(svcName); + } + + if (partnerName != null) { + setPartnerName(partnerName); + } + + if (targetEntity != null) { + setTargetEntity(targetEntity); + } + + if (targetServiceName != null) { + setTargetServiceName(targetServiceName); + } + + if (targetVirtualEntity != null) { + setTargetVirtualEntity(targetVirtualEntity); + } + + this.lastMsg = msg; + + + } + + public void logResponse(String statusCode, String responseCode, String responseDescription) { + setEndTimestamp(System.currentTimeMillis()); + + setStatusCode(statusCode); + setResponseCode(responseCode); + setResponseDescription(responseDescription); + + METRIC.info(lastMsg); + + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java new file mode 100644 index 000000000..b4d62ab48 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java @@ -0,0 +1,42 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.util.Map; + +public interface SvcLogicAdaptor { + + public enum ConfigStatus { + SUCCESS, + ALREADY_ACTIVE, + NOT_FOUND, + NOT_READY, + FAILURE + } + + public ConfigStatus configure(String key, Map parameters, SvcLogicContext ctx); + + public ConfigStatus activate(String key, SvcLogicContext ctx); + + public ConfigStatus deactivate(String key, SvcLogicContext ctx); + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java new file mode 100644 index 000000000..9ac648933 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java @@ -0,0 +1,174 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class SvcLogicAtom extends SvcLogicExpression { + + public enum AtomType { + NUMBER, + STRING, + IDENTIFIER, + CONTEXT_VAR + + } + + private AtomType atomType; + private String atom; + + + public SvcLogicAtom(String atomType, String atom) + { + this.atomType = AtomType.valueOf(atomType); + this.atom = atom; + + } + + public SvcLogicAtom(String atom) + { + + if (atom == null) + { + this.atomType = null; + this.atom = null; + } + else + { + if (atom.startsWith("$")) + { + this.atomType = AtomType.CONTEXT_VAR; + this.atom = atom.substring(1); + } + else + { + if (Character.isDigit(atom.charAt(0))) + { + this.atomType = AtomType.NUMBER; + this.atom = atom; + } + else if (atom.charAt(0) == '\'') + { + this.atomType = AtomType.STRING; + this.atom = atom.substring(1, atom.length()-1); + } + else + { + this.atomType = AtomType.IDENTIFIER; + this.atom = atom; + + } + + } + } + } + + public AtomType getAtomType() { + return atomType; + } + + public void setAtomType(String newType) + { + atomType = AtomType.valueOf(newType); + } + + public String getAtom() { + return atom; + } + + + + public void setAtomType(AtomType atomType) { + this.atomType = atomType; + } + + public void setAtom(String atom) { + this.atom = atom; + } + + + + public String toString() + { + StringBuffer sbuff = new StringBuffer(); + switch(getAtomType()) + { + case CONTEXT_VAR: + sbuff.append("$"); + case IDENTIFIER: + boolean needDot = false; + for (SvcLogicExpression term: this.getOperands()) + { + if (needDot) + { + sbuff.append("."); + } + sbuff.append(term.toString()); + needDot = true; + } + return(sbuff.toString()); + case STRING: + case NUMBER: + default: + return(atom); + } + } + + public String asParsedExpr() + { + // simplify debugging output for NUMBER type + if (atomType == AtomType.NUMBER) { + return atom; + } + + StringBuffer sbuff = new StringBuffer(); + + sbuff.append("(atom"); + sbuff.append("<"); + sbuff.append(atomType.toString()); + sbuff.append(">"); + + switch(atomType) + { + case IDENTIFIER: + case CONTEXT_VAR: + for (SvcLogicExpression term : getOperands()) + { + sbuff.append(" "); + sbuff.append(term.asParsedExpr()); + + } + break; + default: + sbuff.append(" "); + sbuff.append(atom); + } + + sbuff.append(")"); + return(sbuff.toString()); + } + + + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java new file mode 100644 index 000000000..1d780d7e7 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java @@ -0,0 +1,149 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.util.LinkedList; +import java.util.List; + +public class SvcLogicBinaryExpression extends SvcLogicExpression { + + + public enum OperatorType { + addOp("+"), + subOp("-"), + multOp("*"), + divOp("/"), + equalOp("=="), + ltOp("<"), + leOp("<="), + gtOp(">"), + geOp(">="), + neOp("!="), + andOp("and"), + orOp("or"); + + private String text; + + private OperatorType(String text) + { + this.text = text; + } + + public String getText() + { + return(text); + } + + public static OperatorType fromString(String text) + { + if (text != null) + { + for (OperatorType t : OperatorType.values()) + { + if (text.equalsIgnoreCase(t.getText())) { + + return(t); + } + } + } + return(null); + } + + public String toString() + { + return(text); + } + } + private List operators; + + public List getOperators() { + return operators; + } + + public SvcLogicBinaryExpression() + { + operators = new LinkedList(); + } + + public void addOperator(String operator) + { + operators.add(OperatorType.fromString(operator)); + } + + + public String toString() + { + + Listoperands = getOperands(); + StringBuffer sbuff = new StringBuffer(); + + sbuff.append(operands.get(0).toString()); + for (int i = 0 ; i < operators.size(); i++) + { + sbuff.append(" "); + sbuff.append(operators.get(i)); + sbuff.append(" "); + if (i + 1 < operands.size()) { + sbuff.append(operands.get(i + 1).toString()); + } else { + // expression incomplete; operand not bound yet + sbuff.append("?"); + } + } + + return(sbuff.toString()); + + } + + public String asParsedExpr() { + + List operands = getOperands(); + + if (operators.isEmpty()) { + return operands.get(0).asParsedExpr(); + } else { + StringBuffer sbuff = new StringBuffer(); + // operators in reverse order for left associativity + for (int i = operators.size() - 1; i >= 0; --i) { + sbuff.append("("); + sbuff.append(operators.get(i).getText()); + sbuff.append(" "); + } + for (int i = 0; i < operators.size() + 1; ++i) { + if (i < operands.size()) { + sbuff.append(operands.get(i).asParsedExpr()); + } else { + // expression incomplete; operand not bound yet + sbuff.append("?"); + } + if (i != 0) { + sbuff.append(")"); + } + if (i < operators.size()) { + sbuff.append(" "); + } + } + return sbuff.toString(); + } + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java new file mode 100644 index 000000000..79082af29 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java @@ -0,0 +1,248 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + + +public class SvcLogicContext { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicContext.class); + + private HashMap attributes; + + private DOMDataBroker domDataBroker; + + private String status = "success"; + + public SvcLogicContext() + { + this.attributes = new HashMap (); + + } + + public SvcLogicContext(Properties props) + { + this.attributes = new HashMap (); + + if (props.containsKey("SvcLogic.status")) + { + this.status = props.getProperty("SvcLogic.status"); + } + + for (Object nameObj : props.keySet()) + { + String propName = (String) nameObj; + attributes.put(propName, props.getProperty(propName)); + } + } + + + + public DOMDataBroker getDomDataBroker() { + return domDataBroker; + } + + public void setDomDataBroker(DOMDataBroker domDataBroker) { + this.domDataBroker = domDataBroker; + } + + public String getAttribute(String name) + { + if (attributes.containsKey(name)) + { + return(attributes.get(name)); + } + else + { + return(null); + } + } + + public void setAttribute(String name, String value) + { + if (value == null) { + if (attributes.containsKey(name)) { + attributes.remove(name); + } + } else { + attributes.put(name, value); + } + } + + public Set getAttributeKeySet() + { + return(attributes.keySet()); + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Properties toProperties() + { + Properties props = new Properties(); + + if (status != null) + { + props.setProperty("SvcLogic.status", status); + } + + for (String attrName : attributes.keySet()) + { + String attrVal = attributes.get(attrName); + if (attrVal == null) { + LOG.warn("attribute " + attrName + + "null - setting to empty string"); + props.setProperty(attrName, ""); + } else { + props.setProperty(attrName, attributes.get(attrName)); + } + } + + return(props); + } + + public void mergeDocument(String pfx, Document doc) { + String prefix = ""; + + if (pfx != null) { + prefix = pfx; + } + + Element root = doc.getDocumentElement(); + + mergeElement(prefix, root, null); + } + + public void mergeElement(String pfx, Element element, Map nodeMap) { + + // In XML, cannot tell the difference between containers and lists. + // So, have to treat each element as both (ugly but necessary). + // We do this by passing a nodeMap to be used to count instance of each tag, + // which will be used to set _length and to set index + + LOG.trace("mergeElement("+pfx+","+element.getTagName()+","+nodeMap+")"); + + String curTagName = element.getTagName(); + String prefix = curTagName; + + if (pfx != null) { + prefix = pfx + "." + prefix; + } + + int myIdx = 0; + + if (nodeMap != null) { + if (nodeMap.containsKey(curTagName)) { + myIdx = nodeMap.get(curTagName).intValue(); + } + + nodeMap.put(curTagName, new Integer(myIdx+1)); + this.setAttribute(prefix+"_length", ""+(myIdx+1)); + } + + NodeList children = element.getChildNodes(); + + int numChildren = children.getLength(); + + Map childMap = new HashMap(); + Map idxChildMap = new HashMap(); + + for (int i = 0 ; i < numChildren ; i++) { + Node curNode = children.item(i); + + if (curNode instanceof Text) { + Text curText = (Text) curNode; + String curTextValue = curText.getTextContent(); + LOG.trace("Setting ctx variable "+prefix+" = "+curTextValue); + this.setAttribute(prefix, curText.getTextContent()); + + + } else if (curNode instanceof Element) { + mergeElement(prefix, (Element) curNode, childMap); + if (nodeMap != null) { + + mergeElement(prefix+"["+myIdx+"]", (Element)curNode, idxChildMap); + + } + } + } + + } + + public String resolve(String ctxVarName) { + + if (ctxVarName.indexOf('[') == -1) { + // Ctx variable contains no arrays + return (this.getAttribute(ctxVarName)); + } + + // Resolve any array references + StringBuffer sbuff = new StringBuffer(); + String[] ctxVarParts = ctxVarName.split("\\["); + sbuff.append(ctxVarParts[0]); + for (int i = 1; i < ctxVarParts.length; i++) { + if (ctxVarParts[i].startsWith("$")) { + int endBracketLoc = ctxVarParts[i].indexOf("]"); + if (endBracketLoc == -1) { + // Missing end bracket ... give up parsing + LOG.warn("Variable reference " + ctxVarName + + " seems to be missing a ']'"); + return (this.getAttribute(ctxVarName)); + } + + String idxVarName = ctxVarParts[i].substring(1, endBracketLoc); + String remainder = ctxVarParts[i].substring(endBracketLoc); + + sbuff.append("["); + sbuff.append(this.getAttribute(idxVarName)); + sbuff.append(remainder); + + } else { + // Index is not a variable reference + sbuff.append("["); + sbuff.append(ctxVarParts[i]); + } + } + + return (this.getAttribute(sbuff.toString())); + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java new file mode 100644 index 000000000..d494eaab2 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java @@ -0,0 +1,533 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.sql.Blob; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import javax.sql.rowset.CachedRowSet; + +import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager; +import org.openecomp.sdnc.sli.resource.dblib.DbLibService; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicDblibStore implements SvcLogicStore { + + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicDblibStore.class); + + private static final String DBLIB_SERVICE = + // "org.openecomp.sdnc.sli.resource.dblib.DBLibService"; + "org.openecomp.sdnc.sli.resource.dblib.DBResourceManager"; + + Properties props = null; + + public void init(Properties props) throws ConfigurationException { + + DbLibService dbSvc = getDbLibService(); + if(dbSvc == null) { + LOG.error("SvcLogic cannot acquire DBLIB_SERVICE"); + return; + } + try { + dbSvc.getData("select 1 from DUAL", new ArrayList(), null); + LOG.debug("SQL test was successful"); + } catch (SQLException e) { + LOG.error("Failed SQL test", e); + } + } + + public boolean hasGraph(String module, String rpc, String version, + String mode) throws SvcLogicException { + + DbLibService dbSvc = getDbLibService(); + + boolean retval = false; + CachedRowSet results = null; + String hasVersionGraphSql = "SELECT count(*) FROM SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + String hasActiveGraphSql = "SELECT count(*) FROM SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + + PreparedStatement hasGraphStmt = null; + + ArrayList args = new ArrayList(); + args.add(module); + args.add(rpc); + args.add(mode); + + try { + + if (version == null) { + results = dbSvc.getData(hasActiveGraphSql, args, null); + } else { + args.add(version); + results = dbSvc.getData(hasVersionGraphSql, args, null); + } + + if (results.next()) { + int cnt = results.getInt(1); + + if (cnt > 0) { + retval = true; + } + + } + } catch (Exception e) { + throw new ConfigurationException("SQL query failed", e); + } finally { + if (results != null) { + try { + + results.close(); + } catch (SQLException x) { + } + } + + } + + return (retval); + + } + + public SvcLogicGraph fetch(String module, String rpc, String version, + String mode) throws SvcLogicException { + + DbLibService dbSvc = getDbLibService(); + + Connection dbConn = null; + SvcLogicGraph retval = null; + ResultSet results = null; + + String fetchVersionGraphSql = "SELECT graph FROM SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + String fetchActiveGraphSql = "SELECT graph FROM SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + + + try { + dbConn = ((DBResourceManager) dbSvc).getConnection(); + PreparedStatement fetchGraphStmt; + + ArrayList args = new ArrayList(); + args.add(module); + args.add(rpc); + args.add(mode); + + if (version == null) { + fetchGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); + } else { + fetchGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); + } + + fetchGraphStmt.setString(1, module); + fetchGraphStmt.setString(2, rpc); + fetchGraphStmt.setString(3, mode); + if (version != null) { + fetchGraphStmt.setString(4,version); + } + + results = fetchGraphStmt.executeQuery(); + + if (results.next()) { + Blob graphBlob = results.getBlob("graph"); + + ObjectInputStream gStream = new ObjectInputStream( + graphBlob.getBinaryStream()); + + Object graphObj = gStream.readObject(); + gStream.close(); + + if (graphObj instanceof SvcLogicGraph) { + retval = (SvcLogicGraph) graphObj; + } else { + throw new ConfigurationException("invalid type for graph (" + + graphObj.getClass().getName()); + + } + + } else { + return (null); + } + } catch (SQLException e) { + throw new ConfigurationException("SQL query failed", e); + } catch (Exception e) { + throw new ConfigurationException("Graph processing failed", e); + } finally { + if (results != null) { + try { + results.close(); + } catch (SQLException x) { + } + } + try { + if (dbConn != null && !dbConn.isClosed()) { + dbConn.close(); + } + } catch (Throwable exc) { + // the exception not monitored + } finally { + dbConn = null; + } + + } + + return (retval); + + } + + public void store(SvcLogicGraph graph) throws SvcLogicException { + + DbLibService dbSvc = getDbLibService(); + + String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph)" + + " VALUES(?, ?, ?, ?, ?, ?)"; + + if (graph == null) { + throw new SvcLogicException("graph cannot be null"); + } + + byte[] graphBytes = null; + + ByteArrayOutputStream byteStr = null; + ObjectOutputStream goutStr = null; + + try { + byteStr = new ByteArrayOutputStream(); + goutStr = new ObjectOutputStream(byteStr); + goutStr.writeObject(graph); + + graphBytes = byteStr.toByteArray(); + + } catch (Exception e) { + throw new SvcLogicException("could not serialize graph", e); + } finally { + + if (goutStr != null) { + try { + goutStr.close(); + } catch (IOException e) { + + } + } + + if (byteStr != null) { + try { + byteStr.close(); + } catch (IOException e) { + + } + } + } + + // If object already stored in database, delete it + if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), + graph.getMode())) { + delete(graph.getModule(), graph.getRpc(), graph.getVersion(), + graph.getMode()); + } + + Connection dbConn = null; + + try { + dbConn = ((DBResourceManager) dbSvc).getConnection(); + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + PreparedStatement storeGraphStmt = dbConn + .prepareStatement(storeGraphSql); + storeGraphStmt.setString(1, graph.getModule()); + storeGraphStmt.setString(2, graph.getRpc()); + storeGraphStmt.setString(3, graph.getVersion()); + storeGraphStmt.setString(4, graph.getMode()); + storeGraphStmt.setString(5, "N"); + storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); + + storeGraphStmt.executeUpdate(); + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + } catch (Exception e) { + throw new SvcLogicException("Could not write object to database", e); + } finally { + try { + if (dbConn != null && !dbConn.isClosed()) { + dbConn.close(); + } + } catch (Throwable exc) { + // the exception not monitored + } finally { + dbConn = null; + } + + } + } + + public void delete(String module, String rpc, String version, String mode) + throws SvcLogicException { + + DbLibService dbSvc = getDbLibService(); + + String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + + ArrayList args = new ArrayList(); + + args.add(module); + args.add(rpc); + args.add(version); + args.add(mode); + + try { + dbSvc.writeData(deleteGraphSql, args, null); + } catch (Exception e) { + throw new SvcLogicException( + "Could not delete object from database", e); + } + } + + public void activate(SvcLogicGraph graph) throws SvcLogicException { + DbLibService dbSvc = getDbLibService(); + + String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; + + String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + ArrayList args = new ArrayList(); + + args.add(graph.getModule()); + args.add(graph.getRpc()); + args.add(graph.getMode()); + + try { + + dbSvc.writeData(deactivateSql, args, null); + + args.add(graph.getVersion()); + dbSvc.writeData(activateSql, args, null); + + } catch (Exception e) { + throw new SvcLogicException("Could not activate graph", e); + } + } + + @Override + public void registerNodeType(String nodeType) throws SvcLogicException { + + String registerNodeSql = "INSERT INTO NODE_TYPES (nodetype) VALUES(?)"; + + if (isValidNodeType(nodeType)) { + return; + } + + DbLibService dbSvc = getDbLibService(); + ArrayList args = new ArrayList(); + + args.add(nodeType); + + try { + dbSvc.writeData(registerNodeSql, args, null); + } catch (Exception e) { + throw new SvcLogicException("Could not add node type to database", + e); + } + + } + + @Override + public void unregisterNodeType(String nodeType) throws SvcLogicException { + + if (!isValidNodeType(nodeType)) { + return; + } + + String unregisterNodeSql = "DELETE FROM NODE_TYPES WHERE nodetype = ?"; + + DbLibService dbSvc = getDbLibService(); + ArrayList args = new ArrayList(); + + args.add(nodeType); + + try { + dbSvc.writeData(unregisterNodeSql, args, null); + } catch (Exception e) { + throw new SvcLogicException( + "Could not delete node type from database", e); + } + + } + + @Override + public boolean isValidNodeType(String nodeType) throws SvcLogicException { + + String validateNodeSql = "SELECT count(*) FROM NODE_TYPES WHERE nodetype = ?"; + + DbLibService dbSvc = getDbLibService(); + + ArrayList args = new ArrayList(); + + args.add(nodeType); + + boolean isValid = false; + + CachedRowSet results = null; + try { + results = dbSvc.getData(validateNodeSql, args, null); + if (results != null) { + if (results.next()) { + int cnt = results.getInt(1); + + if (cnt > 0) { + isValid = true; + } + } + } + } catch (Exception e) { + throw new SvcLogicException( + "Cannot select node type from database", e); + } finally { + if (results != null) { + try { + results.close(); + } catch (SQLException x) { + } + } + + } + + return (isValid); + } + + private DbLibService getDbLibService() { + + // Get DbLibService interface object. + DbLibService dblibSvc = null; + ServiceReference sref = null; + BundleContext bctx = null; + + Bundle bundle = FrameworkUtil.getBundle(SvcLogicDblibStore.class); + + if (bundle != null) { + bctx = bundle.getBundleContext(); + + if (bctx != null) { + sref = bctx.getServiceReference(DBLIB_SERVICE); + } + + if (sref == null) { + LOG.warn("Could not find service reference for DBLIB service (" + + DBLIB_SERVICE + ")"); + } else { + dblibSvc = (DbLibService) bctx.getService(sref); + if (dblibSvc == null) { + + LOG.warn("Could not find service reference for DBLIB service (" + + DBLIB_SERVICE + ")"); + } + } + } + + // initialize a stand-alone instance of dblib resource + else { + // Try to create a DbLibService object from dblib properties + if(JavaSingleton.getInstance() == null){ + Properties dblibProps = new Properties(); + + String propDir = System.getenv(SDNC_CONFIG_DIR); + if (propDir == null) { + + propDir = "/opt/sdnc/data/properties"; + } + String propPath = propDir + "/dblib.properties"; + + File propFile = new File(propPath); + + if (!propFile.exists()) { + + LOG.warn( + "Missing configuration properties file : " + + propFile); + return(null); + } + + try { + + dblibProps.load(new FileInputStream(propFile)); + } catch (Exception e) { + LOG.warn( + "Could not load properties file " + propPath, e); + return(null); + + } + + try { + dblibSvc = DBResourceManager.create(dblibProps); + JavaSingleton.setInstance(dblibSvc); + } catch (Exception e) { + LOG.warn("Caught exception trying to create DBResourceManager", e); + } + } else { + dblibSvc = JavaSingleton.getInstance(); + } + } + return (dblibSvc); + } + + + static class JavaSingleton { + /* Private constructor */ + private JavaSingleton() { + /* the body of the constructor here */ + } + + /* instance of the singleton declaration */ + private static volatile DbLibService INSTANCE ; + + /* Access point to the unique instance of the singleton */ + public static DbLibService getInstance() { + return INSTANCE; + } + + public static void setInstance(DbLibService dbresource) { + INSTANCE = dbresource; + } + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java new file mode 100644 index 000000000..c087b8ad8 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java @@ -0,0 +1,46 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +public class SvcLogicException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public SvcLogicException() + { + super(); + } + + public SvcLogicException(String message) + { + super(message); + } + + public SvcLogicException(String message, Throwable t) + { + super(message, t); + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java new file mode 100644 index 000000000..4fef12fbc --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java @@ -0,0 +1,316 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.util.LinkedList; +import java.util.List; + +import org.antlr.v4.runtime.tree.TerminalNode; +import org.openecomp.sdnc.sli.ExprGrammarParser.AddExprContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.AtomContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.CompareExprContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.ConstantContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.ExprContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.FuncExprContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.MultExprContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.ParenExprContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.RelExprContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.VariableContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.VariableLeadContext; +import org.openecomp.sdnc.sli.ExprGrammarParser.VariableTermContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicExprListener extends ExprGrammarBaseListener +{ + + + + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExprListener.class); + + private SvcLogicExpression curExpr; + private SvcLogicExpression topExpr; + private LinkedList exprStack; + + public SvcLogicExprListener() + { + exprStack = new LinkedList(); + } + + public SvcLogicExpression getParsedExpr() + { + return(curExpr); + } + + private void pushOperand(SvcLogicExpression operand) + { + if (curExpr == null) + { + curExpr = operand; + } + else + { + curExpr.addOperand(operand); + } + } + + private void pushExpr(SvcLogicExpression expr) + { + LOG.trace("Pushing expression ["+expr.getClass().getName()+"]"); + if (curExpr != null) + { + exprStack.push(curExpr); + } + curExpr = expr; + } + + private void popExpr() + { + if (exprStack.isEmpty()) + { + LOG.trace("Popping last expression"); + topExpr = curExpr; + } + else + { + SvcLogicExpression lastExpr = curExpr; + curExpr = exprStack.pop(); + curExpr.addOperand(lastExpr); + LOG.trace("New curExpr is ["+curExpr.getClass().getName()+"]"); + } + + } + + @Override + public void enterAtom(AtomContext ctx) { + + String atomText = ctx.getText(); + + LOG.trace("enterAtom: text = "+atomText); + + + SvcLogicAtom newAtom = new SvcLogicAtom(atomText); + + pushExpr(newAtom); + } + + + @Override + public void enterMultExpr(MultExprContext ctx) { + LOG.trace("enterMultExpr: text = "+ctx.getText()); + + SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); + pushExpr(curBinExpr); + + List opList = ctx.MULTOP(); + + for (TerminalNode nd : opList) + { + LOG.trace("enterMultExpr: operator - "+nd.getText()); + curBinExpr.addOperator(nd.getText()); + } + + } + + @Override + public void exitMultExpr(MultExprContext ctx) { + + LOG.trace("exitMultExpr: text = "+ctx.getText()); + + popExpr(); + + } + + @Override + public void exitAtom(AtomContext ctx) { + LOG.trace("exitAtom: text = "+ctx.getText()); + popExpr(); + } + + @Override + public void enterAddExpr(AddExprContext ctx) { + LOG.trace("enterAddExpr: text = "+ctx.getText()); + List opList = ctx.ADDOP(); + + + SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); + pushExpr(curBinExpr); + + + for (TerminalNode nd : opList) + { + LOG.trace("enterAddExpr: operator - "+nd.getText()); + curBinExpr.addOperator(nd.getText()); + } + + } + + @Override + public void exitAddExpr(AddExprContext ctx) { + LOG.trace("exitAddExpr: text = "+ctx.getText()); + + popExpr(); + } + + @Override + public void enterFuncExpr(FuncExprContext ctx) { + LOG.trace("enterFuncExpr: text = "+ctx.getText()); + LOG.trace("enterFuncExpr - IDENTIFIER : "+ctx.IDENTIFIER().getText()); + + for (ExprContext expr: ctx.expr()) + { + LOG.trace("enterFuncExpr - expr = "+expr.getText()); + } + + + pushExpr(new SvcLogicFunctionCall(ctx.IDENTIFIER().getText())); + } + + @Override + public void exitFuncExpr(FuncExprContext ctx) { + LOG.trace("exitFuncExpr: text = "+ctx.getText()); + + popExpr(); + } + + @Override + public void enterParenExpr(ParenExprContext ctx) { + LOG.trace("enterParenExpr: text = "+ctx.getText()); + LOG.trace("enterParenExpr: expr = "+ctx.expr().getText()); + } + + @Override + public void exitParenExpr(ParenExprContext ctx) { + LOG.trace("exitParenExpr: text = "+ctx.getText()); + } + + @Override + public void enterRelExpr(RelExprContext ctx) { + LOG.trace("enterRelExpr: text = "+ctx.getText()); + + List opList = ctx.RELOP(); + + + SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); + pushExpr(curBinExpr); + + + for (TerminalNode nd : opList) + { + LOG.trace("enterRelExpr: operator - "+nd.getText()); + curBinExpr.addOperator(nd.getText()); + } + + } + + @Override + public void exitRelExpr(RelExprContext ctx) { + LOG.trace("exitRelExpr: text = "+ctx.getText()); + + popExpr(); + } + + @Override + public void enterCompareExpr(CompareExprContext ctx) { + LOG.trace("enterCompareExpr: text = "+ctx.getText()); + + TerminalNode nd = ctx.COMPAREOP(); + + SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); + pushExpr(curBinExpr); + + LOG.trace("enterCompareExpr: operator - "+nd.getText()); + curBinExpr.addOperator(nd.getText()); + + } + + @Override + public void exitCompareExpr(CompareExprContext ctx) { + LOG.trace("exitCompareExpr : text = "+ctx.getText()); + + popExpr(); + } + + + + @Override + public void enterConstant(ConstantContext ctx) { + LOG.trace("enterConstant: text = "+ctx.getText()); + } + + @Override + public void exitConstant(ConstantContext ctx) { + LOG.trace("exitConstant: text = "+ctx.getText()); + } + + + @Override + public void enterVariable(VariableContext ctx) { + LOG.trace("enterVariable: text = "+ctx.getText()); + + + } + + @Override + public void exitVariable(VariableContext ctx) { + LOG.debug("exitVariable: text ="+ctx.getText()); + + } + + + @Override + public void enterVariableLead(VariableLeadContext ctx) { + + LOG.debug("enterVariableLead: text ="+ctx.getText()); + + + } + + @Override + public void exitVariableLead(VariableLeadContext ctx) { + + LOG.trace("exitVariableLead: text ="+ctx.getText()); + } + + @Override + public void enterVariableTerm(VariableTermContext ctx) { + LOG.trace("enterVariableTerm: text ="+ctx.getText()); + + String name = ctx.getText(); + + int subscrStart = name.indexOf("["); + if (subscrStart > -1) + { + name = name.substring(0, subscrStart); + } + SvcLogicVariableTerm vterm = new SvcLogicVariableTerm(name); + pushExpr(vterm); + } + + @Override + public void exitVariableTerm(VariableTermContext ctx) { + LOG.trace("exitVariableTerm: text="+ctx.getText()); + popExpr(); + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java new file mode 100644 index 000000000..4c7dd22be --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java @@ -0,0 +1,44 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import org.antlr.v4.runtime.BaseErrorListener; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.Recognizer; +import org.antlr.v4.runtime.misc.ParseCancellationException; + +public class SvcLogicExprParserErrorListener extends BaseErrorListener { + + private static final SvcLogicExprParserErrorListener instance = new SvcLogicExprParserErrorListener(); + + public static SvcLogicExprParserErrorListener getInstance() { + return(instance); + } + + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, + String msg, RecognitionException e) throws ParseCancellationException { + throw new ParseCancellationException(msg); + } + + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java new file mode 100644 index 000000000..a6af82018 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java @@ -0,0 +1,51 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + + +public abstract class SvcLogicExpression implements Serializable { + + private List operands = new LinkedList(); + + + public void addOperand(SvcLogicExpression expr) + { + operands.add(expr); + } + + public List getOperands() { + return operands; + } + + public int numOperands() + { + return(operands.size()); + } + + public abstract String asParsedExpr(); + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java new file mode 100644 index 000000000..cce8e044d --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java @@ -0,0 +1,99 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.antlr.v4.runtime.ANTLRInputStream; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.tree.ParseTreeWalker; +import org.openecomp.sdnc.sli.ExprGrammarParser.ExprContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class SvcLogicExpressionFactory { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExpressionFactory.class); + + + public static SvcLogicExpression parse(String exprStr) throws IOException + { + LOG.trace("parse("+exprStr+")"); + InputStream exprStream = new ByteArrayInputStream(exprStr.getBytes()); + CharStream input = new ANTLRInputStream(exprStream); + ExprGrammarLexer lexer = new ExprGrammarLexer(input); + CommonTokenStream tokens = new CommonTokenStream(lexer); + ExprGrammarParser parser = new ExprGrammarParser(tokens); + + lexer.removeErrorListeners(); + lexer.addErrorListener(SvcLogicExprParserErrorListener.getInstance()); + parser.removeErrorListeners(); + parser.addErrorListener(SvcLogicExprParserErrorListener.getInstance()); + + ExprContext expression = null; + + try { + expression = parser.expr(); + } catch (Exception e) { + String errorMsg = e.getMessage(); + + LOG.error(errorMsg); + throw new SvcLogicParserException(errorMsg); + } + + + ParseTreeWalker walker = new ParseTreeWalker(); + SvcLogicExprListener listener = new SvcLogicExprListener(); + walker.walk(listener, expression); + + + return(listener.getParsedExpr()); + } + + public static void main(String argv[]) { + + + System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug"); + + StringBuffer sbuff = new StringBuffer(); + + for (int i = 0 ; i < argv.length ; i++) + { + if (sbuff.length() > 0) + { + sbuff.append(" "); + } + sbuff.append(argv[i]); + } + + try { + SvcLogicExpressionFactory.parse(sbuff.toString()); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java new file mode 100644 index 000000000..a98cf6b22 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java @@ -0,0 +1,80 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +public class SvcLogicFunctionCall extends SvcLogicExpression { + + private String functionName; + + public SvcLogicFunctionCall(String functionName) + { + this.functionName = functionName; + } + + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(String functionName) { + this.functionName = functionName; + } + + public String toString() + { + StringBuffer sbuff = new StringBuffer(); + + sbuff.append(functionName); + sbuff.append("("); + boolean needComma = false; + for (SvcLogicExpression operand: getOperands()) + { + if (needComma) + { + sbuff.append(","); + } + else + { + needComma = true; + } + sbuff.append(operand.toString()); + + } + sbuff.append(")"); + return(sbuff.toString()); + } + + public String asParsedExpr() + { + StringBuffer sbuff = new StringBuffer(); + + sbuff.append("("); + sbuff.append(functionName); + for (SvcLogicExpression operand: getOperands()) + { + sbuff.append(" "); + sbuff.append(operand.asParsedExpr()); + } + sbuff.append(")"); + return(sbuff.toString()); + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java new file mode 100644 index 000000000..d3d6d9504 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java @@ -0,0 +1,184 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.PrintStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class SvcLogicGraph implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private String module = null; + private String rpc = null; + private String mode = null; + private String version = null; + + private Map attributes; + private Map namedNodes; + private SvcLogicNode rootNode; + + public SvcLogicGraph() + { + attributes = new HashMap(); + namedNodes = new HashMap(); + rootNode = null; + } + + + public String getModule() { + return module; + } + + + public void setModule(String module) { + this.module = module; + } + + + public String getRpc() { + return rpc; + } + + + public void setRpc(String rpc) { + this.rpc = rpc; + } + + + + + public String getMode() { + return mode; + } + + + public void setMode(String mode) { + this.mode = mode; + } + + + public String getVersion() { + return version; + } + + + public void setVersion(String version) { + this.version = version; + } + + + public void setRootNode(SvcLogicNode rootNode) + { + this.rootNode = rootNode; + } + + public SvcLogicNode getRootNode() + { + return(rootNode); + } + + public Serializable getAttribute(String name) + { + if (attributes.containsKey(name)) + { + return(attributes.get(name)); + } + else + { + return(null); + } + + } + + public void setAttribute(String name, Serializable value) throws DuplicateValueException + { + if (attributes.containsKey(name)) + { + throw new DuplicateValueException("Duplicate attribute "+name); + } + + attributes.put(name, value); + } + + public SvcLogicNode getNamedNode(String nodeName) + { + if (namedNodes.containsKey(nodeName)) + { + return(namedNodes.get(nodeName)); + } + else + { + return(null); + } + } + + public void setNamedNode(String nodeName, SvcLogicNode node) throws DuplicateValueException + { + if (namedNodes.containsKey(nodeName)) + { + throw new DuplicateValueException("Duplicate node name "+nodeName); + } + + namedNodes.put(nodeName, node); + } + + + + public void printAsGv(PrintStream pstr) + { + pstr.println("digraph g {"); + pstr.println("START [label=\"START\\n"+module+":"+rpc+"\"];"); + + if (rootNode != null) + { + pstr.println("START -> node"+rootNode.getNodeId()+";"); + rootNode.setVisited(false, true); + rootNode.printAsGv(pstr); + } + pstr.println("}"); + } + + public void printAsXml(PrintStream pstr) + { + pstr.println(""); + pstr.println(" "); + if (rootNode != null) + { + rootNode.setVisited(false, true); + rootNode.printAsXml(pstr, 2); + } + pstr.println(" "); + pstr.println(""); + } + + @Override + public String toString() { + return "SvcLogicGraph [module=" + module + ", rpc=" + rpc + ", mode=" + mode + ", version=" + version + "]"; + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java new file mode 100644 index 000000000..ac14cacc1 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java @@ -0,0 +1,34 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.util.Map; + +public interface SvcLogicJavaPlugin { + + /** + * A marker interface, used to indicate that a class exposes methods that can be + * called from an node. Such methods must have the signature: + * void methodName(Map, SvcLogicContext) + */ + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java new file mode 100644 index 000000000..b9e7f80ec --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java @@ -0,0 +1,895 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.sql.Blob; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.Driver; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class SvcLogicJdbcStore implements SvcLogicStore { + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicJdbcStore.class); + + private String dbUrl = null; + private String dbName = null; + private String dbUser = null; + private String dbPasswd = null; + private String dbDriver = null; + + private Connection dbConn; + private PreparedStatement hasActiveGraphStmt = null; + private PreparedStatement hasVersionGraphStmt = null; + private PreparedStatement fetchActiveGraphStmt = null; + private PreparedStatement fetchVersionGraphStmt = null; + private PreparedStatement storeGraphStmt = null; + private PreparedStatement deleteGraphStmt = null; + + private PreparedStatement deactivateStmt = null; + private PreparedStatement activateStmt = null; + + private PreparedStatement registerNodeStmt = null; + private PreparedStatement unregisterNodeStmt = null; + private PreparedStatement validateNodeStmt = null; + + private void getConnection() throws ConfigurationException + { + + Properties jdbcProps = new Properties(); + + jdbcProps.setProperty("user", dbUser); + jdbcProps.setProperty("password", dbPasswd); + + try { + Driver dvr = new com.mysql.jdbc.Driver(); + if (dvr.acceptsURL(dbUrl)) + { + LOG.debug("Driver com.mysql.jdbc.Driver accepts "+dbUrl); + } + else + { + LOG.warn("Driver com.mysql.jdbc.Driver does not accept "+dbUrl); + } + } catch (SQLException e1) { + LOG.error("Caught exception trying to load com.mysql.jdbc.Driver", e1); + + + } + + + try + { + this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps); + } + catch (Exception e) + { + throw new ConfigurationException("failed to get database connection ["+dbUrl+"]", e); + } + + } + + private void createTable() throws ConfigurationException + { + + + DatabaseMetaData dbm = null; + + + try { + dbm = dbConn.getMetaData(); + } catch (SQLException e) { + + throw new ConfigurationException("could not get databse metadata", e); + } + + // See if table SVC_LOGIC exists. If not, create it. + try + { + + + ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null); + if (tables.next()) { + // Table exists + } + else { + + String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC (" + + "module varchar(80) NOT NULL," + + "rpc varchar(80) NOT NULL," + + "version varchar(40) NOT NULL," + + "mode varchar(5) NOT NULL," + + "active varchar(1) NOT NULL," + + "graph BLOB," + + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; + + Statement stmt = null; + ConfigurationException myExc = null; + try + { + stmt = dbConn.createStatement(); + stmt.executeUpdate(crTableCmd); + } + catch (SQLException e1) + { + myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1); + } + finally + { + if (stmt != null) + { + stmt.close(); + } + } + + if (myExc != null) + { + throw myExc; + } + } + } + catch (Exception e) + { + throw new ConfigurationException("could not create SVC_LOGIC table", e); + } + + // See if NODE_TYPES table exists and, if not, create it + + try + { + + + ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null); + if (tables.next()) { + // Table exists + } + else { + + String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES (" + + "nodetype varchar(80) NOT NULL," + + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))"; + + Statement stmt = null; + ConfigurationException myExc = null; + try + { + stmt = dbConn.createStatement(); + stmt.executeUpdate(crTableCmd); + } + catch (SQLException e1) + { + myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1); + } + finally + { + if (stmt != null) + { + stmt.close(); + } + } + + if (myExc != null) + { + throw myExc; + } + } + } + catch (Exception e) + { + throw new ConfigurationException("could not create SVC_LOGIC table", e); + } + } + + private void prepStatements() throws ConfigurationException + { + + // Prepare statements + String hasVersionGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + try + { + hasVersionGraphStmt = dbConn.prepareStatement(hasVersionGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); + + } + + String hasActiveGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + + try + { + hasActiveGraphStmt = dbConn.prepareStatement(hasActiveGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); + + } + + String fetchVersionGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + try + { + fetchVersionGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); + + } + + String fetchActiveGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + + try + { + fetchActiveGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); + + } + + String storeGraphSql = "INSERT INTO "+dbName+".SVC_LOGIC (module, rpc, version, mode, active, graph)" + + " VALUES(?, ?, ?, ?, ?, ?)"; + + try + { + storeGraphStmt = dbConn.prepareStatement(storeGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+storeGraphSql, e); + } + + String deleteGraphSql = "DELETE FROM "+dbName+".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + + try + { + deleteGraphStmt = dbConn.prepareStatement(deleteGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+deleteGraphSql, e); + } + + String deactivateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; + + try + { + deactivateStmt = dbConn.prepareStatement(deactivateSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+deactivateSql, e); + } + + String activateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + + try + { + activateStmt = dbConn.prepareStatement(activateSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+activateSql, e); + } + + String registerNodeSql = "INSERT INTO "+dbName+".NODE_TYPES (nodetype) VALUES(?)"; + try + { + registerNodeStmt = dbConn.prepareStatement(registerNodeSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+registerNodeSql, e); + } + + String unregisterNodeSql = "DELETE FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; + try + { + unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+unregisterNodeSql, e); + } + + String validateNodeSql = "SELECT count(*) FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; + try + { + validateNodeStmt = dbConn.prepareStatement(validateNodeSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+validateNodeSql, e); + } + } + + private void initDbResources() throws ConfigurationException + { + if ((dbDriver != null) && (dbDriver.length() > 0)) + { + + try + { + Class.forName(dbDriver); + } + catch (Exception e) + { + throw new ConfigurationException("could not load driver class "+dbDriver, e); + } + } + getConnection(); + createTable(); + prepStatements(); + } + + + public void init(Properties props) throws ConfigurationException { + + + dbUrl = props.getProperty("org.openecomp.sdnc.sli.jdbc.url"); + if ((dbUrl == null) || (dbUrl.length() == 0)) + { + throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.url unset"); + } + + dbName = props.getProperty("org.openecomp.sdnc.sli.jdbc.database"); + if ((dbName == null) || (dbName.length() == 0)) + { + throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.database unset"); + } + + dbUser = props.getProperty("org.openecomp.sdnc.sli.jdbc.user"); + if ((dbUser == null) || (dbUser.length() == 0)) + { + throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.user unset"); + } + + + dbPasswd = props.getProperty("org.openecomp.sdnc.sli.jdbc.password"); + if ((dbPasswd == null) || (dbPasswd.length() == 0)) + { + throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.password unset"); + } + + dbDriver = props.getProperty("org.openecomp.sdnc.sli.jdbc.driver"); + + + initDbResources(); + + } + + private boolean isDbConnValid() + { + + boolean isValid = false; + + try + { + if (dbConn != null) + { + isValid = dbConn.isValid(1); + } + } + catch (SQLException e) + {} + + return(isValid); + } +public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { + + + + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + + + boolean retval = false; + ResultSet results = null; + + PreparedStatement hasGraphStmt = null; + if (version == null) + { + hasGraphStmt = hasActiveGraphStmt; + } + else + { + hasGraphStmt = hasVersionGraphStmt; + } + + + + try + { + hasGraphStmt.setString(1, module); + hasGraphStmt.setString(2, rpc); + hasGraphStmt.setString(3, mode); + + + if (version != null) + { + hasGraphStmt.setString(4, version); + } + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + results = hasGraphStmt.executeQuery(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + + if (results.next()) + { + int cnt = results.getInt(1); + + if (cnt > 0) + { + retval = true; + } + + } + } + catch (Exception e) + { + throw new ConfigurationException("SQL query failed", e); + } + finally + { + if (results != null) + { + try + { + + results.close(); + } + catch (SQLException x) + {} + } + + } + + + return(retval); + + + } + + public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { + + + + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + + + SvcLogicGraph retval = null; + ResultSet results = null; + + PreparedStatement fetchGraphStmt = null; + if (version == null) + { + fetchGraphStmt = fetchActiveGraphStmt; + } + else + { + fetchGraphStmt = fetchVersionGraphStmt; + } + try + { + fetchGraphStmt.setString(1, module); + fetchGraphStmt.setString(2, rpc); + fetchGraphStmt.setString(3, mode); + + + if (version != null) + { + fetchGraphStmt.setString(4, version); + } + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + results = fetchGraphStmt.executeQuery(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + + if (results.next()) + { + Blob graphBlob = results.getBlob("graph"); + + ObjectInputStream gStream = new ObjectInputStream(graphBlob.getBinaryStream()); + + Object graphObj = gStream.readObject(); + gStream.close(); + + if (graphObj instanceof SvcLogicGraph) + { + retval = (SvcLogicGraph) graphObj; + } + else + { + throw new ConfigurationException("invalid type for graph ("+graphObj.getClass().getName()); + + } + + } + else + { + return(null); + } + } + catch (Exception e) + { + throw new ConfigurationException("SQL query failed", e); + } + finally + { + if (results != null) + { + try + { + results.close(); + } + catch (SQLException x) + {} + } + + } + + + return(retval); + + + } + + public void store(SvcLogicGraph graph) throws SvcLogicException { + + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + if (graph == null) + { + throw new SvcLogicException("graph cannot be null"); + } + + byte[] graphBytes = null; + + ByteArrayOutputStream byteStr = null; + ObjectOutputStream goutStr = null; + + try + { + byteStr = new ByteArrayOutputStream(); + goutStr = new ObjectOutputStream(byteStr); + goutStr.writeObject(graph); + + graphBytes = byteStr.toByteArray(); + + } + catch (Exception e) + { + throw new SvcLogicException("could not serialize graph", e); + } + finally + { + + if (goutStr != null) + { + try { + goutStr.close(); + } catch (IOException e) { + + } + } + + if (byteStr != null) + { + try { + byteStr.close(); + } catch (IOException e) { + + } + } + } + + + // If object already stored in database, delete it + if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode())) + { + delete(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode()); + } + + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + storeGraphStmt.setString(1, graph.getModule()); + storeGraphStmt.setString(2, graph.getRpc()); + storeGraphStmt.setString(3, graph.getVersion()); + storeGraphStmt.setString(4, graph.getMode()); + storeGraphStmt.setString(5, "N"); + storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); + + storeGraphStmt.executeUpdate(); + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + } + catch (Exception e) + { + throw new SvcLogicException("Could not write object to database", e); + } + } + + public void delete(String module, String rpc, String version, String mode) throws SvcLogicException + { + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + deleteGraphStmt.setString(1, module); + deleteGraphStmt.setString(2, rpc); + deleteGraphStmt.setString(3, version); + deleteGraphStmt.setString(4, mode); + + + deleteGraphStmt.executeUpdate(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + } + catch (Exception e) + { + throw new SvcLogicException("Could not delete object from database", e); + } + } + + public void activate(SvcLogicGraph graph) throws SvcLogicException + { + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + + dbConn.setAutoCommit(false); + + // Deactivate any current active version + deactivateStmt.setString(1, graph.getModule()); + deactivateStmt.setString(2, graph.getRpc()); + deactivateStmt.setString(3, graph.getMode()); + deactivateStmt.executeUpdate(); + + // Activate this version + activateStmt.setString(1, graph.getModule()); + activateStmt.setString(2, graph.getRpc()); + activateStmt.setString(3, graph.getVersion()); + activateStmt.setString(4, graph.getMode()); + activateStmt.executeUpdate(); + + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + + } + catch (Exception e) + { + throw new SvcLogicException("Could not activate graph", e); + } + } + + @Override + public void registerNodeType(String nodeType) throws SvcLogicException { + + if (isValidNodeType(nodeType)) + { + return; + } + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + registerNodeStmt.setString(1, nodeType); + registerNodeStmt.executeUpdate(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + } + catch (Exception e) + { + throw new SvcLogicException("Could not add node type to database", e); + } + + } + + @Override + public void unregisterNodeType(String nodeType) throws SvcLogicException { + + if (!isValidNodeType(nodeType)) + { + return; + } + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + unregisterNodeStmt.setString(1, nodeType); + unregisterNodeStmt.executeUpdate(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + } + catch (Exception e) + { + throw new SvcLogicException("Could not delete node type from database", e); + } + + } + + @Override + public boolean isValidNodeType(String nodeType) throws SvcLogicException { + + boolean isValid = false; + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + ResultSet results = null; + try + { + validateNodeStmt.setString(1, nodeType); + + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + results = validateNodeStmt.executeQuery(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + + if (results != null) + { + if (results.next()) + { + int cnt = results.getInt(1); + + if (cnt > 0) + { + isValid = true; + } + } + } + + } + catch (Exception e) + { + throw new SvcLogicException("Cannot select node type from database", e); + } + finally + { + if (results != null) + { + try + { + results.close(); + } + catch (SQLException x) + {} + } + + } + + return(isValid); + } + + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java new file mode 100644 index 000000000..6828e9ad1 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java @@ -0,0 +1,456 @@ +/*- + * ============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========================================================= + */ + +/** + * + */ +package org.openecomp.sdnc.sli; + +import java.io.IOException; +import java.io.PrintStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +import org.apache.commons.lang3.StringEscapeUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.Locator; + + +public class SvcLogicNode implements Serializable { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExprListener.class); + + private static final long serialVersionUID = 2L; + + private String nodeName; + private int nodeId; + private String nodeType; + private boolean visited; + private SvcLogicGraph graph; + + + private HashMap attributes; + private HashMap outcomes; + private HashMap parameters; + + public SvcLogicNode(int nodeId, String nodeType, SvcLogicGraph graph) + { + this.nodeId = nodeId; + nodeName = ""; + this.nodeType = nodeType; + this.graph = graph; + attributes = new HashMap (); + parameters = new HashMap (); + outcomes = null; + + } + + public SvcLogicNode(int nodeId, String nodeType, String nodeName, SvcLogicGraph graph) throws DuplicateValueException + { + this.nodeId = nodeId; + this.nodeName = nodeName; + this.nodeType = nodeType; + this.graph = graph; + attributes = new HashMap (); + parameters = new HashMap (); + outcomes = null; + graph.setNamedNode(nodeName, this); + } + + + public int getNodeId() + { + return nodeId; + } + + public String getNodeName() + { + return(nodeName); + } + + public String getNodeType() + { + return(nodeType); + } + + public SvcLogicGraph getGraph() + { + return(graph); + } + + public int getNumOutcomes() + { + if (outcomes == null) + { + return(0); + } + else + { + return(outcomes.size()); + } + } + + public SvcLogicExpression getAttribute(String name) + { + if (attributes.containsKey(name)) + { + return(attributes.get(name)); + } + else + { + return(null); + } + + } + + public void setAttribute(String name, String value) throws SvcLogicException + { + setAttribute(name, new SvcLogicAtom("STRING", value)); + } + + public void setAttribute(String name, SvcLogicExpression value) throws SvcLogicException + { + if (attributes.containsKey(name)) + { + throw new DuplicateValueException("Duplicate attribute "+name); + } + + attributes.put(name, value); + } + + + public void mapParameter(String name, String value) throws SvcLogicException + { + + if (parameters.containsKey(name)) + { + throw new DuplicateValueException("Duplicate parameter "+name); + } + try + { + SvcLogicExpression parmValue; + if ((value == null) || (value.length() == 0)) + { + parmValue = new SvcLogicAtom("STRING", ""); + } + else if (value.trim().startsWith("`")) + { + int lastParen = value.lastIndexOf("`"); + String evalExpr = value.trim().substring(1, lastParen); + parmValue = SvcLogicExpressionFactory.parse(evalExpr); + + } + else + { + if (Character.isDigit(value.charAt(0))) + { + parmValue = new SvcLogicAtom("NUMBER", value); + } + else + { + parmValue = new SvcLogicAtom("STRING", value); + } + } + LOG.debug("Setting parameter "+name+" = "+value+" = "+parmValue.asParsedExpr()); + parameters.put(name, parmValue); + } + catch (IOException e) { + + LOG.error("Invalid parameter value expression ("+value+")"); + throw new SvcLogicException(e.getMessage()); + } + } + + public SvcLogicExpression getParameter(String name) + { + if (parameters.containsKey(name)) + { + return(parameters.get(name)); + } + else + { + return(null); + } + } + + public boolean isVisited() { + return visited; + } + + public void setVisited(boolean visited, boolean recursive) { + this.visited = visited; + + if (recursive) + { + Set> outcomeSet = getOutcomeSet(); + + if (outcomeSet == null) + { + return; + } + + for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) + { + Map.Entry curOutcome = iter.next(); + SvcLogicNode outNode = curOutcome.getValue(); + outNode.setVisited(visited, recursive); + } + } + } + + public void addOutcome(String outcomeValue, SvcLogicNode node) throws SvcLogicException + { + if (outcomes == null) + { + outcomes = new HashMap(); + } + + if (outcomeValue.length() == 0) { + outcomeValue = "\"\""; + } + if (outcomes.containsKey(outcomeValue)) + { + throw new DuplicateValueException("Duplicate outcome value "+outcomeValue); + } + + outcomes.put(outcomeValue, node); + } + + public Set> getOutcomeSet() + { + if (outcomes == null) + { + return null; + } + + return(outcomes.entrySet()); + + } + + public Set> getParameterSet() + { + if (parameters == null) + { + return null; + } + + return(parameters.entrySet()); + + } + + public void printAsGv(PrintStream pstr) + { + + if (visited) + { + return; + } + else + { + visited = true; + } + + StringBuffer sbuff = new StringBuffer(); + + sbuff.append("node"); + sbuff.append(nodeId); + sbuff.append(" [ shape=none, margin=0, label=<"); + sbuff.append(""); + + if (nodeName.length() > 0) + { + sbuff.append(""); + } + + Set> attrSet = attributes.entrySet(); + for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) + { + Map.Entry curAttr = iter.next(); + sbuff.append(""); + } + sbuff.append("
"); + sbuff.append(nodeId); + sbuff.append(" : "); + sbuff.append(nodeType); + sbuff.append("
AttributeValue
name"); + sbuff.append(nodeName); + sbuff.append("
"); + sbuff.append(curAttr.getKey()); + sbuff.append(""); + sbuff.append(StringEscapeUtils.escapeHtml3(curAttr.getValue().toString())); + sbuff.append("
>];"); + + pstr.println(sbuff.toString()); + + + if (outcomes != null) + { + TreeMap sortedOutcomes = new TreeMap(outcomes); + Set> outcomeSet = sortedOutcomes.entrySet(); + + for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) + { + Map.Entry curOutcome = iter.next(); + String outValue = curOutcome.getKey(); + SvcLogicNode outNode = curOutcome.getValue(); + pstr.println("node"+nodeId+" -> node"+outNode.getNodeId()+" [label=\""+outValue+"\"];"); + outNode.printAsGv(pstr); + } + } + } + + public void printAsXml(PrintStream pstr, int indentLvl) + { + if (visited) + { + return; + } + // Print node tag + for (int i = 0 ; i < indentLvl ; i++) + { + pstr.print(" "); + } + pstr.print("<"); + pstr.print(this.getNodeType()); + + Set> attrSet = attributes.entrySet(); + for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) + { + Map.Entry curAttr = iter.next(); + pstr.print(" "); + pstr.print(curAttr.getKey()); + pstr.print("='`"); + pstr.print(curAttr.getValue()); + pstr.print("'`"); + } + + if (((parameters == null) || (parameters.isEmpty())) && + ((outcomes == null) || outcomes.isEmpty())) + { + pstr.print("/>\n"); + pstr.flush(); + return; + } + else + { + pstr.print(">\n"); + } + + // Print parameters (if any) + if (parameters != null) + { + Set> paramSet = parameters.entrySet(); + for (Iterator> iter = paramSet.iterator() ; iter.hasNext();) + { + for (int i = 0 ; i < indentLvl+1 ; i++) + { + pstr.print(" "); + } + pstr.print(" curAttr = iter.next(); + pstr.print(" name='"); + pstr.print(curAttr.getKey()); + pstr.print("' value='`"); + pstr.print(curAttr.getValue().toString()); + pstr.print("`'/>\n"); + } + } + + // Print outcomes (if any) + if (outcomes != null) + { + Set> outcomeSet = outcomes.entrySet(); + for (Iterator> iter = outcomeSet.iterator() ; iter.hasNext();) + { + for (int i = 0 ; i < indentLvl+1 ; i++) + { + pstr.print(" "); + } + pstr.print(" curAttr = iter.next(); + pstr.print(" value='"); + pstr.print(curAttr.getKey()); + pstr.print("'>\n"); + SvcLogicNode outNode = curAttr.getValue(); + outNode.printAsXml(pstr, indentLvl+2); + for (int i = 0 ; i < indentLvl+1 ; i++) + { + pstr.print(" "); + } + pstr.print("\n"); + } + } + + // Print node end tag + for (int i = 0 ; i < indentLvl ; i++) + { + pstr.print(" "); + } + pstr.print("\n"); + pstr.flush(); + + } + + + public SvcLogicNode getOutcomeValue(String value) + { + + if (value.length() == 0) { + value = "\"\""; + } + if (outcomes == null) + { + return(null); + } + + if (outcomes.containsKey(value)) + { + return(outcomes.get(value)); + } + else + { + StringBuffer keyBuffer = new StringBuffer(); + keyBuffer.append("{"); + for (String key : outcomes.keySet()) { + keyBuffer.append(" ("+key+")"); + } + keyBuffer.append("}"); + LOG.info("Outcome (" + value + ") not found, keys are " + keyBuffer.toString()); + + if (outcomes.containsKey("Other")) + { + return(outcomes.get("Other")); + } + else + { + return(null); + } + } + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java new file mode 100644 index 000000000..398c28de7 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java @@ -0,0 +1,598 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; +import java.util.LinkedList; + +import javax.xml.XMLConstants; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.Attributes; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * @author dt5972 + * + */ +public class SvcLogicParser { + + SvcLogicStore store = null; + static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; + static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; + static final String JAXP_DYNAMIC_VALIDATION = "http://apache.org/xml/features/validation/dynamic"; + static final String JAXP_SCHEMA_VALIDATION = "http://apache.org/xml/features/validation/schema"; + + private static final String LOAD_MESSAGE = "Getting SvcLogicGraph from database - "; + private static final String LOAD_ERROR_MESSAGE = "SvcLogicGraph not found - "; + private static final String ACTIVATION_ERROR_MESSAGE = "Could not activate SvcLogicGraph - "; + private static final String PRINT_ERROR_MESSAGE = "Could not print SvcLogicGraph - "; + private static final String SVC_LOGIC_STORE_ERROR = "Could not get service logic store"; + + private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicParser.class); + private static final String SLI_VALIDATING_PARSER = "org.openecomp.sdnc.sli.parser.validate"; + private static final String SVCLOGIC_XSD = "/svclogic.xsd"; + + private class SvcLogicHandler extends DefaultHandler { + private Locator locator = null; + private String module = null; + private String version = null; + private LinkedList graphs = null; + private SvcLogicGraph curGraph = null; + private SvcLogicNode curNode = null; + private LinkedList nodeStack = null; + private int curNodeId = 0; + private String outcomeValue = null; + private LinkedList outcomeStack = null; + private SvcLogicStore svcLogicStore = null; + + public SvcLogicHandler(LinkedList graphs, SvcLogicStore store) { + this.graphs = graphs; + this.curNode = null; + this.nodeStack = new LinkedList<>(); + this.outcomeStack = new LinkedList<>(); + this.curNodeId = 1; + this.outcomeValue = null; + this.svcLogicStore = store; + + } + + @Override + public void setDocumentLocator(Locator locator) { + this.locator = locator; + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + + // Handle service-logic (graph) tag + if ("service-logic".equalsIgnoreCase(qName)) { + + module = attributes.getValue("module"); + if (module == null || module.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'module' attribute from service-logic tag"); + } + + version = attributes.getValue("version"); + if (version == null || version.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'version' attribute from service-logic tag"); + } + + return; + } + + if ("method".equalsIgnoreCase(qName)) { + if (curGraph != null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot nest module tags"); + } + curGraph = new SvcLogicGraph(); + curGraph.setModule(module); + curGraph.setVersion(version); + this.curNodeId = 1; + + String attrValue = attributes.getValue("rpc"); + if (attrValue == null || attrValue.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'rpc' attribute for method tag"); + } + curGraph.setRpc(attrValue); + + attrValue = attributes.getValue("mode"); + if (attrValue == null || attrValue.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'mode' attribute for method tag"); + } + curGraph.setMode(attrValue); + + return; + + } + + // Handle outcome (edge) tag + if ("outcome".equalsIgnoreCase(qName)) { + String refValue = attributes.getValue("ref"); + + if (refValue != null) { + SvcLogicNode refNode = curGraph.getNamedNode(refValue); + + if (refNode != null) { + try { + curNode.addOutcome(attributes.getValue("value"), refNode); + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot add outcome", e); + } + } else { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "ref to unknown node " + refValue); + } + return; + } + + if (outcomeValue != null) { + outcomeStack.push(outcomeValue); + } + outcomeValue = attributes.getValue("value"); + + return; + } + + // Handle parameter tag + if ("parameter".equalsIgnoreCase(qName)) { + String parmName = attributes.getValue("name"); + String parmValue = attributes.getValue("value"); + + if (parmName != null && parmName.length() > 0 && parmValue != null) { + try { + + curNode.mapParameter(parmName, parmValue); + } catch (Exception e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + " cannot set parameter " + parmName + " to " + parmValue + " [" + e.getMessage() + "]"); + } + } + + return; + } + + // Handle node tags + + String nodeName = attributes.getValue("name"); + SvcLogicNode thisNode = null; + + try { + if (!svcLogicStore.isValidNodeType(qName)) { + throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Unknown tag " + qName); + } + } catch (Exception e) { + throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot validate node type " + qName); + } + + try { + if (nodeName != null && nodeName.length() > 0) { + thisNode = new SvcLogicNode(curNodeId++, qName, nodeName, curGraph); + } else { + thisNode = new SvcLogicNode(curNodeId++, qName, curGraph); + } + + if (curGraph.getRootNode() == null) { + curGraph.setRootNode(thisNode); + } + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); + + } + + int numAttributes = attributes.getLength(); + + for (int i = 0; i < numAttributes; i++) { + String attrName = attributes.getQName(i); + if (!"name".equalsIgnoreCase(attrName)) { + try { + + String attrValueStr = attributes.getValue(i); + SvcLogicExpression attrValue = null; + if (attrValueStr.trim().startsWith("`")) { + int lastParen = attrValueStr.lastIndexOf("`"); + String evalExpr = attrValueStr.trim().substring(1, lastParen); + attrValue = SvcLogicExpressionFactory.parse(evalExpr); + + } else { + if (Character.isDigit(attrValueStr.charAt(0))) { + attrValue = new SvcLogicAtom("NUMBER", attrValueStr); + } else { + attrValue = new SvcLogicAtom("STRING", attrValueStr); + } + } + thisNode.setAttribute(attrName, attrValue); + } catch (Exception e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot set attribute " + attrName, e); + } + } + } + + if (curNode != null) { + try { + if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) || "while".equalsIgnoreCase(curNode.getNodeType())) { + curNode.addOutcome("" + (curNode.getNumOutcomes() + 1), thisNode); + } else { + if (outcomeValue == null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType()); + } + curNode.addOutcome(outcomeValue, thisNode); + } + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); + } + nodeStack.push(curNode); + } + curNode = thisNode; + + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + + // Handle close of service-logic tag + if ("service-logic".equalsIgnoreCase(qName)) { + // Nothing more to do + return; + } + + // Handle close of method tag + if ("method".equalsIgnoreCase(qName)) { + graphs.add(curGraph); + curGraph = null; + return; + } + + // Handle close of outcome tag + if ("outcome".equalsIgnoreCase(qName)) { + // Finished this outcome - pop the outcome stack + if (outcomeStack.isEmpty()) { + outcomeValue = null; + } else { + outcomeValue = outcomeStack.pop(); + } + return; + } + + // Handle close of parameter tag - do nothing + if ("parameter".equalsIgnoreCase(qName)) { + return; + } + + // Handle close of a node tag + if (nodeStack.isEmpty()) { + curNode = null; + } else { + curNode = nodeStack.pop(); + } + } + + @Override + public void error(SAXParseException arg0) throws SAXException { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + arg0.getMessage()); + } + + } + + public SvcLogicParser(SvcLogicStore store) { + this.store = store; + } + + public SvcLogicParser(String propFile) { + + try { + this.store = SvcLogicStoreFactory.getSvcLogicStore(propFile); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + + } + + } + + public SvcLogicParser(InputStream propStr) { + + try { + this.store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + + } + + } + + public LinkedList parse(String fileName) throws SvcLogicException { + LinkedList graphs = null; + + URL xsdUrl = null; + Schema schema = null; + String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true"); + + if (validateSchema != null || validateSchema.equalsIgnoreCase("true")) { + xsdUrl = getClass().getResource(SVCLOGIC_XSD); + + } + + if (xsdUrl != null) { + try { + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + schema = schemaFactory.newSchema(xsdUrl); + } catch (Exception e) { + LOGGER.warn("Could not validate using schema " + xsdUrl.getPath(), e); + } + } else { + LOGGER.warn("Could not find resource " + SVCLOGIC_XSD); + } + + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + + if (schema != null) { + factory.setNamespaceAware(true); + factory.setSchema(schema); + } + SAXParser saxParser = factory.newSAXParser(); + + if (saxParser.isValidating()) { + LOGGER.info("Validating against schema " + xsdUrl.getPath()); + } + graphs = new LinkedList<>(); + + saxParser.parse(fileName, new SvcLogicHandler(graphs, store)); + + } catch (Exception e) { + String msg = e.getMessage(); + if (msg != null) { + LOGGER.error(msg); + throw new SvcLogicException("Compiler error: " + fileName + " @ " + msg); + } else { + LOGGER.info("Caught exception parsing " + fileName, e); + throw new SvcLogicException("Compiler error: " + fileName, e); + } + } + + return graphs; + } + + public static void main(String argv[]) { + + if (argv.length == 0) { + SvcLogicParser.usage(); + } + + if ("load".equalsIgnoreCase(argv[0])) { + if (argv.length == 3) { + String xmlfile = argv[1]; + String propfile = argv[2]; + + SvcLogicStore store = SvcLogicParser.getStore(propfile); + try { + SvcLogicParser.load(xmlfile, store); + } catch (Exception e) { + LOGGER.error(e.getMessage(), e); + } + } else { + SvcLogicParser.usage(); + } + } else if ("print".equalsIgnoreCase(argv[0])) { + String version = null; + String propfile = null; + + switch (argv.length) { + case 6: + version = argv[4]; + propfile = argv[5]; + case 5: + if (propfile == null) { + propfile = argv[4]; + } + SvcLogicStore store = SvcLogicParser.getStore(propfile); + SvcLogicParser.print(argv[1], argv[2], argv[3], version, store); + break; + default: + SvcLogicParser.usage(); + } + } else if ("get-source".equalsIgnoreCase(argv[0])) { + + switch (argv.length) { + case 6: + SvcLogicStore store = SvcLogicParser.getStore(argv[5]); + SvcLogicParser.getSource(argv[1], argv[2], argv[3], argv[4], store); + break; + default: + SvcLogicParser.usage(); + } + } else if ("activate".equalsIgnoreCase(argv[0])) { + if (argv.length == 6) { + SvcLogicStore store = SvcLogicParser.getStore(argv[5]); + SvcLogicParser.activate(argv[1], argv[2], argv[3], argv[4], store); + } else { + SvcLogicParser.usage(); + } + } else if ("validate".equalsIgnoreCase(argv[0])) { + if (argv.length == 3) { + String xmlfile = argv[1]; + String propfile = argv[2]; + + System.setProperty(SLI_VALIDATING_PARSER, "true"); + SvcLogicStore store = SvcLogicParser.getStore(propfile); + try { + SvcLogicParser.validate(xmlfile, store); + } catch (Exception e) { + LOGGER.error(e.getMessage(), e); + } + } else { + SvcLogicParser.usage(); + } + } + + System.exit(0); + } + + private static SvcLogicStore getStore(String propfile) { + + SvcLogicStore store = null; + + try { + store = SvcLogicStoreFactory.getSvcLogicStore(propfile); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + System.exit(1); + } + + return store; + + } + + public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException { + File xmlFile = new File(xmlfile); + if (!xmlFile.canRead()) { + throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); + } + + SvcLogicParser parser = new SvcLogicParser(store); + LinkedList graphs = null; + try { + graphs = parser.parse(xmlfile); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + if (graphs == null) { + throw new SvcLogicException("Could not parse " + xmlfile); + } + + for (SvcLogicGraph graph : graphs) { + + String module = graph.getModule(); + String rpc = graph.getRpc(); + String version = graph.getVersion(); + String mode = graph.getMode(); + try { + LOGGER.info("Saving SvcLogicGraph to database (module:" + module + ",rpc:" + rpc + ",version:" + version + ",mode:" + mode + ")"); + store.store(graph); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + } + + } + + public static void validate(String xmlfile, SvcLogicStore store) throws SvcLogicException { + File xmlFile = new File(xmlfile); + if (!xmlFile.canRead()) { + throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); + } + + SvcLogicParser parser = new SvcLogicParser(store); + LinkedList graphs = null; + try { + LOGGER.info("Validating " + xmlfile); + graphs = parser.parse(xmlfile); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + if (graphs == null) { + throw new SvcLogicException("Could not parse " + xmlfile); + } else { + LOGGER.info("Compilation successful for " + xmlfile); + } + + } + + private static void print(String module, String rpc, String mode, String version, SvcLogicStore store) { + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + + try { + LOGGER.info(LOAD_MESSAGE + details); + + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE + details); + System.exit(1); + } + graph.printAsGv(System.out); + } catch (Exception e) { + LOGGER.error(PRINT_ERROR_MESSAGE + details, e); + System.exit(1); + } + + } + + private static void getSource(String module, String rpc, String mode, String version, SvcLogicStore store) { + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + + try { + LOGGER.info(LOAD_MESSAGE + details); + + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE + details); + System.exit(1); + } + graph.printAsXml(System.out); + } catch (Exception e) { + LOGGER.error(PRINT_ERROR_MESSAGE + details, e); + System.exit(1); + } + + } + + private static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) { + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + + try { + LOGGER.info(LOAD_MESSAGE + details); + + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE + details); + System.exit(1); + } + store.activate(graph); + } catch (Exception e) { + LOGGER.error(ACTIVATION_ERROR_MESSAGE + details, e); + System.exit(1); + } + + } + + private static void usage() { + System.err.println("Usage: SvcLogicParser load "); + System.err.println(" OR SvcLogicParser print [] "); + System.err.println(" OR SvcLogicParser get-source "); + System.err.println(" OR SvcLogicParser activate "); + System.exit(1); + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java new file mode 100644 index 000000000..ac9c515e9 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java @@ -0,0 +1,43 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.IOException; + +public class SvcLogicParserException extends IOException { + + public SvcLogicParserException() { + super(); + } + + public SvcLogicParserException(String msg) { + super(msg); + } + + public SvcLogicParserException(Throwable t) { + super(t); + } + + public SvcLogicParserException(String msg, Throwable t) { + super(msg, t); + } +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java new file mode 100644 index 000000000..8a23adf1a --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java @@ -0,0 +1,30 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.util.Map; + +public interface SvcLogicRecorder { + + void record(Map parmMap) throws SvcLogicException; + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java new file mode 100644 index 000000000..5fc00f87b --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java @@ -0,0 +1,53 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.sql.SQLException; +import java.util.Map; + +public interface SvcLogicResource { + + public enum QueryStatus { + SUCCESS, + NOT_FOUND, + FAILURE + } + + public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, String orderBy, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map parms, String prefix, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus update(String resource, String key, Map parms, String prefix, SvcLogicContext ctx) throws SvcLogicException; + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java new file mode 100644 index 000000000..6959c86a8 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java @@ -0,0 +1,37 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.util.Properties; + +public interface SvcLogicStore { + + public void init(Properties props) throws SvcLogicException; + public void registerNodeType(String nodeType) throws SvcLogicException; + public void unregisterNodeType(String nodeType) throws SvcLogicException; + public boolean isValidNodeType(String nodeType) throws SvcLogicException; + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; + public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException; + public void store(SvcLogicGraph graph) throws SvcLogicException; + public void delete(String module, String rpc, String version, String mode) throws SvcLogicException; + public void activate(SvcLogicGraph graph) throws SvcLogicException; +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java new file mode 100644 index 000000000..8b6618bef --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java @@ -0,0 +1,96 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicStoreFactory { + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicStoreFactory.class); + + public static SvcLogicStore getSvcLogicStore(String propfile) + throws SvcLogicException { + File propFile = new File(propfile); + if (!propFile.canRead()) { + throw new ConfigurationException("Cannot read property file " + + propfile); + + } + + try { + return (getSvcLogicStore(new FileInputStream(propFile))); + } catch (Exception e) { + throw new ConfigurationException( + "Could load service store from properties file " + propfile, + e); + } + + } + + public static SvcLogicStore getSvcLogicStore(InputStream inStr) throws SvcLogicException + { + Properties props = new Properties(); + + try { + props.load(inStr); + } catch (Exception e) { + throw new ConfigurationException("Could not get load properties from input stream", e); + } + + return(getSvcLogicStore(props)); + } + + public static SvcLogicStore getSvcLogicStore(Properties props) + throws SvcLogicException { + String storeType = props.getProperty("org.openecomp.sdnc.sli.dbtype"); + if ((storeType == null) || (storeType.length() == 0)) { + throw new ConfigurationException( + "property org.openecomp.sdnc.sli.dbtype unset"); + + } + + SvcLogicStore retval = null; + LOG.debug(String.format("Using org.openecomp.sdnc.sli.dbtype=%s", storeType)); + + if ("jdbc".equalsIgnoreCase(storeType)) { + retval = new SvcLogicJdbcStore(); + + } else if ("dblib".equalsIgnoreCase(storeType)) { + retval = new SvcLogicDblibStore(); + } else { + throw new ConfigurationException("unsupported dbtype (" + storeType + + ")"); + + } + + + retval.init(props); + return (retval); + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java new file mode 100644 index 000000000..9ddc3c0b8 --- /dev/null +++ b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java @@ -0,0 +1,77 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +public class SvcLogicVariableTerm extends SvcLogicExpression { + + private String name = null; + + public String getName() { + return name; + } + + + public SvcLogicVariableTerm(String identifier) + { + this.name = identifier; + } + + public SvcLogicExpression getSubscript() + { + if (numOperands() > 0) + { + return(getOperands().get(0)); + } + else + { + return(null); + } + } + + + public String toString() + { + String retval = ""; + + if (numOperands() > 0) + { + retval = name + "[" + getSubscript().toString() + "]"; + } + else + { + retval = name; + } + return(retval); + } + + @Override + public String asParsedExpr() { + if (numOperands() == 0) { + return("(variable-term "+name+")"); + } + else + { + return("(variable-term "+name+" "+getSubscript().asParsedExpr()+")"); + } + } + +} diff --git a/sli/common/src/main/resources/crAseNetwork.sql b/sli/common/src/main/resources/crAseNetwork.sql new file mode 100644 index 000000000..412311761 --- /dev/null +++ b/sli/common/src/main/resources/crAseNetwork.sql @@ -0,0 +1,82 @@ +--- +-- ============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========================================================= +--- + +CREATE TABLE sdnctl.ASE ( + ase_network_id INT NOT NULL, + topology VARCHAR(25), + CONSTRAINT P_ASE PRIMARY KEY(ase_network_id)); + +CREATE TABLE sdnctl.ASE_PORT ( + esm_name VARCHAR(25), + resource_emt_clli VARCHAR(25) NOT NULL, + resource_emt_ip_addr VARCHAR(25) NOT NULL, + port_action VARCHAR(25), + profile VARCHAR(25) , + port VARCHAR(15) NOT NULL, + state VARCHAR(25), + resource_mode VARCHAR(25), + speed INT, + resource_lldp VARCHAR(1), + resource_mtu VARCHAR(5), + resource_autoneg VARCHAR(10), + resource_twamp VARCHAR(10), + resource_description VARCHAR(80), + uni_circuit_id VARCHAR(45), + CONSTRAINT P_ASE_PORT PRIMARY KEY(resource_emt_clli, port)); + +CREATE TABLE sdnctl.ASE_EVC ( + esm_name VARCHAR(25), + emt_ip_addr VARCHAR(25) NOT NULL, + evc_action VARCHAR(25), + service_id VARCHAR(25), + serv_type VARCHAR(25), + evc_choice VARCHAR(25), + uni_port VARCHAR(25) NOT NULL, + lag_port VARCHAR(25), + mac_onoff VARCHAR(25), + ppcos VARCHAR(25), + cir VARCHAR(25), + cbs VARCHAR(25), + ebs VARCHAR(25), + sgos VARCHAR(25), + pe VARCHAR(25), + unit VARCHAR(25), + qinq VARCHAR(25), + interface VARCHAR(25), + evc_description VARCHAR(80), + bandwidth VARCHAR(10), + svlan VARCHAR(5), + cvlan VARCHAR(5), + routing_instance VARCHAR(25), + rd VARCHAR(25), + rt VARCHAR(25), + evc_limit VARCHAR(25), + label_block_size VARCHAR(25), + site VARCHAR(25), + int_mac_limit VARCHAR(5), + sgos_grade VARCHAR(25), + bum_rate VARCHAR(25), + uni_circuit_id VARCHAR(45), + leg INT, + CONSTRAINT P_ASE_EVC PRIMARY KEY(emt_ip_addr, uni_port,leg)); + + + diff --git a/sli/common/src/main/resources/svclogic.xsd b/sli/common/src/main/resources/svclogic.xsd new file mode 100755 index 000000000..f74bd5dcd --- /dev/null +++ b/sli/common/src/main/resources/svclogic.xsd @@ -0,0 +1,334 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/common/src/main/yang/ase-network.yang b/sli/common/src/main/yang/ase-network.yang new file mode 100755 index 000000000..ae654ae04 --- /dev/null +++ b/sli/common/src/main/yang/ase-network.yang @@ -0,0 +1,179 @@ +module ase { + namespace "att:ase"; + prefix ase; + revision "2014-06-03" { + description "Example ASE Network Module"; + } + + container ase { + config true; + leaf ase-network-id{ + type uint32; + } + leaf topology { + type string ; // check enum + } + } + + container ase-port { + config true; + // is this really a list of cpe ports one for each uni-ckt + leaf esm-name { + type string; + } + + leaf resource-emt-clli { + type string; + } + + leaf resource-emt-ip-addr{ + type string; + } + leaf port-action { + type string; + } + leaf profile { + type string; + } + leaf port { + type string; + } + leaf state { + type string; + } + leaf resource-mode { + type string; + } + leaf speed { + type string; + } + leaf resource-lldp { + type string; + } + leaf resource-mtu { + type string; + } + leaf resource-autoneg{ + type string; + } + leaf resource-twamp { + type string; + } + leaf resource-description { + type string; + } + leaf uni-circuit-id { + type string; + } + } // ase-port container + + container ase-evc { +// Port contains a list of EVC +// EVCs are either point to point or multipoint (topology) +// EVCs are connected ? what ID is used to connected them ? (network-id) ? + config true; + leaf esm-name { + type string; + } + leaf emt-ip-addr { + type string; + } + leaf evc-action { + type string; + } + leaf service-id { + type string; + } + + leaf serv-type { + type string; + } + leaf evc-choice { + type string; + } + leaf uni-port { + type string; + } + leaf lag-port { + type string; + } + leaf mac-onoff { + type string; + } + + leaf ppcos { + type string; + } + leaf cir { + type string; + } + leaf cbs { + type string; + } + leaf ebs { + type string; + } + leaf sgos { + type string; + } +// ipag Device Data + leaf pe { + type string; + } + leaf unit { + type string; + } + leaf qinq { + type string; + } + leaf interface { + type string; + } + leaf evc-description { + type string; + } + leaf bandwidth { + type string; + } + leaf svlan { + type string; + description "Service VLAN is either outer tag or only tag depending on QinQ"; + } + leaf cvlan { + type string; + description "Customer VLAN is null if not QinQ"; + } + leaf routing-instance { + type string; + } + leaf rd { + type string; + } + leaf rt { + type string; + } + leaf limit { + type string; + } + leaf label-block-size { + type string; + } + leaf site { + type string; + } + leaf int-mac-limit { + type string; + } + leaf sgos-grade { + type string; + } + leaf bum-rate { + type string; + } + leaf uni-circuit-id { + type string; + } + } // ase-evc container + +} // module ase-network + diff --git a/sli/common/src/main/yang/ase-type.yang b/sli/common/src/main/yang/ase-type.yang new file mode 100755 index 000000000..2de186e69 --- /dev/null +++ b/sli/common/src/main/yang/ase-type.yang @@ -0,0 +1,561 @@ +module ase-type { + + namespace "att:ase:type"; + prefix ase-type; + + organization "AT&T ASE"; + + revision 2014-06-09 { + description + "Initial version"; + } + + ///////////////////////////////////////////////////// + // ASE Service Model Typedefs & Groupings + ///////////////////////////////////////////////////// + + typedef query-type { + type enumeration { + enum getDevicePortDetails{ + value 0; + } + enum GetServiceDetailsRequest{ + value 1; + } + } + } + + typedef uni-action-type { + type enumeration { + enum PortPreReserveRequest{ + value 0; + } + enum PortReleaseRequest{ + value 1; + } + enum PortDeProvRequest{ + value 2; + } + enum ChangePortProvRequest{ + value 3; + } + enum PortActivateRequest{ + value 4; + } + enum ChangePortActivateRequest{ + value 5; + } + enum DisconnectPortRequest{ + value 6; + } + enum getDevicePortDetails{ + value 7; + } + } + } + + typedef evc-action-type { + type enumeration { + enum ConnectionProvRequest{ + value 0; + } + enum ChangeConnectionProvRequest{ + value 1; + } + enum ConnectionDeProvrequest{ + value 2; + } + enum ConnectionActivateRequest{ + value 3; + } + enum ChangeConnectionActivateRequest{ + value 4; + } + enum DisconnectConnectionRequest{ + value 5; + } + enum GetServiceDetailsRequest{ + value 6; + } + } + } + + typedef evc-gos-type { + type enumeration { + enum "REAL-TIME"{ + value 0; + } + enum "INTERACTIVE"{ + value 1; + } + enum "BUSINESS-CRITICAL-HIGH"{ + value 2; + } + enum "BUSINESS-CRITICAL-MEDIUM"{ + value 3; + } + enum "NON-CRITICAL-HIGH"{ + value 4; + } + enum "NON-CRITICAL-LOW"{ + value 5; + } + } + } + + typedef cir-rate-type { + type enumeration { + enum "Mbps"{ + value 0; + } + enum "Gbps"{ + value 1; + } + } + } + + typedef ase-yes-no-type { + type enumeration { + enum "Y"{ + value 0; + } + enum "N"{ + value 1; + } + } + } + + typedef provisioning-indicator { + type enumeration { + enum "Y"{ + value 0; + } + enum "N"{ + value 1; + } + } + } + + typedef media-type { + type enumeration { + enum "SFP-1GE-SX"{ + value 0; + } + enum "SFP-1GE-LX"{ + value 1; + } + enum "SFP-1GE"{ + value 2; + } + enum "Ethernet-10_100_1000M"{ + value 3; + } + } + } + + typedef media-speed-type { + type enumeration { + enum "100"{ + value 0; + } + enum "1000"{ + value 1; + } + enum "10000"{ + value 2; + } + } + } + + typedef cos-category-type { + type enumeration { + enum "GOS"{ + value 0; + } + enum "PPCOS"{ + value 1; + } + } + } + + typedef uni-gos-type { + type enumeration { + enum "INTERACTIVE"{ + value 0; + } + enum "BUSINESS-CRITICAL-HIGH"{ + value 1; + } + enum "BUSINESS-CRITICAL-MEDIUM"{ + value 2; + } + enum "NON-CRITICAL-HIGH"{ + value 3; + } + } + } + + typedef uni-cir-value-type { + type enumeration { + enum "2"{ + value 0; + } + enum "4"{ + value 1; + } + enum "5"{ + value 2; + } + enum "8"{ + value 3; + } + enum "10"{ + value 4; + } + enum "20"{ + value 5; + } + enum "30"{ + value 6; + } + enum "40"{ + value 7; + } + enum "50"{ + value 8; + } + enum "60"{ + value 9; + } + enum "70"{ + value 10; + } + enum "80"{ + value 11; + } + enum "90"{ + value 12; + } + enum "100"{ + value 13; + } + enum "125"{ + value 14; + } + enum "150"{ + value 15; + } + enum "175"{ + value 16; + } + enum "200"{ + value 17; + } + enum "225"{ + value 18; + } + enum "250"{ + value 19; + } + } + } + + typedef uni-mac-limit-type { + description "MAC address limit for UNI port"; + type enumeration { + enum "Y"{ + value 0; + } + enum "N"{ + value 1; + } + } + } + + typedef port-tagging-type { + type enumeration { + enum "port-based"{ + value 0; + } + enum "vlan-based"{ + value 1; + } + } + } + + typedef port-status { + type enumeration { + enum "Available"{ + value 0; + } + enum "Reserved"{ + value 1; + } + enum "Active" { + value 2; + } + } + } + + grouping uni-common-request-hdr { + leaf request-id { + type string; + mandatory true; + } + leaf source { + description "The source system requesting action or info"; + type string; + mandatory true; + } + leaf request-action { + description "action indicator for this service instance"; + type uni-action-type; + } + leaf undo-indicator { + type provisioning-indicator; + } + leaf notification-url { + description "When this field exists, NCS will return an " + + "acknowledgement that the request is legal " + + "Once the activate is finished (or fails) NCS" + + "will utilize the URL to indicate the status"; + type string; + } + } + + grouping uni-common-return-hdr { + leaf request-action { + description "action indicator for this service instance"; + type uni-action-type; + } + leaf request-id { + description "Identifier for the request from NGO"; + type string; + + } + } + + grouping uni-common-error-format { + leaf error-code { + description "Error code"; + type int32; + } + leaf error-message { + description "Error text describing the API error occurance"; + type string; + } + } + + grouping query-common-hdr { + leaf request-id { + description "Identifier for the request from NGO"; + type string; + } + leaf request-type { + description "action indicator for this service instance"; + type query-type; + } + } + + grouping query-error-format { + leaf error-code { + description "Error code"; + type int32; + } + leaf error-message { + description "Error text describing the API error occurance"; + type string; + } + } + + grouping evc-common-request-hdr { + leaf request-id { + description "Identifier for the request from NGO"; + type string; + } + leaf source { + description "The source system requesting action or info"; + type string; + mandatory true; + } + leaf uni-order-number { + type string; + } + leaf request-action { + description "action indicator for this service instance"; + type evc-action-type; + mandatory true; + } + leaf undo-indicator { + type provisioning-indicator; + } + leaf notification-url { + description "When this field exists, NCS will return an " + + "acknowledgement that the request is legal " + + "Once the activate is finished (or fails) NCS" + + "will utilize the URL to indicate the status"; + type string; + } + leaf evc-name { + type string; + mandatory true; + } + } + + grouping evc-common-error-format { + leaf error-code { + description "Error code"; + type int32; + } + leaf error-message { + description "Error text describing the API error occurance"; + type string; + } + } + + ///////////////////////////////////////// + // UNI-PORTS table contains all circuits + ///////////////////////////////////////// + container uni-ports { + description + "UNI port container"; + list uni-port { + key "uni-circuit-id"; + leaf uni-circuit-id { + type string; + mandatory true; + } + leaf subscriber-name { + type string; + mandatory true; + } + leaf uni-order-number { + type string; + mandatory true; + } + leaf edge-device-clli { + description "Edge device (e.g. EMT) on which port " + + " reservation is needed"; + type string; + mandatory true; + } + leaf uni-location-city { + type string; + mandatory true; + } + leaf uni-location-state { + type string; + mandatory true; + } + leaf media-type { + type media-type; + mandatory true; + } + leaf media-speed { + type media-speed-type; + mandatory true; + } + leaf uni-cir-value { + description "Integer value for the CIR"; + type uni-cir-value-type; + mandatory true; + } + leaf uni-cir-units { + description "Units for the CIR"; + type cir-rate-type; + mandatory true; + } + leaf cos-category { + description "CoS Type"; + type cos-category-type; + mandatory true; + } + leaf gos-profile { + description "GoS tpye"; + type uni-gos-type; + mandatory true; + } + leaf aditional-mac-allowed { + type uni-mac-limit-type; + } + leaf port-tagging { + type port-tagging-type; + mandatory true; + } + leaf port-status { + type port-status; + } + leaf name-value-pair { + type string; + } + } + } + + /////////////////////////////////////////// + // EVCS table contains all evc associations + /////////////////////////////////////////// + container evcs { + list evc { + key "evc-name"; + leaf evc-name { + type string; + mandatory true; + } + leaf topology { + type enumeration { + enum "MultiPoint"{ + value 0; + } + enum "PointToPoint"{ + value 1; + } + } + } + list evc-leg { + key evc-access-name; + leaf evc-access-name { + type string; + } + leaf subscriber-name { + type string; + } + leaf cvlan { + type uint16 { + range "2..4090"; + } + } + leaf connection-cir-value { + type uni-cir-value-type; + } + leaf connection-cir-units-string { + type cir-rate-type; + } + leaf connection-gos-profile { + type evc-gos-type; + } + leaf connection-additional-mac-allowed { + type uni-mac-limit-type; + } + leaf connection-emc-indicator { + type enumeration { + enum "Y"{ + value 0; + } + enum "N"{ + value 1; + } + } + } + leaf connection-emc-speed-value { + type uni-cir-value-type; + } + leaf connection-emc-speed-units-string { + type cir-rate-type; + } + } + leaf name-value-pair { + type string; + } + } + } +} diff --git a/sli/common/src/main/yang/ase.yang b/sli/common/src/main/yang/ase.yang new file mode 100755 index 000000000..0b36a5610 --- /dev/null +++ b/sli/common/src/main/yang/ase.yang @@ -0,0 +1,558 @@ +module ase { + + namespace "att:ase"; + prefix ase; + + import ase-type {prefix ase-type; revision-date "2014-06-09";} + + organization "AT&T ASE"; + + description + "This submodule contains a collection of YANG definitions for + defining the ASE service model(s) for UNI and EVC"; + + revision 2014-03-27 { + description + "Additional detail for UNI and EVC API"; + } + revision 2014-03-18 { + description + "Initial version"; + } + + + ///////////////////////////////////////////////////// + // ASE Query Actions + ///////////////////////////////////////////////////// + + //// + // Port Reserve Request + //// + rpc ase-port-reserve { + input { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + mandatory true; + } + leaf edge-device-clli { + description "Edge device (e.g. EMT) on which port " + + " reservation is needed"; + type string; + mandatory true; + } + leaf uni-cir-value { + description "Integer value for the CIR"; + type ase-type:uni-cir-value-type; + mandatory true; + } + leaf uni-cir-units { + description "Units for the CIR"; + type ase-type:cir-rate-type; + mandatory true; + } + } + output { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + } + leaf uni-port-id { + description "Allocated UNI port id"; + type string; + } + + uses ase-type:uni-common-error-format; + } + } + + //// + // Release Port Request + //// + rpc ase-release-port-request { + input { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + mandatory true; + } + } + output { + uses ase-type:uni-common-return-hdr; + uses ase-type:uni-common-error-format; + } + } + + //// + // Port Provisioning Request + //// + rpc ase-port-prov-request { + input { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + mandatory true; + } + leaf subscriber-name { + type string; + mandatory true; + } + leaf uni-order-number { + type string; + mandatory true; + } + leaf edge-device-clli { + description "Edge device (e.g. EMT) on which port " + + " reservation is needed"; + type string; + mandatory true; + } + leaf uni-location-city { + type string; + mandatory true; + } + leaf uni-location-state { + type string; + mandatory true; + } + leaf media-type { + type ase-type:media-type; + mandatory true; + } + leaf media-speed { + type ase-type:media-speed-type; + mandatory true; + } + leaf uni-cir-value { + description "Integer value for the CIR"; + type ase-type:uni-cir-value-type; + mandatory true; + } + leaf uni-cir-units { + description "Units for the CIR"; + type ase-type:cir-rate-type; + mandatory true; + } + leaf cos-category { + description "CoS Type"; + type ase-type:cos-category-type; + mandatory true; + } + leaf gos-profile { + description "GoS tpye"; + type ase-type:uni-gos-type; + mandatory true; + } + leaf aditional-mac-allowed { + type ase-type:uni-mac-limit-type; + } + leaf port-tagging { + type ase-type:port-tagging-type; + mandatory true; + } + leaf name-value-pair { + type string; + } + } + output { + uses ase-type:uni-common-return-hdr; + uses ase-type:uni-common-error-format; + } + } + + //// + // Deprovisioning Port Request + //// + rpc ase-deprov-port-request { + input { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + mandatory true; + } + } + output { + uses ase-type:uni-common-error-format; + } + } + + //// + // Change Port Provisioning Request + //// + rpc ase-change-port-prov-request { + input { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + mandatory true; + } + leaf subscriber-name { + type string; + } + leaf media-speed { + type ase-type:media-speed-type; + } + leaf uni-cir-value { + description "Integer value for the CIR"; + type ase-type:uni-cir-value-type; + } + leaf uni-cir-units { + description "Units for the CIR"; + type ase-type:cir-rate-type; + } + leaf cos-catagory { + type ase-type:cos-category-type; + } + leaf gos-profile { + type ase-type:uni-gos-type; + } + leaf additional-mac-allowed { + type ase-type:uni-mac-limit-type; + } + leaf port-tagging { + type ase-type:port-tagging-type; + mandatory true; + } + leaf name-value-pair { + type string; + } + } + output { + uses ase-type:uni-common-error-format; + } + } + + //// + // Port Activate Request + //// + rpc ase-port-activate-request { + input { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + mandatory true; + } + } + output { + uses ase-type:uni-common-error-format; + } + } + + //// + // Port Change Activation Request + //// + rpc ase-change-port-activation-request { + input { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + mandatory true; + } + } + output { + uses ase-type:uni-common-error-format; + } + } + + //// + // Port Disconnect Request + //// + rpc ase-port-disconnect-request { + input { + uses ase-type:uni-common-request-hdr; + + leaf uni-circuit-id { + type string; + mandatory true; + } + } + output { + uses ase-type:uni-common-error-format; + } + } + + ///////////////////////////////////////////////////// + // EVC API + ///////////////////////////////////////////////////// + + //// + // EVC Provision Request + //// + rpc ase-evc-activation { + input { + uses ase-type:evc-common-request-hdr; + leaf topology { + type enumeration { + enum "MultiPoint"{ + value 0; + } + enum "PointToPoint"{ + value 1; + } + } + } + list evc-leg { + key evc-access-name; + leaf evc-access-name { + type string; + } + leaf subscriber-name { + type string; + } + leaf cvlan { + type uint16 { + range "2..4090"; + } + } + leaf connection-cir-value { + type ase-type:uni-cir-value-type; + } + leaf connection-cir-units-string { + type ase-type:cir-rate-type; + } + leaf connection-gos-profile { + type ase-type:evc-gos-type; + } + leaf connection-additional-mac-allowed { + type ase-type:uni-mac-limit-type; + } + leaf connection-emc-indicator { + type enumeration { + enum "Y"{ + value 0; + } + enum "N"{ + value 1; + } + } + } + leaf connection-emc-speed-value { + type ase-type:uni-cir-value-type; + } + leaf connection-emc-speed-units-string { + type ase-type:cir-rate-type; + } + } + leaf name-value-pair { + type string; + } + } + output { + uses ase-type:evc-common-error-format; + } + } + + //// + // EVC Change Activation Request + //// + rpc ase-evc-change-activation { + input { + uses ase-type:evc-common-request-hdr; + leaf topology { + type enumeration { + enum "MultiPoint"{ + value 0; + } + enum "PointToPoint"{ + value 1; + } + } + } + list evc-leg { + key evc-access-name; + leaf evc-access-name { + type string; + } + leaf connection-cir-value { + type ase-type:uni-cir-value-type; + } + leaf connection-cir-units-string { + type ase-type:cir-rate-type; + } + leaf connection-gos-profile { + type ase-type:evc-gos-type; + } + leaf connection-additional-mac-allowed { + type ase-type:uni-mac-limit-type; + } + + } + leaf name-value-pair { + type string; + } + + } + output { + uses ase-type:evc-common-error-format; + } + } + + //// + // EVC Disconnet Connection Request + //// + rpc ase-evc-disconnect-request { + input { + uses ase-type:evc-common-request-hdr; + leaf topology { + type enumeration { + enum "MultiPoint"{ + value 0; + } + enum "PointToPoint"{ + value 1; + } + } + } + list evc-leg { + key evc-access-name; + leaf evc-access-name { + type string; + } + } + leaf name-value-pair { + type string; + } + + } + output { + uses ase-type:evc-common-error-format; + } + } + + ///////////////////////////////////////////////////// + // ASE Query Actions + ///////////////////////////////////////////////////// + + rpc find-available-ports { + description "Return a count of available ports"; + input { + uses ase-type:query-common-hdr; + leaf edge-device-clli { + type string; + mandatory true; + } + + leaf port-role { + type enumeration { + enum "NETWORK"{ + value 0; + } + enum "ACCESS"{ + value 1; + } + enum "SDN-ACCESS"{ + value 2; + } + } + mandatory true; + } + leaf port-assigned { + type string; + } + } + output { + uses ase-type:query-common-hdr; + container statuss { + leaf edge-device-clli { + type string; + } + container max-cir { + leaf cir-value { + type uint16; + } + leaf cir-type { + type ase-type:cir-rate-type; + } + } + leaf if-count { + type uint16; + } + } + uses ase-type:query-error-format; + } + } + + rpc find-evcs-in-uni { + description "Return EVC instances for a specified UNI"; + input { + uses ase-type:query-common-hdr; + + leaf uni-circuit-id { + type string; //leafref + } + leaf edge-device-clli { + description "Edge device (e.g. EMT) on which port " + + " reservation is needed"; + type string; + } + } + output { + uses ase-type:query-common-hdr; + + leaf uni-leg-name { + description "NGO-proivded named"; + type string; + } + uses ase-type:query-error-format; + } + } + + rpc find-service-details { + description "Return EVC instances for a specified UNI"; + input { + uses ase-type:query-common-hdr; + leaf uni-circuit-id { + type string; //leafref + } + leaf source { + type string; + mandatory true; + } + leaf service-name { + type string; + mandatory true; + } + leaf service-type { + type string; + mandatory true; + } + } + output { + uses ase-type:query-common-hdr; + + leaf service-name { + type string; + mandatory true; + } + leaf service-type { + type string; + mandatory true; + } + leaf service-state { + type enumeration { + enum "Active"{ + value 0; + } + enum "NotActive"{ + value 1; + } + } + } + leaf has-pending-change { + type ase-type:ase-yes-no-type; + } + leaf allowed-connection-count { + type int16; + } + uses ase-type:query-error-format; + } + } +} //module diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java new file mode 100644 index 000000000..6e6656e89 --- /dev/null +++ b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java @@ -0,0 +1,69 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Enumeration; +import java.util.Properties; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; + +import junit.framework.TestCase; + +public class SvcLogicContextTest extends TestCase { + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicContext.class); + + public void testMerge() { + + try { + InputStream testStr = getClass().getResourceAsStream("/mergetest.xml"); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + Document theDocument = db.parse(testStr); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.mergeDocument("test-merge", theDocument); + Properties props = ctx.toProperties(); + LOG.info("SvcLogicContext contains the following : "); + for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) { + String propName = (String) e.nextElement(); + LOG.info(propName+" = "+props.getProperty(propName)); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to merge", e); + fail("Caught exception trying to merge"); + } + + } + +} diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java new file mode 100644 index 000000000..d6503b60c --- /dev/null +++ b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java @@ -0,0 +1,69 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.openecomp.sdnc.sli.SvcLogicExprListener; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicExpressionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.TestCase; + +public class SvcLogicExpressionParserTest extends TestCase { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExprListener.class); + + public void testParse() { + try + { + InputStream testStr = getClass().getResourceAsStream("/expression.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + String testExpr = null; + while ((testExpr = testsReader.readLine()) != null) { + + SvcLogicExpression parsedExpr = SvcLogicExpressionFactory.parse(testExpr); + if (parsedExpr == null) + { + fail("parse("+testExpr+") returned null"); + } + else + { + LOG.info("test expression = ["+testExpr+"] ; parsed expression = ["+parsedExpr.asParsedExpr()+"]"); + + } + } + } + catch (Exception e) + { + e.printStackTrace(); + fail("Caught exception processing test cases"); + } + } + +} diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java new file mode 100644 index 000000000..e8ff2feeb --- /dev/null +++ b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java @@ -0,0 +1,163 @@ +/*- + * ============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========================================================= + */ + +/** + * + */ +package org.openecomp.sdnc.sli; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.LinkedList; + +import org.openecomp.sdnc.sli.SvcLogicParser; +import org.openecomp.sdnc.sli.SvcLogicParserException; +import org.openecomp.sdnc.sli.SvcLogicStore; +import org.openecomp.sdnc.sli.SvcLogicStoreFactory; + +import junit.framework.TestCase; + +/** + * @author dt5972 + * + */ +public class SvcLogicParserTest extends TestCase { + + /** + * Test method for {@link org.openecomp.sdnc.sli.SvcLogicParser#parse(java.lang.String)}. + */ + + + public void testParse() { + + + try + { + + URL propUrl = getClass().getResource("/svclogic.properties"); + + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + + assertNotNull(store); + + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + + + InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + String testCaseFile = null; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) + { + if (!testCaseFile.startsWith("/")) + { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) + { + fail("Could not resolve test case file "+testCaseFile); + } + + try { + SvcLogicParser.validate(testCaseUrl.getPath(), store); + } catch (Exception e) { + fail("Validation failure ["+e.getMessage()+"]"); + + } + + + + + + } + } + + testStr = getClass().getResourceAsStream("/parser-bad.tests"); + testsReader = new BufferedReader(new InputStreamReader(testStr)); + testCaseFile = null; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) + { + if (!testCaseFile.startsWith("/")) + { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) + { + fail("Could not resolve test case file "+testCaseFile); + } + + boolean valid = true; + try { + SvcLogicParser.load(testCaseUrl.getPath(), store); + } catch (Exception e) { + System.out.println(e.getMessage()); + valid = false; + } + + if (valid) { + fail("Expected compiler error on "+testCaseFile+", but got success"); + } + + + } + } + } + catch (SvcLogicParserException e) + { + fail("Parser error : "+e.getMessage()); + } + catch (Exception e) + { + e.printStackTrace(); + fail("Caught exception processing test cases"); + } + + + } + + + +} diff --git a/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml new file mode 100644 index 000000000..097078a8a --- /dev/null +++ b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml b/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml new file mode 100644 index 000000000..080844205 --- /dev/null +++ b/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml @@ -0,0 +1,263 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml b/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml new file mode 100644 index 000000000..5a835b7be --- /dev/null +++ b/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/common/src/test/resources/bad_neutron_logic_v11.xml b/sli/common/src/test/resources/bad_neutron_logic_v11.xml new file mode 100644 index 000000000..4e1e8d9b4 --- /dev/null +++ b/sli/common/src/test/resources/bad_neutron_logic_v11.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/common/src/test/resources/expression.tests b/sli/common/src/test/resources/expression.tests new file mode 100755 index 000000000..c352e9b08 --- /dev/null +++ b/sli/common/src/test/resources/expression.tests @@ -0,0 +1,19 @@ +$uni-circuit-id +$asePort +length($uni-circuit-id) > 0 +$asePort.uni-circuit-id +$uni-cir-units * 1000 * 100 / 100 +$uni-cir-units / 1000 +$uni-cir-units - 100 +$uni-cir-units + 100 +(value * 3 - $arg1 > 0) and (length($uni-circuit-id) == 0) +'pg-'+$network.name +$network.segment[0].provider-physical-network +length($network_segment[0].provider-physical-network) >= 5 +substr($network_segment[0].provider-physical-network,0,5) == 'dvspg' +length($network_segment[0].provider-physical-network) >= 5 and substr($network_segment[0].provider-physical-network,0,5) == 'dvspg' +(length($network_segment[0].provider-physical-network) >= 5) and (substr($network_segment[0].provider-physical-network,0,5) == 'dvspg') +4-2-2 +1+1 +1 +1+2*3-4 diff --git a/sli/common/src/test/resources/mergetest.xml b/sli/common/src/test/resources/mergetest.xml new file mode 100644 index 000000000..12e083c79 --- /dev/null +++ b/sli/common/src/test/resources/mergetest.xml @@ -0,0 +1,54 @@ + + + + Y + + Y + 11.11.11.11 + 2.2.2.2 + 100 + 1.1.1.1 + N + + 4.4.4.4 + + + 3.3.3.3 + + + 8.8.8.8 + + 10.10.10.10 + + + 9.9.9.9 + + + + 7.7.7.7 + + 6.6.6.6 + + + 5.5.5.5 + + + + diff --git a/sli/common/src/test/resources/neutron_logic_v10.xml b/sli/common/src/test/resources/neutron_logic_v10.xml new file mode 100644 index 000000000..9cd331279 --- /dev/null +++ b/sli/common/src/test/resources/neutron_logic_v10.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/common/src/test/resources/nonsense.xml b/sli/common/src/test/resources/nonsense.xml new file mode 100644 index 000000000..61220825e --- /dev/null +++ b/sli/common/src/test/resources/nonsense.xml @@ -0,0 +1,24 @@ + + + +Hello world + diff --git a/sli/common/src/test/resources/parser-bad.tests b/sli/common/src/test/resources/parser-bad.tests new file mode 100755 index 000000000..82913afc2 --- /dev/null +++ b/sli/common/src/test/resources/parser-bad.tests @@ -0,0 +1,3 @@ +bad_neutron_logic_v11.xml +EvcActivateSvcLogic_v100.xml +nonsense.xml \ No newline at end of file diff --git a/sli/common/src/test/resources/parser-good.tests b/sli/common/src/test/resources/parser-good.tests new file mode 100755 index 000000000..06543126f --- /dev/null +++ b/sli/common/src/test/resources/parser-good.tests @@ -0,0 +1,2 @@ +ReleasePortSvcLogic_v101.xml +neutron_logic_v10.xml diff --git a/sli/common/src/test/resources/simplelogger.properties b/sli/common/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..6f70984c9 --- /dev/null +++ b/sli/common/src/test/resources/simplelogger.properties @@ -0,0 +1,24 @@ +### +# ============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========================================================= +### + +org.slf4j.simpleLogger.defaultLogLevel=info +org.slf4j.simplelogger.log.org.openecomp.sdnc.sli.SvcLogicContext=debug +org.slf4j.simplelogger.log.SvcLogicContext=debug diff --git a/sli/common/src/test/resources/svclogic.properties b/sli/common/src/test/resources/svclogic.properties new file mode 100644 index 000000000..fa33146e5 --- /dev/null +++ b/sli/common/src/test/resources/svclogic.properties @@ -0,0 +1,26 @@ +### +# ============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========================================================= +### + +org.openecomp.sdnc.sli.dbtype = jdbc +org.openecomp.sdnc.sli.jdbc.url = jdbc:mysql://localhost:3306/sdnctl +org.openecomp.sdnc.sli.jdbc.database = sdnctl +org.openecomp.sdnc.sli.jdbc.user = sdnctl +org.openecomp.sdnc.sli.jdbc.password = gamma diff --git a/sli/common/src/test/resources/svclogic.sh b/sli/common/src/test/resources/svclogic.sh new file mode 100644 index 000000000..09f0637d5 --- /dev/null +++ b/sli/common/src/test/resources/svclogic.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +### +# ============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========================================================= +### + +MYSQL_JDBC_DRIVER=${MYSQL_JDBC_DRIVER:-/home/ubuntu/mysql-connector-java-5.1.38.1.jar} +SLI_COMMON_TARGETDIR=${SLI_COMMON_TARGETDIR:-/home/ubuntu/opendaylight/plugins} +#SLI_COMMON_TARGETDIR=${SLI_COMMON_TARGETDIR:-/home/ubuntu/git/sdnctl/sli/common/target} +SLI_VERSION=${SLI_VERSION:-1.1.0-SNAPSHOT} +SLI_COMMON_JAR=${SLI_COMMON_JAR:=${SLI_COMMON_TARGETDIR}/sli-common-${SLI_VERSION}.jar} + +echo SLI_COMMON_JAR is $SLI_COMMON_JAR + +java -cp ${CLASSPATH}:${MYSQL_JDBC_DRIVER}:${SLI_COMMON_JAR} org.openecomp.sdnc.sli.SvcLogicParser $* diff --git a/sli/common/src/test/resources/svclogic.xsd b/sli/common/src/test/resources/svclogic.xsd new file mode 100755 index 000000000..074308915 --- /dev/null +++ b/sli/common/src/test/resources/svclogic.xsd @@ -0,0 +1,323 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/features/pom.xml b/sli/features/pom.xml new file mode 100755 index 000000000..2556a5795 --- /dev/null +++ b/sli/features/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + sli + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + sli-features + SLI - Features + + jar + + + + org.openecomp.sdnc.core + sli-common + ${project.version} + + + + + org.openecomp.sdnc.core + sli-recording + ${project.version} + + + commons-lang + commons-lang + 2.6 + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/sli/features/src/main/resources/features.xml b/sli/features/src/main/resources/features.xml new file mode 100644 index 000000000..e1ce255a5 --- /dev/null +++ b/sli/features/src/main/resources/features.xml @@ -0,0 +1,39 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + + odl-mdsal-broker + mvn:org.openecomp.sdnc.core/sli-common/${project.version} + mvn:org.openecomp.sdnc.core/sli-provider/${project.version} + mvn:org.openecomp.sdnc.core/sli-recording/${project.version} + sdnc-dblib + mvn:mysql/mysql-connector-java/${mysql.connector.version} + + + diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml new file mode 100755 index 000000000..d43769e28 --- /dev/null +++ b/sli/installer/pom.xml @@ -0,0 +1,149 @@ + + + 4.0.0 + + sli + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + sli-installer + SLI - Karaf Installer + pom + + + sdnc-sli + sdnc-sli + mvn:org.openecomp.sdnc.core/sli-features/${project.version}/xml/features + false + + + + + + org.openecomp.sdnc.core + sli-features + ${project.version} + features + xml + + + * + * + + + + + + org.openecomp.sdnc.core + sli-common + ${project.version} + + + + org.openecomp.sdnc.core + sli-provider + ${project.version} + + + + org.openecomp.sdnc.core + sli-recording + ${project.version} + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.openecomp.sdnc + dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/sli/installer/src/assembly/assemble_installer_zip.xml b/sli/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..85e2e1e8f --- /dev/null +++ b/sli/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + bin + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/sli/installer/src/assembly/assemble_mvnrepo_zip.xml b/sli/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..38e6d47b1 --- /dev/null +++ b/sli/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + bin + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/sli/installer/src/main/resources/scripts/install-feature.sh b/sli/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..93236c5be --- /dev/null +++ b/sli/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +### +# ============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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/sli/pom.xml b/sli/pom.xml new file mode 100755 index 000000000..53a8b6298 --- /dev/null +++ b/sli/pom.xml @@ -0,0 +1,65 @@ + + + + + + org.openecomp.sdnc.core + sdnc-core + 0.0.1-SNAPSHOT + + 4.0.0 + pom + org.openecomp.sdnc.core + sli + + + + + + org.openecomp.sdnc.core + sli-features + features + xml + ${project.version} + + + + org.openecomp.sdnc.core + sli-common + ${project.version} + + + + org.openecomp.sdnc.core + sli-provider + ${project.version} + + + + org.openecomp.sdnc.core + sli-recording + ${project.version} + + + + + + + + Service Logic Interpreter + The Service Logic Interpreter (SLI) allows service planners to design the flow of logic within the SDN controller in an XML format, without a need for custom Java code. + + + common + provider + recording + features + installer + + + openECOMP + + 0.0.1-SNAPSHOT + + + diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml new file mode 100755 index 000000000..f73d0071a --- /dev/null +++ b/sli/provider/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + org.openecomp.sdnc.core + sli + 0.0.1-SNAPSHOT + + sli-provider + bundle + SLI - Provider + + UTF-8 + + + + junit + junit + 3.8.1 + test + + + org.openecomp.sdnc.core + sli-common + ${project.version} + compile + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + commons-lang + commons-lang + ${commons.lang.version} + compile + + + + + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.openecomp.sdnc.sli.provider.SvcLogicActivator + org.openecomp.sdnc.sli.provider;version=${project.version} + + * + + + org.openecomp.sdnc.sli;version="${project.version}",* + + *;scope=compile;artifactId=commons-lang|commons-lang3 + + true + + + + + + + + + SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. + diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BlockNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BlockNodeExecutor.java new file mode 100644 index 000000000..f83154d9e --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BlockNodeExecutor.java @@ -0,0 +1,75 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BlockNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(BlockNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + SvcLogicExpression atomicExpr = node.getAttribute("atomic"); + String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); + boolean isAtomic = "true".equalsIgnoreCase(atomicStr); + + // Initialize status to success so that at least one outcome will execute + ctx.setStatus("success"); + + int numOutcomes = node.getNumOutcomes(); + + for (int i = 0; i < numOutcomes; i++) { + if ("failure".equals(ctx.getStatus()) && isAtomic) { + LOG.info("Block - stopped executing nodes due to failure status"); + return(null); + } + + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Block - executing outcome " + (i + 1)); + } + while (nextNode != null) + { + nextNode = svc.executeNode(nextNode, ctx); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("Block - done: no outcome " + (i + 1)); + } + } + } + + return (null); + } + + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BreakNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BreakNodeExecutor.java new file mode 100644 index 000000000..0f8719c8a --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BreakNodeExecutor.java @@ -0,0 +1,42 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.BreakNodeException; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BreakNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(BreakNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + String message = "BreakNodeExecutor encountered break with nodeId " + node.getNodeId(); + LOG.debug(message); + throw new BreakNodeException(message); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java new file mode 100644 index 000000000..7b79c19f6 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java @@ -0,0 +1,165 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicGraph; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CallNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(CallNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String outValue = "not-found"; + + SvcLogicGraph myGraph = node.getGraph(); + + if (myGraph == null) + { + LOG.debug("execute: getGraph returned null"); + } + else + { + LOG.debug("execute: got SvcLogicGraph"); + } + + SvcLogicExpression moduleExpr = null; + + String module = null; + + moduleExpr = node.getAttribute("module"); + if (moduleExpr != null) + { + module = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + if ((module == null) || (module.length() == 0)) + { + if (myGraph != null) + { + module = myGraph.getModule(); + LOG.debug("myGraph.getModule() returned "+module); + } + } + + SvcLogicExpression rpcExpr = null; + String rpc = null; + rpcExpr = node.getAttribute("rpc"); + if (rpcExpr != null) + { + rpc = SvcLogicExpressionResolver.evaluate(rpcExpr, node, ctx); + } + + if ((rpc == null) || (rpc.length() == 0)) + { + if (myGraph != null) + { + rpc = myGraph.getRpc(); + LOG.debug("myGraph.getRpc() returned "+rpc); + } + } + + String mode = null; + + moduleExpr = node.getAttribute("mode"); + if (moduleExpr != null) + { + mode = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + if ((mode == null) || (mode.length() == 0)) + { + if (myGraph != null) + { + mode = myGraph.getMode(); + + LOG.debug("myGraph.getMode() returned "+mode); + } + } + + String version = null; + + moduleExpr = node.getAttribute("version"); + if (moduleExpr != null) + { + version = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + String parentGraph = ctx.getAttribute("currentGraph"); + ctx.setAttribute("parentGraph", parentGraph); + + SvcLogicStore store = getStore(); + + if (store != null) { + SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); + LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); + ctx.setAttribute("currentGraph", calledGraph.toString()); + if (calledGraph != null) { + svc.execute(calledGraph, ctx); + + outValue = ctx.getStatus(); + } else { + LOG.error("Could not find service logic for [" + module + "," + rpc + "," + version + "," + mode + "]"); + } + } + else + { + LOG.debug("Could not get SvcLogicStore reference"); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + ctx.setAttribute("currentGraph", parentGraph); + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + ctx.setAttribute("currentGraph", parentGraph); + ctx.setAttribute("parentGraph", null); + + return (nextNode); + + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java new file mode 100644 index 000000000..a3f2874fb --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java @@ -0,0 +1,248 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.openecomp.sdnc.sli.SvcLogicAdaptor; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConfigureNodeExecutor extends SvcLogicNodeExecutor { + private static final Logger LOG = LoggerFactory + .getLogger(ConfigureNodeExecutor.class); + + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String adaptorName = SvcLogicExpressionResolver.evaluate( + node.getAttribute("adaptor"), node, ctx); + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("configure node encountered - looking for adaptor " + + adaptorName); + } + + SvcLogicAdaptor adaptor = getAdaptor(adaptorName); + + if (adaptor != null) { + String activate = SvcLogicExpressionResolver.evaluate( + node.getAttribute("activate"), node, ctx); + String key = SvcLogicExpressionResolver.evaluate( + node.getAttribute("key"), node, ctx); + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); + + parmMap.put(curName,curExprValue); + } + + if (hasParms) { + SvcLogicAdaptor.ConfigStatus confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + confStatus = adaptor.configure(key, parmMap, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".configure", e); + confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + + switch (confStatus) { + case SUCCESS: + outValue = "success"; + if ((activate != null) && (activate.length() > 0)) { + if ("true".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + activateStatus = adaptor.activate(key, ctx); + } catch (Exception e) { + + LOG.warn("Caught exception from "+adaptorName+".activate", e); + activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (activateStatus) { + case SUCCESS: + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else if ("false".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + deactivateStatus = adaptor.deactivate(key, ctx); + } catch (Exception e) { + + LOG.warn("Caught exception from "+adaptorName+".deactivate", e); + deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (deactivateStatus) { + case SUCCESS: + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } + } + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else { + if ((activate != null) && (activate.length() > 0)) { + if ("true".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + try { + activateStatus = adaptor.activate(key, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".activate", e); + activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (activateStatus) { + case SUCCESS: + outValue = "success"; + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else if ("false".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + deactivateStatus = adaptor.deactivate(key, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".deactivate", e); + deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (deactivateStatus) { + case SUCCESS: + outValue = "success"; + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } + } else { + LOG.warn("Nothing to configure - no parameters passed, and activate attribute is not set"); + outValue = "success"; + } + } + } else { + if (LOG.isWarnEnabled()) { + LOG.warn("Adaptor for " + adaptorName + " not found"); + } + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java new file mode 100644 index 000000000..081cbcfa1 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java @@ -0,0 +1,101 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DeleteNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(DeleteNodeExecutor.class); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("delete node encountered - looking for resource class " + + plugin); + } + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + + try { + + switch (resourcePlugin.delete(resourceType, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java new file mode 100644 index 000000000..7ae4d0db9 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java @@ -0,0 +1,161 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExecuteNodeExecutor extends SvcLogicNodeExecutor { + private static final Logger LOG = LoggerFactory + .getLogger(ExecuteNodeExecutor.class); + + private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure."; + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String pluginName = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("execute node encountered - looking for plugin " + + pluginName); + } + + SvcLogicJavaPlugin plugin = getSvcLogicJavaPlugin(pluginName); + + if (plugin == null) { + outValue = "not-found"; + } else { + + String methodName = evaluate(node.getAttribute("method"), node, ctx); + + Class pluginClass = plugin.getClass(); + + Method pluginMethod = null; + + try { + pluginMethod = pluginClass.getMethod(methodName, Map.class, SvcLogicContext.class); + } catch (NoSuchMethodException e) { + LOG.error(pluginErrorMessage, e); + } + + if (pluginMethod == null) { + outValue = "unsupported-method"; + } else { + try { + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); + + parmMap.put(curName,curExprValue); + } + + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + + outValue = mapOutcome(o, emitsOutcome); + + } catch (InvocationTargetException e) { + if(e.getCause() != null){ + LOG.error(pluginErrorMessage, e.getCause()); + }else{ + LOG.error(pluginErrorMessage, e); + } + outValue = "failure"; + ctx.setStatus("failure"); + } catch (IllegalAccessException e) { + LOG.error(pluginErrorMessage, e); + outValue = "failure"; + ctx.setStatus("failure"); + } catch (IllegalArgumentException e) { + LOG.error(pluginErrorMessage, e); + outValue = "failure"; + ctx.setStatus("failure"); + } + } + + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + return (nextNode); + } + + protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + return SvcLogicExpressionResolver.evaluate(node.getAttribute("method"), node, ctx); + } + + public String mapOutcome(Object o, String emitsOutcome) { + if (emitsOutcome != null) { + Boolean nodeEmitsOutcome = Boolean.valueOf(emitsOutcome); + if (nodeEmitsOutcome) { + return (String) o; + } else { + return "success"; + } + + } else { + return "success"; + } + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java new file mode 100644 index 000000000..688a86e53 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java @@ -0,0 +1,105 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExistsNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ExistsNodeExecutor.class); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("exists node encountered - looking for resource class " + + plugin); + } + + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + + switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) { + case SUCCESS: + outValue = "true"; + break; + case NOT_FOUND: + outValue = "false"; + break; + case FAILURE: + default: + outValue = "false"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ForNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ForNodeExecutor.java new file mode 100644 index 000000000..e9fdc55ef --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ForNodeExecutor.java @@ -0,0 +1,109 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.BreakNodeException; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ForNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ForNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + SvcLogicExpression atomicExpr = node.getAttribute("atomic"); + String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); + boolean isAtomic = !("false".equalsIgnoreCase(atomicStr)); + + int numOutcomes = node.getNumOutcomes(); + String idxVar = SvcLogicExpressionResolver.evaluate( + node.getAttribute("index"), node, ctx); + String startVal = SvcLogicExpressionResolver.evaluate( + node.getAttribute("start"), node, ctx); + String endVal = SvcLogicExpressionResolver.evaluate( + node.getAttribute("end"), node, ctx); + + LOG.debug("Executing "+ (isAtomic ? "atomic" : "non-atomic") + " for loop - for (int " + idxVar + " = " + startVal + + "; " + idxVar + " < " + endVal + "; " + idxVar + "++)"); + + int startIdx = 0; + int endIdx = 0; + + try { + startIdx = Integer.parseInt(startVal); + endIdx = Integer.parseInt(endVal); + } catch (NumberFormatException e) { + SvcLogicExpression silentFailureExpr = node.getAttribute("silentFailure"); + String silentFailure = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); + boolean isSilentFailure = Boolean.parseBoolean(silentFailure); + String message = "Invalid index values [" + startVal + "," + endVal + "]"; + if(!isSilentFailure){ + throw new SvcLogicException(message); + }else{ + LOG.debug(message + ". Not exiting because silentFailure was set to true."); + return(null); + } + } + + try { + for (int ctr = startIdx; ctr < endIdx; ctr++) { + + ctx.setAttribute(idxVar, "" + ctr); + + for (int i = 0; i < numOutcomes; i++) { + + if ("failure".equals(ctx.getStatus()) && isAtomic) { + LOG.info("For - stopped executing nodes due to failure status"); + return(null); + } + + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("For - executing outcome " + (i + 1)); + } + SvcLogicNode innerNextNode = nextNode; + while (innerNextNode != null) { + innerNextNode = svc.executeNode(innerNextNode, ctx); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("For - done: no outcome " + (i + 1)); + } + } + } + } + } catch (BreakNodeException br) { + LOG.debug("ForNodeExecutor caught break"); + } + return (null); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java new file mode 100644 index 000000000..d431a18af --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java @@ -0,0 +1,134 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GetResourceNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(GetResourceNodeExecutor.class); + + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + String localOnlyStr = SvcLogicExpressionResolver.evaluate( + node.getAttribute("local-only"), node, ctx); + + // Note: for get-resource, only refresh from A&AI if the DG explicitly set + // local-only to false. Otherwise, just read from local database. + boolean localOnly = true; + + if ("false".equalsIgnoreCase(localOnlyStr)) { + localOnly = false; + } + + SvcLogicExpression selectExpr = node.getAttribute("select"); + String select = null; + + if (selectExpr != null) { + select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, + ctx); + } + + SvcLogicExpression orderByExpr = node.getAttribute("order-by"); + String orderBy = null; + + if (orderByExpr != null) { + orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, + ctx); + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug(node.getNodeType() + + " node encountered - looking for resource class " + + plugin); + } + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.query(resourceType, localOnly, select, key, + pfx, orderBy, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java new file mode 100644 index 000000000..0df73682c --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java @@ -0,0 +1,103 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(IsAvailableNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("is-available node encountered - looking for resource class " + + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + + if (resourcePlugin != null) { + try { + switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) { + case SUCCESS: + outValue = "true"; + break; + case NOT_FOUND: + outValue = "false"; + break; + case FAILURE: + default: + outValue = "false"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/MdsalHelper.java new file mode 100644 index 000000000..4c5ee0686 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/MdsalHelper.java @@ -0,0 +1,1186 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yangtools.yang.binding.Identifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MdsalHelper { + + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); + private static Properties yangMappingProperties = new Properties(); + + @Deprecated + public static void setProperties(Properties input) { + setYangMappingProperties(input); + } + + public static void setYangMappingProperties(Properties properties) { + for (Object propNameObj : properties.keySet()) { + String propName = (String) propNameObj; + MdsalHelper.yangMappingProperties.setProperty(propName, properties.getProperty(propName)); + } + } + + public static void loadProperties(String propertiesFile) { + File file = new File(propertiesFile); + Properties properties = new Properties(); + InputStream input = null; + if (file.isFile() && file.canRead()) { + try { + input = new FileInputStream(file); + properties.load(input); + MdsalHelper.setYangMappingProperties(properties); + LOG.info("Loaded properties from " + propertiesFile); + } catch (Exception e) { + LOG.error("Failed to load properties " + propertiesFile + "\n", e); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + LOG.error("Failed to close properties file " + propertiesFile + "\n", e); + } + } + } + }else{ + LOG.error("Failed to load the properties file " + propertiesFile + "\n"); + LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); + } + } + + public static Properties toProperties(Properties props, Object fromObj) { + Class fromClass = null; + + if (fromObj != null) { + fromClass = fromObj.getClass(); + } + return (toProperties(props, "", fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj) { + Class fromClass = null; + + if (fromObj != null) { + fromClass = fromObj.getClass(); + } + + return (toProperties(props, pfx, fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { + + if (fromObj == null) { + return (props); + } + + String simpleName = fromClass.getSimpleName(); + + LOG.trace("Extracting properties from " + fromClass.getName() + " class"); + if (fromObj instanceof List) { + + // Class is a List. List should contain yang-generated classes. + LOG.trace(fromClass.getName() + " is a List"); + + List fromList = (List) fromObj; + + for (int i = 0; i < fromList.size(); i++) { + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); + } + props.setProperty(pfx + "_length", "" + fromList.size()); + + } else if (isYangGenerated(fromClass)) { + // Class is yang generated. + LOG.trace(fromClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + + // If called from a list (so prefix ends in ']'), don't + // add class name again + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx; + } else { + propNamePfx = toLowerHyphen(fromClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // save from + + int numGetters = 0; + String lastGetterName = null; + String propVal = null; + + for (Method m : fromClass.getMethods()) { + if (isGetter(m)) { + + numGetters++; + lastGetterName = m.getName(); + + Class returnType = m.getReturnType(); + String fieldName; + if (m.getName().startsWith("get")) { + fieldName = toLowerHyphen(m.getName().substring(3)); + } else { + + fieldName = toLowerHyphen(m.getName().substring(2)); + } + + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + // Is the return type a yang generated class? + if (isYangGenerated(returnType)) { + // Is it an enum? + if (returnType.isEnum()) { + // Return type is a typedef. Save its value. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + Object retValue = m.invoke(fromObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + String propName = propNamePfx + "." + fieldName; + propVal = retValue.toString(); + props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert Yang-generated enum returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpv4Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = retValue.getValue().toString(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpv6Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = retValue.getValue().toString(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpAddress(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + IpAddress retValue = (IpAddress) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = new String(retValue.getValue()); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpPrefix(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + IpPrefix retValue = (IpPrefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = new String(retValue.getValue()); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + + if (retValue instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + retValue = new String((byte[]) retValue, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + retValue); + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); + } + } catch (Exception e) { + + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert Yang-generated class returned by" + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } else if (returnType.equals(Class.class)) { + + LOG.trace(m.getName() + " returns a Class object - not interested"); + + } else if (List.class.isAssignableFrom(returnType)) { + + // This getter method returns a list. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retList = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + // Figure out what type of elements are stored in + // this array. + Type paramType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + + } else { + + // Method returns something that is not a List and not + // yang-generated. + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object propValObj = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (propValObj != null) { + if (propValObj instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + propVal = new String((byte[]) propValObj, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + propVal); + + } else { + propVal = propValObj.toString(); + } + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + + } + } + + // End of method loop. If there was only one getter, named + // "getValue", then + // set value identified by "prefix" to that one value. + if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { + LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + " = " + propVal); + props.setProperty(propNamePfx, propVal); + } else { + LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " + lastGetterName); + + } + + } else { + // Class is not yang generated and not a list + // It must be an element of a leaf list - set "prefix" to value + String fromVal = null; + if (fromObj instanceof byte[]) { + try { + fromVal = new String((byte[]) fromObj, "UTF-8"); + LOG.trace("Converted byte array " + pfx + "to string " + fromVal); + } catch (Exception e) { + LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); + fromVal = fromObj.toString(); + } + + } else { + fromVal = fromObj.toString(); + } + LOG.debug("Setting property " + pfx + " to " + fromVal); + props.setProperty(pfx, fromVal); + } + + return (props); + } + + public static Object toBuilder(Properties props, Object toObj) { + + return (toBuilder(props, "", toObj)); + } + + public static List toList(Properties props, String pfx, List toObj, Class elemType) { + + int maxIdx = -1; + boolean foundValue = false; + + LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); + + if (props.contains(pfx + "_length")) { + try { + int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); + + if (listLength > 0) { + maxIdx = listLength - 1; + } + } catch (Exception e) { + // Ignore exception + } + } + + if (maxIdx == -1) { + // Figure out array size + for (Object pNameObj : props.keySet()) { + String key = (String) pNameObj; + + if (key.startsWith(pfx + "[")) { + String idxStr = key.substring(pfx.length() + 1); + int endloc = idxStr.indexOf("]"); + if (endloc != -1) { + idxStr = idxStr.substring(0, endloc); + } + + try { + int curIdx = Integer.parseInt(idxStr); + if (curIdx > maxIdx) { + maxIdx = curIdx; + } + } catch (Exception e) { + LOG.error("Illegal subscript in property " + key); + } + + } + } + } + + LOG.trace(pfx + " has max index of " + maxIdx); + for (int i = 0; i <= maxIdx; i++) { + + String curBase = pfx + "[" + i + "]"; + + if (isYangGenerated(elemType)) { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + LOG.trace("Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class " + builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from " + pfx); + } + } else { + // Must be a leaf list + String curValue = props.getProperty(curBase, ""); + + toObj.add(curValue); + + if ((curValue != null) && (curValue.length() > 0)) { + foundValue = true; + } + } + + } + + if (foundValue) { + return (toObj); + } else { + return (null); + } + + } + + public static Object toBuilder(Properties props, String pfx, Object toObj) { + return (toBuilder(props, pfx, toObj, false)); + } + + public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { + Class toClass = toObj.getClass(); + boolean foundValue = false; + + LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); + + Ipv4Address addr; + + if (isYangGenerated(toClass)) { + // Class is yang generated. + LOG.trace(toClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + if (preservePfx) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + if (toObj instanceof Identifier) { + LOG.trace(toClass.getName() + " is a Key - skipping"); + return (toObj); + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + if (isSetter(m)) { + Class paramTypes[] = m.getParameterTypes(); + Class paramClass = paramTypes[0]; + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + String paramValue = props.getProperty(propName); + if (paramValue == null) { + LOG.trace(propName + " is unset"); + } else { + LOG.trace(propName + " = " + paramValue); + } + + // Is the return type a yang generated class? + if (isYangGenerated(paramClass)) { + // Is it an enum? + if (paramClass.isEnum()) { + + LOG.trace(m.getName() + " expects an Enum"); + // Param type is a typedef. + if ((paramValue != null) && (paramValue.length() > 0)) { + Object paramObj = null; + + try { + paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); + } catch (Exception e) { + LOG.error("Caught exception trying to convert field " + propName + " to enum " + paramClass.getName(), e); + } + + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to create Yang-generated enum expected by" + toClass.getName() + "." + m.getName() + "() from Properties entry", e); + } + } + } else { + + String simpleName = paramClass.getSimpleName(); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName)) { + + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); + + if ("Ipv4Address".equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv4Address()); + } else if ("Ipv6Address".equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv6Address()); + + } else { + m.invoke(toObj, ipAddr); + } + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + paramValue + ")", e); + + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to call " + toClass.getName() + "." + m.getName() + "() with Properties entry", e); + } + } + } else if ("IpPrefix".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); + m.invoke(toObj, ipPrefix); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + paramValue + ")", e); + } + } + } else { + // setter expects a yang-generated class. Need + // to + // create a builder to set it. + + String builderName = paramClass.getName() + "Builder"; + Class builderClass = null; + Object builderObj = null; + Object paramObj = null; + + Object constObj = null; + + LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " + builderName); + try { + builderClass = Class.forName(builderName); + builderObj = builderClass.newInstance(); + paramObj = toBuilder(props, propNamePfx, builderObj); + } catch (ClassNotFoundException e) { + + if (paramValue == null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(null)"); + m.invoke(toObj, new Object[] { null }); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e1) { + LOG.error("Caught exception trying to cally" + toClass.getName() + "." + m.getName() + "() with Properties entry", e1); + } + } else { + try { + // See if I can find a constructor I + // can + // use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj == null) { + + // Last chance - see if + // parameter class has a static + // method + // getDefaultInstance(String) + try { + Method gm = paramClass.getMethod("getDefaultInstance", String.class); + + int gmodifier = gm.getModifiers(); + if (Modifier.isStatic(gmodifier)) { + // Invoke static + // getDefaultInstance(String) + paramObj = gm.invoke(null, paramValue); + } + + } catch (Exception gme) { + // Ignore exceptions + } + } + + } catch (Exception e1) { + LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); + } + + if (constObj == null) { + LOG.warn("Could not find builder class " + builderName + " and could not find a String or Long constructor or static getDefaultInstance(String) - trying just to set passing paramValue"); + + } + } + } catch (Exception e) { + LOG.error("Caught exception trying to create builder " + builderName, e); + } + + if (paramObj != null) { + + try { + + Method buildMethod = builderClass.getMethod("build"); + LOG.trace("Calling " + paramObj.getClass().getName() + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(paramObj); + + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); + m.invoke(toObj, builtObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to set Yang-generated class expected by" + toClass.getName() + "." + m.getName() + "() from Properties entry", e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + if (constObj != null) { + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + constObj.toString() + ")"); + m.invoke(toObj, constObj); + } else { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramValue); + + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(paramClass)) { + + LOG.trace("Parameter class " + paramClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type paramType = m.getGenericParameterTypes()[0]; + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + Object paramObj = new LinkedList(); + try { + paramObj = toList(props, propName, (List) paramObj, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to create list expected as argument to " + toClass.getName() + "." + m.getName()); + } + + if (paramObj != null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert List returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } else { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace("Parameter class " + paramClass.getName() + " is not a yang-generated class or a List"); + + if ((paramValue != null) && (paramValue.length() > 0)) { + + Object constObj = null; + + try { + // See if I can find a constructor I can use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + constObj + ")"); + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error("Caught exception trying to call " + m.getName(), e2); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } catch (Exception e1) { + LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); + } + + } + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + if (foundValue) { + return (toObj); + } else { + return (null); + } + } + + public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { + boolean foundValue = false; + + LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); + + if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { + // Class is yang generated. + LOG.trace(toClass.getName() + " is a Yang-generated class"); + + if (toClass.getName().endsWith("Key")) { + if (Identifier.class.isAssignableFrom(toClass)) { + LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); + } else { + + LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); + } + } + + String propNamePfx = null; + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + LOG.trace("Is " + m.getName() + " method a getter?"); + if (isGetter(m)) { + LOG.trace(m.getName() + " is a getter"); + Class returnClass = m.getReturnType(); + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + // Is the return type a yang generated class? + if (isYangGenerated(returnClass)) { + // Is it an enum? + if (returnClass.isEnum()) { + + LOG.trace(m.getName() + " is an Enum"); + pstr.print("\n\n * " + propName); + + } else { + + String simpleName = returnClass.getSimpleName(); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName)) { + LOG.trace(m.getName() + " is an " + simpleName); + pstr.print("\n\n * " + propName); + } else { + printPropertyList(pstr, propNamePfx, returnClass); + } + + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(returnClass)) { + + LOG.trace("Parameter class " + returnClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type returnType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + Class elementClass = (Class) elementType; + LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); + printPropertyList(pstr, propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", elementClass); + + } else if (!returnClass.equals(Class.class)) { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace("Parameter class " + returnClass.getName() + " is not a yang-generated class or a List"); + + pstr.print("\n\n * " + propName); + + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + } + + public static boolean isYangGenerated(Class c) { + if (c == null) { + return (false); + } else { + return (c.getName().startsWith("org.opendaylight.yang.gen.")); + } + } + + public static boolean isIpPrefix(Class c) { + + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("IpPrefix".equals(simpleName)); + } + + public static boolean isIpv4Address(Class c) { + + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv4Address".equals(simpleName)); + } + + public static boolean isIpv6Address(Class c) { + + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv6Address".equals(simpleName)); + } + + public static boolean isIpAddress(Class c) { + + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("IpAddress".equals(simpleName)); + } + + public static String toLowerHyphen(String inStr) { + if (inStr == null) { + return (null); + } + + String str = inStr.substring(0, 1).toLowerCase(); + if (inStr.length() > 1) { + str = str + inStr.substring(1); + } + + String regex = "(([a-z0-9])([A-Z]))"; + String replacement = "$2-$3"; + + String retval = str.replaceAll(regex, replacement).toLowerCase(); + + LOG.trace("Converting " + inStr + " => " + str + " => " + retval); + return (retval); + } + + //This is called when mapping the yang value back to a valid java enumeration + public static String toJavaEnum(String inStr) { + if (inStr == null) { + return (null); + } else if (inStr.length() == 0) { + return (inStr); + } + + //This will strip out all periods, which cannot be in a java enum + inStr = inStr.replaceAll("\\.", ""); + + String[] terms = inStr.split("-"); + StringBuffer sbuff = new StringBuffer(); + + //appends an _ if the string starts with a digit to make it a valid java enum + if (Character.isDigit(inStr.charAt(0))) { + sbuff.append('_'); + } + //If the string contains hyphens it will convert the string to upperCamelCase without hyphens + for (String term : terms) { + sbuff.append(term.substring(0, 1).toUpperCase()); + if (term.length() > 1) { + sbuff.append(term.substring(1)); + } + } + return (sbuff.toString()); + + } + + public static boolean isGetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { + if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { + if (!"getClass".equals(m.getName())) { + return (true); + } + } + + if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { + return (true); + } + + if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { + return (true); + } + } + + return (false); + } + + public static boolean isSetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { + if (m.getName().matches("^set[A-Z].*")) { + Class[] paramTypes = m.getParameterTypes(); + if (paramTypes[0].isAssignableFrom(Identifier.class) || Identifier.class.isAssignableFrom(paramTypes[0])) { + return (false); + } else { + return (true); + } + } + + } + + return (false); + } + + public static String getFullPropertiesPath(String propertiesFileName) { + return "/opt/bvc/controller/configuration/" + propertiesFileName; + } + + //This is called when mapping a valid java enumeration back to the yang model value + public static String mapEnumeratedValue(String propertyName, String propertyValue) { + LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); + String mappingKey = "yang." + propertyName + "." + propertyValue; + if (yangMappingProperties.containsKey(mappingKey)) { + return (yangMappingProperties.getProperty(mappingKey)); + } else { + LOG.info("yangMappingProperties did not contain the key " + mappingKey + " returning the original value."); + return propertyValue; + } + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java new file mode 100644 index 000000000..706014a32 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java @@ -0,0 +1,102 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NotifyNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(NotifyNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String action = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("action"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("release node encountered - looking for resource class " + + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + + try { + + switch (resourcePlugin.notify(resourceType, action, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java new file mode 100644 index 000000000..8ba14d276 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java @@ -0,0 +1,119 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RecordNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(RecordNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String outValue = "failure"; + + if (LOG.isTraceEnabled()) { + LOG.trace(node.getNodeType() + + " node encountered - looking for recorder class " + + plugin); + } + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, + node, ctx); + + if (LOG.isTraceEnabled()) { + LOG.trace("executeRecordNode : parameter " + curName + " = " + + curExpr + " => " + curExprValue); + } + parmMap.put(curName, curExprValue); + } + + + SvcLogicRecorder recorder = getSvcLogicRecorder(plugin); + + if (recorder != null) { + + try { + recorder.record(parmMap); + } catch (SvcLogicException e) { + LOG.error("Caught exception from recorder plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicRecorder object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isTraceEnabled()) { + LOG.trace("no failure or Other branch found"); + } + } + return (nextNode); + } + + + + + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java new file mode 100644 index 000000000..0d8416cdd --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java @@ -0,0 +1,100 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReleaseNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ReleaseNodeExecutor.class); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("release node encountered - looking for resource class " + + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + + try { + + switch (resourcePlugin.release(resourceType, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java new file mode 100644 index 000000000..f0bbda88f --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java @@ -0,0 +1,114 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReserveNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ReserveNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"),node,ctx); + + + SvcLogicExpression selectExpr = node.getAttribute("select"); + String select = null; + + if (selectExpr != null) + { + select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("reserve node encountered - looking for resource class " + + plugin); + } + + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReturnNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReturnNodeExecutor.java new file mode 100644 index 000000000..5cca47128 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReturnNodeExecutor.java @@ -0,0 +1,78 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReturnNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ReturnNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String status = SvcLogicExpressionResolver.evaluate( + node.getAttribute("status"), node, ctx); + + if (status != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Returning status " + status); + } + ctx.setStatus(status); + } else { + if (LOG.isWarnEnabled()) { + LOG.warn("Return node has no status attribute set"); + } + } + + Set> parameterSet = node + .getParameterSet(); + + for (Iterator> iter = parameterSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + String curValue = SvcLogicExpressionResolver.evaluate( + curEnt.getValue(), node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.debug("Setting context attribute " + curName + " to " + + curValue); + } + ctx.setAttribute(curName, curValue); + } + return null; + } + + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java new file mode 100644 index 000000000..57eac7f7b --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java @@ -0,0 +1,142 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SaveNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(SaveNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String forceStr = SvcLogicExpressionResolver.evaluate( + node.getAttribute("force"), node, ctx); + String localOnlyStr = SvcLogicExpressionResolver.evaluate( + node.getAttribute("local-only"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + boolean force = "true".equalsIgnoreCase(forceStr); + boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate( + curExpr, node, ctx); + + LOG.debug("Parameter " + curName + " = " + + curExpr.asParsedExpr() + " resolves to " + + curExprValue); + + parmMap.put(curName, curExprValue); + } + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + + plugin); + } + + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.save(resourceType, force, localOnly, key, + parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java new file mode 100644 index 000000000..013997eda --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java @@ -0,0 +1,189 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.Set; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicExpressionFactory; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SetNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(SetNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String ifunsetStr = SvcLogicExpressionResolver.evaluate( + node.getAttribute("only-if-unset"), node, ctx); + + boolean ifunset = "true".equalsIgnoreCase(ifunsetStr); + + Set> parameterSet = node + .getParameterSet(); + + for (Iterator> iter = parameterSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + String lhsVarName = curName; + + // Resolve LHS of assignment (could contain index variables) + try { + SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); + lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); + } catch (Exception e) { + LOG.warn("Caught exception trying to resolve variable name ("+curName+")", e); + } + + + boolean setValue = true; + + if (curName.endsWith(".")) { + + // Copy subtree - value should be a variable name + SvcLogicExpression curValue = curEnt.getValue(); + + if (curValue != null) { + String rhsRoot = curValue.toString(); + + if ((rhsRoot != null) && (rhsRoot.length() > 0)) { + if (rhsRoot.endsWith(".")) { + rhsRoot = rhsRoot + .substring(0, rhsRoot.length() - 1); + } + + + // SDNGC-2321 : rhsRoot is variable name, possibly with subscript(s) to be resolved + try { + SvcLogicExpression rhsExpr = SvcLogicExpressionFactory.parse(rhsRoot); + rhsRoot = SvcLogicExpressionResolver.resolveVariableName(rhsExpr, node, ctx); + } catch (Exception e) { + LOG.warn("Caught exception trying to resolve variable name ("+rhsRoot+")", e); + } + + // See if the parameters are reversed (copying service-data to input) .. this + // was done as a workaround to earlier issue + if (curName.endsWith("-input.") && rhsRoot.startsWith("service-data")) { + LOG.warn("Arguments appear to be reversed .. will copy input to service-data instead"); + lhsVarName = rhsRoot + "."; + rhsRoot = curName.substring(0, curName.length()-1); + } + + rhsRoot = rhsRoot + "."; + String lhsPrefix = lhsVarName; + + if (lhsPrefix.endsWith(".")) { + lhsPrefix = lhsPrefix.substring(0, + lhsPrefix.length()-1); + } + int lhsPfxLength = lhsPrefix.length(); + HashMap parmsToAdd = new HashMap(); + + for (String sourceVarName : ctx.getAttributeKeySet()) { + + if (sourceVarName.startsWith(rhsRoot)) { + + String targetVar = lhsPrefix + + "." + + sourceVarName + .substring(rhsRoot.length()); + + LOG.debug("Copying " + sourceVarName + + " value to " + targetVar); + + parmsToAdd.put(targetVar, + ctx.getAttribute(sourceVarName)); + } + } + + for (String newParmName : parmsToAdd.keySet()) { + ctx.setAttribute(newParmName, parmsToAdd.get(newParmName)); + } + + } else { + // If RHS is empty, unset attributes in LHS + String lhsPrefix = lhsVarName.substring(0, + lhsVarName.length() - 1); + int lhsPfxLength = lhsPrefix.length(); + + LinkedList parmsToRemove = new LinkedList (); + + for (String curCtxVarname : ctx.getAttributeKeySet()) { + + if (curCtxVarname.startsWith(lhsPrefix)) { + LOG.debug("Unsetting " + curCtxVarname); + parmsToRemove.add(curCtxVarname); + } + } + + for (String parmName : parmsToRemove) { + ctx.setAttribute(parmName, null); + } + + } + } + + } else { + + if (ifunset) { + String ctxValue = ctx.getAttribute(lhsVarName); + + if ((ctxValue != null) && (ctxValue.length() > 0)) { + setValue = false; + LOG.debug("Attribute " + + lhsVarName + + " already set and only-if-unset is true, so not overriding"); + } + } + + if (setValue) { + String curValue = SvcLogicExpressionResolver.evaluate( + curEnt.getValue(), node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.trace("Parameter value " + + curEnt.getValue().asParsedExpr() + + " resolves to " + curValue); + LOG.debug("Setting context attribute " + lhsVarName + + " to " + curValue); + } + ctx.setAttribute(lhsVarName, curValue); + } + } + } + + return null; + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java new file mode 100644 index 000000000..ae42e2c7e --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java @@ -0,0 +1,225 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.io.File; +import java.io.FileInputStream; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.Map; +import java.util.Properties; + +import org.openecomp.sdnc.sli.ConfigurationException; +import org.openecomp.sdnc.sli.SvcLogicAdaptor; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicStore; +import org.openecomp.sdnc.sli.SvcLogicStoreFactory; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.mysql.jdbc.Driver; + +public class SvcLogicActivator implements BundleActivator { + + private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + put("break", new BreakNodeExecutor()); + + } + }; + + private static LinkedList registrations = new LinkedList(); + + private static HashMap adaptorMap = null; + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicActivator.class); + + private static Properties props = null; + + private static BundleContext bundleCtx = null; + + private static SvcLogicService svcLogicServiceImpl = null; + + @Override + public void start(BundleContext ctx) throws Exception { + + LOG.info("Activating SLI"); + + bundleCtx = ctx; + + // Read properties + props = new Properties(); + String propPath = System.getenv(SVCLOGIC_PROP_VAR); + + if (propPath == null) { + String propDir = System.getenv(SDNC_CONFIG_DIR); + if (propDir == null) { + + propDir = "/opt/sdnc/data/properties"; + } + propPath = propDir + "/svclogic.properties"; + LOG.warn("Environment variable "+SVCLOGIC_PROP_VAR+" unset - defaulting to "+propPath); + } + + File propFile = new File(propPath); + + if (!propFile.exists()) { + + throw new ConfigurationException( + "Missing configuration properties file : " + + propFile); + } + try { + + props.load(new FileInputStream(propFile)); + } catch (Exception e) { + throw new ConfigurationException( + "Could not load properties file " + propPath, e); + + } + + + if (registrations == null) { + + registrations = new LinkedList(); + } + + // Advertise SvcLogicService + svcLogicServiceImpl = new SvcLogicServiceImpl(); + + LOG.info("SLI: Registering service " + SvcLogicService.NAME + + " in bundle " + ctx.getBundle().getSymbolicName()); + ServiceRegistration reg = ctx.registerService(SvcLogicService.NAME, + svcLogicServiceImpl, null); + registrations.add(reg); + + // Initialize SvcLogicStore + try { + SvcLogicStore store = getStore(); + registerNodeTypes(store); + } catch (ConfigurationException e) { + LOG.warn("Could not initialize SvcLogicScore", e); + } + + LOG.info("SLI - done registering services"); + } + + @Override + public void stop(BundleContext ctx) throws Exception { + + if (registrations != null) { + for (ServiceRegistration reg : registrations) { + ServiceReference regRef = reg.getReference(); + /* Don't bother to remove node types from table + String nodeType = (String) regRef.getProperty("nodeType"); + if (nodeType != null) { + LOG.info("SLI - unregistering node type " + nodeType); + store.unregisterNodeType(nodeType); + } + */ + reg.unregister(); + } + registrations = null; + } + } + + public static SvcLogicStore getStore() throws SvcLogicException { + // Create and initialize SvcLogicStore object - used to access + // saved service logic. + + SvcLogicStore store = null; + + try { + Driver dvr = new Driver(); + store = SvcLogicStoreFactory.getSvcLogicStore(props); + } catch (Exception e) { + throw new ConfigurationException( + "Could not get service logic store", e); + + } + + try { + store.init(props); + } catch (Exception e) { + throw new ConfigurationException( + "Could not get service logic store", e); + } + + return(store); + } + + private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException { + + if (store == null) { + return; + } + // Advertise built-in node executors + LOG.info("SLI : Registering built-in node executors"); + Hashtable propTable = new Hashtable(); + + for (String nodeType : BUILTIN_NODES.keySet()) { + LOG.info("SLI - registering node type " + nodeType); + propTable.clear(); + propTable.put("nodeType", nodeType); + + ServiceRegistration reg = bundleCtx.registerService(SvcLogicNodeExecutor.class.getName(), + BUILTIN_NODES.get(nodeType), propTable); + registrations.add(reg); + + store.registerNodeType(nodeType); + + LOG.info("SLI - registering node executor"); + + ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + + } + + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicAdaptorFactory.java new file mode 100644 index 000000000..aa8c005a6 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicAdaptorFactory.java @@ -0,0 +1,86 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.HashMap; + +import org.openecomp.sdnc.sli.SvcLogicAdaptor; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicAdaptorFactory { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicAdaptorFactory.class); + + private static HashMap adaptorMap = new HashMap(); + + public static void registerAdaptor(SvcLogicAdaptor adaptor) { + String name = adaptor.getClass().getName(); + LOG.info("Registering adaptor " + name); + adaptorMap.put(name, adaptor); + + } + + public static void unregisterAdaptor(String name) { + if (adaptorMap.containsKey(name)) { + LOG.info("Unregistering " + name); + adaptorMap.remove(name); + } + } + + public static SvcLogicAdaptor getInstance(String name) { + if (adaptorMap.containsKey(name)) { + return (adaptorMap.get(name)); + } else { + BundleContext bctx = null; + try + { + bctx = FrameworkUtil.getBundle(SvcLogicAdaptorFactory.class) + .getBundleContext(); + } + catch (Exception e) + { + LOG.debug("Caught exception trying to locate device adaptor "+name, e); + return(null); + } + + ServiceReference sref = bctx.getServiceReference(name); + + if (sref != null) { + SvcLogicAdaptor adaptor = (SvcLogicAdaptor) bctx + .getService(sref); + + if (adaptor != null) { + registerAdaptor(adaptor); + + return (adaptor); + } + return (null); + } + } + return(null); + } +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java new file mode 100644 index 000000000..5c17c7997 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java @@ -0,0 +1,605 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.openecomp.sdnc.sli.SvcLogicAtom; +import org.openecomp.sdnc.sli.SvcLogicAtom.AtomType; +import org.openecomp.sdnc.sli.SvcLogicBinaryExpression; +import org.openecomp.sdnc.sli.SvcLogicBinaryExpression.OperatorType; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicFunctionCall; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicVariableTerm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicExpressionResolver { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExpressionResolver.class); + + public static String evaluate(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + if (expr == null) { + return (null); + } + + + + if (expr instanceof SvcLogicAtom) { + SvcLogicAtom atom = (SvcLogicAtom) expr; + + AtomType atomType = atom.getAtomType(); + switch (atomType) { + case NUMBER: + case STRING: + return (atom.toString()); + case CONTEXT_VAR: + case IDENTIFIER: + + String varName = resolveVariableName(atom, node, ctx); + + if (atomType == AtomType.CONTEXT_VAR) + { + LOG.trace("Evaluating context variable $"+varName); + + String varValue = ctx.getAttribute(varName); + + if (varValue == null) { + LOG.trace("Context variable $"+varName+" unset - treating as empty string"); + varValue = ""; + } + + return (varValue); + } + SvcLogicExpression parm = node.getParameter(varName); + if (parm != null) { + LOG.trace("Evaluating value of parameter "+varName+": "+parm.asParsedExpr()); + + return (evaluate(parm, node, ctx)); + } + else + { + return(varName); + } + default: + return(null); + } + + } else if (expr instanceof SvcLogicBinaryExpression) { + SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; + List operators = binExpr.getOperators(); + if (operators.isEmpty()) + { + List operands = binExpr.getOperands(); + if (operands.size() == 1) + { + LOG.trace("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); + return(evaluate(operands.get(0), node, ctx)); + } + else + { + if (operands.isEmpty()) + { + LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); + } + else + { + LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); + } + return(null); + } + } + switch (operators.get(0)) { + case addOp: + case subOp: + case multOp: + case divOp: + return(evalArithExpression(binExpr, node, ctx)); + case equalOp: + case neOp: + case ltOp: + case leOp: + case gtOp: + case geOp: + return (evalCompareExpression(binExpr, node, ctx)); + case andOp: + case orOp: + return(evalLogicExpression(binExpr, node, ctx)); + + default: + return(null); + } + } + else if (expr instanceof SvcLogicFunctionCall) + { + return(evalFunctionCall((SvcLogicFunctionCall)expr, node, ctx)); + } + else + { + throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); + } + } + + private static String evalArithExpression(SvcLogicBinaryExpression binExpr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + List operands = binExpr.getOperands(); + List operators = binExpr.getOperators(); + if (operands.size() != (operators.size()+1)) + { + throw new SvcLogicException("Invalid expression ("+binExpr+")"); + } + String retval = evaluate(operands.get(0), node, ctx); + String retsval = retval; + long retlval = 0; + boolean valueIsLong = false; + + int i = 1; + try + { + + if ((retval.length() > 0) && StringUtils.isNumeric(retval)) + { + retlval = Long.parseLong(retval); + valueIsLong = true; + } + for (OperatorType operator: operators) + { + String curOperandValue = evaluate(operands.get(i++), node, ctx); + switch(operator) { + case addOp: + retsval = retsval + curOperandValue; + if (valueIsLong) + { + if ((curOperandValue.length() > 0) && StringUtils.isNumeric(curOperandValue) ) + { + retlval = retlval + Long.parseLong(curOperandValue); + } + else + { + valueIsLong = false; + } + } + break; + case subOp: + retlval = retlval - Long.parseLong(curOperandValue); + break; + case multOp: + retlval = retlval * Long.parseLong(curOperandValue); + break; + case divOp: + retlval = retlval / Long.parseLong(curOperandValue); + break; + } + + } + } + catch (NumberFormatException e1) + { + throw new SvcLogicException("Illegal value in arithmetic expression", e1); + } + + if (valueIsLong) + { + return("" + retlval); + } + else + { + return(retsval); + } + + } + + + + private static String evalCompareExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + + List operators = expr.getOperators(); + List operands = expr.getOperands(); + + if ((operators.size() != 1) || (operands.size() != 2)) + { + throw new SvcLogicException ("Invalid comparison expression : "+expr); + } + + OperatorType operator = operators.get(0); + String op1Value = evaluate(operands.get(0), node, ctx); + String op2Value = evaluate(operands.get(1), node, ctx); + + if ((StringUtils.isNotEmpty(op1Value) && StringUtils.isNumeric(op1Value) && StringUtils.isNotEmpty(op2Value) && StringUtils.isNumeric(op2Value))) + { + try + { + double op1dbl = Double.parseDouble(op1Value); + double op2dbl = Double.parseDouble(op2Value); + + switch(operator) + { + case equalOp: + return(Boolean.toString(op1dbl == op2dbl)); + case neOp: + return(Boolean.toString(op1dbl != op2dbl)); + case ltOp: + return(Boolean.toString(op1dbl < op2dbl)); + case leOp: + return(Boolean.toString(op1dbl <= op2dbl)); + case gtOp: + return(Boolean.toString(op1dbl > op2dbl)); + case geOp: + return(Boolean.toString(op1dbl >= op2dbl)); + default: + return(null); + } + } + catch (NumberFormatException e) + { + throw new SvcLogicException("Caught exception trying to compare numeric values", e); + } + } + else + { + + int compResult = 0; + + if (op1Value == null) { + compResult = -1; + } else if (op2Value == null ) { + compResult = 1; + } else { + compResult = op1Value.compareToIgnoreCase(op2Value); + } + + switch(operator) + { + case equalOp: + return(Boolean.toString(compResult == 0)); + case neOp: + return(Boolean.toString(compResult != 0)); + case ltOp: + return(Boolean.toString(compResult < 0)); + case leOp: + return(Boolean.toString(compResult <= 0)); + case gtOp: + return(Boolean.toString(compResult > 0)); + case geOp: + return(Boolean.toString(compResult >= 0)); + default: + return(null); + } + } + + } + + private static String evalLogicExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + boolean retval; + + List operands = expr.getOperands(); + List operators = expr.getOperators(); + + if (operands.size() != (operators.size()+1)) + { + throw new SvcLogicException("Invalid expression ("+expr+")"); + } + + try + { + retval = Boolean.parseBoolean(evaluate(operands.get(0), node, ctx)); + int i = 1; + for (OperatorType operator : operators) + { + if (operator == OperatorType.andOp) + { + retval = retval && Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); + } + else + { + + retval = retval || Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); + } + + } + } + catch (Exception e) + { + throw new SvcLogicException("Invalid expression ("+expr+")"); + } + + + return(Boolean.toString(retval)); + } + + private static String evalFunctionCall(SvcLogicFunctionCall func, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + String funcName = func.getFunctionName(); + List operands = func.getOperands(); + + if ("length".equalsIgnoreCase(funcName)) + { + + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + return(""+opValue.length()); + } + else + { + throw new SvcLogicException("Invalid call to length() function"); + } + } + else if ("substr".equalsIgnoreCase(funcName)) + { + if (operands.size() == 3) + { + String op1Value = evaluate(operands.get(0), node, ctx); + String op2Value = evaluate(operands.get(1), node, ctx); + String op3Value = evaluate(operands.get(2), node, ctx); + + if (!StringUtils.isNumeric(op2Value) || !StringUtils.isNumeric(op3Value)) + { + throw new SvcLogicException("Invalid arguments to substr() function"); + } + + try + { + return(op1Value.substring(Integer.parseInt(op2Value), Integer.parseInt(op3Value))); + } + catch (Exception e) + { + throw new SvcLogicException("Caught exception trying to take substring", e); + } + } + else + { + + throw new SvcLogicException("Invalid call to substr() function"); + } + + } + else if ("toUpperCase".equalsIgnoreCase(funcName)) + { + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + if (opValue != null) { + return(opValue.toUpperCase()); + } else { + return(""); + } + } + else + { + throw new SvcLogicException("Invalid call to toUpperCase() function"); + } + } + else if ("toLowerCase".equalsIgnoreCase(funcName)) + { + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + if (opValue != null) { + return(opValue.toLowerCase()); + } else { + return(""); + } + } + else + { + throw new SvcLogicException("Invalid call to toLowerCase() function"); + } + } + else if ("convertBase".equalsIgnoreCase(funcName)) { + int fromBase = 10; + int toBase = 10; + String srcString = ""; + + if (operands.size() == 2) + { + fromBase = 10; + srcString = evaluate(operands.get(0), node, ctx); + toBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); + } else if (operands.size() == 3) { + + srcString = evaluate(operands.get(0), node, ctx); + fromBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); + toBase = Integer.parseInt(evaluate(operands.get(2), node, ctx)); + } else { + throw new SvcLogicException("Invalid call to convertBase() function"); + } + + long srcValue = Long.parseLong(srcString, fromBase); + return(Long.toString(srcValue, toBase)); + } + else + { + throw new SvcLogicException("Unrecognized function ("+funcName+")"); + } + + } + + public static String evaluateAsKey(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + if (expr == null) { + return (null); + } + + + + if (expr instanceof SvcLogicAtom) { + SvcLogicAtom atom = (SvcLogicAtom) expr; + + AtomType atomType = atom.getAtomType(); + StringBuffer varNameBuff = new StringBuffer(); + switch (atomType) { + case NUMBER: + return (atom.toString()); + case STRING: + return("'"+atom.toString()+"'"); + case CONTEXT_VAR: + case IDENTIFIER: + boolean needDot = false; + for (SvcLogicExpression term : atom.getOperands()) + { + if (needDot) + { + varNameBuff.append("."); + } + if (term instanceof SvcLogicVariableTerm) + { + SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; + varNameBuff.append(vterm.getName()); + if (vterm.numOperands() > 0) + { + varNameBuff.append("["); + varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); + varNameBuff.append("]"); + + } + } + else + { + varNameBuff.append(term.toString()); + } + needDot = true; + } + + String varName = varNameBuff.toString(); + LOG.debug("Evaluating context variable $"+varName); + String ctxValue = ctx.getAttribute(varName); + if (ctxValue == null) + { + return(null); + } + if (StringUtils.isNumeric(ctxValue)) + { + return(ctxValue); + } + else + { + return("'"+ctxValue+"'"); + } + + default: + return(null); + } + + } else if (expr instanceof SvcLogicBinaryExpression) { + SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; + List operators = binExpr.getOperators(); + List operands = binExpr.getOperands(); + if (operators.isEmpty()) + { + if (operands.size() == 1) + { + LOG.debug("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); + return(evaluateAsKey(operands.get(0), node, ctx)); + } + else + { + if (operands.isEmpty()) + { + LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); + } + else + { + LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); + } + return(null); + } + } + StringBuffer sbuff = new StringBuffer(); + sbuff.append(evaluateAsKey(operands.get(0), node, ctx)); + int i = 1; + for (OperatorType operator : operators) + { + sbuff.append(" "); + sbuff.append(operator.toString()); + sbuff.append(" "); + sbuff.append(evaluateAsKey(operands.get(i++), node,ctx)); + } + return(sbuff.toString()); + } + else if (expr instanceof SvcLogicFunctionCall) + { + StringBuffer sbuff = new StringBuffer(); + SvcLogicFunctionCall funcCall = (SvcLogicFunctionCall) expr; + sbuff.append(funcCall.getFunctionName()); + sbuff.append("("); + boolean needComma = false; + for (SvcLogicExpression operand : funcCall.getOperands()) + { + if (needComma) + { + sbuff.append(","); + } + else + { + needComma = true; + } + sbuff.append(evaluateAsKey(operand, node, ctx)); + } + sbuff.append(")"); + return(sbuff.toString()); + } + else + { + throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); + } + } + + public static String resolveVariableName(SvcLogicExpression atom, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + StringBuffer varNameBuff = new StringBuffer(); + + boolean needDot = false; + for (SvcLogicExpression term : atom.getOperands()) + { + if (needDot) + { + varNameBuff.append("."); + } + if (term instanceof SvcLogicVariableTerm) + { + SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; + varNameBuff.append(vterm.getName()); + if (vterm.numOperands() > 0) + { + varNameBuff.append("["); + varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); + varNameBuff.append("]"); + } + } + else + { + varNameBuff.append(term.toString()); + } + needDot = true; + } + return(varNameBuff.toString()); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java new file mode 100644 index 000000000..0c8166ae1 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java @@ -0,0 +1,110 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicAdaptor; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicRecorder; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.openecomp.sdnc.sli.SvcLogicStore; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class SvcLogicNodeExecutor { + + public abstract SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class); + + protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + if (node == null) { + return null; + } + + return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"), + node, ctx)); + + } + + protected SvcLogicStore getStore() throws SvcLogicException { + return SvcLogicActivator.getStore(); + } + + protected SvcLogicAdaptor getAdaptor(String adaptorName) { + return SvcLogicAdaptorFactory.getInstance(adaptorName); + } + + protected SvcLogicResource getSvcLogicResource(String plugin) { + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) + .getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(plugin); + if (sref != null) { + SvcLogicResource resourcePlugin = (SvcLogicResource) bctx + .getService(sref); + return resourcePlugin; + } + else { + LOG.warn("Could not find service reference object for plugin " + plugin); + return null; + } + } + + protected SvcLogicRecorder getSvcLogicRecorder(String plugin) { + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) + .getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(plugin); + if (sref != null) { + SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx + .getService(sref); + return resourcePlugin; + } + else { + return null; + } + } + + protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){ + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) + .getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(pluginName); + + if (sref == null) { + LOG.warn("Could not find service reference object for plugin " + pluginName); + return null; + } else { + SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx + .getService(sref); + return plugin; + } + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java new file mode 100644 index 000000000..f30b3fc06 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java @@ -0,0 +1,76 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.Properties; + +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.openecomp.sdnc.sli.SvcLogicException; + +public interface SvcLogicService { + + public static final String NAME = "org.openecomp.sdnc.sli.provider.SvcLogicService"; + + // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException; + /** + * Check for existence of a directed graph + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, looks for active version + * @param mode - mode (sync/async) + * @return true if directed graph found, false otherwise + * @throws SvcLogicException + */ + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; + + /** + * Execute a directed graph + * + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, use active version + * @param mode - mode (sync/async) + * @param parms - parameters, used to set SvcLogicContext attributes + * @return final values of attributes from SvcLogicContext, as Properties + * @throws SvcLogicException + * + * + * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead + */ + @Deprecated + public Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; + + /** + * Execute a directed graph + * + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, use active version + * @param mode - mode (sync/async) + * @param parms - parameters, used to set SvcLogicContext attributes + * @param domDataBroker - DOMDataBroker object + * @return final values of attributes from SvcLogicContext, as Properties + * @throws SvcLogicException + */ + public Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException; + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicServiceImpl.java new file mode 100644 index 000000000..ba929bae7 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicServiceImpl.java @@ -0,0 +1,273 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.HashMap; +import java.util.Properties; + +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.openecomp.sdnc.sli.MetricLogger; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicGraph; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicStore; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTracker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +public class SvcLogicServiceImpl implements SvcLogicService { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicServiceImpl.class); + + private HashMap nodeExecutors = null; + + private BundleContext bctx = null; + + private void registerExecutors() { + + LOG.info("Entered register executors"); + if (bctx == null) { + bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + } + + if (nodeExecutors == null) { + nodeExecutors = new HashMap(); + } + + LOG.info("Opening service tracker"); + ServiceTracker tracker = new ServiceTracker(bctx, + SvcLogicNodeExecutor.class.getName(), null); + + tracker.open(); + + ServiceListener listener = new ServiceListener() { + + public void serviceChanged(ServiceEvent ev) { + ServiceReference sr = ev.getServiceReference(); + switch (ev.getType()) { + case ServiceEvent.REGISTERED: { + registerExecutor(sr); + } + break; + case ServiceEvent.UNREGISTERING: { + unregisterExecutor(sr); + } + break; + } + } + }; + + LOG.info("Adding service listener"); + String filter = "(objectclass=" + SvcLogicNodeExecutor.class.getName() + + ")"; + try { + bctx.addServiceListener(listener, filter); + ServiceReference[] srl = bctx.getServiceReferences( + SvcLogicNodeExecutor.class.getName(), null); + for (int i = 0; srl != null && i < srl.length; i++) { + listener.serviceChanged(new ServiceEvent( + ServiceEvent.REGISTERED, srl[i])); + } + } catch (InvalidSyntaxException e) { + e.printStackTrace(); + } + LOG.info("Done registerExecutors"); + } + + public void registerExecutor(ServiceReference sr) { + + String nodeName = (String) sr.getProperty("nodeType"); + if (nodeName != null) { + + SvcLogicNodeExecutor executor = null; + + try { + executor = (SvcLogicNodeExecutor) bctx.getService(sr); + } catch (Exception e) { + LOG.error("Cannot get service executor for " + nodeName); + return; + } + + registerExecutor(nodeName, executor); + + } + } + + public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) + { + if (nodeExecutors == null) { + nodeExecutors = new HashMap(); + } + LOG.info("SLI - registering executor for node type "+nodeName); + nodeExecutors.put(nodeName, executor); + } + + public void unregisterExecutor(ServiceReference sr) { + String nodeName = (String) sr.getProperty("nodeType"); + + if (nodeName != null) { + + unregisterExecutor(nodeName); + + } + + } + + public void unregisterExecutor(String nodeName) + { + + LOG.info("SLI - unregistering executor for node type "+nodeName); + nodeExecutors.remove(nodeName); + } + + + + + public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) + throws SvcLogicException { + + if (nodeExecutors == null) { + registerExecutors(); + } + + // Set service name in MDC to reference current working directed graph + MDC.put(MetricLogger.SERVICE_NAME, graph.getModule()+":"+graph.getRpc()+"/v"+graph.getVersion()); + + SvcLogicNode curNode = graph.getRootNode(); + LOG.info("About to execute graph " + graph.toString()); + + + + while (curNode != null) { + LOG.info("About to execute node # "+curNode.getNodeId()+" ("+curNode.getNodeType()+")"); + + SvcLogicNode nextNode = executeNode(curNode, ctx); + curNode = nextNode; + } + + return (ctx); + } + + + public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + if (node == null) { + return (null); + } + + if (LOG.isDebugEnabled()) { + LOG.debug("Executing node " + node.getNodeId()); + } + + SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); + + if (executor != null) { + LOG.debug("Executing node executor for node type "+node.getNodeType()+" - "+executor.getClass().getName()); + return (executor.execute(this, node, ctx)); + } else { + if (LOG.isDebugEnabled()) { + LOG.debug(node.getNodeType() + " node not implemented"); + } + SvcLogicNode nextNode = node.getOutcomeValue("failure"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute failure branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no failure or Other branch found"); + } + } + return (nextNode); + } + + } + + @Override + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException + { + SvcLogicStore store = SvcLogicActivator.getStore(); + + return (store.hasGraph(module, rpc, version, mode)); + } + + @Override + public Properties execute(String module, String rpc, String version, String mode, Properties props) + throws SvcLogicException { + return(execute(module, rpc, version, mode, props, null)); + } + + + @Override + public Properties execute(String module, String rpc, String version, String mode, + Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { + + + // See if there is a service logic defined + // + SvcLogicStore store = SvcLogicActivator.getStore(); + + LOG.info("Fetching service logic from data store"); + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + + + + if (graph == null) + { + Properties retProps = new Properties(); + retProps.setProperty("error-code", "401"); + retProps.setProperty("error-message", "No service logic found for ["+module+","+rpc+","+version+","+mode+"]"); + return(retProps); + + } + + SvcLogicContext ctx = new SvcLogicContext(props); + ctx.setAttribute("currentGraph", graph.toString()); + ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); + ctx.setDomDataBroker(domDataBroker); + + execute(graph, ctx); + + return(ctx.toProperties()); + } + + + + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java new file mode 100644 index 000000000..e8ae7c89d --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java @@ -0,0 +1,63 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SwitchNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(SwitchNodeExecutor.class); + + @Override + + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + + String testResult = evaluateNodeTest(node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.debug("Executing switch node"); + + + LOG.debug("test expression (" + node.getAttribute("test") + + ") evaluates to " + testResult); + } + + SvcLogicNode nextNode = node.getOutcomeValue(testResult); + + if (LOG.isDebugEnabled()) { + if (nextNode != null) { + LOG.debug("Next node to execute is node " + nextNode.getNodeId()); + } else { + LOG.debug("No next node found"); + } + } + return (nextNode); + + } +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java new file mode 100644 index 000000000..9eeab65a3 --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java @@ -0,0 +1,136 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UpdateNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(UpdateNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate( + curExpr, node, ctx); + + LOG.debug("Parameter " + curName + " = " + + curExpr.asParsedExpr() + " resolves to " + + curExprValue); + + parmMap.put(curName, curExprValue); + } + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + + plugin); + } + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.update(resourceType, key, + parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java new file mode 100644 index 000000000..5bbab323b --- /dev/null +++ b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java @@ -0,0 +1,75 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.BreakNodeException; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WhileNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + + String testResult = evaluateNodeTest(node, ctx); + SvcLogicExpression silentFailureExpr = node.getAttribute("do"); + String doWhile = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); + if ("true".equals(doWhile)) { + LOG.debug("While loop will execute once regardless of expression because do is set to true"); + } + + try { + while ("true".equals(testResult) || "true".equals(doWhile)) { + if (!"true".equals(doWhile)) { + LOG.debug("Test expression (" + node.getAttribute("test") + ") evaluates to true, executing loop."); + } + int numOutcomes = node.getNumOutcomes() + 1; + for (int i = 0; i < numOutcomes; i++) { + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + while (nextNode != null) { + nextNode = svc.executeNode(nextNode, ctx); + } + } else { + if ("true".equals(doWhile)) { + LOG.debug("Do executed, will only execute again if test expression is true."); + doWhile = "false"; + } + testResult = evaluateNodeTest(node, ctx); + LOG.debug("test expression (" + node.getAttribute("test") + ") evaluates to " + testResult); + } + } + } + LOG.debug("testResult was " + testResult + " which is not equal to true, exiting while loop."); + } catch (BreakNodeException e) { + LOG.debug("WhileNodeExecutor caught break"); + } + return (null); + } + +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java new file mode 100644 index 000000000..d1ab4cfdd --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java @@ -0,0 +1,56 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.Map; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + + +public class BadPlugin implements SvcLogicJavaPlugin { + public String selectLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + String day = parameters.get("day"); + if (day == null || day.length() < 1) { + throw new SvcLogicException("What day is it?"); + } + switch (day) { + case ("monday"): { + return "pizza"; + } + case ("tuesday"): { + return "soup"; + } + case ("wednesday"): { + return "salad"; + } + case ("thursday"): { + return "sushi"; + } + case ("friday"): { + return "bbq"; + } + } + throw new SvcLogicException("Lunch cannot be served"); + } +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java new file mode 100644 index 000000000..3d43ee11d --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java @@ -0,0 +1,57 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.Map.Entry; + +import org.openecomp.sdnc.sli.DuplicateValueException; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicGraph; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; +import org.openecomp.sdnc.sli.SvcLogicNode; + +import junit.framework.TestCase; + +public class ExecuteNodeExecutorTest extends TestCase { + public class MockExecuteNodeExecutor extends ExecuteNodeExecutor { + + protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { + return (SvcLogicJavaPlugin) new LunchSelectorPlugin(); + } + + protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + return "selectLunch"; + } + } + + public void testBadPlugin() throws DuplicateValueException, SvcLogicException { + LunchSelectorPlugin p = new LunchSelectorPlugin(); + MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor(); + SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph()); + node.setAttribute("method", "selectLunch"); + execute.execute(new SvcLogicServiceImpl(), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); + } + +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java new file mode 100644 index 000000000..b9156bcdc --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java @@ -0,0 +1,78 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.Map; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + + + +public class LunchSelectorPlugin implements SvcLogicJavaPlugin { + public class UnknownLunchDayException extends Exception{ + + public UnknownLunchDayException(String string) { + super(string); + } + + } + class Sandwhich { + String meat; + String cheese; + + public Sandwhich(String meat, String cheese) { + this.meat = meat; + this.cheese = cheese; + } + } + + public String selectLunch(Map parameters, SvcLogicContext ctx) throws Exception { + String day = parameters.get("day"); + if (day == null || day.length() < 1) { + throw new UnknownLunchDayException("What day is it?"); + } + switch (day) { + case ("monday"): { + return "pizza"; + } + case ("tuesday"): { + return "soup"; + } + case ("wednesday"): { + return "salad"; + } + case ("thursday"): { + return "sushi"; + } + case ("friday"): { + return "bbq"; + } + } + throw new SvcLogicException("Lunch cannot be served"); + } + + public Sandwhich makeLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + return new Sandwhich("ham", "american"); + } +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java new file mode 100644 index 000000000..a4e41bbad --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java @@ -0,0 +1,43 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import junit.framework.TestCase; + +public class MdsalHelperTest extends TestCase { + + public static final String pathToSdnPropertiesFile = "./src/test/resources/l3sdn.properties"; + + public void testSdnProperties() { + MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile); + assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); + assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); + assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete")); + assertEquals("service-configuration-operation", MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", + "ServiceConfigurationOperation")); + } + + public void testNegativeSdnProperties() { + assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); + } + +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java new file mode 100644 index 000000000..01e333f6e --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java @@ -0,0 +1,37 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import org.openecomp.sdnc.sli.provider.MdsalHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MdsalHelperTesterUtil extends MdsalHelper { + + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTesterUtil.class); + + //Normally static init of classes goes here for some weird classloader thing + static { + String str = "Hello World!"; + } + +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java new file mode 100644 index 000000000..035cd3e79 --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java @@ -0,0 +1,106 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicGraph; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; +import org.openecomp.sdnc.sli.SvcLogicNode; + +import junit.framework.TestCase; + +public class PluginTest extends TestCase { + + // The existing plugins work just like a VoidDummyPlugin + // They will return null simply because they are all void + // The attribute emitsOutcome will not be present, the expected outcome is success when no exception is thrown by the plugin + public void testOldPlugin() throws Exception { + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new VoidDummyPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("dummy", Map.class, SvcLogicContext.class); + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("success",outValue); + } + + //Newer plugins can set the attribute emitsOutcome to true, if so they should return a string + //The string represents the outcome value + public void testNewPlugin() throws Exception { + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("selectLunch", Map.class, SvcLogicContext.class); + + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + + parmMap.put("day", "monday"); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + node.setAttribute("emitsOutcome", "true"); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("pizza", outValue); + + parmMap.put("day", "tuesday"); + outValue = (String) pluginMethod.invoke(plugin, parmMap, ctx); + o = pluginMethod.invoke(plugin, parmMap, ctx); + outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("soup",outValue); + + } + + //APPC had some legacy plugins returning objects which should not be treated as outcomes + //The attribute emitsOutcome will not be set + //The outcome should be success as it has always been + public void testObjPlugin() throws Exception{ + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("makeLunch", Map.class, SvcLogicContext.class); + + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("success",outValue); + } + +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java new file mode 100644 index 000000000..618154883 --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java @@ -0,0 +1,123 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicExprListener; +import org.openecomp.sdnc.sli.SvcLogicExpression; +import org.openecomp.sdnc.sli.SvcLogicExpressionFactory; +import org.openecomp.sdnc.sli.SvcLogicGraph; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.provider.SvcLogicExpressionResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.Assert; +import junit.framework.TestCase; + +public class SvcLogicExpressionResolverTest extends TestCase { + + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExpressionResolver.class); + + public void testEvaluate() + { + InputStream testStr = getClass().getResourceAsStream("/expression.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + try + { + SvcLogicContext ctx = new SvcLogicContext(); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + graph.setRootNode(node); + + String line = null; + int lineNo = 0; + while ((line = testsReader.readLine()) != null) { + ++lineNo; + if (line.startsWith("#")) + { + String testExpr = line.trim().substring(1).trim(); + String[] nameValue = testExpr.split("="); + String name = nameValue[0].trim(); + String value = nameValue[1].trim(); + + if (name.startsWith("$")) + { + LOG.info("Setting context attribute "+name+" = "+value); + ctx.setAttribute(name.substring(1), value); + } + else + { + + LOG.info("Setting node attribute "+name+" = "+value); + node.setAttribute(name, value); + + } + } + else + { + // if the line contains #, what comes before is the expression to evaluate, and what comes after + // is the expected value + String[] substrings = line.split("#"); + String expectedValue = substrings.length > 1 ? substrings[1].trim() : null; + String testExpr = substrings[0].trim(); + + LOG.info("Parsing expression "+testExpr); + SvcLogicExpression expr = SvcLogicExpressionFactory.parse(testExpr); + if (expr == null) + { + fail("Unable to parse expression "+testExpr); + } + else + { + LOG.info("Evaluating parsed expression "+expr.asParsedExpr()); + String exprValue = SvcLogicExpressionResolver.evaluate(expr, node, ctx); + if (exprValue == null) + { + fail("Unable to evaluate expression "+testExpr); + } + else + { + LOG.info("Expression " + testExpr + " evaluates to " + exprValue); + if (expectedValue != null) { + Assert.assertEquals("Line " + lineNo + ": " + testExpr, expectedValue, exprValue); + } + } + } + } + } + } + catch (Exception e) + { + LOG.error("Caught exception", e); + fail("Caught exception"); + } + } + +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java new file mode 100644 index 000000000..2e8b35e12 --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java @@ -0,0 +1,212 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Properties; + +import org.openecomp.sdnc.sli.MetricLogger; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicGraph; +import org.openecomp.sdnc.sli.SvcLogicNode; +import org.openecomp.sdnc.sli.SvcLogicParser; +import org.openecomp.sdnc.sli.SvcLogicStore; +import org.openecomp.sdnc.sli.SvcLogicStoreFactory; +import org.openecomp.sdnc.sli.provider.BlockNodeExecutor; +import org.openecomp.sdnc.sli.provider.CallNodeExecutor; +import org.openecomp.sdnc.sli.provider.ConfigureNodeExecutor; +import org.openecomp.sdnc.sli.provider.DeleteNodeExecutor; +import org.openecomp.sdnc.sli.provider.ExecuteNodeExecutor; +import org.openecomp.sdnc.sli.provider.ExistsNodeExecutor; +import org.openecomp.sdnc.sli.provider.ForNodeExecutor; +import org.openecomp.sdnc.sli.provider.GetResourceNodeExecutor; +import org.openecomp.sdnc.sli.provider.IsAvailableNodeExecutor; +import org.openecomp.sdnc.sli.provider.NotifyNodeExecutor; +import org.openecomp.sdnc.sli.provider.RecordNodeExecutor; +import org.openecomp.sdnc.sli.provider.ReleaseNodeExecutor; +import org.openecomp.sdnc.sli.provider.ReserveNodeExecutor; +import org.openecomp.sdnc.sli.provider.ReturnNodeExecutor; +import org.openecomp.sdnc.sli.provider.SaveNodeExecutor; +import org.openecomp.sdnc.sli.provider.SetNodeExecutor; +import org.openecomp.sdnc.sli.provider.SvcLogicNodeExecutor; +import org.openecomp.sdnc.sli.provider.SvcLogicServiceImpl; +import org.openecomp.sdnc.sli.provider.SwitchNodeExecutor; +import org.openecomp.sdnc.sli.provider.UpdateNodeExecutor; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.TestCase; + +public class SvcLogicGraphExecutorTest extends TestCase { + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicGraph.class); + + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + + } + }; + + public void testExecute() { + + try { + InputStream testStr = getClass().getResourceAsStream("/executor.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + + assertNotNull(store); + + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + SvcLogicParser parser = new SvcLogicParser(store); + + // Loop through executor tests + + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); + + for (String nodeType : BUILTIN_NODES.keySet()) { + + LOG.info("SLI - registering node executor for node type "+nodeType); + + svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + + } + String testCaseLine = null; + while ((testCaseLine = testsReader.readLine()) != null) { + + String[] testCaseFields = testCaseLine.split(":"); + String testCaseFile = testCaseFields[0]; + String testCaseMethod = testCaseFields[1]; + String testCaseParameters = null; + + if (testCaseFields.length > 2) { + testCaseParameters = testCaseFields[2]; + } + + SvcLogicContext ctx = new SvcLogicContext(); + if (testCaseParameters != null) { + String[] testCaseParameterSettings = testCaseParameters.split(","); + + for (int i = 0 ; i < testCaseParameterSettings.length ; i++) { + String[] nameValue = testCaseParameterSettings[i].split("="); + if (nameValue != null) { + String name = nameValue[0]; + String value = ""; + if (nameValue.length > 1) { + value = nameValue[1]; + } + + ctx.setAttribute(name, value); + } + } + } + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) { + if (!testCaseFile.startsWith("/")) { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) { + fail("Could not resolve test case file "+testCaseFile); + } + + LinkedList graphs = parser.parse(testCaseUrl.getPath()); + + + assertNotNull(graphs); + + for (SvcLogicGraph graph: graphs) { + if (graph.getRpc().equals(testCaseMethod)) { + Properties props = ctx.toProperties(); + LOG.info("SvcLogicContext before executing "+testCaseMethod+":"); + for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements() ; ) { + String propName = (String) e1.nextElement(); + LOG.info(propName+" = "+props.getProperty(propName)); + } + + svc.execute(graph, ctx); + + props = ctx.toProperties(); + LOG.info("SvcLogicContext after executing "+testCaseMethod+":"); + for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements() ; ) { + String propName = (String) e2.nextElement(); + LOG.info(propName+" = "+props.getProperty(propName)); + } + } + } + + } + + + } + + + } catch (Exception e) { + LOG.error("Caught exception executing directed graphs", e); + fail("Exception executing graphs"); + } + } + + +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java new file mode 100644 index 000000000..6c8214ab7 --- /dev/null +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java @@ -0,0 +1,38 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.provider; + +import java.util.Map; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + + + +public class VoidDummyPlugin implements SvcLogicJavaPlugin { + + public void dummy(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + return; + } + +} diff --git a/sli/provider/src/test/resources/executor.tests b/sli/provider/src/test/resources/executor.tests new file mode 100755 index 000000000..e7547e633 --- /dev/null +++ b/sli/provider/src/test/resources/executor.tests @@ -0,0 +1,2 @@ +l3sdn_logic_v10.xml:switchTester:test-value="" +l3sdn_logic_v10.xml:switchTester:test-value="hi" \ No newline at end of file diff --git a/sli/provider/src/test/resources/expression.tests b/sli/provider/src/test/resources/expression.tests new file mode 100755 index 000000000..848a0e7a4 --- /dev/null +++ b/sli/provider/src/test/resources/expression.tests @@ -0,0 +1,24 @@ +# $uni-circuit-id = abc123 +# $uni-cir-units = 10 +# value = 1 +# $arg1 = 2 +# $network.name = vCE0001.in +# $network.segment[0].provider-segmentation-id = 1212 +# $network.segment[1].provider-segmentation-id = 1213 +# $availability-zone = mtsnj-esx-az01 +length($uni-circuit-id) > 0 # true +$uni-cir-units * 1000 * 100 / 100 # 10000 +$uni-cir-units / 1000 # 0 +$uni-cir-units - 100 # -90 +$uni-cir-units + 100 # 110 +(value * 3 - $arg1 > 0) and (length($uni-circuit-id) == 0) # true +'pg-'+$network.name # pg-vCE0001.in +$network.segment[0].provider-segmentation-id # 1212 +toUpperCase($network.name) # VCE0001.IN +toLowerCase($network.name) # vce0001.in +toUpperCase(substr($availability-zone, 0, 5)) # MTSNJ +convertBase(1234, 10) # 1234 +convertBase(10, 16, 10) # 16 +convertBase(ZZ, 36, 10) # 1295 +convertBase(10, 10, 36) # a +(0 - 1) * $arg1 # -1 diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml new file mode 100644 index 000000000..d81b8b789 --- /dev/null +++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/provider/src/test/resources/simplelogger.properties b/sli/provider/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..3581395a4 --- /dev/null +++ b/sli/provider/src/test/resources/simplelogger.properties @@ -0,0 +1,22 @@ +### +# ============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========================================================= +### + +org.slf4j.simpleLogger.defaultLogLevel=info diff --git a/sli/provider/src/test/resources/svclogic.properties b/sli/provider/src/test/resources/svclogic.properties new file mode 100644 index 000000000..fa33146e5 --- /dev/null +++ b/sli/provider/src/test/resources/svclogic.properties @@ -0,0 +1,26 @@ +### +# ============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========================================================= +### + +org.openecomp.sdnc.sli.dbtype = jdbc +org.openecomp.sdnc.sli.jdbc.url = jdbc:mysql://localhost:3306/sdnctl +org.openecomp.sdnc.sli.jdbc.database = sdnctl +org.openecomp.sdnc.sli.jdbc.user = sdnctl +org.openecomp.sdnc.sli.jdbc.password = gamma diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml new file mode 100755 index 000000000..4fb4a797b --- /dev/null +++ b/sli/recording/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + org.openecomp.sdnc.core + sli + 0.0.1-SNAPSHOT + + sli-recording + bundle + SLI - Recording + + UTF-8 + + + + junit + junit + 3.8.1 + test + + + org.openecomp.sdnc.core + sli-common + ${project.version} + compile + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + + commons-lang + commons-lang + 2.6 + compile + + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.openecomp.sdnc.sli.recording.RecordingActivator + org.openecomp.sdnc.sli.recording;version=${project.version} + * + true + + + + + + + + + + + SLI Recording is an OSGi bundle that implements recording service for the service logic record node. + diff --git a/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/FileRecorder.java b/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/FileRecorder.java new file mode 100644 index 000000000..dc857b255 --- /dev/null +++ b/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/FileRecorder.java @@ -0,0 +1,117 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.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.openecomp.sdnc.sli.ConfigurationException; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.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); + PrintWriter recPrinter = null; + 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 + { + + recPrinter = new PrintWriter(new FileWriter(recordFile, true)); + recPrinter.println(record); + } + catch (Exception e) + { + throw new SvcLogicException("Cannot write record to file", e); + } + finally + { + if (recPrinter != null) + { + recPrinter.close(); + } + } + + + } + +} + diff --git a/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/RecordingActivator.java b/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/RecordingActivator.java new file mode 100644 index 000000000..d6e016afc --- /dev/null +++ b/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/RecordingActivator.java @@ -0,0 +1,75 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.recording; + +import java.util.LinkedList; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class RecordingActivator implements BundleActivator { + + private LinkedList registrations = new LinkedList(); + + private static final Logger LOG = LoggerFactory + .getLogger(RecordingActivator.class); + + @Override + public void start(BundleContext ctx) throws Exception { + + if (registrations == null) + { + registrations = new LinkedList(); + } + + + FileRecorder fileRecorder = new FileRecorder(); + String regName = fileRecorder.getClass().getName(); + LOG.debug("Registering FileRecorder service "+regName); + ServiceRegistration reg =ctx.registerService(regName, fileRecorder, null); + registrations.add(reg); + + Slf4jRecorder slf4jRecorder = new Slf4jRecorder(); + regName = slf4jRecorder.getClass().getName(); + LOG.debug("Registering Slf4jRecorder service "+regName); + reg =ctx.registerService(regName, slf4jRecorder, null); + registrations.add(reg); + + } + + @Override + public void stop(BundleContext arg0) throws Exception { + if (registrations != null) { + for (ServiceRegistration reg : registrations) { + ServiceReference regRef = reg.getReference(); + reg.unregister(); + } + registrations = null; + } + } + +} diff --git a/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/Slf4jRecorder.java b/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/Slf4jRecorder.java new file mode 100644 index 000000000..5aad6f25a --- /dev/null +++ b/sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/Slf4jRecorder.java @@ -0,0 +1,130 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.recording; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.TimeZone; + +import org.openecomp.sdnc.sli.ConfigurationException; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.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/svclogic.properties b/sli/recording/src/main/resources/svclogic.properties new file mode 100644 index 000000000..0cf3b419d --- /dev/null +++ b/sli/recording/src/main/resources/svclogic.properties @@ -0,0 +1,26 @@ +### +# ============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========================================================= +### + +org.openecomp.sdnc.sli.dbtype = jdbc +org.openecomp.sdnc.sli.jdbc.url = jdbc:mysql://dbhost:3306/sdnctl +org.openecomp.sdnc.sli.jdbc.database = sdnctl +org.openecomp.sdnc.sli.jdbc.user = sdnctl +org.openecomp.sdnc.sli.jdbc.password = gamma diff --git a/sliPluginUtils/.gitignore b/sliPluginUtils/.gitignore new file mode 100755 index 000000000..b73caf31e --- /dev/null +++ b/sliPluginUtils/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/sliPluginUtils/.sonar/checkstyle.xml b/sliPluginUtils/.sonar/checkstyle.xml new file mode 100755 index 000000000..3fa231535 --- /dev/null +++ b/sliPluginUtils/.sonar/checkstyle.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sliPluginUtils/.sonar/pmd.xml b/sliPluginUtils/.sonar/pmd.xml new file mode 100755 index 000000000..80343b3bd --- /dev/null +++ b/sliPluginUtils/.sonar/pmd.xml @@ -0,0 +1,67 @@ + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 2 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 5 + + + 2 + + + 3 + + + 3 + + + diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml new file mode 100755 index 000000000..9d189177e --- /dev/null +++ b/sliPluginUtils/features/pom.xml @@ -0,0 +1,127 @@ + + + + sliPluginUtils-features + jar + 4.0.0 + + + sliPluginUtils + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + + SliPluginUtils Plugin - Features + + + + org.openecomp.sdnc.core + sliPluginUtils-provider + ${project.version} + + + commons-lang + commons-lang + 2.6 + compile + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + runtime + + + + org.opendaylight.odlparent + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/sliPluginUtils/features/src/main/resources/features.xml b/sliPluginUtils/features/src/main/resources/features.xml new file mode 100644 index 000000000..c7dca2e5a --- /dev/null +++ b/sliPluginUtils/features/src/main/resources/features.xml @@ -0,0 +1,39 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + + odl-mdsal-broker + sdnc-sli + mvn:org.openecomp.sdnc.core/sliPluginUtils-provider/${project.version} + mvn:mysql/mysql-connector-java/${mysql.connector.version} + + + diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml new file mode 100755 index 000000000..6520867bf --- /dev/null +++ b/sliPluginUtils/installer/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + + sliPluginUtils + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + sliPluginUtils-installer + SLI Plugin Utilities - Karaf Installer + pom + + + sdnc-sliPluginUtils + sdnc-sliPluginUtils + mvn:org.openecomp.sdnc.core/sliPluginUtils-features/${project.version}/xml/features + false + + + + + + org.openecomp.sdnc.core + sliPluginUtils-features + ${project.version} + features + xml + + + * + * + + + + + + org.openecomp.sdnc.core + sliPluginUtils-provider + ${project.version} + + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.openecomp.sdnc + sli-common,sli-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/sliPluginUtils/installer/src/assembly/assemble_installer_zip.xml b/sliPluginUtils/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..85e2e1e8f --- /dev/null +++ b/sliPluginUtils/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + bin + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml b/sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..bf7805f70 --- /dev/null +++ b/sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + bin + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh b/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..93236c5be --- /dev/null +++ b/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +### +# ============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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml new file mode 100755 index 000000000..a14b41ff8 --- /dev/null +++ b/sliPluginUtils/pom.xml @@ -0,0 +1,41 @@ + + + + org.openecomp.sdnc.core + sliPluginUtils + 0.0.1-SNAPSHOT + pom + 4.0.0 + + + + org.openecomp.sdnc.core + sdnc-core + 0.0.1-SNAPSHOT + + Service Logic Interface Plugin Utilities + A package of static utility functions to be used when developing SLI plugins + + + + + org.openecomp.sdnc.core + SliPluginUtils-features + features + xml + ${project.version} + + + org.openecomp.sdnc.core + SliPluginUtils-provider + ${project.version} + + + + + + provider + features + installer + + diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml new file mode 100755 index 000000000..cad7a0bcc --- /dev/null +++ b/sliPluginUtils/provider/pom.xml @@ -0,0 +1,85 @@ + + + + sliPluginUtils-provider + bundle + 4.0.0 + + + org.openecomp.sdnc.core + sliPluginUtils + 0.0.1-SNAPSHOT + + + SliPluginUtils Plugin - Provider + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 4.11 + test + + + org.openecomp.sdnc.core + sli-common + ${project.version} + compile + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.apache.commons + commons-lang3 + 3.1 + + + org.hamcrest + hamcrest-library + 1.3 + test + + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.openecomp.sdnc.sli.SliPluginUtils + org.openecomp.sdnc.sli.SliPluginUtils.SliPluginUtilsActivator + org.openecomp.sdnc.sli.SliPluginUtils + org.openecomp.sdnc.*,org.osgi.framework.*,org.slf4j.*,java.net.* + *;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mysql-connector-java|slf4j-api|jcl-over-slf4j + true + + + + + + + + diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/DME2.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/DME2.java new file mode 100644 index 000000000..39612716e --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/DME2.java @@ -0,0 +1,111 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import java.util.Map; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + + +/** + * A SvcLogicJavaPlugin that generates DME2 proxy urls using parameters from context memory. + */ +public class DME2 implements SvcLogicJavaPlugin { + String aafUserName; + String aafPassword; + String envContext; + String routeOffer; + String[] proxyUrls; + Integer index; + String commonServiceVersion; + String partner; + + private static final Logger LOG = LoggerFactory.getLogger(DME2.class); + + public void setPartner(String partner) { + if (partner != null && partner.length() > 0) { + this.partner = partner; + } + } + + public DME2(String aafUserName, String aafPassword, String envContext, String routeOffer, String[] proxyUrls, String commonServiceVersion) { + this.aafUserName = aafUserName; + this.aafPassword = aafPassword; + this.envContext = envContext; + this.routeOffer = routeOffer; + this.proxyUrls = proxyUrls; + this.index = 0; + this.commonServiceVersion = commonServiceVersion; + } + + // constructs a URL to contact the proxy which contacts a DME2 service + public String constructUrl(String service, String version, String subContext) { + StringBuilder sb = new StringBuilder(); + + // The hostname is assigned in a round robin fashion + sb.append(acquireHostName()); + sb.append("/service=" + service); + + //If the directedGraph passes an explicit version use that, if not use the commonServiceVersion found in the properties file + if (version == null) { + version = this.commonServiceVersion; + } + sb.append("/version=" + version); + + sb.append("/envContext=" + this.envContext); + if (this.routeOffer != null && this.routeOffer.length() > 0) { + sb.append("/routeOffer=" + this.routeOffer); + } + if (subContext != null && subContext.length() > 0) { + sb.append("/subContext=" + subContext); + } + sb.append("?dme2.password=" + this.aafPassword); + sb.append("&dme2.username=" + this.aafUserName); + if (this.partner != null) { + sb.append("&dme2.partner=" + this.partner); + } + sb.append("&dme2.allowhttpcode=true"); + return (sb.toString()); + } + + public synchronized String acquireHostName() { + String retVal = proxyUrls[index]; + index++; + if (index == this.proxyUrls.length) { + index = 0; + } + return retVal; + } + + // Node entry point + public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] { "service", "outputPath" }, LOG); + String completeProxyUrl = constructUrl(parameters.get("service"), parameters.get("version"), parameters.get("subContext")); + ctx.setAttribute(parameters.get("outputPath"), completeProxyUrl); + } + +} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils.java new file mode 100644 index 000000000..c73315f4f --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils.java @@ -0,0 +1,754 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; +import java.util.Set; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A utility class used to streamline the interface between Java plugins, + * the Service Logic Context, and Directed Graphs. + * @version 7.0.1 + * @see org.openecomp.sdnc.sli.SvcLogicContext + */ +public class SliPluginUtils implements SvcLogicJavaPlugin { + public enum LogLevel { + TRACE, DEBUG, INFO, WARN, ERROR; + } + + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils.class); + + + // ========== CONSTRUCTORS ========== + + public SliPluginUtils() {} + + public SliPluginUtils( Properties props ) {} + + + + // ========== CONTEXT MEMORY FUNCTIONS ========== + + /** + * Removes 1 or more elements from a list in context memory. + *

+ * Values are removed based on either the index in the list, a key-value + * pair, or a list of key-value pairs that all must match in the element. + * @param parameters + * @param ctx Reference to context memory + * @throws SvcLogicException All exceptions are wrapped in + * SvcLogicException for compatibility with SLI. + * @since 7.0.1 + */ + public void ctxListRemove( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + try{ + LOG.debug( "ENTERING Execute Node \"ctxListRemove\"" ); + + // Validate, Log, & read parameters + checkParameters(parameters, new String[]{"list_pfx"}, LOG); + logExecuteNodeParameters(parameters, LOG, LogLevel.DEBUG); + String list_pfx = parameters.get("list_pfx"); + String param_index = parameters.get("index"); + String param_key = parameters.get("key"); + String param_value = parameters.get("value"); + String param_keys_length = parameters.get("keys_length"); + + // Initialize context memory list mimic + SvcLogicContextList list; + + // Process based on input parameters: + // index: remove object at specific index + // key & value: remove all objects with key-value pair + // keys_length: remove all objects that match all key-value pairs + // in list + if( param_index != null ) { + // Parse index + LOG.trace("executing remove by index logic"); + int index; + try { + index = Integer.parseInt(param_index); + } + catch( NumberFormatException e ) { + throw new IllegalArgumentException("\"index\" parameter is not a number. index = " + param_index, e); + } + + // Extract list from context memory & remove object @ index + LOG.trace("extracting list from context memory"); + list = SvcLogicContextList.extract(ctx, list_pfx); + LOG.trace("removing elements from list"); + list.remove(index); + } + else if( param_value != null ) { + if( param_key == null ) { param_key = ""; } + + // Extract list from context memory & remove objects with + // key-value pair + LOG.trace("executing remove by key-value pair logic"); + LOG.trace("extracting list from context memory"); + list = SvcLogicContextList.extract(ctx, list_pfx); + LOG.trace("removing elements from list"); + list.remove( param_key, param_value ); + } + else if( param_keys_length != null ) { + // Parse keys_length + LOG.trace("executing remove by key-value pair list logic"); + int keys_length; + try { + keys_length = Integer.parseInt(param_keys_length); + } + catch( NumberFormatException e ) { + throw new IllegalArgumentException("\"keys_length\" parameters is not a number. keys_length = " + param_keys_length, e); + } + + // Obtain key-value pairs to check from parameters + LOG.trace("reading keys parameter list"); + HashMap keys_values = new HashMap(); + for( int i = 0; i < keys_length; i++ ) { + keys_values.put(parameters.get("keys[" + i + "].key"), parameters.get("keys[" + i + "].value")); + } + + // Extract list from context memory & remove objects with all + // key-value pairs matching + LOG.trace("extracting list from context memory"); + list = SvcLogicContextList.extract(ctx, list_pfx); + LOG.trace("removing elements from list"); + list.remove(keys_values); + } + else { + throw new IllegalArgumentException("Required parameters missing. Requires one of: index, key & value, or keys_length array"); + } + + // Remove index from list + LOG.trace("writing list back into context memory"); + list.writeToContext(ctx); + } + catch( Exception e ) { + throw new SvcLogicException( "An error occurred in the ctxListRemove Execute node", e ); + } + finally { + LOG.debug( "EXITING Execute Node \"ctxListRemove\"" ); + } + } + + /** + * ctxSortList + * @param parameters - the set of required parameters must contain list and delimiter. + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public void ctxSortList( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + checkParameters(parameters, new String[]{"list","delimiter"}, LOG); + ArrayList list = new ArrayList(); + + String[] sort_fields = null; + if( parameters.containsKey("sort-fields") ) { + sort_fields = parameters.get("sort-fields").split(parameters.get("delimiter"), 0); + } + + String ctx_list_str = parameters.get("list"); + int listSz = getArrayLength(ctx, ctx_list_str); + + + + for( int i = 0; i < listSz; i++ ) { + list.add( new SortableCtxListElement(ctx, ctx_list_str + '[' + i + ']', sort_fields) ); + } + Collections.sort(list); + + ctxBulkErase(ctx, ctx_list_str); + int i = 0; + for( SortableCtxListElement list_element : list ) { + for( Map.Entry entry : list_element.child_elements.entrySet() ) { + if( sort_fields == null ) { + ctx.setAttribute(ctx_list_str + '[' + i + ']', entry.getValue()); + } + else { + ctx.setAttribute(ctx_list_str + '[' + i + "]." + entry.getKey(), entry.getValue()); + } + } + i++; + } + // Reset list length (removed by ctxBulkErase above) + ctx.setAttribute(ctx_list_str+"_length", ""+listSz); + } + + /** + * generates a UUID and writes it to context memory + * @param parameters - ctx-destination is a required parameter + * @param ctx Reference to context memory + * @throws SvcLogicException thrown if a UUID cannot be generated or if ctx-destination is missing or null + */ + public void generateUUID( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + checkParameters(parameters, new String[]{"ctx-destination"}, LOG); + ctx.setAttribute(parameters.get("ctx-destination"), UUID.randomUUID().toString() ); + } + + /** + * Provides substring functionality to Directed Graphs. + *

+ * Calls either String.substring(String beginIndex) or + * String.substring(String beginInded, String endIndex) if the end-index + * is present or not. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
stringMandatoryString to perform substring on
resultMandatoryKey in context memory to populate the resulting string in
begin-indexMandatoryBeginning index to pass to Java substring function
end-indexOptionalEnding index to pass to Java substring function. If not included, String.substring(begin) will be called.
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 8.0.1 + * @see SliPluginUtils#substring(Map, SvcLogicContext) + */ + @Deprecated + public void substring( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + try { + checkParameters( parameters, new String[]{"string","begin-index","result"}, LOG ); + final String string = parameters.get("string"); + final String result = parameters.get("result"); + final String begin = parameters.get("begin-index"); + final String end = parameters.get("end-index"); + + if( StringUtils.isEmpty(end) ) { + ctx.setAttribute( result, string.substring(Integer.parseInt(begin)) ); + } + else { + ctx.setAttribute( result, string.substring(Integer.parseInt(begin), Integer.parseInt(end)) ); + } + } + catch( Exception e ) { + throw new SvcLogicException( "An error occurred while the Directed Graph was performing a substring", e ); + } + } + + + + // ========== PUBLIC STATIC UTILITY FUNCTIONS ========== + + /** + * Throws an exception and writes an error to the log file if a required + * parameters is not found in the parametersMap. + *

+ * Use at the beginning of functions that can be called by Directed Graphs + * and can take parameters to verify that all parameters have been provided + * by the Directed Graph. + * @param parametersMap parameters Map passed to this node + * @param requiredParams Array of parameters required by the calling function + * @param log Reference to Logger to log to + * @throws SvcLogicException if a String in the requiredParams array is + * not a key in parametersMap. + * @since 1.0 + */ + public static final void checkParameters(Map parametersMap, String[] requiredParams, Logger log) throws SvcLogicException { + if( requiredParams == null || requiredParams.length < 1){ + log.debug("required parameters was empty, exiting early."); + return; + } + if (parametersMap == null || parametersMap.keySet().size() < 1){ + String errorMessage = "This method requires the parameters [" + StringUtils.join(requiredParams,",") + "], but no parameters were passed in."; + log.error(errorMessage); + throw new SvcLogicException(errorMessage); + } + + for (String param : requiredParams) { + if (!parametersMap.containsKey(param)) { + String errorMessage = "Required parameter \"" + param + "\" was not found in parameter list."; + log.error(errorMessage); + log.error("Total list of required parameters is [" + StringUtils.join(requiredParams, ",") + "]."); + throw new SvcLogicException(errorMessage); + } + } + } + + /** + * Removes all key-value pairs with keys that begin with pfx + * @param ctx Reference to context memory + * @param pfx Prefix of key-value pairs to remove + * @since 1.0 + */ + public static final void ctxBulkErase( SvcLogicContext ctx, String pfx ) { + ArrayList Keys = new ArrayList( ctx.getAttributeKeySet() ); + for( String key : Keys ) { + if( key.startsWith( pfx ) ) { + ctx.setAttribute( pfx + key.substring(pfx.length()) , null); + } + } + } + + /** + * Copies all context memory key-value pairs that start with src_pfx to + * the keys that start with dest_pfx + suffix, where suffix is the result + * of {@code key.substring(src_pfx.length())}. + *

+ * Does NOT guarantee removal of all keys at the destination before + * copying, but will overwrite any destination keys that have a + * corresponding source key. Use {@link #ctxBulkErase(SvcLogicContext, String) ctxBulkErase} + * before copy to erase destination root before copying from source. + * @param ctx Reference to context memory. + * @param src_pfx Prefix of the keys to copy values from. + * @param dest_pfx Prefix of the keys to copy values to. + * @since 1.0 + */ + public static final void ctxBulkCopy( SvcLogicContext ctx, String src_pfx, String dest_pfx ) { + // Remove trailing period from dest_pfx + if( dest_pfx.charAt(dest_pfx.length()-1) == '.' ) { + dest_pfx = dest_pfx.substring(0,dest_pfx.length()-1); + } + + // For each context key that begins with src_pfx, set the value of the + // key dest_pfx + the suffix of the key to the key's value + ArrayList Keys = new ArrayList(ctx.getAttributeKeySet()); + for( String key : Keys ) { + if( key.startsWith(src_pfx) ) { + // Get suffix (no leading period) + String suffix = key.substring(src_pfx.length()); + if( suffix.charAt(0) == '.') { + suffix = suffix.substring(1); + } + + // Set destination's value to key's value + ctx.setAttribute(dest_pfx + '.' + suffix, ctx.getAttribute(key)); + } + } + } + + /** + * Creates and returns a {@code Map} that is a subset of + * context memory where all keys begin with the prefix. + * @param ctx Reference to context memory. + * @param prefix Returned map's keys should all begin with this value. + * @return A {@code Map} containing all the key-value pairs + * in ctx whose key begins with prefix. + */ + public static final Map ctxGetBeginsWith( SvcLogicContext ctx, String prefix ) { + Map prefixMap = new HashMap(); + + for( String key : ctx.getAttributeKeySet() ) { + if( key.startsWith(prefix) ) { + prefixMap.put( key, ctx.getAttribute(key) ); + } + } + + return prefixMap; + } + + /** + * Returns true if key's value in context memory is "" or if it doesn't + * exist in context memory. + * @param ctx Reference to context memory. + * @param key Key to search for. + * @return true if key's value in context memory is "" or if it doesn't + * exist in context memory. + * @since 1.0 + */ + public static final boolean ctxKeyEmpty( SvcLogicContext ctx, String key ) { + String value = ctx.getAttribute(key); + return value == null || value.isEmpty(); + } + + /** + * Adds all key-value pairs in the entries Map to context memory. + * @param ctx Reference to context memory. Value's {@code toString()} + * function is used to add it. + * @param entries {@code Map} of key-value pairs to add to + * context memory. Value's {@code toString()} function is used to add it. + * @return Reference to context memory to be used for function chaining. + */ + public static final SvcLogicContext ctxPutAll( SvcLogicContext ctx, Map entries ) { + for( Map.Entry entry : entries.entrySet() ) { + ctxSetAttribute( ctx, entry.getKey(), entry.getValue() ); + //ctx.setAttribute(entry.getKey(), entry.getValue().toString()); + } + + return ctx; + } + + /** + * Sets a key in context memory to the output of object's toString(). The + * key is deleted from context memory if object is null. + * @param ctx Reference to context memory. + * @param key Key to set. + * @param object Object whose toString() will be the value set + */ + public static final void ctxSetAttribute( SvcLogicContext ctx, String key, Object object ) { + if( object == null ) { + ctx.setAttribute(key, null); + } + else { + ctx.setAttribute(key, object.toString()); + } + } + + /** + * Sets a key in context memory to the output of object's toString(). + *

+ * The key is deleted from context memory if object is null. The key and + * value set in context memory are logged to the Logger at the provided + * logLevel level. + * @param Any Java object + * @param ctx Reference to context memory. + * @param key Key to set. + * @param obj Object whose toString() will be the value set + * @param LOG Logger to log to + * @param logLevel level to log at in Logger + */ + public static final void ctxSetAttribute( SvcLogicContext ctx, String key, O obj, Logger LOG, LogLevel logLevel ) { + String value = Objects.toString( obj, null ); + ctx.setAttribute( key, value ); + if( logLevelIsEnabled(LOG, logLevel ) ) { + if( value == null ) { + logMessageAtLevel( LOG, logLevel, "Deleting " + key ); + } + else { + logMessageAtLevel( LOG, logLevel, "Setting " + key + " = " + value ); + } + } + } + + /** + * Utility function used to get an array's length from context memory. + * Will return 0 if key doesn't exist in context memory or isn't numeric. + *

+ * Use to obtain a context memory array length without having to worry + * about throwing a NumberFormatException. + * @param ctx Reference to context memory + * @param key Key in context memory whose value is the array's length. If + * the key doesn't end in "_length", then "_length is appended. + * @param log Reference to Logger to log to + * @return The array length or 0 if the key is not found in context memory. + * @since 1.0 + */ + public static final int getArrayLength( SvcLogicContext ctx, String key ) { + return getArrayLength(ctx, key, null, null, null); + } + + /** + * Utility function used to get an array's length from context memory. + * Will return 0 if key doesn't exist in context memory or isn't numeric + * and print the provided log message to the configured log file. + *

+ * Use to obtain a context memory array length without having to worry + * about throwing a NumberFormatException. + * @param ctx Reference to context memory. + * @param key Key in context memory whose value is the array's length. If + * the key doesn't end in "_length", then "_length is appended. + * @param log Reference to Logger to log to. Doesn't log if null. + * @param logLevel Logging level to log the message at if the context + * memory key isn't found. Doesn't log if null. + * @param log_message Message to log if the context memory key isn't found. + * Doesn't log if null. + * @return The array length or 0 if the key is not found in context memory. + * @since 1.0 + */ + public static final int getArrayLength( SvcLogicContext ctx, String key, Logger log, LogLevel logLevel, String log_message ) { + String ctxKey = ( key.endsWith("_length") ) ? key : key + "_length"; + try { + return Integer.parseInt(ctx.getAttribute(ctxKey)); + } + catch( NumberFormatException e ) { + if( log != null && logLevel != null && log_message != null ) { + switch( logLevel ) { + case TRACE: + log.trace(log_message); + case DEBUG: + log.debug(log_message); + break; + case INFO: + log.info(log_message); + break; + case WARN: + log.warn(log_message); + break; + case ERROR: + log.error(log_message); + break; + } + } + } + + return 0; + } + + /** + * Prints sorted context memory key-value pairs to the log file at the log + * level. Returns immediately if the log level isn't enabled. + *

+ * O(n log(n)) time where n = size of context memory + * @param ctx Reference to context memory + * @param log Reference to Logger to log to + * @param logLevel Logging level to log the context memory key-value pairs + * at. + * @since 1.0 + */ + public static final void logContextMemory( SvcLogicContext ctx, Logger log, LogLevel logLevel ) { + logLevelIsEnabled( log, logLevel ); + + // Print sorted context memory key-value pairs to the log + ArrayList keys = new ArrayList(ctx.getAttributeKeySet()); + Collections.sort(keys); + for( String key : keys ) { + logMessageAtLevel( log, logLevel, key + " = " + ctx.getAttribute(key) ); + } + } + + + + // ========== PRIVATE FUNCTIONS ========== + + // TODO: javadoc + /** + * + * @param parameters + * @param log + * @param loglevel + * @since 7.0.1 + */ + public static final void logExecuteNodeParameters( Map parameters, Logger log, LogLevel loglevel ) { + logLevelIsEnabled( log, loglevel ); + + for( Map.Entry param : parameters.entrySet() ) { + logMessageAtLevel( log, loglevel, "PARAM: " + param.getKey() + " = " + param.getValue() ); + } + } + + // TODO: javadoc + /** + * Returns true if the loglevel is enabled. Otherwise, returns false. + * @param log Reference to logger + * @param loglevel Log level to check if enabled + * @return True if the loglevel is enabled. Otherwise, false + * @since 7.0.1 + */ + private static final boolean logLevelIsEnabled( Logger log, LogLevel loglevel ) { + // Return immediately if logging level isn't enabled + switch( loglevel ) { + case TRACE: + if( log.isTraceEnabled() ) { return true; } + return false; + case DEBUG: + if( log.isDebugEnabled() ) { return true; } + return false; + case INFO: + if( log.isInfoEnabled() ) { return true; } + return false; + case WARN: + if( log.isWarnEnabled() ) { return true; } + return false; + case ERROR: + if( log.isErrorEnabled() ) { return true; } + return false; + default: + throw new IllegalArgumentException("Unknown LogLevel: " + loglevel.toString()); + } + } + + // TODO: javadoc + /** + * + * @param log + * @param loglevel + * @param msg + * @since 7.0.1 + */ + private static final void logMessageAtLevel( Logger log, LogLevel loglevel, String msg ) { + switch( loglevel ) { + case TRACE: + log.trace(msg); + return; + case DEBUG: + log.debug(msg); + return; + case INFO: + log.info(msg); + return; + case WARN: + log.warn(msg); + return; + case ERROR: + log.error(msg); + return; + } + } + + + + // ========== LOCAL CLASSES ========== + + private class SortableCtxListElement implements Comparable { + HashMap child_elements = new HashMap(); + String[] sort_fields; + + public SortableCtxListElement( SvcLogicContext ctx, String root, String[] sort_fields ) { + this.sort_fields = sort_fields; + + for( String key : ctx.getAttributeKeySet() ) { + if( key.startsWith(root) ) { + if( key.length() == root.length() ) { + child_elements.put("", ctx.getAttribute(key)); + break; + } + else { + child_elements.put(key.substring(root.length()+1), ctx.getAttribute(key)); + } + } + } + } + + @Override + public int compareTo(SortableCtxListElement arg0) { + if( sort_fields == null ) { + return this.child_elements.get("").compareTo(arg0.child_elements.get("")); + } + + for( String field : this.sort_fields ) { + int result = this.child_elements.get(field).compareTo(arg0.child_elements.get(field)); + if( result != 0 ) { + return result; + } + } + + return 0; + } + } + + /** + * Creates a file that contains the content of context memory. + * @param parameters - must contain the parameter filename + * @param ctx Reference to context memory + * @throws SvcLogicException thrown if file cannot be created or if parameters are missing + */ + public static void printContext(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + if (parameters == null || parameters.isEmpty()) { + throw new SvcLogicException("no parameters passed"); + } + + checkParameters(parameters, new String[]{"filename"}, LOG); + + String fileName = parameters.get("filename"); + + + try (FileOutputStream fstr = new FileOutputStream(new File(fileName)); + PrintStream pstr = new PrintStream(fstr, true);) + { + pstr.println("#######################################"); + for (String attr : ctx.getAttributeKeySet()) { + pstr.println(attr + " = " + ctx.getAttribute(attr)); + } + } catch (Exception e) { + throw new SvcLogicException("Cannot write context to file " + fileName, e); + } + + + } + + /** + * Checks context memory for a set of required parameters + * Every parameter aside from prefix will be treated as mandatory + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + *
parameterMandatory/Optionaldescription
prefixOptionalthe prefix will be added to each parameter
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void requiredParameters(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + if (parameters == null || parameters.keySet().size() < 1) { + String errorMessage = "requiredParameters should not be called if the parameters hashmap is null or empty!"; + LOG.error(errorMessage); + throw new SvcLogicException(errorMessage); + } + String prefixValue = null; + String prefix = "prefix"; + if(parameters.containsKey(prefix)){ + prefixValue = parameters.get(prefix); + parameters.remove(prefix); + } + checkParameters(prefixValue, ctx.getAttributeKeySet(), parameters.keySet(), LOG); + } + + private static void checkParameters(String prefixValue, Set ctx, Set parameters, Logger log) throws SvcLogicException { + for (String param : parameters) { + if (prefixValue != null) { + param = prefixValue + param; + } + if (!ctx.contains(param)) { + String errorMessage = "This method requires the parameters [" + StringUtils.join(parameters, ",") + + "], but " + param + " was not passed in."; + log.error(errorMessage); + throw new SvcLogicException(errorMessage); + } + } + } + + /** + * is in a different DG invocation just before/after we call NCS and set the state to InProgress + */ + /** + * setTime write the current date time to a string located at outputPath + * @param parameters - requires outputPath to not be null + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public static void setTime(Map parameters, SvcLogicContext ctx) throws SvcLogicException + { + checkParameters(parameters, new String[] { "outputPath" }, LOG); + + // Set the DateFormat + // "2015-03-16T12:18:35.138Z" + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + + // Parse the date + String ctxVariable = parameters.get("outputPath"); + try { + String dateTime = format.format(new Date()); + ctx.setAttribute(ctxVariable, dateTime); + } catch (Exception ex) { + throw new SvcLogicException("problem with setTime", ex); + } + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtilsActivator.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtilsActivator.java new file mode 100644 index 000000000..e0568ab77 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtilsActivator.java @@ -0,0 +1,95 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SliPluginUtilsActivator implements BundleActivator { + @SuppressWarnings("rawtypes") private List registrations = new LinkedList(); + + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtilsActivator.class); + private static final String SDNC_ROOT_DIR = "SDNC_CONFIG_DIR"; + private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; + + @Override + public void start(BundleContext ctx) throws Exception { + SliPluginUtils plugin = new SliPluginUtils(new Properties()); + LOG.info("Registering service " + plugin.getClass().getName()); + registrations.add(ctx.registerService(plugin.getClass().getName(), plugin, null)); + + SliStringUtils sliStringUtils_Plugin = new SliStringUtils(); + LOG.info("Registering service " + sliStringUtils_Plugin.getClass().getName()); + registrations.add(ctx.registerService(sliStringUtils_Plugin.getClass().getName(), sliStringUtils_Plugin, null)); + + try { + String path = System.getenv(SDNC_ROOT_DIR) + File.separator + DME2_PROPERTIES_FILE_NAME; + DME2 dmePlugin = initDme2(path); + if (dmePlugin != null) { + LOG.info("Registering service " + dmePlugin.getClass().getName()); + registrations.add(ctx.registerService(dmePlugin.getClass().getName(), dmePlugin, null)); + } + } catch (Exception e) { + LOG.error("DME2 plugin could not be started", e); + } + } + + public DME2 initDme2(String pathToDmeProperties) { + Properties dme2properties = new Properties(); + String loadPropertiesErrorMessage = "Couldn't load DME2 properties at path " + pathToDmeProperties; + File dme2propertiesFile = new File(pathToDmeProperties); + + try { + dme2properties.load(new FileReader(dme2propertiesFile)); + String proxyUrlProperty = dme2properties.getProperty("proxyUrl"); + String[] proxyUrls = proxyUrlProperty.split(","); + DME2 dmePlugin = new DME2(dme2properties.getProperty("aafUserName"), dme2properties.getProperty("aafPassword"), dme2properties.getProperty("envContext"), dme2properties.getProperty("routeOffer"), proxyUrls, dme2properties.getProperty("commonServiceVersion")); + dmePlugin.setPartner(dme2properties.getProperty("partner")); + return dmePlugin; + } catch (FileNotFoundException e) { + LOG.error(loadPropertiesErrorMessage); + } catch (IOException e) { + LOG.error(loadPropertiesErrorMessage); + } + LOG.error("Couldn't create DME2 plugin"); + return null; + } + + @Override + public void stop(BundleContext ctx) throws Exception { + for (@SuppressWarnings("rawtypes") ServiceRegistration registration : registrations) { + registration.unregister(); + registration = null; + } + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtils.java new file mode 100644 index 000000000..43af6f59a --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtils.java @@ -0,0 +1,396 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A SvcLogicJavaPlugin that exposes java.lang.String functions to DirectedGraph + */ +public class SliStringUtils implements SvcLogicJavaPlugin { + private static final Logger LOG = LoggerFactory.getLogger(SliStringUtils.class); + + public SliStringUtils() {} + + /** + * Provides split functionality to Directed Graphs. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
original_stringMandatoryString to perform split on
regexMandatorythe delimiting regular expression
limitOptionalresult threshold. See String.split method for further description. Defaults to 0
ctx_memory_result_keyMandatoryKey in context memory to populate the resulting array of strings under
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + * @see String#split(String, int) + */ + public void split( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + final String original_string = parameters.get("original_string"); + LOG.trace("original_string = " + original_string); + final String regex = parameters.get("regex"); + LOG.trace("regex = " + regex); + final String limit_str = parameters.get("limit"); + LOG.trace("limit_str = " + limit_str); + final String ctx_memory_result_key = parameters.get("ctx_memory_result_key"); + LOG.trace("ctx_memory_result_key = " + ctx_memory_result_key); + + try { + // Validation that parameters are not null + SliPluginUtils.checkParameters( parameters, new String[]{"original_string","regex","ctx_memory_result_key"}, LOG ); + + // Read limit from context memory. Default to 0 if null/empty + int limit = 0; + if( StringUtils.isNotEmpty(limit_str) ) { + try { + limit = Integer.parseInt(limit_str); + } + catch( NumberFormatException e ) { + throw new IllegalArgumentException( "The limit parameter of the SliStringUtils.split() function must be a number, empty string, or null", e ); + } + } + + // Call String.split(regex,limit) on string passed in + String[] split_string = original_string.split(regex, limit); + + // Populate context memory with results + for( int i = 0; i < split_string.length; i++ ) { + SliPluginUtils.ctxSetAttribute(ctx, ctx_memory_result_key + '[' + i + ']', split_string[i], LOG, SliPluginUtils.LogLevel.DEBUG); + } + SliPluginUtils.ctxSetAttribute(ctx, ctx_memory_result_key + "_length", new Integer(split_string.length), LOG, SliPluginUtils.LogLevel.DEBUG); + } + catch( Exception e ) { + // Have error message print parameters + throw new SvcLogicException( "An error occurred during SliStringUtils.split() where original_string = " + quotedOrNULL(regex) + + " regex = " + quotedOrNULL(regex) + + " limit = " + quotedOrNULL(regex) + + " ctx_memory_result_key = " + quotedOrNULL(regex), e ); + } + } + + private static String quotedOrNULL( String str ) { + return (str == null) ? "NULL" : '"' + str + '"'; + } + + /** + * exposes equalsIgnoreCase to directed graph + * @param parameters HashMap of parameters passed by the DG to this function + * emits a true or false outcome + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static String equalsIgnoreCase(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); + if(parameters.get("source").equalsIgnoreCase(parameters.get("target"))){ + return "true"; + } + return "false"; + } + + /** + * exposes toUpperCase to directed graph + * writes an upperCase version of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void toUpper(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").toUpperCase()); + } + + /** + * exposes toLowerCase to directed graph + * writes a lowerCase version of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void toLower(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").toLowerCase()); + } + + /** + * exposes contains to directed graph to test if one string contains another + * tests if the source contains the target + * @param parameters HashMap of parameters passed by the DG to this function + * emits a true or false outcome + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static String contains(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); + if(parameters.get("source").contains(parameters.get("target"))){ + return "true"; + } + return "false"; + } + + /** + * exposes endsWith to directed graph to test if one string endsWith another string + * tests if the source ends with the target + * @param parameters HashMap of parameters passed by the DG to this function + * emits a true or false outcome + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static String endsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); + if(parameters.get("source").endsWith(parameters.get("target"))){ + return "true"; + } + return "false"; + } + + /** + * exposes startsWith to directed graph to test if one string endsWith another string + * tests if the source ends with the target + * @param parameters HashMap of parameters passed by the DG to this function + * emits a true or false outcome + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static String startsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); + if(parameters.get("source").startsWith(parameters.get("target"))){ + return "true"; + } + return "false"; + } + + /** + * exposes trim to directed graph + * writes a trimmed version of the string to the outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void trim(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").trim()); + } + + /** + * exposes String.length() to directed graph + * writes the length of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void getLength(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), String.valueOf(parameters.get("source").length())); + } + + /** + * exposes replace to directed graph + * writes the length of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatoryThe sequence of char values to be replaced
replacementMandatoryThe replacement sequence of char values
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void replace(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath","target","replacement"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), (parameters.get("source").replace(parameters.get("target"), parameters.get("replacement")))); + } + + /** + * Provides substring functionality to Directed Graphs. + *

+ * Calls either String.substring(String beginIndex) or + * String.substring(String beginInded, String endIndex) if the end-index + * is present or not. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
stringMandatoryString to perform substring on
resultMandatoryKey in context memory to populate the resulting string in
begin-indexMandatoryBeginning index to pass to Java substring function
end-indexOptionalEnding index to pass to Java substring function. If not included, String.substring(begin) will be called.
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public void substring( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + try { + SliPluginUtils.checkParameters( parameters, new String[]{"string","begin-index","result"}, LOG ); + final String string = parameters.get("string"); + final String result = parameters.get("result"); + final String begin = parameters.get("begin-index"); + final String end = parameters.get("end-index"); + if( StringUtils.isEmpty(end) ) { + ctx.setAttribute( result, string.substring(Integer.parseInt(begin)) ); + } + else { + ctx.setAttribute( result, string.substring(Integer.parseInt(begin), Integer.parseInt(end)) ); + } + } + catch( Exception e ) { + throw new SvcLogicException( "An error occurred while the Directed Graph was performing a substring", e ); + } + } + + /** + * Provides concat functionality to Directed Graphs. + *

+ * Will concat target to source and write the result to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatoryThe sequence of char values to be replaced
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void concat( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + SliPluginUtils.checkParameters( parameters, new String[]{"source","target","outputPath"}, LOG ); + String result = parameters.get("source").concat(parameters.get("target")); + ctx.setAttribute(parameters.get("outputPath"), result); + } + + /** + * Provides url encoding functionality to Directed Graphs. + *

+ * Will url encode the source and write the result to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
encodingOptionalthe name of a supported character encoding, defaulted to UTF-8 if not supplied
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + */ + public static void urlEncode(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] { "source", "outputPath" }, LOG); + String encoding = parameters.get("encoding"); + if (encoding == null) { + encoding = "UTF-8"; + } + try { + String result = URLEncoder.encode(parameters.get("source"), encoding); + ctx.setAttribute(parameters.get("outputPath"), result); + } catch (UnsupportedEncodingException e) { + throw new SvcLogicException("Url encode failed.", e); + } + } + +} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextList.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextList.java new file mode 100644 index 000000000..89a4a98ff --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextList.java @@ -0,0 +1,210 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.ListIterator; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdnc.sli.SvcLogicContext; + +/** + * A utility class used to manage list manipulation in the context memory. + * @see org.openecomp.sdnc.sli.SvcLogicContext + */ +public class SvcLogicContextList { + /** + * Internal flag indicating if list should be deleted from context memory + * when it is copied into the SvcLogicContextList object. + */ + private enum OperType { + COPY, EXTRACT + } + + // TODO: javadoc + protected final String prefix; + // TODO: javadoc + protected final ArrayList> list; + + + // TODO: javadoc + public SvcLogicContextList( SvcLogicContext ctx, String list_prefix ) { + this(ctx, list_prefix, OperType.COPY); + } + + // TODO: javadoc + private SvcLogicContextList( SvcLogicContext ctx, String list_prefix, OperType operation ) { + this.prefix = list_prefix; + + // Initialize list + int capacity = getCtxListLength(ctx, prefix); + this.list = new ArrayList>(capacity); + for( int i = 0; i < capacity; i++ ) { + this.list.add(i, new HashMap()); + } + + // Populate "elements" in list + String prefix_bracket = this.prefix + '['; + for (String key : new HashSet(ctx.getAttributeKeySet())) { + if( key.startsWith(prefix_bracket) ) { + // Extract the index of the list + int index = getCtxListIndex(key, this.prefix, capacity); + + // Store the + String suffix = key.substring((prefix_bracket + index + ']').length()); + suffix = suffix.isEmpty() ? suffix : suffix.substring(1); + this.list.get(index).put( suffix, ctx.getAttribute(key)); + + // If flag to extract set, remove data from context memory as + // it is read into this list + if( operation == OperType.EXTRACT ) { + ctx.setAttribute(key, null); + } + } + } + + // If flag to extract set, remove list _length value from cxt mem + if( operation == OperType.EXTRACT ) { + ctx.setAttribute(this.prefix + "_length", null); + } + } + + // TODO: javadoc + public static SvcLogicContextList extract( SvcLogicContext ctx, String list_prefix ) { + return new SvcLogicContextList(ctx, list_prefix, OperType.EXTRACT); + } + + + // ========== PUBLIC FUNCTIONS ========== + + // TODO: javadoc + public HashMap get( int index ) { + return this.list.get(index); + } + + // TODO: javadoc + public HashMap remove( int index ) { + return this.list.remove(index); + } + + // TODO: javadoc + public void remove( String value ) { + remove( "", value ); + } + + // TODO: javadoc + public void remove( String key, String value ) { + if( value == null ) { + throw new IllegalArgumentException("value cannot be null"); + } + + ListIterator> itr = this.list.listIterator(); + while( itr.hasNext() ) { + if( value.equals(itr.next().get(key)) ) { + itr.remove(); + } + } + } + + // TODO javadoc + public void remove( Map primary_key ) { + ListIterator> itr = this.list.listIterator(); + while( itr.hasNext() ) { + boolean found = true; + HashMap list_element = itr.next(); + for( Map.Entry key : primary_key.entrySet() ) { + if( !key.getValue().equals(list_element.get(key.getKey())) ) { + found = false; + break; + } + } + + if( found ) { + itr.remove(); + } + } + } + + // TODO: javadoc + public int size() { + return list.size(); + } + + // TODO: javadoc + public void writeToContext( SvcLogicContext ctx ) { + ctx.setAttribute( prefix + "_length", Integer.toString(this.list.size()) ); + + for( int i = 0; i < this.list.size(); i++ ) { + for( Map.Entry entry : this.list.get(i).entrySet() ) { + if( entry.getKey().equals("") ) { + ctx.setAttribute(prefix + '[' + i + ']', entry.getValue()); + } else { + ctx.setAttribute(prefix + '[' + i + "]." + entry.getKey(), entry.getValue()); + } + } + } + } + + + + // ========== PRIVATE STATIC FUNCTIONS ========== + + // TODO: javadoc + private static int getCtxListIndex( String key, String prefix, int list_size ) { + int index = getCtxListIndex( key, prefix ); + if( index >= list_size ) { + throw new IllegalArgumentException("Context memory list \"" + prefix + "[]\" contains an index >= the size of the list", new ArrayIndexOutOfBoundsException("index \"" + index + "\" is outside the bounds of the context memory list \"" + prefix + "[]. List Length = " + list_size)); + } else if (index < 0) { + throw new IllegalArgumentException("Context memory list \"" + prefix + "[]\" contains a negative index", new NegativeArraySizeException("index \"" + index + "\" of context memory list is negative")); + } + + return index; + } + + // TODO: javadoc + private static int getCtxListIndex( String key, String prefix ) { + String ctx_index_str = StringUtils.substringBetween(key.substring(prefix.length()), "[", "]"); + try { + return Integer.parseInt( ctx_index_str ); + } catch (NumberFormatException e) { + throw new IllegalStateException("Could not parse index value \"" + ctx_index_str + "\" in context memory key \"" + key + "\"", e); + } + } + + // TODO: javadoc + private static int getCtxListLength( SvcLogicContext ctx, String prefix ) { + String _length_key = prefix + "_length"; + String _length_val_str = ctx.getAttribute(_length_key); + try { + return Integer.parseInt(_length_val_str); + } catch (NumberFormatException e) { + if( _length_val_str == null ) { + throw new IllegalStateException( "Could not find list length \"" + _length_key + "\" in context memory." ); + } else { + throw new IllegalStateException( "Could not parse index value \"" + _length_val_str + "\" of context memory list length \"" + _length_key + "\"" , e ); + } + } + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextObject.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextObject.java new file mode 100644 index 000000000..d79522f04 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextObject.java @@ -0,0 +1,28 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import org.openecomp.sdnc.sli.SvcLogicContext; + +public interface SvcLogicContextObject { + public void writeToContext( SvcLogicContext ctx, String root ); +} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/YesNo.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/YesNo.java new file mode 100644 index 000000000..4d2fb4c29 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/YesNo.java @@ -0,0 +1,51 @@ +/*- + * ============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========================================================= + */ + +/** + * + */ +package org.openecomp.sdnc.sli.SliPluginUtils.commondatastructures; + +/** + * An enum found in many Yang models. It is commonly used as a + * substitute for boolean. + */ +public enum YesNo { + N, Y; + + /** + * Method overload for {@link #valueOf(String)} for the char primative + */ + public static YesNo valueOf( final char name ) { + return YesNo.valueOf( Character.toString(name) ); + } + + /** + * Method overload for {@link #valueOf(String)} for the Character object + */ + public static YesNo valueOf( final Character name ) { + if( name == null ) { + return null; + } + + return YesNo.valueOf( name.toString() ); + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/package-info.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/package-info.java new file mode 100644 index 000000000..4a81d9a30 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/package-info.java @@ -0,0 +1,28 @@ +/*- + * ============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========================================================= + */ + +/** + * + */ +/** + * + */ +package org.openecomp.sdnc.sli.SliPluginUtils.commondatastructures; diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/CheckParametersTest.java new file mode 100644 index 000000000..318e4643e --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/CheckParametersTest.java @@ -0,0 +1,116 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CheckParametersTest { + + @Test + public void nullRequiredParameters() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = null; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void emptyParametersMap() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = new String[] { "param1", "param2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void paramNotFound() throws Exception { + Map parametersMap = new HashMap(); + parametersMap.put("tst", "me"); + String[] requiredParams = new String[] { "param1", "parm2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test + public void testSunnyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param2", "world"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test + public void testSunnyRequiredParametersWithPrefix() throws Exception { + String prefixValue = "my.unique.path."; + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(prefixValue + "param1", "hello"); + ctx.setAttribute(prefixValue + "param2", "world"); + ctx.setAttribute(prefixValue + "param3", "!"); + + Map parameters = new HashMap(); + parameters.put("prefix", prefixValue); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testRainyMissingRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", null); + parameters.put("param2", null); + parameters.put("param3", null); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testEmptyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + + SliPluginUtils.requiredParameters(parameters, ctx); + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/Dme2Test.java new file mode 100644 index 000000000..d66b01145 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/Dme2Test.java @@ -0,0 +1,109 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.sdnc.sli.SliPluginUtils.DME2; +import org.openecomp.sdnc.sli.SliPluginUtils.SliPluginUtilsActivator; + +public class Dme2Test { + + @Test + public void createInstarUrl() { + String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com"; + DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(instarUrl, constructedUrl); + } + + @Test + public void createInstarUrlNoSubContext() { + String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com"; + DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); + Map parameters = new HashMap(); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", parameters.get(null)); + assertEquals(instarUrl, constructedUrl); + } + + @Test + public void testRoundRobin() { + String[] proxyHostNames = new String[] { "http://one:25055", "http://two:25055", "http://three:25055" }; + String urlSuffix = "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com"; + DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNames, "common"); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + } + + @Test + public void createDme2EndtoEnd() { + SliPluginUtilsActivator activator = new SliPluginUtilsActivator(); + DME2 dme2 = activator.initDme2("src/test/resources/dme2.e2e.properties"); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("UAT", dme2.envContext); + assertEquals("UAT", dme2.routeOffer); + Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); + assertEquals("1702.0", dme2.commonServiceVersion); + assertEquals(null, dme2.partner); + + String constructedUrl = dme2.constructUrl("sample.com/restservices/instar/v1/assetSearch", null, "/mySubContext"); + assertNotNull(constructedUrl); + System.out.println(constructedUrl); + } + + @Test + public void createDme2Prod() { + SliPluginUtilsActivator activator = new SliPluginUtilsActivator(); + DME2 dme2 = activator.initDme2("src/test/resources/dme2.prod.properties"); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("PROD", dme2.envContext); + assertEquals("", dme2.routeOffer); + Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); + assertEquals("1.0", dme2.commonServiceVersion); + assertEquals("LPP_PROD", dme2.partner); + + String constructedUrl = dme2.constructUrl("sample.com/restservices/instar/v1/assetSearch", null, "/mySubContext"); + assertNotNull(constructedUrl); + System.out.println(constructedUrl); + } + +} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_StaticFunctionsTest.java new file mode 100644 index 000000000..e69d08676 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_StaticFunctionsTest.java @@ -0,0 +1,250 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SliPluginUtils_StaticFunctionsTest { + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_StaticFunctionsTest.class); + SliPluginUtils utils = new SliPluginUtils(); + private SvcLogicContext ctx; + private HashMap parameters; + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + parameters = new HashMap(); + } + + // TODO: javadoc + @Test + public final void testCtxGetBeginsWith() { + ctx.setAttribute("service-data.oper-status.order-status", "InProgress"); + ctx.setAttribute("service-data.service-information.service-instance-id", "my-instance"); + ctx.setAttribute("service-data.service-information.service-type", "my-service"); + + Map entries = SliPluginUtils.ctxGetBeginsWith(ctx, "service-data.service-information"); + + assertEquals("my-instance", entries.get("service-data.service-information.service-instance-id")); + assertEquals("my-service", entries.get("service-data.service-information.service-type")); + assertFalse(entries.containsKey("service-data.oper-status.order-status")); + } + + // TODO: javadoc + @Test + public final void testCtxListRemove_index() throws SvcLogicException { + LOG.trace("=== testCtxListRemove_index ==="); + ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); + ctx.setAttribute("service-data.vnf-l3_length", "3"); + + parameters.put("index", "1"); + parameters.put("list_pfx", "service-data.vnf-l3"); + + utils.ctxListRemove(parameters, ctx); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); + assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); + assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); + assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); + assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); + } + + // TODO: javadoc + @Test + public final void textCtxListRemove_keyValue() throws SvcLogicException { + LOG.trace("=== textCtxListRemove_keyValue ==="); + ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); + // 2nd entry + ctx.setAttribute("service-data.vnf-l3[3].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[3].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3_length", "4"); + + parameters.put("list_pfx", "service-data.vnf-l3"); + parameters.put("key", "vnf-host-name"); + parameters.put("value", "vnf-host-name_1"); + + utils.ctxListRemove(parameters, ctx); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); + assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); + assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); + assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); + assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); + } + + // TODO: javadoc + @Test + public final void textCtxListRemove_keyValue_nullkey() throws SvcLogicException { + LOG.trace("=== textCtxListRemove_keyValue_nullkey ==="); + ctx.setAttribute("service-data.vnf-l3[0]", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1]", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2]", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3_length", "3"); + + parameters.put("list_pfx", "service-data.vnf-l3"); + parameters.put("value", "vnf-host-name_1"); + + utils.ctxListRemove(parameters, ctx); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); + assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0]")); + assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1]")); + } + + // TODO: javadoc + @Test + public final void textCtxListRemove_keyValueList() throws SvcLogicException { + LOG.trace("=== textCtxListRemove_keyValueList ==="); + ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); + // 2nd entry + ctx.setAttribute("service-data.vnf-l3[3].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[3].device-host-name", "device-host-name_1"); + // entries with only 1 of 2 key-value pairs matching + ctx.setAttribute("service-data.vnf-l3[4].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[4].device-host-name", "device-host-name_4"); + ctx.setAttribute("service-data.vnf-l3[5].vnf-host-name", "vnf-host-name_5"); + ctx.setAttribute("service-data.vnf-l3[5].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3_length", "6"); + + parameters.put("list_pfx", "service-data.vnf-l3"); + parameters.put("keys_length", "2"); + parameters.put("keys[0].key", "vnf-host-name"); + parameters.put("keys[0].value", "vnf-host-name_1"); + parameters.put("keys[1].key", "device-host-name"); + parameters.put("keys[1].value", "device-host-name_1"); + + utils.ctxListRemove(parameters, ctx); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + assertEquals("4", ctx.getAttribute("service-data.vnf-l3_length")); + assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); + assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); + assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); + assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); + assertEquals("vnf-host-name_1", ctx.getAttribute("service-data.vnf-l3[2].vnf-host-name")); + assertEquals("device-host-name_4", ctx.getAttribute("service-data.vnf-l3[2].device-host-name")); + assertEquals("vnf-host-name_5", ctx.getAttribute("service-data.vnf-l3[3].vnf-host-name")); + assertEquals("device-host-name_1", ctx.getAttribute("service-data.vnf-l3[3].device-host-name")); + } + + // TODO: javadoc + @Test(expected = SvcLogicException.class) + public final void testCtxListRemove_nullListLength() throws SvcLogicException { + LOG.trace("=== testCtxListRemove_nullListLength ==="); + ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); + + parameters.put("index", "1"); + parameters.put("list_pfx", "service-data.vnf-l3"); + + utils.ctxListRemove(parameters, ctx); + } + + // TODO: javadoc + @Test + public final void testCtxPutAll() { + HashMap entries = new HashMap(); + entries.put("service-data.oper-status.order-status", "InProgress"); + entries.put("service-data.service-information.service-instance-id", "my-instance"); + entries.put("service-data.request-information.order-number", 1234); + entries.put("service-data.request-information.request-id", null); + + SliPluginUtils.ctxPutAll(ctx, entries); + + assertEquals("InProgress", ctx.getAttribute("service-data.oper-status.order-status")); + assertEquals("my-instance", ctx.getAttribute("service-data.service-information.service-instance-id")); + assertEquals("1234", ctx.getAttribute("service-data.request-information.order-number")); + assertFalse(ctx.getAttributeKeySet().contains("service-data.request-information.request-id")); + } + + // TODO: javadoc + @Test + public final void testCtxSetAttribute_LOG() { + LOG.debug("=== testCtxSetAttribute_LOG ==="); + Integer i = new Integer(3); + SliPluginUtils.ctxSetAttribute(ctx, "test", i, LOG, SliPluginUtils.LogLevel.TRACE); + } + + /*@Test + public void printContext() throws SvcLogicException, IOException { + String filePath = "/src/test/resources/printContext.txt"; + parameters.put("filename", filePath); + File f = new File(filePath); + assert (f.exists()); + assert (!f.isDirectory()); + ctx.setAttribute("hello", "world"); + ctx.setAttribute("name", "value"); + + SliPluginUtils.printContext(parameters, ctx); + BufferedReader br = new BufferedReader(new FileReader(f)); + String line = br.readLine(); + assertEquals("#######################################", line); + line = br.readLine(); + assertEquals("hello = world", line); + line = br.readLine(); + assertEquals("name = value", line); + br.close(); + Files.delete(Paths.get(filePath)); + }*/ + + @Test + public void setTime() throws SvcLogicException { + String outputPath = "output"; + parameters.put("outputPath", outputPath); + SliPluginUtils.setTime(parameters, ctx); + assertNotNull(ctx.getAttribute(outputPath)); + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortList.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortList.java new file mode 100644 index 000000000..b1cae54a0 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortList.java @@ -0,0 +1,96 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Random; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings("unused") +public class SliPluginUtils_ctxSortList { + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class); + SliPluginUtils utils = new SliPluginUtils(); + SvcLogicContext ctx; + HashMap parameters; + Random rand = new Random(); + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + this.parameters = new HashMap(); + } + + @Test + public final void list_of_containers() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("sort-fields", "sort-key"); + this.parameters.put("delimiter",","); + + ctx.setAttribute("input.list_length", "10"); + for( int i = 0; i < 10; i++ ) { + this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString( rand.nextInt(10) )); + this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString( rand.nextInt(10) )); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for( int i = 0; i < 9; i++ ) { + assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i+1) + "].sort-key")) < 1 ); + } + } + + @Test public final void list_of_elements() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("delimiter",","); + + this.ctx.setAttribute("input.list_length", "10"); + for( int i = 0; i < 10; i++ ) { + this.ctx.setAttribute("input.list[" + i + ']', Integer.toString( rand.nextInt(10) )); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for( int i = 0; i < 9; i++ ) { + assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i+1) + ']')) < 1 ); + } + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortListTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortListTest.java new file mode 100644 index 000000000..e2fcb33d7 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortListTest.java @@ -0,0 +1,97 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Random; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings("unused") +public class SliPluginUtils_ctxSortListTest { + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortListTest.class); + SliPluginUtils utils = new SliPluginUtils(); + SvcLogicContext ctx; + HashMap parameters; + Random rand = new Random(); + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + this.parameters = new HashMap(); + } + + @Test + public final void list_of_containers() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("sort-fields", "sort-key"); + this.parameters.put("delimiter", ","); + + ctx.setAttribute("input.list_length", "10"); + for (int i = 0; i < 10; i++) { + this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString(rand.nextInt(10))); + this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString(rand.nextInt(10))); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for (int i = 0; i < 9; i++) { + assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i + 1) + "].sort-key")) < 1); + } + } + + @Test + public final void list_of_elements() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("delimiter", ","); + + this.ctx.setAttribute("input.list_length", "10"); + for (int i = 0; i < 10; i++) { + this.ctx.setAttribute("input.list[" + i + ']', Integer.toString(rand.nextInt(10))); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for (int i = 0; i < 9; i++) { + assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i + 1) + ']')) < 1); + } + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtilsTest.java new file mode 100644 index 000000000..d57cefa0d --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtilsTest.java @@ -0,0 +1,244 @@ +/*- + * ============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========================================================= + */ + +/** + * + */ +package org.openecomp.sdnc.sli.SliPluginUtils; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; + +/** + * @author km991u + * + */ +public class SliStringUtilsTest { + private SvcLogicContext ctx; + private HashMap param; + private SliStringUtils stringUtils = new SliStringUtils(); + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + param = new HashMap(); + } + + /** + * @throws SvcLogicException + * @see SliStringUtils#split(Map, SvcLogicContext) + */ + @Test + public final void testSplit() throws SvcLogicException { + param.put("original_string", "one ## two ## three"); + param.put("regex", " ## "); + param.put("ctx_memory_result_key", "result"); + + stringUtils.split(param, ctx); + + assertThat(ctx.getAttribute("result[0]"), equalTo("one")); + assertThat(ctx.getAttribute("result[1]"), equalTo("two")); + assertThat(ctx.getAttribute("result[2]"), equalTo("three")); + assertThat(ctx.getAttribute("result_length"), equalTo("3")); + } + + /** + * @throws SvcLogicException + * @see SliStringUtils#split(Map, SvcLogicContext) + */ + @Test + public final void testSplit_limit() throws SvcLogicException { + param.put("original_string", "one ## two ## three"); + param.put("regex", " ## "); + param.put("limit", "2"); + param.put("ctx_memory_result_key", "result"); + + stringUtils.split(param, ctx); + + assertThat(ctx.getAttribute("result[0]"), equalTo("one")); + assertThat(ctx.getAttribute("result[1]"), equalTo("two ## three")); + assertThat(ctx.getAttribute("result_length"), equalTo("2")); + } + + @Test + public void equalsIgnoreCaseTrue() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + String targetSTring = "HELLOWORLD"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.equalsIgnoreCase(param, ctx)); + } + + @Test + public void equalsIgnoreCaseFalse() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + String targetSTring = "goodbyeWORLD"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.equalsIgnoreCase(param, ctx)); + } + + @Test + public void toUpper() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + param.put("source", sourceString); + String path = "my.unique.path."; + param.put("outputPath", path); + SliStringUtils.toUpper(param, ctx); + assertEquals(sourceString.toUpperCase(), ctx.getAttribute(path)); + } + + @Test + public void toLower() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + param.put("source", sourceString); + String path = "my.unique.path."; + param.put("outputPath", path); + SliStringUtils.toLower(param, ctx); + assertEquals(sourceString.toLowerCase(), ctx.getAttribute(path)); + } + + @Test + public void containsTrue() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "izza"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.contains(param, ctx)); + } + + @Test + public void containsFalse() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "muffin"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.contains(param, ctx)); + } + + @Test + public void endsWithTrue() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "za"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.endsWith(param, ctx)); + } + + @Test + public void endsWithFalse() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "muffin"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.endsWith(param, ctx)); + } + + @Test + public void trim() throws SvcLogicException { + String sourceString = " H E L L O W O R L D"; + String outputPath = "muffin"; + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.trim(param, ctx); + assertEquals(sourceString.trim(), ctx.getAttribute(outputPath)); + } + + @Test + public void getLength() throws SvcLogicException { + String sourceString = "SomeRandomString"; + String outputPath = "muffin"; + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.getLength(param, ctx); + assertEquals(String.valueOf(sourceString.length()), ctx.getAttribute(outputPath)); + } + + @Test + public void startsWithFalse() throws SvcLogicException { + String sourceString = "Java"; + String targetSTring = "DG"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.startsWith(param, ctx)); + } + + @Test + public void startsWithTrue() throws SvcLogicException { + String sourceString = "Java"; + String targetSTring = "Ja"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.startsWith(param, ctx)); + } + + @Test + public void replace() throws SvcLogicException { + String sourceString = "cat Hello World cat"; + String old = "cat"; + String neww = "dog"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("target", old); + param.put("replacement", neww); + param.put("outputPath", outputPath); + SliStringUtils.replace(param, ctx); + assertEquals(sourceString.replace(old, neww), ctx.getAttribute(outputPath)); + } + + @Test + public void concat() throws SvcLogicException { + String sourceString = "cat"; + String targetString = "dog"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("target", targetString); + param.put("outputPath", outputPath); + SliStringUtils.concat(param, ctx); + assertEquals(sourceString + targetString, ctx.getAttribute(outputPath)); + } + + @Test + public void urlEncode() throws SvcLogicException { + String sourceString = "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.urlEncode(param, ctx); + assertEquals("102%2FGE100%2FSNJSCAMCJP8%2FSNJSCAMCJT4", ctx.getAttribute(outputPath)); + } + +} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextListTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextListTest.java new file mode 100644 index 000000000..5d7bb249a --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextListTest.java @@ -0,0 +1,307 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sli.SliPluginUtils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.HashMap; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdnc.sli.SvcLogicContext; + +public class SvcLogicContextListTest { + //private static final Logger LOG = LoggerFactory.getLogger(SvcLogicContextTest.class); + private SvcLogicContext ctx; + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + } + + // TODO: javadoc + @Test + public final void testSvcLogicContextList_SingleValueList() { + ctx.setAttribute("list[0]", "0"); + ctx.setAttribute("list[1]", "1"); + ctx.setAttribute("list[2]", "2"); + ctx.setAttribute("list[3]", "3"); + ctx.setAttribute("list[4]", "4"); + ctx.setAttribute("list_length", "5"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + + // Check that size of list is 5 + assertEquals(5, list.size()); + + // Check that each HashMap has it's list value in the empty string key + // and has no other values + assertEquals(1, list.get(0).size()); + assertEquals("0", list.get(0).get("")); + assertEquals(1, list.get(1).size()); + assertEquals("1", list.get(1).get("")); + assertEquals(1, list.get(2).size()); + assertEquals("2", list.get(2).get("")); + assertEquals(1, list.get(3).size()); + assertEquals("3", list.get(3).get("")); + assertEquals(1, list.get(4).size()); + assertEquals("4", list.get(4).get("")); + } + + // TODO: javadoc + @Test + public final void testSvcLogicContextList_ObjectList() { + ctx.setAttribute("list[0].ipv4", "1.1.1.0"); + ctx.setAttribute("list[0].ipv6", "2001::0"); + ctx.setAttribute("list[1].ipv4", "1.1.1.1"); + ctx.setAttribute("list[1].ipv6", "2001::1"); + ctx.setAttribute("list[2].ipv4", "1.1.1.2"); + ctx.setAttribute("list[2].ipv6", "2001::2"); + ctx.setAttribute("list[3].ipv4", "1.1.1.3"); + ctx.setAttribute("list[3].ipv6", "2001::3"); + ctx.setAttribute("list[4].ipv4", "1.1.1.4"); + ctx.setAttribute("list[4].ipv6", "2001::4"); + ctx.setAttribute("list_length", "5"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + + // Check that size of list is 5 + assertEquals(5, list.size()); + + assertEquals(2, list.get(0).size()); + assertEquals("1.1.1.0", list.get(0).get("ipv4")); + assertEquals("2001::0", list.get(0).get("ipv6")); + assertEquals(2, list.get(1).size()); + assertEquals("1.1.1.1", list.get(1).get("ipv4")); + assertEquals("2001::1", list.get(1).get("ipv6")); + assertEquals(2, list.get(2).size()); + assertEquals("1.1.1.2", list.get(2).get("ipv4")); + assertEquals("2001::2", list.get(2).get("ipv6")); + assertEquals(2, list.get(3).size()); + assertEquals("1.1.1.3", list.get(3).get("ipv4")); + assertEquals("2001::3", list.get(3).get("ipv6")); + assertEquals(2, list.get(4).size()); + assertEquals("1.1.1.4", list.get(4).get("ipv4")); + assertEquals("2001::4", list.get(4).get("ipv6")); + } + + // TODO: javadoc + @Test + public final void testExtract() { + ctx.setAttribute("list[0]", "0"); + ctx.setAttribute("list[1]", "1"); + ctx.setAttribute("list[2]", "2"); + ctx.setAttribute("list[3]", "3"); + ctx.setAttribute("list[4]", "4"); + ctx.setAttribute("list_length", "5"); + ctx.setAttribute("Other", "other"); + + SvcLogicContextList list = SvcLogicContextList.extract(ctx, "list"); + + // Check that size of list is 5 + assertEquals(5, list.size()); + + // Check that all list values exist in list object + assertEquals(1, list.get(0).size()); + assertEquals("0", list.get(0).get("")); + assertEquals(1, list.get(1).size()); + assertEquals("1", list.get(1).get("")); + assertEquals(1, list.get(2).size()); + assertEquals("2", list.get(2).get("")); + assertEquals(1, list.get(3).size()); + assertEquals("3", list.get(3).get("")); + assertEquals(1, list.get(4).size()); + assertEquals("4", list.get(4).get("")); + + // Check that all list values no longer exist in ctx + assertNull(ctx.getAttribute("list[0]")); + assertNull(ctx.getAttribute("list[1]")); + assertNull(ctx.getAttribute("list[2]")); + assertNull(ctx.getAttribute("list[3]")); + assertNull(ctx.getAttribute("list[4]")); + assertNull(ctx.getAttribute("list_length")); + + // Check that non-list values still exist in ctx + assertEquals("other", ctx.getAttribute("Other")); + } + + // TODO: javadoc + @Test + public final void testRemove_int() { + ctx.setAttribute("list[0]", "0"); + ctx.setAttribute("list[1]", "1"); + ctx.setAttribute("list[2]", "2"); + ctx.setAttribute("list[3]", "3"); + ctx.setAttribute("list[4]", "4"); + ctx.setAttribute("list_length", "5"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + list.remove(2); + + // Check that size of list is 4 (1 less than original) + assertEquals(4, list.size()); + + // Check that value was remove from list + assertEquals(1, list.get(0).size()); + assertEquals("0", list.get(0).get("")); + assertEquals(1, list.get(1).size()); + assertEquals("1", list.get(1).get("")); + assertEquals(1, list.get(2).size()); + assertEquals("3", list.get(2).get("")); + assertEquals(1, list.get(3).size()); + assertEquals("4", list.get(3).get("")); + } + + // TODO: javadoc + @Test + public final void testRemove_StringString() { + ctx.setAttribute("list[0].ipv4", "1.1.1.0"); + ctx.setAttribute("list[0].ipv6", "2001::0"); + ctx.setAttribute("list[1].ipv4", "1.1.1.1"); + ctx.setAttribute("list[1].ipv6", "2001::1"); + ctx.setAttribute("list[2].ipv4", "1.1.1.2"); + ctx.setAttribute("list[2].ipv6", "2001::2"); + ctx.setAttribute("list[3].ipv4", "1.1.1.3"); + ctx.setAttribute("list[3].ipv6", "2001::3"); + ctx.setAttribute("list[4].ipv4", "1.1.1.4"); + ctx.setAttribute("list[4].ipv6", "2001::4"); + ctx.setAttribute("list[5].ipv4", "1.1.1.2"); + ctx.setAttribute("list[5].ipv6", "2001::2"); + ctx.setAttribute("list_length", "6"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + list.remove("ipv4", "1.1.1.2"); + + // Check that size of list is 4 (2 less than original) + assertEquals(4, list.size()); + + // Check that all elements with values ending in 2 were removed + assertEquals("1.1.1.0", list.get(0).get("ipv4")); + assertEquals("2001::0", list.get(0).get("ipv6")); + assertEquals("1.1.1.1", list.get(1).get("ipv4")); + assertEquals("2001::1", list.get(1).get("ipv6")); + assertEquals("1.1.1.3", list.get(2).get("ipv4")); + assertEquals("2001::3", list.get(2).get("ipv6")); + assertEquals("1.1.1.4", list.get(3).get("ipv4")); + assertEquals("2001::4", list.get(3).get("ipv6")); + } + + // TODO: javadoc + @Test + public final void testRemove_StringString_ValueList() { + ctx.setAttribute("list[0]", "5"); + ctx.setAttribute("list[1]", "6"); + ctx.setAttribute("list[2]", "7"); + ctx.setAttribute("list[3]", "8"); + ctx.setAttribute("list[4]", "9"); + ctx.setAttribute("list_length", "5"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + list.remove("", "6"); + + // Check that size of list is 4 (1 less than original) + assertEquals(4, list.size()); + + // Check that value was remove from list + assertEquals(1, list.get(0).size()); + assertEquals("5", list.get(0).get("")); + assertEquals(1, list.get(1).size()); + assertEquals("7", list.get(1).get("")); + assertEquals(1, list.get(2).size()); + assertEquals("8", list.get(2).get("")); + assertEquals(1, list.get(3).size()); + assertEquals("9", list.get(3).get("")); + } + + // TODO: javadoc + @Test + public final void testRemove_Map() { + ctx.setAttribute("list[0].ipv4", "1.1.1.0"); + ctx.setAttribute("list[0].ipv6", "2001::0"); + ctx.setAttribute("list[1].ipv4", "1.1.1.1"); + ctx.setAttribute("list[1].ipv6", "2001::1"); + ctx.setAttribute("list[2].ipv4", "1.1.1.2"); + ctx.setAttribute("list[2].ipv6", "2001::2"); + ctx.setAttribute("list[3].ipv4", "1.1.1.3"); + ctx.setAttribute("list[3].ipv6", "2001::3"); + ctx.setAttribute("list[4].ipv4", "1.1.1.4"); + ctx.setAttribute("list[4].ipv6", "2001::4"); + ctx.setAttribute("list[5].ipv4", "1.1.1.2"); + ctx.setAttribute("list[5].ipv6", "2001::2"); + ctx.setAttribute("list_length", "6"); + + HashMap remove_key = new HashMap(); + remove_key.put("ipv4", "1.1.1.2"); + remove_key.put("ipv6", "2001::2"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + list.remove(remove_key); + + // Check that size of list is 4 (2 less than original) + assertEquals(4, list.size()); + + // Check that all elements with values ending in 2 were removed + assertEquals("1.1.1.0", list.get(0).get("ipv4")); + assertEquals("2001::0", list.get(0).get("ipv6")); + assertEquals("1.1.1.1", list.get(1).get("ipv4")); + assertEquals("2001::1", list.get(1).get("ipv6")); + assertEquals("1.1.1.3", list.get(2).get("ipv4")); + assertEquals("2001::3", list.get(2).get("ipv6")); + assertEquals("1.1.1.4", list.get(3).get("ipv4")); + assertEquals("2001::4", list.get(3).get("ipv6")); + } + + // TODO: javadoc + @Test + public final void testWriteToContext() { + ctx.setAttribute("list[0]", "0"); + ctx.setAttribute("list[1]", "1"); + ctx.setAttribute("list[2]", "2"); + ctx.setAttribute("list[3]", "3"); + ctx.setAttribute("list[4]", "4"); + ctx.setAttribute("list_length", "5"); + ctx.setAttribute("Other", "other"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + + // Erase context memory + ctx = new SvcLogicContext(); + + // Write list back into context memory + list.writeToContext(ctx); + + // Check that size of list is 5 + assertEquals(5, list.size()); + + // Check that all list values exist in list object + assertEquals("0", ctx.getAttribute("list[0]")); + assertEquals("1", ctx.getAttribute("list[1]")); + assertEquals("2", ctx.getAttribute("list[2]")); + assertEquals("3", ctx.getAttribute("list[3]")); + assertEquals("4", ctx.getAttribute("list[4]")); + assertEquals("5", ctx.getAttribute("list_length")); + + // Check that old list values aren't in new list + assertNull(ctx.getAttribute("Other")); + } +} diff --git a/sliapi/.gitignore b/sliapi/.gitignore new file mode 100755 index 000000000..b73caf31e --- /dev/null +++ b/sliapi/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/sliapi/README.txt b/sliapi/README.txt new file mode 100755 index 000000000..f9f4a2ab5 --- /dev/null +++ b/sliapi/README.txt @@ -0,0 +1,35 @@ +====================== +Introduction +====================== +You have generated an MD-SAL module using the Brocade Archetype. + +* You should be able to successfully run 'mvn clean install' on this project. +* This will produce a .zip file under the karaf.extension directory which you can deploy using +Brocade's extension deployment mechanism. + +====================== +Next Steps: +====================== +* run a 'mvn clean install' if you haven't already. This will generate some code from the yang models. +* Modify the model yang file under the model project. +* Follow the comments in the generated provider class to wire your new provider into the generated +code. +* Modify the generated provider model to respond to and handle the yang model. Depending on what +you added to your model you may need to inherit additional interfaces or make other changes to +the provider model. + +====================== +Generated Bundles: +====================== +* model + - Provides the yang model for your application. This is your primary northbound interface. +* provider + - Provides a template implementation for a provider to respond to your yang model. +* features + - Defines a karaf feature. If you add dependencies on third-party bundles then you will need to + modify the features.xml to list out the dependencies. +* karaf.extension + - Bundles all of the jars and third party dependencies (minus ODL dependencies) into a single + .zip file with the necessary configuration files to work correctly with the Brocade extension + mechanism. + diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml new file mode 100755 index 000000000..fcc08eb7d --- /dev/null +++ b/sliapi/features/pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + sliapi + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + sliapi-features + + jar + + + + org.openecomp.sdnc.core + sliapi-model + + + org.openecomp.sdnc.core + sliapi-provider + config + xml + + + org.openecomp.sdnc.core + sliapi-provider + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + + + + org.opendaylight.odlparent + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + + org.opendaylight.odlparent + features-test + test + ${odl.commons.opendaylight.version} + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/sliapi/features/src/main/resources/features.xml b/sliapi/features/src/main/resources/features.xml new file mode 100644 index 000000000..630b11157 --- /dev/null +++ b/sliapi/features/src/main/resources/features.xml @@ -0,0 +1,39 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + odl-mdsal-broker + sdnc-sli + mvn:org.openecomp.sdnc.core/sliapi-model/${project.version} + mvn:org.openecomp.sdnc.core/sliapi-provider/${project.version} + mvn:org.openecomp.sdnc.core/sliapi-provider/${project.version}/xml/config + + + diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml new file mode 100755 index 000000000..a0204f3b5 --- /dev/null +++ b/sliapi/installer/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + sliapi + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + sliapi-installer + pom + + + sdnc-sliapi + sdnc-sliapi + mvn:org.openecomp.sdnc.core/sliapi-features/${project.version}/xml/features + false + + + + + + org.openecomp.sdnc.core + sliapi-features + ${project.version} + features + xml + + + * + * + + + + + + org.openecomp.sdnc.core + sliapi-provider + ${project.version} + + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.openecomp.sdnc.core + sli-common,sli-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/sliapi/installer/src/assembly/assemble_installer_zip.xml b/sliapi/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..85e2e1e8f --- /dev/null +++ b/sliapi/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + bin + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml b/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..18700a1b7 --- /dev/null +++ b/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,55 @@ + + + + + + bin + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + ../provider/src/main/resources/initial/${feature-name}-provider.xml + ./etc/opendaylight/karaf/200-${feature-name}provider.xml + + + + + diff --git a/sliapi/installer/src/main/resources/scripts/install-feature.sh b/sliapi/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..93236c5be --- /dev/null +++ b/sliapi/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +### +# ============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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml new file mode 100755 index 000000000..be8c8b3c0 --- /dev/null +++ b/sliapi/model/pom.xml @@ -0,0 +1,79 @@ + + + 4.0.0 + + sliapi + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + sliapi-model + bundle + + + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${odl.yangtools.yang.maven.plugin.version} + + + org.opendaylight.mdsal + maven-sal-api-gen-plugin + ${odl.sal.api.gen.plugin.version} + jar + + + + + + generate-sources + + + ${yang.file.directory} + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + + + + org.opendaylight.mdsal + yang-binding + ${odl.mdsal.yang.binding.version} + + + org.opendaylight.yangtools + yang-common + ${odl.yangtools.version} + + + org.opendaylight.mdsal.model + ietf-inet-types + ${odl.ietf-inet-types.version} + + + org.opendaylight.mdsal.model + ietf-yang-types + ${odl.ietf-yang-types.version} + + + diff --git a/sliapi/model/src/main/yang/sliapi.yang b/sliapi/model/src/main/yang/sliapi.yang new file mode 100755 index 000000000..047fd6909 --- /dev/null +++ b/sliapi/model/src/main/yang/sliapi.yang @@ -0,0 +1,111 @@ +module SLI-API { + + yang-version 1; + + namespace "org:openecomp:sdnc:sliapi"; + + prefix sample; + + import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; } + + organization "openECOMP"; + + contact + "Dan Timoney"; + + description + "Defines API to service logic interpreter"; + + revision "2016-11-10" { + description + "REST API to Service Logic Interpreter"; + } + + grouping parameter-setting { + description + "Parameter setting"; + + leaf parameter-name { + type string; + description "Parameter name"; + } + + leaf int-value { + type int32; + } + leaf string-value { + type string; + } + leaf boolean-value { + type boolean; + } + } + + grouping response-fields { + leaf response-code { + type string; + } + leaf ack-final-indicator { + type string; + } + leaf response-message { + type string; + } + leaf context-memory-json { + type string; + } + } + + container test-results { + description "Test results"; + + list test-result { + key "test-identifier"; + + leaf test-identifier { + type string; + } + + leaf-list results { + type string; + } + } + } + + rpc execute-graph { + description " Method to add a new parameter."; + input { + + leaf module-name { + type string; + } + + leaf rpc-name { + type string; + } + + leaf mode { + type enumeration { + enum sync; + enum async; + } + } + + list sli-parameter { + key "parameter-name"; + uses parameter-setting; + } + } + + output { + uses response-fields; + } + } + + rpc healthcheck { + output { + uses response-fields; + } + } + +} diff --git a/sliapi/pom.xml b/sliapi/pom.xml new file mode 100755 index 000000000..06ee5e0ed --- /dev/null +++ b/sliapi/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + + + org.openecomp.sdnc.core + sdnc-core + 0.0.1-SNAPSHOT + + + pom + org.openecomp.sdnc.core + sliapi + 0.0.1-SNAPSHOT + + + sliapi + + + + + + + + org.openecomp.sdnc.core + sliapi-features + features + xml + ${project.version} + + + + org.openecomp.sdnc.core + sliapi-model + ${project.version} + + + org.openecomp.sdnc.core + sliapi-provider + ${project.version} + config + xml + + + org.openecomp.sdnc.core + sliapi-provider + ${project.version} + + + + + + + + model + features + provider + installer + + diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml new file mode 100755 index 000000000..b4a6ff0f5 --- /dev/null +++ b/sliapi/provider/pom.xml @@ -0,0 +1,144 @@ + + + 4.0.0 + + sliapi + org.openecomp.sdnc.core + 0.0.1-SNAPSHOT + + sliapi-provider + bundle + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.opendaylight.controller.config.yang.config.sliapi.impl + * + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${odl.yangtools.yang.maven.plugin.version} + + + config + + generate-sources + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + ${jmxGeneratorPath} + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + org.opendaylight.mdsal + maven-sal-api-gen-plugin + ${odl.sal.api.gen.plugin.version} + jar + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${odl.yang.jmx.generator.version} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/initial/sliapi-provider.xml + xml + config + + + + + + + + + + + + org.openecomp.sdnc.core + sliapi-model + + + org.opendaylight.controller + config-api + ${odl.controller.config.api.version} + + + + + org.opendaylight.controller + sal-binding-config + ${odl.mdsal.version} + + + + org.opendaylight.controller + sal-binding-api + ${odl.mdsal.version} + + + + org.opendaylight.controller + sal-common-util + ${odl.mdsal.version} + + + + + org.openecomp.sdnc.core + sli-common + ${project.version} + + + org.openecomp.sdnc.core + sli-provider + ${project.version} + + + org.opendaylight.controller + sal-core-api + ${odl.mdsal.version} + + + org.opendaylight.yangtools + yang-data-impl + ${odl.yangtools.version} + + + diff --git a/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/sliapi/provider/impl/rev140523/SliapiProviderModule.java b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/sliapi/provider/impl/rev140523/SliapiProviderModule.java new file mode 100644 index 000000000..e05103cd5 --- /dev/null +++ b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/sliapi/provider/impl/rev140523/SliapiProviderModule.java @@ -0,0 +1,59 @@ +/*- + * ============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========================================================= + */ + +package org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.provider.impl.rev140523; + +import org.openecomp.sdnc.sliapi.sliapiProvider; + +public class SliapiProviderModule extends org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.provider.impl.rev140523.AbstractSliapiProviderModule { + public SliapiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public SliapiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.provider.impl.rev140523.SliapiProviderModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + + final sliapiProvider provider = new sliapiProvider(); + provider.setDataBroker( getDataBrokerDependency() ); + provider.setNotificationService( getNotificationServiceDependency() ); + provider.setRpcRegistry( getRpcRegistryDependency() ); + provider.initialize(); + return new AutoCloseable() { + + @Override + public void close() throws Exception { + //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION + //SERVIE/RPC REGISTRY + provider.close(); + } + }; + } + +} diff --git a/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java new file mode 100644 index 000000000..fbd20365f --- /dev/null +++ b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java @@ -0,0 +1,34 @@ +/*- + * ============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========================================================= + */ + +/* +* Generated file +* +* Generated from: yang module name: slitester-provider-impl yang module local name: sliapi-provider-impl +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri Oct 21 10:42:49 EDT 2016 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.provider.impl.rev140523; +public class SliapiProviderModuleFactory extends org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.provider.impl.rev140523.AbstractSliapiProviderModuleFactory { + +} diff --git a/sliapi/provider/src/main/java/org/openecomp/sdnc/sliapi/SliapiHelper.java b/sliapi/provider/src/main/java/org/openecomp/sdnc/sliapi/SliapiHelper.java new file mode 100644 index 000000000..4ad4f0166 --- /dev/null +++ b/sliapi/provider/src/main/java/org/openecomp/sdnc/sliapi/SliapiHelper.java @@ -0,0 +1,40 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sliapi; + +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.openecomp.sdnc.sli.provider.MdsalHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SliapiHelper extends MdsalHelper { + + private static final Logger LOG = LoggerFactory.getLogger(SliapiHelper.class); + + static { + ExecuteGraphInputBuilder b1 = new ExecuteGraphInputBuilder(); + SliParameterBuilder b2 = new SliParameterBuilder(); + + } + +} diff --git a/sliapi/provider/src/main/java/org/openecomp/sdnc/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/openecomp/sdnc/sliapi/sliapiProvider.java new file mode 100644 index 000000000..705277c6e --- /dev/null +++ b/sliapi/provider/src/main/java/org/openecomp/sdnc/sliapi/sliapiProvider.java @@ -0,0 +1,557 @@ +/*- + * ============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========================================================= + */ + +package org.openecomp.sdnc.sliapi; + +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.Properties; +import java.util.concurrent.Future; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.binding.impl.AbstractForwardedDataBroker; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.ExecuteGraphInput; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.ExecuteGraphInput.Mode; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.ExecuteGraphOutput; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.ExecuteGraphOutputBuilder; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.HealthcheckOutput; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.HealthcheckOutputBuilder; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.SLIAPIService; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.TestResults; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.test.results.TestResult; +import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.sliapi.rev161110.test.results.TestResultBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; +import org.openecomp.sdnc.sli.provider.SvcLogicService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.Futures; + + +/** + * Defines a base implementation for your provider. This class extends from a helper class + * which provides storage for the most commonly used components of the MD-SAL. Additionally the + * base class provides some basic logging and initialization / clean up methods. + * + * To use this, copy and paste (overwrite) the following method into the TestApplicationProviderModule + * class which is auto generated under src/main/java in this project + * (created only once during first compilation): + * + *

+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+
+         final sliapiProvider provider = new sliapiProvider();
+         provider.setDataBroker( getDataBrokerDependency() );
+         provider.setNotificationService( getNotificationServiceDependency() );
+         provider.setRpcRegistry( getRpcRegistryDependency() );
+         provider.initialize();
+         return new AutoCloseable() {
+
+            @Override
+            public void close() throws Exception {
+                //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION
+                //SERVIE/RPC REGISTRY
+                provider.close();
+            }
+        };
+    }
+
+
+    
+ */ +public class sliapiProvider implements AutoCloseable, SLIAPIService{ + + private final Logger LOG = LoggerFactory.getLogger( sliapiProvider.class ); + private final String appName = "slitester"; + + protected DataBroker dataBroker; + protected DOMDataBroker domDataBroker; + protected NotificationProviderService notificationService; + protected RpcProviderRegistry rpcRegistry; + + protected BindingAwareBroker.RpcRegistration rpcRegistration; + + private static String SLIAPI_NAMESPACE = "org:openecomp:sdnc:sliapi"; + private static String SLIAPI_REVISION = "2016-11-10"; + + private static QName TEST_RESULTS_QNAME = null; + private static QName TEST_RESULT_QNAME = null; + private static QName TEST_ID_QNAME = null; + private static QName RESULTS_QNAME = null; + + static { + + TEST_RESULTS_QNAME = QName.create(SLIAPI_NAMESPACE, SLIAPI_REVISION, "test-results"); + TEST_RESULT_QNAME = QName.create(TEST_RESULTS_QNAME, "test-result"); + TEST_ID_QNAME = QName.create(TEST_RESULT_QNAME, "test-identifier"); + RESULTS_QNAME = QName.create(TEST_RESULT_QNAME, "results"); + } + + + public sliapiProvider() { + this.LOG.info( "Creating provider for " + appName ); + } + + public void initialize(){ + LOG.info( "Initializing provider for " + appName ); + //initialization code goes here. + + rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); + LOG.info( "Initialization complete for " + appName ); + } + + protected void initializeChild() { + //Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + LOG.info( "Closing provider for " + appName ); + //closing code goes here + + rpcRegistration.close(); + LOG.info( "Successfully closed provider for " + appName ); + } + + public void setDataBroker(DataBroker dataBroker) { + this.dataBroker = dataBroker; + if (dataBroker instanceof AbstractForwardedDataBroker) { + domDataBroker = ((AbstractForwardedDataBroker) dataBroker).getDelegate(); + } + if( LOG.isDebugEnabled() ){ + LOG.debug( "DataBroker set to " + (dataBroker==null?"null":"non-null") + "." ); + } + } + + public void setNotificationService( + NotificationProviderService notificationService) { + this.notificationService = notificationService; + if( LOG.isDebugEnabled() ){ + LOG.debug( "Notification Service set to " + (notificationService==null?"null":"non-null") + "." ); + } + } + + public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { + this.rpcRegistry = rpcRegistry; + if( LOG.isDebugEnabled() ){ + LOG.debug( "RpcRegistry set to " + (rpcRegistry==null?"null":"non-null") + "." ); + } + } + + @Override + public Future> executeGraph(ExecuteGraphInput input) { + RpcResult rpcResult = null; + + SvcLogicService svcLogic = getSvcLogicService(); + ExecuteGraphOutputBuilder respBuilder = new ExecuteGraphOutputBuilder(); + + String calledModule = input.getModuleName(); + String calledRpc = input.getRpcName(); + Mode calledMode = input.getMode(); + String modeStr = "sync"; + + if (calledMode == Mode.Async) { + modeStr = "async"; + } + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + + + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + respBuilder.setResponseCode("404"); + respBuilder.setResponseMessage("Directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr+" not found"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + } catch (Exception e) { + LOG.error("Caught exception looking for directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr, e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + + // Load properties + Properties parms = new Properties(); + + // Pass properties using names from sli-parameters + for (SliParameter sliParm : input.getSliParameter()) { + + String propValue = ""; + + Boolean boolval = sliParm.isBooleanValue(); + + if (boolval != null) { + propValue = boolval.toString(); + } else { + Integer intval = sliParm.getIntValue(); + if (intval != null) { + propValue = intval.toString(); + } else { + propValue = sliParm.getStringValue(); + if (propValue == null) { + propValue = ""; + } + } + } + parms.setProperty(sliParm.getParameterName(), propValue); + } + + // Also, pass "meta" properties (i.e. pass SliParameter objects themselves) + ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder(input); + + SliapiHelper.toProperties(parms, "input", inputBuilder); + + try { + LOG.info("Calling directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr); + + if (LOG.isTraceEnabled()) { + StringBuffer argList = new StringBuffer(); + argList.append("Parameters : {"); + Enumeration e = parms.propertyNames(); + while (e.hasMoreElements()) { + String propName = (String) e.nextElement(); + argList.append(" ("+propName+","+parms.getProperty(propName)+") "); + } + argList.append("}"); + LOG.trace(argList.toString()); + argList = null; + } + + + + Properties respProps = svcLogic.execute(calledModule, calledRpc, + null, modeStr, parms, domDataBroker); + + StringBuilder sb = new StringBuilder("{"); + + for (Object key : respProps.keySet()) { + String keyValue = (String) key; + if (keyValue != null && !"".equals(keyValue) && !keyValue.contains("input.sli-parameter")) { + sb.append("\"").append(keyValue).append("\": \"").append(respProps.getProperty(keyValue)).append("\","); + } + } + + sb.setLength(sb.length() - 1); + sb.append("}"); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", ""));// TODO change response-text to response-message to match other BVC APIs + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + respBuilder.setContextMemoryJson(sb.toString()); + + TestResultBuilder testResultBuilder = new TestResultBuilder(); + + SliapiHelper.toBuilder(respProps, testResultBuilder); + + String testIdentifier = testResultBuilder.getTestIdentifier(); + + if ((testIdentifier != null) && (testIdentifier.length() > 0)) { + + // Add test results to config tree + LOG.debug("Saving test results for test id "+testIdentifier); + + DomSaveTestResult(testResultBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + + } + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + + calledModule + ":" + calledRpc + "," + modeStr + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder + .setResponseMessage("Internal error : caught exception executing directed graph " + + calledModule + + "/" + + calledRpc + + "/" + + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder. status(true) + .withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + + private SvcLogicService getSvcLogicService() { + BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext(); + + SvcLogicService svcLogic = null; + + // Get SvcLogicService reference + ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME); + if (sref != null) + { + svcLogic = (SvcLogicService) bctx.getService(sref); + + } + else + { + LOG.warn("Cannot find service reference for "+SvcLogicService.NAME); + + } + + return(svcLogic); + } + + @Override + public Future> healthcheck() { + + RpcResult rpcResult = null; + SvcLogicService svcLogic = getSvcLogicService(); + + HealthcheckOutputBuilder respBuilder = new HealthcheckOutputBuilder(); + + String calledModule = "sli"; + String calledRpc = "healthcheck"; + String modeStr = "sync"; + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. failed().withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + respBuilder.setResponseCode("404"); + respBuilder.setResponseMessage("Directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr+" not found"); + + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + } catch (Exception e) { + LOG.error("Caught exception looking for directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr, e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. failed().withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + + try { + LOG.info("Calling directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr); + + Properties parms = new Properties(); + + Properties respProps = svcLogic.execute(calledModule, calledRpc, + null, modeStr, parms); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + + calledModule + ":" + calledRpc + "," + modeStr + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder + .setResponseMessage("Internal error : caught exception executing directed graph " + + calledModule + + "/" + + calledRpc + + "/" + + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder. status(true) + .withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + private void DomSaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) { + + + if (domDataBroker == null) { + LOG.error("domDataBroker unset - cannot save test result using DOMDataBroker"); + return; + } + + MapEntryNode resultNode = null; + + try { + resultNode = toMapEntryNode(entry); + } catch (Exception e) { + LOG.error("Caught exception trying to create map entry node", e); + } + + if (resultNode == null) { + LOG.error("Could not convert entry to MapEntryNode"); + return; + } + + + YangInstanceIdentifier testResultsPid = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME).node(QName.create(TEST_RESULTS_QNAME, "test-result")).build(); + YangInstanceIdentifier testResultPid = testResultsPid.node(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, resultNode.getIdentifier().getKeyValues())); + + + + int tries = 2; + while(true) { + try { + DOMDataWriteTransaction wtx = domDataBroker.newWriteOnlyTransaction(); + if (merge) { + LOG.info("Merging test identifier "+entry.getTestIdentifier()); + wtx.merge(storeType, testResultPid, resultNode); + } else { + LOG.info("Putting test identifier "+entry.getTestIdentifier()); + wtx.put(storeType, testResultPid, resultNode); + } + wtx.submit().checkedGet(); + LOG.trace("Update DataStore succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if(e instanceof OptimisticLockFailedException) { + if(--tries <= 0) { + LOG.trace("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + LOG.trace("Got OptimisticLockFailedException - trying again "); + } else { + LOG.trace("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + + } + + private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException + { + // Each entry will be identifiable by a unique key, we have to create that identifier + InstanceIdentifier.InstanceIdentifierBuilder testResultIdBuilder = + InstanceIdentifier.builder(TestResults.class) + .child(TestResult.class, entry.getKey()); + InstanceIdentifier path = testResultIdBuilder.toInstance(); + int tries = 2; + while(true) { + try { + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); + if (merge) { + tx.merge(storeType, path, entry); + } else { + tx.put(storeType, path, entry); + } + tx.submit().checkedGet(); + LOG.trace("Update DataStore succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if(e instanceof OptimisticLockFailedException) { + if(--tries <= 0) { + LOG.trace("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + LOG.trace("Got OptimisticLockFailedException - trying again "); + } else { + LOG.trace("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + } + + private MapEntryNode toMapEntryNode(TestResult testResult) { + + + YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME).node(TEST_RESULT_QNAME).build(); + + // Construct results list + LinkedList> entryList = new LinkedList>(); + for (String result : testResult.getResults()) { + LeafSetEntryNode leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create() + .withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result)) + .withValue(result) + .build(); + entryList.add(leafSetEntryNode); + } + // Construct results LeafSetNode + LeafSetNode resultsNode = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(RESULTS_QNAME)).withValue(entryList).build(); + + + + // Construct test result ContainerNode with 2 children - test-identifier leaf and results leaf-set + MapEntryNode testResultNode = ImmutableNodes.mapEntryBuilder() + .withNodeIdentifier(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, TEST_ID_QNAME, testResult.getTestIdentifier())) + .withChild(ImmutableNodes.leafNode(TEST_ID_QNAME, testResult.getTestIdentifier())) + .withChild(resultsNode) + .build(); + + return(testResultNode); + + } + +} diff --git a/sliapi/provider/src/main/resources/initial/sliapi-provider.xml b/sliapi/provider/src/main/resources/initial/sliapi-provider.xml new file mode 100644 index 000000000..fd2ccbeeb --- /dev/null +++ b/sliapi/provider/src/main/resources/initial/sliapi-provider.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + prefix:sliapi-provider-impl + + sliapi-provider-impl + + + + binding:binding-rpc-registry + binding-rpc-broker + + + + binding:binding-async-data-broker + binding-data-broker + + + + + binding:binding-notification-service + + binding-notification-broker + + + + + + + + + + + org:openecomp:sdnc:sliapi:provider:impl?module=sliapi-provider-impl&revision=2014-05-23 + + + diff --git a/sliapi/provider/src/main/yang/sliapi-provider-impl.yang b/sliapi/provider/src/main/yang/sliapi-provider-impl.yang new file mode 100755 index 000000000..b32ff6c3d --- /dev/null +++ b/sliapi/provider/src/main/yang/sliapi-provider-impl.yang @@ -0,0 +1,61 @@ +module sliapi-provider-impl { + + yang-version 1; + namespace "org:openecomp:sdnc:sliapi:provider:impl"; + prefix "sliapi-provider-impl"; + + import config { prefix config; revision-date 2013-04-05; } + import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } + + description + "This module contains the base YANG definitions for + sliapi-provider impl implementation."; + + revision "2014-05-23" { + description + "Initial revision."; + } + + // This is the definition of the service implementation as a module identity. + identity sliapi-provider-impl { + base config:module-type; + + // Specifies the prefix for generated java classes. + config:java-name-prefix sliapiProvider; + } + + // Augments the 'configuration' choice node under modules/module. + // We consume the three main services, RPCs, DataStore, and Notifications + augment "/config:modules/config:module/config:configuration" { + case sliapi-provider-impl { + when "/config:modules/config:module/config:type = 'sliapi-provider-impl'"; + + container rpc-registry { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity mdsal:binding-rpc-registry; + } + } + } + + container notification-service { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity mdsal:binding-notification-service; + } + } + } + + container data-broker { + uses config:service-ref { + refine type { + mandatory false; + config:required-identity mdsal:binding-async-data-broker; + } + } + } + } + } +} diff --git a/src/site/apt/nodes.apt b/src/site/apt/nodes.apt new file mode 100644 index 000000000..b8ce9879a --- /dev/null +++ b/src/site/apt/nodes.apt @@ -0,0 +1,953 @@ +~~~ +~~ ============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========================================================= +~~~ + + --- + Service Logic Interpreter + --- + Dan Timoney + --- + 2014-11-12 + --- + +Supported node types + + The following built-in node types are currently supported: + + * Flow Control + + * {{{Block node}<>}} + + * {{{Call node}<>}} + + * {{{For node}<>}} + + * {{{Return node}<>}} + + * {{{Set node}<>}} + + * {{{Switch node}<>}} + + * Device Management + + * {{{Configure node}<>}} + + * Java Plugin Support + + * {{{Execute node}<>}} + + * Recording + + * {{{Record node}<>}} + + * Resource Management + + * {{{Delete node}<>}} + + * {{{Exists node}<>}} + + * {{{Get-resource node}<>}} + + * {{{Is-available node}<>}} + + * {{{Notify node}<>}} + + * {{{Release node}<>}} + + * {{{Reserve node}<>}} + + * {{{Save node}<>}} + + * {{{Update node}<>}} + + +* Flow Control + +** Block node + +*** Description + + A <> node is used to executes a set of nodes. + +*** Attributes + +*--------------*--------------------------------------------+ +| <> | if , then if a node returns failure, subsequent nodes will not be executed and nodes already executed will be backed out. +*--------------*--------------------------------------------+ + +*** Parameters + + None + +*** Outcomes + + None + +*** Example + ++-----------------+ + + + + + + + + + + + ++-----------------+ + + + +**Call node + +*** Description + + A <> node is used to call another graph + +*** Attributes + +*--------------*-------+ +| <> | Module of directed graph to call. If unset, defaults to that of calling graph +*--------------*-------+ +| <> | rpc of directed graph to call. +*--------------*-------+ +| <> | version of graph to call, If unset, uses active version. +*--------------*-------+ +| <> | mode (sync/async) of graph to call. If unset, defaults to that of calling graph. +*--------------*-------+ + + + +*** Parameters + + Not applicable + +*** Outcomes + +*----------*---------+ +| <> | Sub graph returned success +*----------*---------+ +| <> | Graph not found +*----------*---------+ +| <> | Subgraph returned success +*----------*---------+ + . + +*** Example + ++-------------------+ + ++-------------------+ + +**For node + +*** Description + + A <> node provides a fixed iteration looping mechanism, similar to the Java for loop + +*** Attributes + +*--------------*-------+ +| <> | index variable +*--------------*-------+ +| <> | initial value +*--------------*-------+ +| <> | maximum value +*--------------*-------+ + + +*** Parameters + + Not applicable. + +*** Outcomes + + Not applicable. The <> node has no outcomes. + +*** Example + ++-------------------+ + + + + + + + ++-------------------+ + +**Return node + +*** Description + + A <> node is used to return a status to the invoking MD-SAL application + +*** Attributes + +*--------------*-------+ +| <> | Status value to return ( or ) +*--------------*-------+ + + +*** Parameters + + The following optional parameters may be passed to convey more + detailed status information. + +*------------*-----------+ +| <> | A brief, usually numeric, code indicating the error condition +*------------*-----------+ +| <> | A more detailed error message +*------------*-----------+ + +*** Outcomes + + Not applicable. The <> node has no outcomes. + +*** Example + ++-------------------+ + + + + ++-------------------+ + +**Set node + +*** Description + + A <> node is used to set one or more values in the execution context + +*** Attributes + +*--------------*-------+ +| <> | If true the set node will only execute if the current value of the target is null +*--------------*-------+ + +*** Parameters + + Values to be set are passed as parameters + +*** Outcomes + + Not applicable. The <> node has no outcomes. + +*** Example + ++-------------------+ + + + ++-------------------+ + +**Switch node + +*** Description + + A <> node is used to make a decision based on its <> attribute. + +*** Attributes + +*--------------*-------+ +| <> | Condition to test +*--------------*-------+ + + +*** Parameters + + None + + +*** Outcomes + + Depends on the <> condition + +*** Example + ++-------------------+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++-------------------+ + +* Device Management + +**Configure node + +*** Description + + A <> node is used to configure a device. + +*** Attributes + +*--------------*-------+ +| <> | Fully qualified Java class of resource adaptor to be used +*--------------*-------+ +| <> | Activate device/interface, for devices that support a separate activation step. +*--------------*-------+ +| <> | SQL-like string specifying criteria for item to configure +*--------------*-------+ + +*** Parameters + + Specific to device adaptor. + +*** Outcomes + +*-----------*-------+ +| <> | Device successfully configured +*-----------*-------+ +| <> | Element to be configured does not exist. +*-----------*--------+ +| <> | Element is not in a state where it can be configured/activated +*-----------*-------+ +| <> | Attempt to activate element that is already active +*-----------*-------+ +| <> | Configure failed for some other reason +*-----------*-------+ + +*** Example + ++-------------------+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++-------------------+ + +* Java Plugin Support + +**Execute node + +*** Description + + An <> node is used to execute Java code supplied as a plugin + +*** Attributes + +*--------------*-------+ +| <> | Fully qualified Java class of plugin to be used +*--------------*-------+ +| <> | Name of method in the plugin class to execute. Method must return void, and take 2 arguments: a Map (for parameters) and a SvcLogicContext (to allow plugin read/write access to context memory) +*--------------*-------+ + +*** Parameters + + Specific to plugin / method + +*** Outcomes + +*-----------*-------+ +| <> | Device successfully configured +*-----------*-------+ +| <> | Plugin class could not be loaded +*-----------*--------+ +| <> | Named method taking (Map, SvcLogicContext) could not be found +*-----------*-------+ +| <> | Configure failed for some other reason +*-----------*-------+ + +*** Example + ++-------------------+ + + + + + + + + + + + + + + + + + + ++-------------------+ + +* Recording + +** Record node + +*** Description + + A <> node is used to record an event. For example, this might be used + to log provisioning events. + +*** Attributes + +*--------------*-------+ +| <> | Fully qualified Java class to handle recording. +*--------------*-------+ + + +*** Parameters + + Parameters will depend on the plugin being used. For the FileRecorder class, + the parameters are as follows + +*------------*-----------+ +| <> | The file to which the record should be written +*------------*-----------+ +| <> | First field to write. There will be <> parameters for each field to write, from <> through <>. A special value __TIMESTAMP__ may be assigned to a field to insert the current timestamp +*------------*-----------+ + + +*** Outcomes + +*----------*---------+ +| <> | Record successfully written +*----------*---------+ +| <> | Record could not be successfully written +*----------*---------+ + +*** Example + ++-------------------+ + + + + + + ++-------------------+ + +* Resource Management + +** Delete node + +*** Description + + A <> node is used to delete a resource from the local resource inventory. + +*** Attributes + +*--------------*-------+ +| <> | Fully qualified Java class of resource adaptor to be used +*--------------*-------+ +| <> | Type of resource to delete +*--------------*-------+ +| <> | SQL-like string specifying key to delete +*--------------*-------+ + +*** Parameters + + None + +*** Outcomes + +*-----------*-------+ +| <> | Resource specified deleted successfully. +*-----------*-------+ +| > | Resource specified was not deleted +*-----------*-------+ + +*** Example + ++-------------------+ + + + + + + + + ++-------------------+ + + +** Exists node + +*** Description + + An <> node is used to determine whether a particular + instance of a resource exists. For example, this might be + used to test whether a particular switch CLLI is provisioned. + +*** Attributes + +*--------------*-------+ +| <> | Fully qualified Java class of resource adaptor to be used +*--------------*-------+ +| <> | Type of resource to check +*--------------*-------+ +| <> | SQL-like string specifying key to check for +*--------------*-------+ + +*** Parameters + + None + +*** Outcomes + +*-----------*-------+ +| <> | Resource specified exists. +*-----------*-------+ +| <> | Resource specified is unknown +*-----------*-------+ + +*** Example + ++-------------------+ + + + + + + + + ++-------------------+ + +** Get-resource node + +*** Description + + A <> node is used to retrieve information about a + particular resource and make it available to other nodes in the + service logic tree. For example, this might be used to + retrieve information about a particular uni-port. + +*** Attributes + +*--------------*-------+ +| <> | Fully qualified Java class of resource adaptor to be used +*--------------*-------+ +| <> | Type of resource to retrieve +*--------------*-------+ +| <> | SQL-like string specifying criteria for retrieval +*--------------*-------+ +| <> | Prefix to add to context variable names set for data retrieved +*--------------*-------+ +| <> | String to specify, if <> matches multiple entries, which entry should take precedence +*--------------*-------+ + +*** Parameters + + None + +*** Outcomes + +*-----------*-------+ +| <> | Resource requested was successfully reserved +*-----------*-------+ +| <> | Resource requested was not successfully reserved +*-----------*-------+ + +*** Example + ++-------------------+ + + + + + + + + ++-------------------+ + +** Save node + +*** Description + + A <> node is used to save information about a + particular resource to persistent storage. For example, this might be used to + save information about a particular uni-port. + +*** Attributes + +*--------------*-------+ +| <> | Fully qualified Java class of resource adaptor to be used +*--------------*-------+ +| <> | Type of resource to save +*--------------*-------+ +| <> | SQL-like string specifying criteria for retrieval +*--------------*-------+ +| <> | If "true", save resource even if this resource is already stored in persistent storage +*--------------*-------+ +| <> | Prefix to be prepended to variable names, when attributes are set in SvcLogicContext +*--------------*-------+ + +*** Parameters + + Values to save (columns) are specified as parameters, with each name + corresponding to a column name and each value corresponding to the + value to set. + +*** Outcomes + +*-----------*-------+ +| <> | Resource successfully saved +*-----------*-------+ +| <> | Resource save failed +*-----------*-------+ + +*** Example + ++-------------------+ + + + + + + + + ++-------------------+ + +** Update node + +*** Description + + An <> node is used to update information about a + particular resource to persistent storage. + +*** Attributes + +*--------------*-------+ +| <> | Fully qualified Java class of resource adaptor to be used +*--------------*-------+ +| <> | Type of resource to update +*--------------*-------+ +| <> | SQL-like string specifying criteria for retrieval +*--------------*-------+ +| <> | Prefix to be prepended to variable names, when attributes are set in SvcLogicContext +*--------------*-------+ + +*** Parameters + + Values to save (columns) are specified as parameters, with each name + corresponding to a column name and each value corresponding to the + value to set. + +*** Outcomes + +*-----------*-------+ +| <> | Resource successfully saved +*-----------*-------+ +| <> | Resource save failed +*-----------*-------+ + +*** Example + ++-------------------+ + + + + + + + + ++-------------------+ + diff --git a/src/site/site.xml b/src/site/site.xml new file mode 100644 index 000000000..7da1eb9fb --- /dev/null +++ b/src/site/site.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/version.properties b/version.properties new file mode 100644 index 000000000..f78b4bdf5 --- /dev/null +++ b/version.properties @@ -0,0 +1,15 @@ +########################################################### +# Versioning variables +# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... ) +# because they are used in Jenkins, whose plug-in doesn't support + + +release_name=1 +sprint_number=1 +feature_revision=2 + +base_version=${release_name}.${sprint_number}.${feature_revision} + +release_version=${base_version} +snapshot_version=${base_version}-SNAPSHOT + -- cgit 1.2.3-korg From e72db85fc2c97226a1aace287651cc8238c4e3eb Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 21 Jul 2017 08:34:58 -0400 Subject: Fix mvn deploy Mvn deploy failed due to credentials issue. Seems like distributionManagement section from parent pom was not processed correctly. Copied that section to top level pom.xml Issue: CCSDK-6 Change-Id: Ib508169bd3cc93ffd82aa0b865cea441b0e30c9b Signed-off-by: Dan Timoney --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index bb0df7e78..d89d59e6d 100755 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,16 @@ + + ecomp-releases + onap-repository-releases + ${onap.nexus.release-url} + + + ecomp-snapshots + onap-repository-snapshots + ${onap.nexus.snapshot-url} + ecomp-site dav:https://${onap.nexus.host}/content/sites/site/org/onap/sdnc/core/${project.artifactId}/${project.version} -- cgit 1.2.3-korg From c95543bf425024f5bd4a127422251b72e408ce2b Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 21 Jul 2017 10:45:06 -0400 Subject: Update groupId to org.onap.ccsdk.sli Update groupIds from org.openecomp.sdnc.core to org.onap.ccsdk.sli.core Issue: CCSDK-11 Change-Id: I0646adab34a88244ab10dc0d2775643ce2bb974d Signed-off-by: Dan Timoney --- dblib/features/pom.xml | 4 +-- dblib/features/src/main/resources/features.xml | 2 +- dblib/installer/pom.xml | 10 +++---- dblib/pom.xml | 4 +-- dblib/provider/pom.xml | 2 +- filters/features/pom.xml | 4 +-- filters/features/src/main/resources/features.xml | 2 +- filters/installer/pom.xml | 10 +++---- filters/pom.xml | 4 +-- filters/provider/pom.xml | 4 +-- pom.xml | 2 +- sli/common/pom.xml | 4 +-- sli/features/pom.xml | 6 ++-- sli/features/src/main/resources/features.xml | 6 ++-- sli/installer/pom.xml | 14 ++++----- .../src/assembly/assemble_mvnrepo_zip.xml | 35 +++++++++------------- sli/pom.xml | 12 ++++---- sli/provider/pom.xml | 4 +-- sli/recording/pom.xml | 4 +-- sliPluginUtils/features/pom.xml | 4 +-- .../features/src/main/resources/features.xml | 2 +- sliPluginUtils/installer/pom.xml | 10 +++---- sliPluginUtils/pom.xml | 8 ++--- sliPluginUtils/provider/pom.xml | 4 +-- sliapi/features/pom.xml | 8 ++--- sliapi/features/src/main/resources/features.xml | 6 ++-- sliapi/installer/pom.xml | 10 +++---- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 12 ++++---- sliapi/provider/pom.xml | 8 ++--- 30 files changed, 100 insertions(+), 107 deletions(-) diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 6c174b1c8..b8b211c6e 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -3,7 +3,7 @@ 4.0.0 dblib - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT dblib-features @@ -15,7 +15,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core dblib-provider ${project.version} diff --git a/dblib/features/src/main/resources/features.xml b/dblib/features/src/main/resources/features.xml index 0c3e8fe38..5f339cba0 100755 --- a/dblib/features/src/main/resources/features.xml +++ b/dblib/features/src/main/resources/features.xml @@ -11,7 +11,7 @@ odl-mdsal-broker wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=com.mysql.*&overwrite=merge - mvn:org.openecomp.sdnc.core/dblib-provider/${project.version} + mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} mvn:mysql/mysql-connector-java/${mysql.connector.version} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 9da6a459f..a06a3969a 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -3,7 +3,7 @@ 4.0.0 dblib - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT dblib-installer @@ -13,14 +13,14 @@ sdnc-dblib sdnc-dblib - mvn:org.openecomp.sdnc.core/dblib-features/${project.version}/xml/features + mvn:org.onap.ccsdk.sli.core/dblib-features/${project.version}/xml/features false - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core dblib-features ${project.version} features @@ -34,7 +34,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core dblib-provider ${project.version} @@ -103,7 +103,7 @@ true false false - org.openecomp.sdnc,org.apache.tomcat + org.onap.ccsdk.sli,org.apache.tomcat sli-common,sli-provider provided diff --git a/dblib/pom.xml b/dblib/pom.xml index 78af665af..722b2d7c6 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -1,7 +1,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sdnc-core 0.0.1-SNAPSHOT @@ -9,7 +9,7 @@ 4.0.0 pom - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index b5acc7e14..078c75499 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core dblib 0.0.1-SNAPSHOT diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 1e3875deb..456b6a475 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -3,7 +3,7 @@ 4.0.0 filters - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT filters-features @@ -15,7 +15,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core filters-provider ${project.version} diff --git a/filters/features/src/main/resources/features.xml b/filters/features/src/main/resources/features.xml index 1c58e6490..d0cadff25 100644 --- a/filters/features/src/main/resources/features.xml +++ b/filters/features/src/main/resources/features.xml @@ -26,7 +26,7 @@ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> - mvn:org.openecomp.sdnc.core/filters-provider/${project.version} + mvn:org.onap.ccsdk.sli.core/filters-provider/${project.version} diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 579c0e9a5..ff09b43d0 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core filters 0.0.1-SNAPSHOT @@ -13,14 +13,14 @@ sdnc-filters sdnc-filters - mvn:org.openecomp.sdnc.core/filters-features/${project.version}/xml/features + mvn:org.onap.ccsdk.sli.core/filters-features/${project.version}/xml/features false - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core filters-features ${project.version} features @@ -34,7 +34,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core filters-provider ${project.version} @@ -98,7 +98,7 @@ true false false - org.openecomp.sdnc + org.onap.ccsdk.sli sli-common,sli-provider provided diff --git a/filters/pom.xml b/filters/pom.xml index b075be985..cbc8f5873 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -2,14 +2,14 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sdnc-core 0.0.1-SNAPSHOT 4.0.0 pom - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index a7b6daec1..83982c7d2 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core filters 0.0.1-SNAPSHOT @@ -50,7 +50,7 @@ ${commons.codec.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common ${project.version} diff --git a/pom.xml b/pom.xml index d89d59e6d..8e9d10b60 100755 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 pom - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sdnc-core SDN-C Core Components diff --git a/sli/common/pom.xml b/sli/common/pom.xml index ce98b947c..9a49e69e4 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -2,7 +2,7 @@ 4.0.0 sli - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT sli-common @@ -84,7 +84,7 @@ compile - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core dblib-provider ${sdnctl.dblib.version} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 2556a5795..f5acafa4b 100755 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -3,7 +3,7 @@ 4.0.0 sli - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT sli-features @@ -13,14 +13,14 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common ${project.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-recording ${project.version} diff --git a/sli/features/src/main/resources/features.xml b/sli/features/src/main/resources/features.xml index e1ce255a5..65fe187b8 100644 --- a/sli/features/src/main/resources/features.xml +++ b/sli/features/src/main/resources/features.xml @@ -29,9 +29,9 @@ odl-mdsal-broker - mvn:org.openecomp.sdnc.core/sli-common/${project.version} - mvn:org.openecomp.sdnc.core/sli-provider/${project.version} - mvn:org.openecomp.sdnc.core/sli-recording/${project.version} + mvn:org.onap.ccsdk.sli.core/sli-common/${project.version} + mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version} + mvn:org.onap.ccsdk.sli.core/sli-recording/${project.version} sdnc-dblib mvn:mysql/mysql-connector-java/${mysql.connector.version} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index d43769e28..905a77dd7 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -3,7 +3,7 @@ 4.0.0 sli - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT sli-installer @@ -13,14 +13,14 @@ sdnc-sli sdnc-sli - mvn:org.openecomp.sdnc.core/sli-features/${project.version}/xml/features + mvn:org.onap.ccsdk.sli.core/sli-features/${project.version}/xml/features false - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-features ${project.version} features @@ -34,19 +34,19 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common ${project.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-provider ${project.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-recording ${project.version} @@ -109,7 +109,7 @@ true false false - org.openecomp.sdnc + org.onap.ccsdk.sli dblib-provider provided diff --git a/sli/installer/src/assembly/assemble_mvnrepo_zip.xml b/sli/installer/src/assembly/assemble_mvnrepo_zip.xml index 38e6d47b1..4ea9baeaa 100644 --- a/sli/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/sli/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -1,23 +1,17 @@ - + 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========================================================= --> @@ -25,14 +19,13 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - bin - - zip + bin + + zip - + false diff --git a/sli/pom.xml b/sli/pom.xml index 53a8b6298..2dda89f5f 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -3,20 +3,20 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sdnc-core 0.0.1-SNAPSHOT 4.0.0 pom - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-features features xml @@ -24,19 +24,19 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common ${project.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-provider ${project.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-recording ${project.version} diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index f73d0071a..69412bb31 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli 0.0.1-SNAPSHOT @@ -20,7 +20,7 @@ test - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common ${project.version} compile diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 4fb4a797b..952f6460a 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli 0.0.1-SNAPSHOT @@ -20,7 +20,7 @@ test - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common ${project.version} compile diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 9d189177e..c90cfc260 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -7,7 +7,7 @@ sliPluginUtils - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT @@ -15,7 +15,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliPluginUtils-provider ${project.version} diff --git a/sliPluginUtils/features/src/main/resources/features.xml b/sliPluginUtils/features/src/main/resources/features.xml index c7dca2e5a..212c39745 100644 --- a/sliPluginUtils/features/src/main/resources/features.xml +++ b/sliPluginUtils/features/src/main/resources/features.xml @@ -32,7 +32,7 @@ odl-mdsal-broker sdnc-sli - mvn:org.openecomp.sdnc.core/sliPluginUtils-provider/${project.version} + mvn:org.onap.ccsdk.sli.core/sliPluginUtils-provider/${project.version} mvn:mysql/mysql-connector-java/${mysql.connector.version} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 6520867bf..2744f7dae 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -3,7 +3,7 @@ 4.0.0 sliPluginUtils - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT sliPluginUtils-installer @@ -13,14 +13,14 @@ sdnc-sliPluginUtils sdnc-sliPluginUtils - mvn:org.openecomp.sdnc.core/sliPluginUtils-features/${project.version}/xml/features + mvn:org.onap.ccsdk.sli.core/sliPluginUtils-features/${project.version}/xml/features false - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliPluginUtils-features ${project.version} features @@ -34,7 +34,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliPluginUtils-provider ${project.version} @@ -98,7 +98,7 @@ true false false - org.openecomp.sdnc + org.onap.ccsdk.sli sli-common,sli-provider,dblib-provider provided diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index a14b41ff8..bb6cad3f6 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -1,7 +1,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliPluginUtils 0.0.1-SNAPSHOT pom @@ -9,7 +9,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sdnc-core 0.0.1-SNAPSHOT @@ -19,14 +19,14 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core SliPluginUtils-features features xml ${project.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core SliPluginUtils-provider ${project.version} diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index cad7a0bcc..cd240d162 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -6,7 +6,7 @@ 4.0.0 - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliPluginUtils 0.0.1-SNAPSHOT @@ -26,7 +26,7 @@ test - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common ${project.version} compile diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index fcc08eb7d..1fc0f61be 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -3,7 +3,7 @@ 4.0.0 sliapi - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT sliapi-features @@ -12,17 +12,17 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-model - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-provider config xml - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-provider diff --git a/sliapi/features/src/main/resources/features.xml b/sliapi/features/src/main/resources/features.xml index 630b11157..51f365a1c 100644 --- a/sliapi/features/src/main/resources/features.xml +++ b/sliapi/features/src/main/resources/features.xml @@ -31,9 +31,9 @@ odl-mdsal-broker sdnc-sli - mvn:org.openecomp.sdnc.core/sliapi-model/${project.version} - mvn:org.openecomp.sdnc.core/sliapi-provider/${project.version} - mvn:org.openecomp.sdnc.core/sliapi-provider/${project.version}/xml/config + mvn:org.onap.ccsdk.sli.core/sliapi-model/${project.version} + mvn:org.onap.ccsdk.sli.core/sliapi-provider/${project.version} + mvn:org.onap.ccsdk.sli.core/sliapi-provider/${project.version}/xml/config diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index a0204f3b5..36570cded 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -3,7 +3,7 @@ 4.0.0 sliapi - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT sliapi-installer @@ -12,14 +12,14 @@ sdnc-sliapi sdnc-sliapi - mvn:org.openecomp.sdnc.core/sliapi-features/${project.version}/xml/features + mvn:org.onap.ccsdk.sli.core/sliapi-features/${project.version}/xml/features false - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-features ${project.version} features @@ -33,7 +33,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-provider ${project.version} @@ -97,7 +97,7 @@ true false false - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common,sli-provider,dblib-provider provided diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index be8c8b3c0..17bee5a99 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -3,7 +3,7 @@ 4.0.0 sliapi - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT sliapi-model diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 06ee5e0ed..1ca872e1f 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -4,13 +4,13 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sdnc-core 0.0.1-SNAPSHOT pom - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi 0.0.1-SNAPSHOT @@ -23,7 +23,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-features features xml @@ -31,19 +31,19 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-model ${project.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-provider ${project.version} config xml - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-provider ${project.version} diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index b4a6ff0f5..d5f491771 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -3,7 +3,7 @@ 4.0.0 sliapi - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core 0.0.1-SNAPSHOT sliapi-provider @@ -91,7 +91,7 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sliapi-model @@ -121,12 +121,12 @@ - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-common ${project.version} - org.openecomp.sdnc.core + org.onap.ccsdk.sli.core sli-provider ${project.version} -- cgit 1.2.3-korg From 32f16144e17d2df0831f14d9e65a83756a6ef844 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 27 Jul 2017 16:32:20 -0400 Subject: Refactor dblib Changed openecomp references in dblib, filters and sli to onap. Note: these must be committed together to get a clean compile. Issue: CCSDK-11 Change-Id: Ibe0f64fb20f3ae9cdda2f7ea969ca722bbde0d15 Signed-off-by: Dan Timoney --- dblib/pom.xml | 4 +- dblib/provider/pom.xml | 9 +- .../ccsdk/sli/core/dblib/CachedDataSource.java | 617 ++++++++++ .../sli/core/dblib/CachedDataSourceFactory.java | 45 + .../ccsdk/sli/core/dblib/DBConfigException.java | 47 + .../sli/core/dblib/DBLIBResourceActivator.java | 130 +++ .../onap/ccsdk/sli/core/dblib/DBLibConnection.java | 390 +++++++ .../onap/ccsdk/sli/core/dblib/DBLibException.java | 39 + .../ccsdk/sli/core/dblib/DBResourceManager.java | 863 ++++++++++++++ .../ccsdk/sli/core/dblib/DBResourceObserver.java | 27 + .../onap/ccsdk/sli/core/dblib/DataAccessor.java | 33 + .../ccsdk/sli/core/dblib/DataSourceComparator.java | 33 + .../onap/ccsdk/sli/core/dblib/DbLibService.java | 46 + .../core/dblib/DblibConfigurationException.java | 45 + .../dblib/NoAvailableConnectionsException.java | 36 + .../core/dblib/TerminatingCachedDataSource.java | 82 ++ .../sli/core/dblib/config/BaseDBConfiguration.java | 104 ++ .../ccsdk/sli/core/dblib/config/DbConfigPool.java | 56 + .../sli/core/dblib/config/JDBCConfiguration.java | 31 + .../factory/AbstractDBResourceManagerFactory.java | 39 + .../factory/AbstractResourceManagerFactory.java | 104 ++ .../sli/core/dblib/factory/DBConfigFactory.java | 99 ++ .../dblib/factory/FactoryNotDefinedException.java | 37 + .../core/dblib/jdbc/JdbcDBCachedDataSource.java | 249 ++++ .../dblib/jdbc/JdbcDbResourceManagerFactory.java | 186 +++ .../sli/core/dblib/jdbc/MySQLCachedDataSource.java | 217 ++++ .../ccsdk/sli/core/dblib/pm/PollingWorker.java | 217 ++++ .../sli/core/dblib/pm/SQLExecutionMonitor.java | 237 ++++ .../core/dblib/pm/SQLExecutionMonitorObserver.java | 37 + .../sdnc/sli/resource/dblib/CachedDataSource.java | 616 ---------- .../resource/dblib/CachedDataSourceFactory.java | 45 - .../sdnc/sli/resource/dblib/DBConfigException.java | 47 - .../sli/resource/dblib/DBLIBResourceActivator.java | 130 --- .../sdnc/sli/resource/dblib/DBLibConnection.java | 390 ------- .../sdnc/sli/resource/dblib/DBLibException.java | 39 - .../sdnc/sli/resource/dblib/DBResourceManager.java | 862 -------------- .../sli/resource/dblib/DBResourceObserver.java | 27 - .../sdnc/sli/resource/dblib/DataAccessor.java | 33 - .../sli/resource/dblib/DataSourceComparator.java | 33 - .../sdnc/sli/resource/dblib/DbLibService.java | 46 - .../dblib/DblibConfigurationException.java | 45 - .../dblib/NoAvailableConnectionsException.java | 36 - .../dblib/TerminatingCachedDataSource.java | 82 -- .../resource/dblib/config/BaseDBConfiguration.java | 104 -- .../sli/resource/dblib/config/DbConfigPool.java | 56 - .../resource/dblib/config/JDBCConfiguration.java | 31 - .../factory/AbstractDBResourceManagerFactory.java | 39 - .../factory/AbstractResourceManagerFactory.java | 104 -- .../resource/dblib/factory/DBConfigFactory.java | 100 -- .../dblib/factory/FactoryNotDefinedException.java | 37 - .../dblib/jdbc/JdbcDBCachedDataSource.java | 249 ---- .../dblib/jdbc/JdbcDbResourceManagerFactory.java | 186 --- .../resource/dblib/jdbc/MySQLCachedDataSource.java | 217 ---- .../sdnc/sli/resource/dblib/pm/PollingWorker.java | 217 ---- .../sli/resource/dblib/pm/SQLExecutionMonitor.java | 237 ---- .../dblib/pm/SQLExecutionMonitorObserver.java | 37 - dblib/provider/src/main/resources/dblib.properties | 24 +- filters/features/src/main/resources/features.xml | 5 +- .../src/assembly/assemble_installer_zip.xml | 5 +- .../src/assembly/assemble_mvnrepo_zip.xml | 5 +- .../src/main/resources/scripts/install-feature.sh | 5 +- filters/provider/pom.xml | 13 +- .../org/onap/ccsdk/sli/core/filters/Activator.java | 62 + .../org/onap/ccsdk/sli/core/filters/LogFilter.java | 221 ++++ .../filters/RequestResponseDbLoggingFilter.java | 297 +++++ .../core/filters/RequestResponseLoggingFilter.java | 288 +++++ .../java/org/openecomp/sdnc/filters/Activator.java | 63 -- .../java/org/openecomp/sdnc/filters/LogFilter.java | 222 ---- .../filters/RequestResponseDbLoggingFilter.java | 297 ----- .../sdnc/filters/RequestResponseLoggingFilter.java | 289 ----- pom.xml | 5 +- sli/common/pom.xml | 6 +- .../org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 | 67 ++ .../antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 | 66 -- .../ccsdk/sli/core/sli/BreakNodeException.java | 45 + .../ccsdk/sli/core/sli/ConfigurationException.java | 44 + .../sli/core/sli/DuplicateValueException.java | 44 + .../org/onap/ccsdk/sli/core/sli/MessageWriter.java | 301 +++++ .../org/onap/ccsdk/sli/core/sli/MetricLogger.java | 300 +++++ .../onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java | 41 + .../org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java | 173 +++ .../sli/core/sli/SvcLogicBinaryExpression.java | 148 +++ .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 247 ++++ .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 532 +++++++++ .../onap/ccsdk/sli/core/sli/SvcLogicException.java | 45 + .../ccsdk/sli/core/sli/SvcLogicExprListener.java | 315 ++++++ .../core/sli/SvcLogicExprParserErrorListener.java | 43 + .../ccsdk/sli/core/sli/SvcLogicExpression.java | 50 + .../sli/core/sli/SvcLogicExpressionFactory.java | 98 ++ .../ccsdk/sli/core/sli/SvcLogicFunctionCall.java | 79 ++ .../org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java | 183 +++ .../ccsdk/sli/core/sli/SvcLogicJavaPlugin.java | 33 + .../onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 894 +++++++++++++++ .../org/onap/ccsdk/sli/core/sli/SvcLogicNode.java | 455 ++++++++ .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 597 ++++++++++ .../sli/core/sli/SvcLogicParserException.java | 42 + .../onap/ccsdk/sli/core/sli/SvcLogicRecorder.java | 29 + .../onap/ccsdk/sli/core/sli/SvcLogicResource.java | 52 + .../org/onap/ccsdk/sli/core/sli/SvcLogicStore.java | 36 + .../ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 95 ++ .../ccsdk/sli/core/sli/SvcLogicVariableTerm.java | 76 ++ .../org/openecomp/sdnc/sli/BreakNodeException.java | 46 - .../openecomp/sdnc/sli/ConfigurationException.java | 45 - .../sdnc/sli/DuplicateValueException.java | 45 - .../java/org/openecomp/sdnc/sli/MessageWriter.java | 302 ----- .../java/org/openecomp/sdnc/sli/MetricLogger.java | 301 ----- .../org/openecomp/sdnc/sli/SvcLogicAdaptor.java | 42 - .../java/org/openecomp/sdnc/sli/SvcLogicAtom.java | 174 --- .../sdnc/sli/SvcLogicBinaryExpression.java | 149 --- .../org/openecomp/sdnc/sli/SvcLogicContext.java | 248 ---- .../org/openecomp/sdnc/sli/SvcLogicDblibStore.java | 533 --------- .../org/openecomp/sdnc/sli/SvcLogicException.java | 46 - .../openecomp/sdnc/sli/SvcLogicExprListener.java | 316 ------ .../sdnc/sli/SvcLogicExprParserErrorListener.java | 44 - .../org/openecomp/sdnc/sli/SvcLogicExpression.java | 51 - .../sdnc/sli/SvcLogicExpressionFactory.java | 99 -- .../openecomp/sdnc/sli/SvcLogicFunctionCall.java | 80 -- .../java/org/openecomp/sdnc/sli/SvcLogicGraph.java | 184 --- .../org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java | 34 - .../org/openecomp/sdnc/sli/SvcLogicJdbcStore.java | 895 --------------- .../java/org/openecomp/sdnc/sli/SvcLogicNode.java | 456 -------- .../org/openecomp/sdnc/sli/SvcLogicParser.java | 598 ---------- .../sdnc/sli/SvcLogicParserException.java | 43 - .../org/openecomp/sdnc/sli/SvcLogicRecorder.java | 30 - .../org/openecomp/sdnc/sli/SvcLogicResource.java | 53 - .../java/org/openecomp/sdnc/sli/SvcLogicStore.java | 37 - .../openecomp/sdnc/sli/SvcLogicStoreFactory.java | 96 -- .../openecomp/sdnc/sli/SvcLogicVariableTerm.java | 77 -- sli/common/src/main/resources/crAseNetwork.sql | 5 +- .../ccsdk/sli/core/sli/SvcLogicContextTest.java | 68 ++ .../sli/core/sli/SvcLogicExpressionParserTest.java | 68 ++ .../ccsdk/sli/core/sli/SvcLogicParserTest.java | 162 +++ .../openecomp/sdnc/sli/SvcLogicContextTest.java | 69 -- .../sdnc/sli/SvcLogicExpressionParserTest.java | 69 -- .../org/openecomp/sdnc/sli/SvcLogicParserTest.java | 163 --- .../test/resources/EvcActivateSvcLogic_v100.xml | 5 +- .../src/test/resources/EvcPortSvcLogic_v100.xml | 5 +- .../test/resources/ReleasePortSvcLogic_v101.xml | 5 +- .../src/test/resources/bad_neutron_logic_v11.xml | 5 +- sli/common/src/test/resources/mergetest.xml | 5 +- .../src/test/resources/neutron_logic_v10.xml | 5 +- sli/common/src/test/resources/nonsense.xml | 5 +- .../src/test/resources/simplelogger.properties | 5 +- sli/common/src/test/resources/svclogic.properties | 5 +- sli/common/src/test/resources/svclogic.sh | 5 +- sli/features/src/main/resources/features.xml | 5 +- .../src/assembly/assemble_installer_zip.xml | 5 +- .../src/assembly/assemble_mvnrepo_zip.xml | 5 +- .../src/main/resources/scripts/install-feature.sh | 5 +- sli/pom.xml | 2 +- sli/provider/pom.xml | 6 +- .../sli/core/sli/provider/BlockNodeExecutor.java | 74 ++ .../sli/core/sli/provider/BreakNodeExecutor.java | 41 + .../sli/core/sli/provider/CallNodeExecutor.java | 164 +++ .../core/sli/provider/ConfigureNodeExecutor.java | 247 ++++ .../sli/core/sli/provider/DeleteNodeExecutor.java | 100 ++ .../sli/core/sli/provider/ExecuteNodeExecutor.java | 160 +++ .../sli/core/sli/provider/ExistsNodeExecutor.java | 104 ++ .../sli/core/sli/provider/ForNodeExecutor.java | 108 ++ .../core/sli/provider/GetResourceNodeExecutor.java | 133 +++ .../core/sli/provider/IsAvailableNodeExecutor.java | 102 ++ .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 1185 +++++++++++++++++++ .../sli/core/sli/provider/NotifyNodeExecutor.java | 101 ++ .../sli/core/sli/provider/RecordNodeExecutor.java | 118 ++ .../sli/core/sli/provider/ReleaseNodeExecutor.java | 99 ++ .../sli/core/sli/provider/ReserveNodeExecutor.java | 113 ++ .../sli/core/sli/provider/ReturnNodeExecutor.java | 77 ++ .../sli/core/sli/provider/SaveNodeExecutor.java | 141 +++ .../sli/core/sli/provider/SetNodeExecutor.java | 188 ++++ .../sli/core/sli/provider/SvcLogicActivator.java | 224 ++++ .../core/sli/provider/SvcLogicAdaptorFactory.java | 85 ++ .../sli/provider/SvcLogicExpressionResolver.java | 604 ++++++++++ .../core/sli/provider/SvcLogicNodeExecutor.java | 109 ++ .../sli/core/sli/provider/SvcLogicService.java | 75 ++ .../sli/core/sli/provider/SvcLogicServiceImpl.java | 272 +++++ .../sli/core/sli/provider/SwitchNodeExecutor.java | 62 + .../sli/core/sli/provider/UpdateNodeExecutor.java | 135 +++ .../sli/core/sli/provider/WhileNodeExecutor.java | 74 ++ .../sdnc/sli/provider/BlockNodeExecutor.java | 75 -- .../sdnc/sli/provider/BreakNodeExecutor.java | 42 - .../sdnc/sli/provider/CallNodeExecutor.java | 165 --- .../sdnc/sli/provider/ConfigureNodeExecutor.java | 248 ---- .../sdnc/sli/provider/DeleteNodeExecutor.java | 101 -- .../sdnc/sli/provider/ExecuteNodeExecutor.java | 161 --- .../sdnc/sli/provider/ExistsNodeExecutor.java | 105 -- .../sdnc/sli/provider/ForNodeExecutor.java | 109 -- .../sdnc/sli/provider/GetResourceNodeExecutor.java | 134 --- .../sdnc/sli/provider/IsAvailableNodeExecutor.java | 103 -- .../openecomp/sdnc/sli/provider/MdsalHelper.java | 1186 -------------------- .../sdnc/sli/provider/NotifyNodeExecutor.java | 102 -- .../sdnc/sli/provider/RecordNodeExecutor.java | 119 -- .../sdnc/sli/provider/ReleaseNodeExecutor.java | 100 -- .../sdnc/sli/provider/ReserveNodeExecutor.java | 114 -- .../sdnc/sli/provider/ReturnNodeExecutor.java | 78 -- .../sdnc/sli/provider/SaveNodeExecutor.java | 142 --- .../sdnc/sli/provider/SetNodeExecutor.java | 189 ---- .../sdnc/sli/provider/SvcLogicActivator.java | 225 ---- .../sdnc/sli/provider/SvcLogicAdaptorFactory.java | 86 -- .../sli/provider/SvcLogicExpressionResolver.java | 605 ---------- .../sdnc/sli/provider/SvcLogicNodeExecutor.java | 110 -- .../sdnc/sli/provider/SvcLogicService.java | 76 -- .../sdnc/sli/provider/SvcLogicServiceImpl.java | 273 ----- .../sdnc/sli/provider/SwitchNodeExecutor.java | 63 -- .../sdnc/sli/provider/UpdateNodeExecutor.java | 136 --- .../sdnc/sli/provider/WhileNodeExecutor.java | 75 -- .../ccsdk/sli/core/sli/provider/BadPlugin.java | 55 + .../core/sli/provider/ExecuteNodeExecutorTest.java | 58 + .../sli/core/sli/provider/LunchSelectorPlugin.java | 77 ++ .../sli/core/sli/provider/MdsalHelperTest.java | 42 + .../core/sli/provider/MdsalHelperTesterUtil.java | 36 + .../ccsdk/sli/core/sli/provider/PluginTest.java | 107 ++ .../provider/SvcLogicExpressionResolverTest.java | 122 ++ .../sli/provider/SvcLogicGraphExecutorTest.java | 211 ++++ .../sli/core/sli/provider/VoidDummyPlugin.java | 37 + .../org/openecomp/sdnc/sli/provider/BadPlugin.java | 56 - .../sdnc/sli/provider/ExecuteNodeExecutorTest.java | 57 - .../sdnc/sli/provider/LunchSelectorPlugin.java | 78 -- .../sdnc/sli/provider/MdsalHelperTest.java | 43 - .../sdnc/sli/provider/MdsalHelperTesterUtil.java | 37 - .../openecomp/sdnc/sli/provider/PluginTest.java | 106 -- .../provider/SvcLogicExpressionResolverTest.java | 123 -- .../sli/provider/SvcLogicGraphExecutorTest.java | 212 ---- .../sdnc/sli/provider/VoidDummyPlugin.java | 38 - .../src/test/resources/l3sdn_logic_v10.xml | 5 +- .../src/test/resources/simplelogger.properties | 5 +- .../src/test/resources/svclogic.properties | 5 +- sli/recording/pom.xml | 4 +- .../ccsdk/sli/core/sli/recording/FileRecorder.java | 116 ++ .../sli/core/sli/recording/RecordingActivator.java | 74 ++ .../sli/core/sli/recording/Slf4jRecorder.java | 129 +++ .../openecomp/sdnc/sli/recording/FileRecorder.java | 117 -- .../sdnc/sli/recording/RecordingActivator.java | 75 -- .../sdnc/sli/recording/Slf4jRecorder.java | 130 --- .../src/main/resources/svclogic.properties | 5 +- .../features/src/main/resources/features.xml | 5 +- .../src/assembly/assemble_installer_zip.xml | 5 +- .../src/assembly/assemble_mvnrepo_zip.xml | 5 +- .../src/main/resources/scripts/install-feature.sh | 5 +- .../openecomp/sdnc/sli/SliPluginUtils/DME2.java | 11 +- .../sdnc/sli/SliPluginUtils/SliPluginUtils.java | 13 +- .../SliPluginUtils/SliPluginUtilsActivator.java | 5 +- .../sdnc/sli/SliPluginUtils/SliStringUtils.java | 11 +- .../sli/SliPluginUtils/SvcLogicContextList.java | 9 +- .../sli/SliPluginUtils/SvcLogicContextObject.java | 7 +- .../SliPluginUtils/commondatastructures/YesNo.java | 5 +- .../commondatastructures/package-info.java | 5 +- .../sli/SliPluginUtils/CheckParametersTest.java | 9 +- .../sdnc/sli/SliPluginUtils/Dme2Test.java | 5 +- .../SliPluginUtils_StaticFunctionsTest.java | 9 +- .../SliPluginUtils/SliPluginUtils_ctxSortList.java | 9 +- .../SliPluginUtils_ctxSortListTest.java | 9 +- .../sli/SliPluginUtils/SliStringUtilsTest.java | 9 +- .../SliPluginUtils/SvcLogicContextListTest.java | 7 +- sliapi/features/src/main/resources/features.xml | 5 +- .../src/assembly/assemble_installer_zip.xml | 5 +- .../src/assembly/assemble_mvnrepo_zip.xml | 5 +- .../src/main/resources/scripts/install-feature.sh | 5 +- .../impl/rev140523/SliapiProviderModule.java | 5 +- .../rev140523/SliapiProviderModuleFactory.java | 5 +- .../org/openecomp/sdnc/sliapi/SliapiHelper.java | 7 +- .../org/openecomp/sdnc/sliapi/sliapiProvider.java | 7 +- .../src/main/resources/initial/sliapi-provider.xml | 5 +- src/site/apt/nodes.apt | 5 +- src/site/site.xml | 5 +- 264 files changed, 16399 insertions(+), 16527 deletions(-) create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBConfigException.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceActivator.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibException.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DblibConfigurationException.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/NoAvailableConnectionsException.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/JDBCConfiguration.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractDBResourceManagerFactory.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/FactoryNotDefinedException.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSource.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBConfigException.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLIBResourceActivator.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibConnection.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibException.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceObserver.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataAccessor.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataSourceComparator.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DbLibService.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DblibConfigurationException.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/NoAvailableConnectionsException.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/TerminatingCachedDataSource.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/BaseDBConfiguration.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/JDBCConfiguration.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/FactoryNotDefinedException.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDbResourceManagerFactory.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/MySQLCachedDataSource.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/PollingWorker.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitor.java delete mode 100644 dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitorObserver.java create mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java create mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java create mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java create mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java delete mode 100644 filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java delete mode 100644 filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java delete mode 100644 filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java delete mode 100644 filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java create mode 100755 sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 delete mode 100755 sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java delete mode 100644 sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java delete mode 100644 sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java delete mode 100644 sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java delete mode 100644 sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BlockNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BreakNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ForNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/MdsalHelper.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReturnNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicAdaptorFactory.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicServiceImpl.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTesterUtil.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java delete mode 100644 sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java create mode 100644 sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java create mode 100644 sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java create mode 100644 sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java delete mode 100644 sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/FileRecorder.java delete mode 100644 sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/RecordingActivator.java delete mode 100644 sli/recording/src/main/java/org/openecomp/sdnc/sli/recording/Slf4jRecorder.java diff --git a/dblib/pom.xml b/dblib/pom.xml index 722b2d7c6..775ff0591 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -34,9 +34,9 @@ 2016 - AT&T + ONAP - openecomp + onap diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 078c75499..41d383ef0 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -63,12 +63,9 @@ true - org.openecomp.sdnc.sli.resource.dblib - org.openecomp.sdnc.sli.resource.dblib.DBLIBResourceActivator - org.openecomp.sdnc.sli.resource.dblib;version=${project.version} - + org.onap.ccsdk.sli.core.dblib + org.onap.ccsdk.sli.core.dblib.DBLIBResourceActivator + org.onap.ccsdk.sli.core.dblib;version=${project.version} * true diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java new file mode 100644 index 000000000..9dc262d07 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -0,0 +1,617 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.io.Closeable; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.sql.Blob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Observer; + +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetProvider; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor.TestObject; + +import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; + + +/** + * @version $Revision: 1.13 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ + +public abstract class CachedDataSource implements DataSource, SQLExecutionMonitorObserver +{ + private static Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); + + protected static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; + + protected long CONN_REQ_TIMEOUT = 30L; + protected long DATA_REQ_TIMEOUT = 100L; + + private final SQLExecutionMonitor monitor; + protected DataSource ds = null; + protected String connectionName = null; + protected boolean initialized = false; + + private long interval = 1000; + private long initialDelay = 5000; + private long expectedCompletionTime = 50L; + private boolean canTakeOffLine = true; + private long unprocessedFailoverThreshold = 3L; + + private long nextErrorReportTime = 0L; + + private String globalHostName = null; + + + public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException + { + configure(jdbcElem); + monitor = new SQLExecutionMonitor(this); + } + + protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; + /* (non-Javadoc) + * @see javax.sql.DataSource#getConnection() + */ + public Connection getConnection() throws SQLException + { + return ds.getConnection(); + } + + public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable + { + TestObject testObject = null; + testObject = monitor.registerRequest(); + + Connection connection = null; + try { + connection = this.getConnection(); + if(connection == null ) { + throw new SQLException("Connection invalid"); + } + if(LOGGER.isDebugEnabled()) + LOGGER.debug("Obtained connection <" + connectionName + ">: "+connection.toString()); + return executePreparedStatement(connection, statement, arguments, true); + } finally { + try { + if(connection != null && !connection.isClosed()) { + connection.close(); + } + } catch(Throwable exc) { + // the exception not monitored + } finally { + connection = null; + } + + monitor.deregisterReguest(testObject); + } + } + + public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable + { + TestObject testObject = null; + testObject = monitor.registerRequest(); + + Connection connection = null; + try { + connection = this.getConnection(); + if(connection == null ) { + throw new SQLException("Connection invalid"); + } + if(LOGGER.isDebugEnabled()) + LOGGER.debug("Obtained connection <" + connectionName + ">: "+connection.toString()); + return executeUpdatePreparedStatement(connection, statement, arguments, true); + } finally { + try { + if(connection != null && !connection.isClosed()) { + connection.close(); + } + } catch(Throwable exc) { + // the exception not monitored + } finally { + connection = null; + } + + monitor.deregisterReguest(testObject); + } + } + + CachedRowSet executePreparedStatement(Connection conn, String statement, ArrayList arguments, boolean close) throws SQLException, Throwable + { + long time = System.currentTimeMillis(); + + CachedRowSet data = null; + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL Statement: "+ statement); + if(arguments != null && !arguments.isEmpty()) { + LOGGER.debug("Argunments: "+ Arrays.toString(arguments.toArray())); + } + } + + ResultSet rs = null; + try { + data = RowSetProvider.newFactory().createCachedRowSet(); + PreparedStatement ps = conn.prepareStatement(statement); + if(arguments != null) + { + for(int i = 0, max = arguments.size(); i < max; i++){ + ps.setObject(i+1, arguments.get(i)); + } + } + rs = ps.executeQuery(); + data.populate(rs); + // Point the rowset Cursor to the start + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL SUCCESS. rows returned: " + data.size()+ ", time(ms): "+ (System.currentTimeMillis() - time)); } + } catch(SQLException exc){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); + } + try { conn.rollback(); } catch(Throwable thr){} + if(arguments != null && !arguments.isEmpty()) { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); + } else { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); + } + throw exc; + } catch(Throwable exc){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); + } + if(arguments != null && !arguments.isEmpty()) { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); + } else { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); + } + throw exc; // new SQLException(exc); + } finally { + + try { + if(rs != null){ + rs.close(); + rs = null; + } + } catch(Exception exc){ + + } + try { + if(conn != null && close){ + conn.close(); + conn = null; + } + } catch(Exception exc){ + + } + } + + return data; + } + + boolean executeUpdatePreparedStatement(Connection conn, String statement, ArrayList arguments, boolean close) throws SQLException, Throwable { + long time = System.currentTimeMillis(); + + CachedRowSet data = null; + + int rs = -1; + try { + data = RowSetProvider.newFactory().createCachedRowSet(); + PreparedStatement ps = conn.prepareStatement(statement); + if(arguments != null) + { + for(int i = 0, max = arguments.size(); i < max; i++){ + if(arguments.get(i) instanceof Blob) { + ps.setBlob(i+1, (Blob)arguments.get(i)); + } else if(arguments.get(i) instanceof Timestamp) { + ps.setTimestamp(i+1, (Timestamp)arguments.get(i)); + } else if(arguments.get(i) instanceof Integer) { + ps.setInt(i+1, (Integer)arguments.get(i)); + } else if(arguments.get(i) instanceof Long) { + ps.setLong(i+1, (Long)arguments.get(i)); + } else if(arguments.get(i) instanceof Date) { + ps.setDate(i+1, (Date)arguments.get(i)); + } else { + ps.setObject(i+1, arguments.get(i)); + } + } + } + rs = ps.executeUpdate(); + // Point the rowset Cursor to the start + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL SUCCESS. rows returned: " + data.size()+ ", time(ms): "+ (System.currentTimeMillis() - time)); + } + } catch(SQLException exc){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); + } + try { conn.rollback(); } catch(Throwable thr){} + if(arguments != null && !arguments.isEmpty()) { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); + } else { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); + } + throw exc; + } catch(Throwable exc){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); + } + if(arguments != null && !arguments.isEmpty()) { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); + } else { + LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); + } + throw exc; // new SQLException(exc); + } finally { + try { + if(conn != null && close){ + conn.close(); + conn = null; + } + } catch(Exception exc){ + + } + } + + return true; + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) + */ + public Connection getConnection(String username, String password) + throws SQLException + { + return ds.getConnection(username, password); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getLogWriter() + */ + public PrintWriter getLogWriter() throws SQLException + { + return ds.getLogWriter(); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getLoginTimeout() + */ + public int getLoginTimeout() throws SQLException + { + return ds.getLoginTimeout(); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) + */ + public void setLogWriter(PrintWriter out) throws SQLException + { + ds.setLogWriter(out); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#setLoginTimeout(int) + */ + public void setLoginTimeout(int seconds) throws SQLException + { + ds.setLoginTimeout(seconds); + } + + + public final String getDbConnectionName(){ + return connectionName; + } + + protected final void setDbConnectionName(String name) { + this.connectionName = name; + } + + public void cleanUp(){ + if(ds != null && ds instanceof Closeable) { + try { + ((Closeable)ds).close(); + } catch (IOException e) { + LOGGER.warn(e.getMessage()); + } + } + ds = null; + monitor.deleteObservers(); + monitor.cleanup(); + } + + public boolean isInitialized() { + return initialized; + } + + protected boolean testConnection(){ + return testConnection(false); + } + + protected boolean testConnection(boolean error_level){ + Connection conn = null; + ResultSet rs = null; + Statement stmt = null; + try + { + Boolean readOnly = null; + String hostname = null; + conn = this.getConnection(); + stmt = conn.createStatement(); + rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); //("SELECT 1 FROM DUAL"); //"select BANNER from SYS.V_$VERSION" + while(rs.next()) + { + readOnly = rs.getBoolean(1); + hostname = rs.getString(2); + + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("SQL DataSource <"+getDbConnectionName() + "> connected to " + hostname + ", read-only is " + readOnly + ", tested successfully "); + } + } + + } catch (Throwable exc) { + if(error_level) { + LOGGER.error("SQL DataSource <" + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } else { + LOGGER.info("SQL DataSource <" + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } + return false; + } finally { + if(rs != null) { + try { + rs.close(); + rs = null; + } catch (SQLException e) { + } + } + if(stmt != null) { + try { + stmt.close(); + stmt = null; + } catch (SQLException e) { + } + } + if(conn !=null){ + try { + conn.close(); + conn = null; + } catch (SQLException e) { + } + } + } + return true; + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + public T unwrap(Class iface) throws SQLException { + return null; + } + + @SuppressWarnings("deprecation") + public void setConnectionCachingEnabled(boolean state) + { +// if(ds != null && ds instanceof OracleDataSource) +// try { +// ((OracleDataSource)ds).setConnectionCachingEnabled(true); +// } catch (SQLException exc) { +// LOGGER.warn("", exc); +// } + } + + public void addObserver(Observer observer) { + monitor.addObserver(observer); + } + + public void deleteObserver(Observer observer) { + monitor.deleteObserver(observer); + } + + public long getInterval() { + return interval; + } + + public long getInitialDelay() { + return initialDelay; + } + + public void setInterval(long value) { + interval = value; + } + + public void setInitialDelay(long value) { + initialDelay = value; + } + + public long getExpectedCompletionTime() { + return expectedCompletionTime; + } + + public void setExpectedCompletionTime(long value) { + expectedCompletionTime = value; + } + + public long getUnprocessedFailoverThreshold() { + return unprocessedFailoverThreshold; + } + + public void setUnprocessedFailoverThreshold(long value) { + this.unprocessedFailoverThreshold = value; + } + + public boolean canTakeOffLine() { + return canTakeOffLine; + } + + public void blockImmediateOffLine() { + canTakeOffLine = false; + final Thread offLineTimer = new Thread() + { + public void run(){ + try { + Thread.sleep(30000L); + }catch(Throwable exc){ + + }finally{ + canTakeOffLine = true; + } + } + }; + offLineTimer.setDaemon(true); + offLineTimer.start(); + } + + /** + * @return the monitor + */ + final SQLExecutionMonitor getMonitor() { + return monitor; + } + + protected boolean isSlave() throws PoolExhaustedException, MySQLNonTransientConnectionException { + CachedRowSet rs = null; + boolean isSlave = true; + String hostname = "UNDETERMINED"; + try { + boolean localSlave = true; + rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList()); + while(rs.next()) { + localSlave = rs.getBoolean(1); + hostname = rs.getString(2); + } + isSlave = localSlave; + } catch(PoolExhaustedException | MySQLNonTransientConnectionException peexc){ + throw peexc; + } catch (SQLException e) { + LOGGER.error("", e); + isSlave = true; + } catch (Throwable e) { + LOGGER.error("", e); + isSlave = true; + } + if(isSlave){ + LOGGER.debug("SQL SLAVE : "+connectionName + " on server " + hostname); + } else { + LOGGER.debug("SQL MASTER : "+connectionName + " on server " + hostname); + } + return isSlave; + } + + public boolean isFabric() { + return false; + } + + protected boolean lockTable(Connection conn, String tableName) { + boolean retValue = false; + Statement lock = null; + try { + if(tableName != null) { + if(LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); + if("SVC_LOGIC".equals(tableName)) { + Exception e = new Exception(); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + LOGGER.debug(sw.toString()); + } + } + lock = conn.createStatement(); + lock.execute("LOCK TABLES " + tableName + " WRITE"); + retValue = true; + } + } catch(Exception exc){ + LOGGER.error("", exc); + retValue = false; + } finally { + try { + lock.close(); + } catch(Exception exc) { + + } + } + return retValue; + } + + protected boolean unlockTable(Connection conn) { + boolean retValue = false; + Statement lock = null; + try { + if(LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'UNLOCK TABLES' on connection " + conn.toString()); + } + lock = conn.createStatement(); + retValue = lock.execute("UNLOCK TABLES"); + } catch(Exception exc){ + LOGGER.error("", exc); + retValue = false; + } finally { + try { + lock.close(); + } catch(Exception exc) { + + } + } + return retValue; + } + + public void getPoolInfo(boolean allocation) { + + } + + public long getNextErrorReportTime() { + return nextErrorReportTime; + } + + public void setNextErrorReportTime(long nextTime) { + this.nextErrorReportTime = nextTime; + } + + public void setGlobalHostName(String hostname) { + this.globalHostName = hostname; + } + + public String getGlobalHostName() { + return globalHostName; + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java new file mode 100644 index 000000000..07e3dfab1 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + + +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.onap.ccsdk.sli.core.dblib.jdbc.JdbcDBCachedDataSource; +import org.onap.ccsdk.sli.core.dblib.jdbc.MySQLCachedDataSource; + +/** + * @version $Revision: 1.1 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class CachedDataSourceFactory { + + public static CachedDataSource createDataSource(BaseDBConfiguration config) { + if(config instanceof JDBCConfiguration) + return JdbcDBCachedDataSource.createInstance(config); + + return (CachedDataSource)null; + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBConfigException.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBConfigException.java new file mode 100644 index 000000000..e41e29b5d --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBConfigException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + + +/** + * @version $Revision: 1.1 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class DBConfigException extends RuntimeException +{ + /** + * + */ + private static final long serialVersionUID = 4752405152537680257L; + + public DBConfigException(Exception e) + { + super(e.toString()); + } + + public DBConfigException(String msg) + { + super(msg); + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceActivator.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceActivator.java new file mode 100644 index 000000000..8ae9a2665 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceActivator.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.io.File; +import java.net.URL; +import java.util.Properties; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DBLIBResourceActivator implements BundleActivator { + + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final String DBLIB_PROP_PATH = "/dblib.properties"; + + private ServiceRegistration registration = null; + + private static final Logger LOG = LoggerFactory.getLogger(DBLIBResourceActivator.class); + + @Override + public void start(BundleContext ctx) throws Exception { + LOG.info("entering DBLIBResourceActivator.start"); + + DbLibService jdbcDataSource = null; + // Read properties + Properties props = new Properties(); + + File file = null; + URL propURL = null; + String propDir = System.getenv(SDNC_CONFIG_DIR); + if ((propDir == null) || (propDir.length() == 0)) { + propDir = "/opt/sdnc/data/properties"; + } + file = new File(propDir + DBLIB_PROP_PATH); + if(file.exists()) { + propURL = file.toURI().toURL(); + LOG.info("Using property file (1): " + file.toString()); + } else { + propURL = ctx.getBundle().getResource("dblib.properties"); + URL tmp = null; + if (propURL == null) { + file = new File(DBLIB_PROP_PATH); + tmp = this.getClass().getResource(DBLIB_PROP_PATH); +// if(!file.exists()) { + if(tmp == null) { + throw new DblibConfigurationException("Missing configuration properties resource(3) : " + DBLIB_PROP_PATH); + } else { + propURL = tmp; //file.toURI().toURL(); + LOG.info("Using property file (4): " + file.toString()); + } + } else { + LOG.info("Using property file (2): " + propURL.toString()); + } + } + + + try { + props.load(propURL.openStream()); + } catch (Exception e) { + throw new DblibConfigurationException("Could not load properties at URL " + propURL.toString(), e); + + } + + + + try { + jdbcDataSource = DBResourceManager.create(props); + } catch (Exception exc) { + throw new DblibConfigurationException("Could not get initialize database", exc); + } + + String regName = jdbcDataSource.getClass().getName(); + + LOG.info("Registering DBResourceManager service "+regName); + registration = ctx.registerService(new String[] { regName, DbLibService.class.getName(), "javax.sql.DataSource" }, jdbcDataSource, null); + } + + @Override + public void stop(BundleContext ctx) throws Exception { + LOG.info("entering DBLIBResourceActivator.stop"); + if (registration != null) + { + try { + ServiceReference sref = ctx.getServiceReference(DbLibService.class.getName()); + + if (sref == null) { + LOG.warn("Could not find service reference for DBLIB service (" + DbLibService.class.getName() + ")"); + } else { + DBResourceManager dblibSvc = (DBResourceManager) ctx.getService(sref); + if (dblibSvc == null) { + LOG.warn("Could not find service reference for DBLIB service (" + DbLibService.class.getName() + ")"); + } else { + dblibSvc.cleanUp(); + } + } + } catch(Throwable exc) { + LOG.warn("Cleanup", exc); + } + + registration.unregister(); + registration = null; + LOG.debug("Deregistering DBResourceManager service"); + } + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java new file mode 100644 index 000000000..8181b1300 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java @@ -0,0 +1,390 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.sql.Array; +import java.sql.Blob; +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.NClob; +import java.sql.PreparedStatement; +import java.sql.SQLClientInfoException; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Struct; +import java.util.ArrayList; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +import javax.sql.rowset.CachedRowSet; + +import org.apache.tomcat.jdbc.pool.PooledConnection; +import org.apache.tomcat.jdbc.pool.ProxyConnection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DBLibConnection implements Connection { + + private static Logger LOGGER = LoggerFactory.getLogger(DBLibConnection.class); + + private final Connection connection; + private final CachedDataSource dataSource; + private boolean locked = false; + private String tableName = null; + + public DBLibConnection(Connection con, CachedDataSource dataSource){ + this.connection = con; + this.dataSource = dataSource; + locked = false; + dataSource.getPoolInfo(true); + } + + public boolean lockTable(String tablename) { + this.tableName = tablename; + return locked = dataSource.lockTable(connection, tableName); + } + + public void resetInactivityTimer() { + Class iface = PooledConnection.class; + try { + PooledConnection pc = connection.unwrap(iface); + pc.setTimestamp(System.currentTimeMillis()); + } catch (SQLException e) { + LOGGER.warn("Failed resetting timeout timer", e); + } + } + + public boolean unlock() { + dataSource.unlockTable(connection); + return locked = false; + } + + public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable + { + ArrayList newList=new ArrayList(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + resetInactivityTimer(); + return dataSource.executeUpdatePreparedStatement(connection, statement, newList, false); + } + + public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable + { + ArrayList newList=new ArrayList(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + resetInactivityTimer(); + return dataSource.executePreparedStatement(connection, statement, newList, false); + } + + @Override + public T unwrap(Class iface) throws SQLException { + return connection.unwrap(iface); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return connection.isWrapperFor(iface); + } + + @Override + public Statement createStatement() throws SQLException { + return connection.createStatement(); + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + return connection.prepareStatement(sql); + } + + @Override + public CallableStatement prepareCall(String sql) throws SQLException { + return connection.prepareCall(sql); + } + + @Override + public String nativeSQL(String sql) throws SQLException { + return connection.nativeSQL(sql); + } + + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + connection.setAutoCommit(autoCommit); + } + + @Override + public boolean getAutoCommit() throws SQLException { + return connection.getAutoCommit(); + } + + @Override + public void commit() throws SQLException { + connection.commit(); + } + + @Override + public void rollback() throws SQLException { + connection.rollback(); + } + + @Override + public void close() throws SQLException { + if(this.locked) { + try { + this.unlock(); + } catch(Throwable th) { + LOGGER.error("Failed unlocking",th); + } + } + if(connection != null && !connection.isClosed()) { + connection.close(); + } + dataSource.getPoolInfo(false); + } + + @Override + public boolean isClosed() throws SQLException { + return connection.isClosed(); + } + + @Override + public DatabaseMetaData getMetaData() throws SQLException { + return connection.getMetaData(); + } + + @Override + public void setReadOnly(boolean readOnly) throws SQLException { + connection.setReadOnly(readOnly); + } + + @Override + public boolean isReadOnly() throws SQLException { + return connection.isReadOnly(); + } + + @Override + public void setCatalog(String catalog) throws SQLException { + connection.setCatalog(catalog); + } + + @Override + public String getCatalog() throws SQLException { + return connection.getCatalog(); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + connection.setTransactionIsolation(level); + } + + @Override + public int getTransactionIsolation() throws SQLException { + return connection.getTransactionIsolation(); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return connection.getWarnings(); + } + + @Override + public void clearWarnings() throws SQLException { + connection.clearWarnings(); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { + return connection.createStatement(resultSetType, resultSetConcurrency); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + return connection.prepareStatement(sql, resultSetType, resultSetConcurrency); + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { + return connection.prepareCall(sql, resultSetType, resultSetConcurrency); + } + + @Override + public Map> getTypeMap() throws SQLException { + return connection.getTypeMap(); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + connection.setTypeMap(map); + } + + @Override + public void setHoldability(int holdability) throws SQLException { + connection.setHoldability(holdability); + } + + @Override + public int getHoldability() throws SQLException { + return connection.getHoldability(); + } + + @Override + public Savepoint setSavepoint() throws SQLException { + return connection.setSavepoint(); + } + + @Override + public Savepoint setSavepoint(String name) throws SQLException { + return connection.setSavepoint(name); + } + + @Override + public void rollback(Savepoint savepoint) throws SQLException { + connection.rollback(savepoint); + } + + @Override + public void releaseSavepoint(Savepoint savepoint) throws SQLException { + connection.releaseSavepoint(savepoint); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) + throws SQLException { + return connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return connection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { + return connection.prepareStatement(sql, autoGeneratedKeys); + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + return connection.prepareStatement(sql, columnIndexes); + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { + return connection.prepareStatement(sql, columnNames); + } + + @Override + public Clob createClob() throws SQLException { + return connection.createClob(); + } + + @Override + public Blob createBlob() throws SQLException { + return connection.createBlob(); + } + + @Override + public NClob createNClob() throws SQLException { + return connection.createNClob(); + } + + @Override + public SQLXML createSQLXML() throws SQLException { + return connection.createSQLXML(); + } + + @Override + public boolean isValid(int timeout) throws SQLException { + return connection.isValid(timeout); + } + + @Override + public void setClientInfo(String name, String value) throws SQLClientInfoException { + connection.setClientInfo(name, value); + } + + @Override + public void setClientInfo(Properties properties) throws SQLClientInfoException { + connection.setClientInfo(properties); + } + + @Override + public String getClientInfo(String name) throws SQLException { + return connection.getClientInfo(name); + } + + @Override + public Properties getClientInfo() throws SQLException { + return connection.getClientInfo(); + } + + @Override + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + return connection.createArrayOf(typeName, elements); + } + + @Override + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { + return connection.createStruct(typeName, attributes); + } + + @Override + public void setSchema(String schema) throws SQLException { + connection.setSchema(schema); + } + + @Override + public String getSchema() throws SQLException { + return connection.getSchema(); + } + + @Override + public void abort(Executor executor) throws SQLException { + connection.abort(executor); + } + + @Override + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + connection.setNetworkTimeout(executor, milliseconds); + } + + @Override + public int getNetworkTimeout() throws SQLException { + return connection.getNetworkTimeout(); + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibException.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibException.java new file mode 100644 index 000000000..de241f478 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibException.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.sql.SQLException; + +/** + * An exception time for handling DBLIB specific error handling. + */ +public class DBLibException extends SQLException { + + /** + * + */ + private static final long serialVersionUID = -5345059355083984696L; + + public DBLibException(String message){ + super(message); + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java new file mode 100644 index 000000000..78b970bf5 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -0,0 +1,863 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLDataException; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.sql.SQLSyntaxErrorException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Observable; +import java.util.PriorityQueue; +import java.util.Properties; +import java.util.Queue; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; + +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; +import org.onap.ccsdk.sli.core.dblib.factory.AbstractDBResourceManagerFactory; +import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory; +import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; +import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; + +import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @version $Revision: 1.15 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class DBResourceManager implements DataSource, DataAccessor, DBResourceObserver, DbLibService { + private static Logger LOGGER = LoggerFactory.getLogger(DBResourceManager.class); + + transient boolean terminating = false; + transient protected long retryInterval = 10000L; + transient boolean recoveryMode = true; + + protected final AtomicBoolean dsSelector = new AtomicBoolean(); + +// Queue dsQueue = new ConcurrentLinkedQueue(); + Queue dsQueue = new PriorityQueue(4, new Comparator(){ + + @Override + public int compare(CachedDataSource left, CachedDataSource right) { + try { + if(!left.isSlave()) + return -1; + if(!right.isSlave()) + return 1; + + } catch (Throwable e) { + LOGGER.warn("", e); + } + return 0; + } + + }); + protected final Set broken = Collections.synchronizedSet(new HashSet()); + protected final Object monitor = new Object(); + protected final Properties configProps; + protected final Thread worker; + + protected final long terminationTimeOut; + protected final boolean monitorDbResponse; + protected final long monitoringInterval; + protected final long monitoringInitialDelay; + protected final long expectedCompletionTime; + protected final long unprocessedFailoverThreshold; + + public DBResourceManager(Properties props){ + this.configProps = props; + + // get retry interval value + retryInterval = getLongFromProperties(props, "org.onap.dblib.connection.retry", 10000L); + + // get recovery mode flag + recoveryMode = getBooleanFromProperties(props, "org.onap.dblib.connection.recovery", true); + if(!recoveryMode) + { + recoveryMode = false; + LOGGER.info("Recovery Mode disabled"); + } + // get time out value for thread cleanup + terminationTimeOut = getLongFromProperties(props, "org.onap.dblib.termination.timeout", 300000L); + // get properties for monitoring + monitorDbResponse = getBooleanFromProperties(props, "org.onap.dblib.connection.monitor", false); + monitoringInterval = getLongFromProperties(props, "org.onap.dblib.connection.monitor.interval", 1000L); + monitoringInitialDelay = getLongFromProperties(props, "org.onap.dblib.connection.monitor.startdelay", 5000L); + expectedCompletionTime = getLongFromProperties(props, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); + unprocessedFailoverThreshold = getLongFromProperties(props, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); + + // initialize performance monitor + PollingWorker.createInistance(props); + + // initialize recovery thread + worker = new RecoveryMgr(); + worker.setName("DBResourcemanagerWatchThread"); + worker.setDaemon(true); + worker.start(); + } + + private void config(Properties ctx) throws Exception { + + DbConfigPool dbConfig = DBConfigFactory.createConfig(this.configProps); + + try { + AbstractResourceManagerFactory factory = AbstractDBResourceManagerFactory.getFactory(dbConfig.getType()); + if(LOGGER.isInfoEnabled()){ + LOGGER.info("Default DB config is : " + dbConfig.getType()); + LOGGER.info("Using factory : " + factory.getClass().getName()); + } + CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, this); + if(cachedDS == null || cachedDS.length == 0) { + LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); + throw new Exception("Failed to initialize DB Library. No data source was created."); + } + + for(int i=0; i 1){ + handleGetConnectionException(dataSource, new Exception(data.toString())); + } + } + } + } + } + + public void testForceRecovery() + { + CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + handleGetConnectionException(active, new Exception("test")); + } + + class RecoveryMgr extends Thread { + + public void run() { + while(!terminating) + { + try { + Thread.sleep(retryInterval); + } catch (InterruptedException e1) { } + CachedDataSource brokenSource = null; + try { + if (!broken.isEmpty()) { + CachedDataSource[] sourceArray = broken.toArray(new CachedDataSource[0]); + for (int i = 0; i < sourceArray.length; i++) + { + brokenSource = sourceArray[i]; + if (brokenSource instanceof TerminatingCachedDataSource) + break; + if (resetConnectionPool(brokenSource)) { + broken.remove(brokenSource); + brokenSource.blockImmediateOffLine(); + dsQueue.add(brokenSource); + LOGGER.info("DataSource <" + + brokenSource.getDbConnectionName() + + "> recovered."); + } + brokenSource = null; + } + } + } catch (Exception exc) { + LOGGER.warn(exc.getMessage()); + if(brokenSource != null){ + try { + if(!broken.contains(brokenSource)) + broken.add(brokenSource); + brokenSource = null; + } catch (Exception e1) { } + } + } + } + LOGGER.info("DBResourceManager.RecoveryMgr <"+this.toString() +"> terminated." ); + } + + private boolean resetConnectionPool(CachedDataSource dataSource){ + try { + return dataSource.testConnection(); + } catch (Exception exc) { + LOGGER.info("DataSource <" + dataSource.getDbConnectionName() + "> resetCache failed with error: "+ exc.getMessage()); + return false; + } + } + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#getData(java.lang.String, java.util.ArrayList, java.lang.String) + */ + @Override + public CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) throws SQLException { + ArrayList newList=new ArrayList(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + if(recoveryMode) + return requestDataWithRecovery(statement, newList, preferredDS); + else + return requestDataNoRecovery(statement, newList, preferredDS); + } + + private CachedRowSet requestDataWithRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + Throwable lastException = null; + CachedDataSource active = null; + + // test if there are any connection pools available + LinkedList sources = new LinkedList(this.dsQueue); + if(sources.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); + } + if(preferredDS != null && !sources.peek().getDbConnectionName().equals(preferredDS)) { + Collections.reverse(sources); + } + + + // loop through available data sources to retrieve data. + while(!sources.isEmpty()) + { + active = sources.peek(); + + long time = System.currentTimeMillis(); + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + master = null; + } + } + sources.remove(active); + return active.getData(statement, arguments); + } catch(SQLDataException exc){ + throw exc; + } catch(SQLSyntaxErrorException exc){ + throw exc; + } catch(SQLIntegrityConstraintViolationException exc){ + throw exc; + } catch(Throwable exc){ + lastException = exc; + String message = exc.getMessage(); + if(message == null) { + if(exc.getCause() != null) { + message = exc.getCause().getMessage(); + } + if(message == null) + message = exc.getClass().getName(); + } + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + handleGetConnectionException(active, exc); + } finally { + if(LOGGER.isDebugEnabled()){ + time = (System.currentTimeMillis() - time); + LOGGER.debug("getData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + if(lastException instanceof SQLException){ + throw (SQLException)lastException; + } + // repackage the exception + // you are here because either you run out of available data sources + // or the last exception was not of SQLException type. + // repackage the exception + if(lastException == null) { + throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); + } else { + SQLException exception = new DBLibException(lastException.getMessage()); + exception.setStackTrace(lastException.getStackTrace()); + if(lastException.getCause() instanceof SQLException) { + throw (SQLException)lastException.getCause(); + } + throw exception; + } + } + + private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + if(dsQueue.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); + } + CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + long time = System.currentTimeMillis(); + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) + active = master; + } + return active.getData(statement, arguments); +// } catch(SQLDataException exc){ +// throw exc; + } catch(Throwable exc){ + String message = exc.getMessage(); + if(message == null) + message = exc.getClass().getName(); + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + if(exc instanceof SQLException) + throw (SQLException)exc; + else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } finally { + if(LOGGER.isDebugEnabled()){ + time = (System.currentTimeMillis() - time); + LOGGER.debug(">> getData : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#writeData(java.lang.String, java.util.ArrayList, java.lang.String) + */ + @Override + public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException + { + ArrayList newList=new ArrayList(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + + return writeDataNoRecovery(statement, newList, preferredDS); + } + + CachedDataSource findMaster() throws PoolExhaustedException, MySQLNonTransientConnectionException { + CachedDataSource master = null; + CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); + for(int i=0; i arguments, String preferredDS) throws SQLException { + if(dsQueue.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); + } + + boolean initialRequest = true; + boolean retryAllowed = true; + CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + long time = System.currentTimeMillis(); + while(initialRequest) { + initialRequest = false; + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } + + return active.writeData(statement, arguments); + } catch(Throwable exc){ + String message = exc.getMessage(); + if(message == null) + message = exc.getClass().getName(); + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + if(exc instanceof SQLException) { + SQLException sqlExc = SQLException.class.cast(exc); + // handle read-only exception + if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { + LOGGER.warn("retrying due to: " + sqlExc.getMessage()); + dsQueue.remove(active); + dsQueue.add(active); + if(retryAllowed){ + retryAllowed = false; + initialRequest = true; + continue; + } + } + throw (SQLException)exc; + } else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } finally { + if(LOGGER.isDebugEnabled()){ + time = (System.currentTimeMillis() - time); + LOGGER.debug("writeData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + return true; + } + + private void setDataSource(CachedDataSource dataSource) { + if(dataSource.testConnection(true)){ + this.dsQueue.add(dataSource); + } else { + this.broken.add(dataSource); + } + } + + public Connection getConnection() throws SQLException { + Throwable lastException = null; + CachedDataSource active = null; + + if(dsQueue.isEmpty()){ + throw new DBLibException("No active DB connection pools are available in GetConnection call."); + } + + try { + active = dsQueue.peek(); + CachedDataSource tmpActive = findMaster(); + if(tmpActive != null) { + active = tmpActive; + } + return new DBLibConnection(active.getConnection(), active); + } catch(javax.sql.rowset.spi.SyncFactoryException exc){ + LOGGER.debug("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); + LOGGER.warn("CLASSPATH issue. Allowing retry", exc); + lastException = exc; + } catch(PoolExhaustedException exc) { + throw new NoAvailableConnectionsException(exc); + } catch(MySQLNonTransientConnectionException exc){ + throw new NoAvailableConnectionsException(exc); + } catch(Exception exc){ + lastException = exc; + if(recoveryMode){ + handleGetConnectionException(active, exc); + } else { + if(exc instanceof MySQLNonTransientConnectionException) { + throw new NoAvailableConnectionsException(exc); + } if(exc instanceof SQLException) { + throw (SQLException)exc; + } else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } + } catch (Throwable trwb) { + DBLibException excptn = new DBLibException(trwb.getMessage()); + excptn.setStackTrace(trwb.getStackTrace()); + throw excptn; + } finally { + if(LOGGER.isDebugEnabled()){ + displayState(); + } + } + + if(lastException instanceof SQLException){ + throw (SQLException)lastException; + } + // repackage the exception + if(lastException == null) { + throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); + } else { + SQLException exception = new DBLibException(lastException.getMessage()); + exception.setStackTrace(lastException.getStackTrace()); + if(lastException.getCause() instanceof SQLException) { +// exception.setNextException((SQLException)lastException.getCause()); + throw (SQLException)lastException.getCause(); + } + throw exception; + } + } + + public Connection getConnection(String username, String password) + throws SQLException { + CachedDataSource active = null; + + if(dsQueue.isEmpty()){ + throw new DBLibException("No active DB connection pools are available in GetConnection call."); + } + + + try { + active = dsQueue.peek(); + CachedDataSource tmpActive = findMaster(); + if(tmpActive != null) { + active = tmpActive; + } + return active.getConnection(username, password); + } catch(Throwable exc){ + if(recoveryMode){ + handleGetConnectionException(active, exc); + } else { + if(exc instanceof SQLException) + throw (SQLException)exc; + else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } + + } + + throw new DBLibException("No connections available in DBResourceManager in GetConnection call."); + } + + private void handleGetConnectionException(CachedDataSource source, Throwable exc) { + try { + if(!source.canTakeOffLine()) + { + LOGGER.error("Could not switch due to blocking"); + return; + } + + boolean removed = dsQueue.remove(source); + if(!broken.contains(source)) + { + if(broken.add(source)) + { + LOGGER.warn("DB Recovery: DataSource <" + source.getDbConnectionName() + "> put in the recovery mode. Reason : " + exc.getMessage()); + } else { + LOGGER.warn("Error putting DataSource <" +source.getDbConnectionName()+ "> in recovery mode."); + } + } else { + LOGGER.info("DB Recovery: DataSource <" + source.getDbConnectionName() + "> already in recovery queue"); + } + if(removed) + { + if(!dsQueue.isEmpty()) + { + LOGGER.warn("DB DataSource <" + dsQueue.peek().getDbConnectionName() + "> became active"); + } + } + } catch (Exception e) { + LOGGER.error("", e); + } + } + + public void cleanUp() { + for(Iterator it=dsQueue.iterator();it.hasNext();){ + CachedDataSource cds = (CachedDataSource)it.next(); + it.remove(); + cds.cleanUp(); + } + + try { + this.terminating = true; + if(broken != null) + { + try { + broken.add( new TerminatingCachedDataSource(null)); + } catch(Exception exc){ + LOGGER.error("Waiting for Worker to stop", exc); + } + } + worker.join(terminationTimeOut); + LOGGER.info("DBResourceManager.RecoveryMgr <"+worker.toString() +"> termination was successful: " + worker.getState()); + } catch(Exception exc){ + LOGGER.error("Waiting for Worker thread to terminate ", exc); + } + } + + public static DBResourceManager create(Properties props) throws Exception { + DBResourceManager dbmanager = new DBResourceManager(props); + dbmanager.config(props); + return dbmanager; + } + + public PrintWriter getLogWriter() throws SQLException { + return ((CachedDataSource)this.dsQueue.peek()).getLogWriter(); + } + + public int getLoginTimeout() throws SQLException { + return ((CachedDataSource)this.dsQueue.peek()).getLoginTimeout(); + } + + public void setLogWriter(PrintWriter out) throws SQLException { + ((CachedDataSource)this.dsQueue.peek()).setLogWriter(out); + } + + public void setLoginTimeout(int seconds) throws SQLException { + ((CachedDataSource)this.dsQueue.peek()).setLoginTimeout(seconds); + } + + public void displayState(){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); + CachedDataSource current = (CachedDataSource)dsQueue.peek(); + if(current != null) { + LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); + } + } + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#isActive() + */ + @Override + public boolean isActive() { + return this.dsQueue.size()>0; + } + + public String getActiveStatus(){ + return "Connected: " + dsQueue.size()+"\tIn-recovery: "+broken.size(); + } + + public String getDBStatus(boolean htmlFormat) { + StringBuilder buffer = new StringBuilder(); + + ArrayList list = new ArrayList(); + list.addAll(dsQueue); + list.addAll(broken); + if (htmlFormat) + { + buffer.append("") + .append("Name:").append(""); + for (int i = 0; i < list.size(); i++) { + buffer.append(""); + buffer.append(((CachedDataSource) list.get(i)).getDbConnectionName()).append(""); + } + buffer.append(""); + + buffer.append("State:"); + for (int i = 0; i < list.size(); i++) { + if (broken.contains(list.get(i))) { + buffer.append("in recovery"); + } + if (dsQueue.contains(list.get(i))) { + if (dsQueue.peek() == list.get(i)) + buffer.append("active"); + else + buffer.append("standby"); + } + } + buffer.append(""); + + } else { + for (int i = 0; i < list.size(); i++) { + buffer.append("Name: ").append(((CachedDataSource) list.get(i)).getDbConnectionName()); + buffer.append("\tState: "); + if (broken.contains(list.get(i))) { + buffer.append("in recovery"); + } else + if (dsQueue.contains(list.get(i))) { + if (dsQueue.peek() == list.get(i)) + buffer.append("active"); + else + buffer.append("standby"); + } + + buffer.append("\n"); + + } + } + return buffer.toString(); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + public T unwrap(Class iface) throws SQLException { + return null; + } + + /** + * @return the monitorDbResponse + */ + public final boolean isMonitorDbResponse() { + return recoveryMode && monitorDbResponse; + } + + public void test(){ + CachedDataSource obj = dsQueue.peek(); + Exception ption = new Exception(); + try { + for(int i=0; i<5; i++) + { + handleGetConnectionException(obj, ption); + } + } catch(Throwable exc){ + LOGGER.warn("", exc); + } + } + + public String getPreferredDSName(){ + if(isActive()){ + return getPreferredDataSourceName(dsSelector); + } + return ""; + } + + public String getPreferredDataSourceName(AtomicBoolean flipper) { + + LinkedList snapshot = new LinkedList(dsQueue); + if(snapshot.size() > 1){ + CachedDataSource first = snapshot.getFirst(); + CachedDataSource last = snapshot.getLast(); + + int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount(); + if(delta < 0) { + flipper.set(false); + } else if(delta > 0) { + flipper.set(true); + } else { + // check the last value and return !last + flipper.getAndSet(!flipper.get()); + } + + if (flipper.get()) + Collections.reverse(snapshot); + } + return snapshot.peek().getDbConnectionName(); + } + + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + return null; + } + + public String getMasterName() { + if(isActive()){ + return getMasterDataSourceName(dsSelector); + } + return ""; + } + + + private String getMasterDataSourceName(AtomicBoolean flipper) { + + LinkedList snapshot = new LinkedList(dsQueue); + if(snapshot.size() > 1){ + CachedDataSource first = snapshot.getFirst(); + CachedDataSource last = snapshot.getLast(); + + int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount(); + if(delta < 0) { + flipper.set(false); + } else if(delta > 0) { + flipper.set(true); + } else { + // check the last value and return !last + flipper.getAndSet(!flipper.get()); + } + + if (flipper.get()) + Collections.reverse(snapshot); + } + return snapshot.peek().getDbConnectionName(); + } + + class RemindTask extends TimerTask { + public void run() { + CachedDataSource ds = dsQueue.peek(); + if(ds != null) + ds.getPoolInfo(false); + } + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java new file mode 100644 index 000000000..2e1a6e953 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.util.Observer; + +public interface DBResourceObserver extends Observer { + public boolean isMonitorDbResponse(); +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java new file mode 100644 index 000000000..7921fa5c5 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.sql.SQLException; +import java.util.ArrayList; + +import javax.sql.rowset.CachedRowSet; + +public interface DataAccessor { + + public abstract CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) + throws SQLException; + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java new file mode 100644 index 000000000..bc14fb8b9 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.util.Comparator; + +public interface DataSourceComparator extends Comparator { + + public abstract CachedDataSource getLastUsed(); + + public abstract void setLastUsed(CachedDataSource lastUsed); + + public abstract int compare(CachedDataSource ds1, CachedDataSource ds2); + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java new file mode 100644 index 000000000..de9846679 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.sql.SQLException; +import java.util.ArrayList; + +import javax.sql.rowset.CachedRowSet; + +public interface DbLibService { + + /* (non-Javadoc) + * @see DataAccessor#getData(java.lang.String, java.util.ArrayList) + */ + public abstract CachedRowSet getData(String statement, + ArrayList arguments, String preferredDS) + throws SQLException; + + /* (non-Javadoc) + * @see DataAccessor#writeData(java.lang.String, java.util.ArrayList) + */ + public abstract boolean writeData(String statement, + ArrayList arguments, String preferredDS) + throws SQLException; + + public abstract boolean isActive(); + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DblibConfigurationException.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DblibConfigurationException.java new file mode 100644 index 000000000..be493aa1f --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DblibConfigurationException.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + + +public class DblibConfigurationException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public DblibConfigurationException() + { + super(); + } + + public DblibConfigurationException(String msg) + { + super(msg); + } + + public DblibConfigurationException(String msg, Throwable t) + { + super(msg, t); + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/NoAvailableConnectionsException.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/NoAvailableConnectionsException.java new file mode 100644 index 000000000..a39e5c5b4 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/NoAvailableConnectionsException.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.sql.SQLException; + +public class NoAvailableConnectionsException extends SQLException { + + /** + * + */ + private static final long serialVersionUID = -6259205931674413018L; + + public NoAvailableConnectionsException(Exception exc) { + super(exc); + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java new file mode 100644 index 000000000..127e6d376 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; + +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; + + +public class TerminatingCachedDataSource extends CachedDataSource implements SQLExecutionMonitorObserver { + + public TerminatingCachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { + super(jdbcElem); + } + + protected void configure(BaseDBConfiguration jdbcElem) throws DBConfigException { + // no action + } + + public long getInterval() { + return 1000; + } + + public long getInitialDelay() { + return 1000; + } + + public long getExpectedCompletionTime() { + return 50; + } + + public void setExpectedCompletionTime(long value) { + + } + + public void setInterval(long value) { + + } + + public void setInitialDelay(long value) { + + } + + public long getUnprocessedFailoverThreshold() { + return 3; + } + + public void setUnprocessedFailoverThreshold(long value) { + + } + + public int compareTo(CachedDataSource ods) + { + return 0; + } + + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java new file mode 100644 index 000000000..4b738d426 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.config; + +import java.util.Properties; + +public abstract class BaseDBConfiguration { + public static final String DATABASE_TYPE = "org.onap.ccsdk.sli.dbtype"; + public static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url"; + public static final String DATABASE_NAME = "org.onap.ccsdk.sli.jdbc.database"; + public static final String CONNECTION_NAME = "org.onap.ccsdk.sli.jdbc.connection.name"; + public static final String DATABASE_USER = "org.onap.ccsdk.sli.jdbc.user"; + public static final String DATABASE_PSSWD = "org.onap.ccsdk.sli.jdbc.password"; + public static final String CONNECTION_TIMEOUT="org.onap.ccsdk.sli.jdbc.connection.timeout"; + public static final String REQUEST_TIMEOUT = "org.onap.ccsdk.sli.jdbc.request.timeout"; + public static final String MIN_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.min"; + public static final String MAX_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.max"; + public static final String INIT_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.init"; + public static final String DATABASE_HOSTS = "org.onap.ccsdk.sli.jdbc.hosts"; + + + protected final Properties props; + + public BaseDBConfiguration(Properties properties) { + this.props = properties; + } + + public int getConnTimeout() { + try { + String value = props.getProperty(CONNECTION_TIMEOUT); + return Integer.parseInt(value); + } catch(Exception exc) { + return -1; + } + } + + public int getRequestTimeout() { + try { + String value = props.getProperty(REQUEST_TIMEOUT); + if(value == null) + return -1; + return Integer.parseInt(value); + } catch(Exception exc) { + return -1; + } + } + + public String getDbConnectionName() { + return props.getProperty(CONNECTION_NAME); + } + + public String getDatabaseName() { + return props.getProperty(DATABASE_NAME); + } + + public String getDbUserId() { + return props.getProperty(DATABASE_USER); + } + + public String getDbPasswd() { + return props.getProperty(DATABASE_PSSWD); + } + + public int getDbMinLimit() { + String value = props.getProperty(MIN_LIMIT); + return Integer.parseInt(value); + } + + public int getDbMaxLimit() { + String value = props.getProperty(MAX_LIMIT); + return Integer.parseInt(value); + } + + public int getDbInitialLimit() { + String value = props.getProperty(INIT_LIMIT); + return Integer.parseInt(value); + } + + public String getDbUrl() { + return props.getProperty(DATABASE_URL); + } + + public String getServerGroup() { + return null; + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java new file mode 100644 index 000000000..21fdab245 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.config; + +import java.util.ArrayList; +import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DbConfigPool { + private static Logger LOGGER = LoggerFactory.getLogger(DbConfigPool.class); + + private final String type; + + private ArrayList configurations = new ArrayList(); + + public DbConfigPool(Properties properties) { + LOGGER.debug("Initializing DbConfigType"); + type = properties.getProperty(BaseDBConfiguration.DATABASE_TYPE, "JDBC").toUpperCase(); + } + + public int getTimeout() { + // TODO Auto-generated method stub + return 0; + } + + public String getType() { + return type; + } + + public JDBCConfiguration[] getJDBCbSourceArray() { + return configurations.toArray(new JDBCConfiguration[configurations.size()]); + } + + public void addConfiguration(BaseDBConfiguration config) { + configurations.add(config); + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/JDBCConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/JDBCConfiguration.java new file mode 100644 index 000000000..fea103569 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/JDBCConfiguration.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.config; + +import java.util.Properties; + +public class JDBCConfiguration extends BaseDBConfiguration { + + public JDBCConfiguration(Properties xmlElem) { + super(xmlElem); + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractDBResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractDBResourceManagerFactory.java new file mode 100644 index 000000000..e88734d2e --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractDBResourceManagerFactory.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.factory; + +import org.onap.ccsdk.sli.core.dblib.jdbc.JdbcDbResourceManagerFactory; + +/** + * @version $Revision: 1.1 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class AbstractDBResourceManagerFactory { + + public static AbstractResourceManagerFactory getFactory(String type) throws FactoryNotDefinedException { + + // JDBC + return JdbcDbResourceManagerFactory.createIntstance(); + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java new file mode 100644 index 000000000..6fc7e7a04 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.factory; + + +import java.sql.SQLException; +import java.util.Set; +import java.util.concurrent.Callable; + +import org.onap.ccsdk.sli.core.dblib.CachedDataSource; +import org.onap.ccsdk.sli.core.dblib.CachedDataSourceFactory; +import org.onap.ccsdk.sli.core.dblib.DBConfigException; +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @version $Revision: 1.6 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public abstract class AbstractResourceManagerFactory { + private static Logger LOGGER = LoggerFactory.getLogger(AbstractResourceManagerFactory.class); + + public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager) throws Exception; + public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager dbResourceManager, String sourceName) throws SQLException ; + + + public static AbstractResourceManagerFactory createIntstance() throws FactoryNotDefinedException { + throw new FactoryNotDefinedException("Factory method 'createIntstance' needs to be overriden in DBResourceManagerFactory"); + } + + public class DBInitTask implements Callable + { + private BaseDBConfiguration config = null; + private Set activeTasks; + + public DBInitTask(JDBCConfiguration jdbcconfig, Set tasks) { + this.config = jdbcconfig; + this.activeTasks = tasks; + } + + public CachedDataSource call() throws Exception { + CachedDataSource ds = null; + try { + ds = CachedDataSourceFactory.createDataSource(config); + return ds; + } finally { + synchronized(activeTasks) { + activeTasks.remove(this); + if (activeTasks.isEmpty()) { + final Runnable closure = new Runnable() { + + public void run() { + try { + Thread.sleep(300); + } catch (Exception e) { + } + synchronized(activeTasks) { + activeTasks.notifyAll(); + } + } + }; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Completed CachedDataSource.Call and notifyAll from " + ds.getDbConnectionName()); + } + Thread worker = new Thread(closure); + worker.setDaemon(true); + worker.start(); + } else { + if (LOGGER.isDebugEnabled()) { + if (ds != null) { + LOGGER.debug("Completed CachedDataSource.Call from " + ds.getDbConnectionName()); + } + } + } + } + } + } + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java new file mode 100644 index 000000000..3caa7767e --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.factory; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.slf4j.LoggerFactory; + +/** + * @version $Revision: 1.1 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki 01/17/08 Initial version + */ +public class DBConfigFactory { + + public static DbConfigPool createConfig(Properties resource) { + return getConfigparams(resource); + } + + static DbConfigPool getConfigparams(Properties properties){ + DbConfigPool xmlConfig = new DbConfigPool(properties); + ArrayList propertySets = new ArrayList(); + + if("JDBC".equalsIgnoreCase(xmlConfig.getType())) { + String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS); + if(hosts == null || hosts.isEmpty()) { + propertySets.add(properties); + } else { + String[] newhost = hosts.split(","); + for(int i=0; i< newhost.length; i++) { + Properties localset = new Properties(); + localset.putAll(properties); + String url = localset.getProperty(BaseDBConfiguration.DATABASE_URL); + if(url.contains("DBHOST")) + url = url.replace("DBHOST", newhost[i]); + if(url.contains("dbhost")) + url = url.replace("dbhost", newhost[i]); + localset.setProperty(BaseDBConfiguration.DATABASE_URL, url); + localset.setProperty(BaseDBConfiguration.CONNECTION_NAME, newhost[i]); + propertySets.add(localset); + } + } + } else { + propertySets.add(properties); + } + try { + Iterator it = propertySets.iterator(); + while(it.hasNext()) { + BaseDBConfiguration config = parse(it.next()); + xmlConfig.addConfiguration(config); + } + + } catch (Exception e) { + LoggerFactory.getLogger(DBConfigFactory.class).warn("",e); + } + + return xmlConfig; + } + + public static BaseDBConfiguration parse(Properties props) throws Exception { + + String type = props.getProperty(BaseDBConfiguration.DATABASE_TYPE); + + BaseDBConfiguration config = null; + + if("JDBC".equalsIgnoreCase(type)) { + config = new JDBCConfiguration(props); + } + + return config; + + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/FactoryNotDefinedException.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/FactoryNotDefinedException.java new file mode 100644 index 000000000..b6383a53b --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/FactoryNotDefinedException.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.factory; + + +/** + * @version 1.3 + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki 01/16/08 Initial version + */ +public class FactoryNotDefinedException extends Exception { + + public FactoryNotDefinedException(String message) { + super(message); + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java new file mode 100644 index 000000000..c024d0021 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java @@ -0,0 +1,249 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.jdbc; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLFeatureNotSupportedException; + +import org.apache.tomcat.jdbc.pool.DataSource; +import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.onap.ccsdk.sli.core.dblib.CachedDataSource; +import org.onap.ccsdk.sli.core.dblib.DBConfigException; +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.mysql.jdbc.Driver; + + +/** + * @version $Revision: 1.7 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ + +public class JdbcDBCachedDataSource extends CachedDataSource +{ + private String dbUserId; + private String dbPasswd; + private String dbUrl; + + private int minLimit; + private int maxLimit; + private int initialLimit; + + private static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; + + private static Logger LOGGER = LoggerFactory.getLogger(JdbcDBCachedDataSource.class); + + /** + * @param jdbcElem + */ + public JdbcDBCachedDataSource(BaseDBConfiguration jdbcElem) + { + super(jdbcElem); + } + + @Override + protected void configure(BaseDBConfiguration xmlElem) throws DBConfigException + { + BaseDBConfiguration jdbcConfig = (BaseDBConfiguration)xmlElem; + if(jdbcConfig.getConnTimeout() > 0){ + this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); + } + if(jdbcConfig.getRequestTimeout() > 0){ + this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); + } + + // set connection pool name + String dbConnectionName = jdbcConfig.getDbConnectionName(); + super.setDbConnectionName(dbConnectionName); + // Configure the JDBC connection + dbUserId = jdbcConfig.getDbUserId(); + if (dbUserId == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + dbPasswd = jdbcConfig.getDbPasswd(); + if (dbPasswd == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + /* + dbDriver = jdbcConfig.getDbDriver(); + if (dbDriver == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new ScpTblUpdateError(errorMsg); + } + */ + + minLimit = jdbcConfig.getDbMinLimit(); +// if (minLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + maxLimit = jdbcConfig.getDbMaxLimit(); +// if (maxLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + initialLimit = jdbcConfig.getDbInitialLimit(); +// if (initialLimit == null) +// { +// String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); +// } + + dbUrl = jdbcConfig.getDbUrl(); + if(dbUrl == null){ + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + try { + Driver dr = new com.mysql.jdbc.Driver(); + Class clazz = Class.forName("com.mysql.jdbc.Driver") ; + + PoolProperties p = new PoolProperties(); + p.setDriverClassName("com.mysql.jdbc.Driver"); + p.setUrl(dbUrl); + p.setUsername(dbUserId); + p.setPassword(dbPasswd); + p.setJmxEnabled(true); + p.setTestWhileIdle(false); + p.setTestOnBorrow(true); + p.setValidationQuery("SELECT 1"); + p.setTestOnReturn(false); + p.setValidationInterval(30000); + p.setTimeBetweenEvictionRunsMillis(30000); + p.setInitialSize(initialLimit); + p.setMaxActive(maxLimit); + p.setMaxIdle(maxLimit); + p.setMaxWait(10000); + p.setRemoveAbandonedTimeout(60); + p.setMinEvictableIdleTimeMillis(30000); + p.setMinIdle(minLimit); + p.setLogAbandoned(true); + p.setRemoveAbandoned(true); + p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" + + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"); + + DataSource dataSource = new DataSource(p); + + synchronized(this) + { + this.ds = dataSource; + Connection con = null; + PreparedStatement st = null; + ResultSet rs = null; + + try { + con = dataSource.getConnection(); + st = con.prepareStatement("Select 1 FROM DUAL"); + rs = st.executeQuery(); + } catch(Exception exc) { + LOGGER.error(exc.getMessage()); + } finally { + if(rs != null) rs.close(); + if(st != null) st.close(); + if(con != null) con.close(); + } + + initialized = true; + LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); + } + +// } catch (SQLException exc) { +// initialized = false; +// StringBuffer sb = new StringBuffer(); +// sb.append("Failed to initialize MySQLDataSource<"); +// sb.append(dbConnectionName).append(">. Reason: "); +// sb.append(exc.getMessage()); +// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +//// throw new DBConfigException(e.getMessage()); + } catch (Exception exc) { + initialized = false; + StringBuffer sb = new StringBuffer(); + sb.append("Failed to initialize MySQLCachedDataSource <"); + sb.append(dbConnectionName).append(">. Reason: "); + sb.append(exc.getMessage()); + LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +// throw new DBConfigException(e.getMessage()); + } + } + + public final String getDbUrl() + { + return dbUrl; + } + + public final String getDbUserId() + { + return dbUserId; + } + + public final String getDbPasswd() + { + return dbPasswd; + } + + public static JdbcDBCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { + return new JdbcDBCachedDataSource(config); + } + + public String toString(){ + return getDbConnectionName(); + } + + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } + + public void cleanUp(){ + DataSource dataSource = (DataSource)ds; + dataSource.getPool().purge(); + int active = dataSource.getActive(); + int size = dataSource.getSize(); + dataSource.close(true); + super.cleanUp(); + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java new file mode 100644 index 000000000..978de0eb3 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java @@ -0,0 +1,186 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.jdbc; + + +import java.sql.SQLException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; + +import org.onap.ccsdk.sli.core.dblib.CachedDataSource; +import org.onap.ccsdk.sli.core.dblib.CachedDataSourceFactory; +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.dblib.DataSourceComparator; +import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @version $Revision: 1.6 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ +public class JdbcDbResourceManagerFactory extends AbstractResourceManagerFactory { + private static Logger LOGGER = LoggerFactory.getLogger(JdbcDbResourceManagerFactory.class ); + private JdbcDbResourceManagerFactory(){ + + } + + class MyFutureTask extends FutureTask + { + + public MyFutureTask(Callable result) { + super(result); + } + + } + + public CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager, String sourceName) throws SQLException + { + // here create the data sources objects + JDBCConfiguration[] list = dbConfig.getJDBCbSourceArray(); + CachedDataSource[] cachedDS = new CachedDataSource[1]; + + for(int i=0, max=list.length; i tasks = new HashSet(); + if(LOGGER.isDebugEnabled()) { + LOGGER.debug("Creating " + list.length + " datasources."); + } + + for(int i=0, max=list.length; i 0){ + this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); + } + if(jdbcConfig.getRequestTimeout() > 0){ + this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); + } + + // set connection pool name + String dbConnectionName = jdbcConfig.getDbConnectionName(); + super.setDbConnectionName(dbConnectionName); + // Configure the JDBC connection + dbUserId = jdbcConfig.getDbUserId(); + if (dbUserId == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + dbPasswd = jdbcConfig.getDbPasswd(); + if (dbPasswd == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + /* + dbDriver = jdbcConfig.getDbDriver(); + if (dbDriver == null) + { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new ScpTblUpdateError(errorMsg); + } + */ + + minLimit = Integer.toString(jdbcConfig.getDbMinLimit()); + if (minLimit == null) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + maxLimit = Integer.toString(jdbcConfig.getDbMaxLimit()); + if (maxLimit == null) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + initialLimit = Integer.toString(jdbcConfig.getDbInitialLimit()); + if (initialLimit == null) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + dbUrl = jdbcConfig.getDbUrl(); + if(dbUrl == null){ + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); + } + + try { + + MysqlDataSource dataSource = new MysqlDataSource(); + dataSource.setUser(dbUserId); + dataSource.setPassword(dbPasswd); + dataSource.setURL(dbUrl); +// dataSource.setInitialSize(5); +// dataSource.setMaxTotal(60); +// dataSource.setMaxActive(100); +// dataSource.setMaxWait(10000); +// dataSource.setMaxIdle(10); + + Properties connAttr = new Properties(); + + connAttr.setProperty("MinLimit", minLimit); + connAttr.setProperty("MaxLimit", maxLimit); + connAttr.setProperty("InitialLimit", initialLimit); + connAttr.setProperty("TRANSACTION_ISOLATION","SERIALIZABLE"); + connAttr.setProperty("CONNECTION_TAG", dbConnectionName.toUpperCase()+"_CONNECTION"); + connAttr.setProperty("InactivityTimeout", "900"); + connAttr.setProperty("AbandonedConnectionTimeout", "600"); + connAttr.setProperty("PropertyCheckInterval", "60"); + connAttr.setProperty("ValidateConnection", "true"); + + + synchronized(this) + { + this.ds = dataSource; + + initialized = true; + LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); + } + +// } catch (SQLException exc) { +// initialized = false; +// StringBuffer sb = new StringBuffer(); +// sb.append("Failed to initialize MySQLDataSource<"); +// sb.append(dbConnectionName).append(">. Reason: "); +// sb.append(exc.getMessage()); +// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +//// throw new DBConfigException(e.getMessage()); + } catch (Exception exc) { + initialized = false; + StringBuffer sb = new StringBuffer(); + sb.append("Failed to initialize MySQLCachedDataSource <"); + sb.append(dbConnectionName).append(">. Reason: "); + sb.append(exc.getMessage()); + LOGGER.error("AS_CONF_ERROR: " + sb.toString()); +// throw new DBConfigException(e.getMessage()); + } + } + + public final String getDbUrl() + { + return dbUrl; + } + + public final String getDbUserId() + { + return dbUserId; + } + + public final String getDbPasswd() + { + return dbPasswd; + } + + public static MySQLCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { + return new MySQLCachedDataSource(config); + } + + public String toString(){ + return getDbConnectionName(); + } + + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java new file mode 100644 index 000000000..b670a832d --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java @@ -0,0 +1,217 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.pm; + +import java.util.Iterator; +import java.util.Properties; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.TreeSet; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.atomic.AtomicLong; + +public class PollingWorker implements Runnable { + + private Logger LOGGER = LoggerFactory.getLogger(PollingWorker.class); + + private static PollingWorker self = null; + + private LinkedBlockingQueue tasks = new LinkedBlockingQueue(100); + private long interval = 1000L; + private Thread worker = null; + private AtomicLong[] counters = null; + private int[] bucketUnit = null; + private static boolean enabled = false; + private Timer timer = null; + + public static void post(long starttime){ + PollingWorker temp = self; + if(temp != null && enabled) { + temp.register(new TestSample(starttime)); + } + } + + public static void createInistance(Properties props){ + self = new PollingWorker(props); + } + + private PollingWorker(Properties ctxprops){ + if(ctxprops==null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm") == null){ + enabled = false; + } else { + if("true".equalsIgnoreCase((String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm"))){ + enabled = true; + } else { + enabled = false; + } + } + + interval = Long.parseLong(( ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval") == null) ? "60" : (String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval")); + // '0' bucket is to count exceptions + String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")==null) ? "0,2,5,10,20,50,100" : (String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")).split(","); + + if(enabled){ + bucketUnit = new int[sampling.length]; + for(int i=0, max = bucketUnit.length; i x.starttime) + return -1; + if(endtime > x.endtime) + return -1; + return 0; + } + return 1; + } + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java new file mode 100644 index 000000000..bcd4360e4 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java @@ -0,0 +1,237 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.pm; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collections; +import java.util.Observable; +import java.util.Observer; +import java.util.SortedSet; +import java.util.Timer; +import java.util.TimerTask; +import java.util.TreeSet; +import java.util.concurrent.atomic.AtomicLong; + +import org.onap.ccsdk.sli.core.dblib.DBResourceObserver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SQLExecutionMonitor extends Observable +{ + private static Logger LOGGER = LoggerFactory.getLogger(SQLExecutionMonitor.class); + + final static long MILISECOND = 1000000L; + final static long SECOND = 1000L*MILISECOND; + + private final Timer timer; + // collection + private final SortedSet innerSet; + private SQLExecutionMonitorObserver parent = null; + private final AtomicLong completionCounter; + private boolean activeState = false; + private final long interval; + private final long initialDelay; + private final long EXPECTED_TIME_TO_COMPLETE; + private final long UNPROCESSED_FAILOVER_THRESHOLD; + + private final class MonitoringTask extends TimerTask + { + + public void run() + { + try { + TestObject testObj = new TestObject(); + testObj.setStartTime(testObj.getStartTime() - EXPECTED_TIME_TO_COMPLETE); + + // take a snapshot of the current task list + TestObject[] array = innerSet.toArray(new TestObject[0]); + SortedSet copyCurrent = new TreeSet(Arrays.asList(array)); + // get the list of the tasks that are older than the specified + // interval. + SortedSet unprocessed = copyCurrent.headSet(testObj); + + long succesfulCount = completionCounter.get(); + int unprocessedCount = unprocessed.size(); + + if (!unprocessed.isEmpty() && unprocessedCount > UNPROCESSED_FAILOVER_THRESHOLD && succesfulCount == 0) + { + // switch the Connection Pool to passive + setChanged(); + notifyObservers("Open JDBC requests=" + unprocessedCount+" in "+SQLExecutionMonitor.this.parent.getDbConnectionName()); + } + } catch (Exception exc) { + LOGGER.error("", exc); + } finally { + completionCounter.set(0L); + } + } + } + + public static class TestObject implements Comparable, Serializable + { + + private static final long serialVersionUID = 1L; + private long starttime; + private long randId; + + public TestObject() + { + starttime = System.nanoTime(); + } + + public long getStartTime() + { + return starttime; + } + + public void setStartTime(long newTime) + { + starttime = newTime; + } + + public int compareTo(TestObject o) + { + if( this == o) + return 0; + if(this.starttime > o.getStartTime()) + return 1; + if(this.starttime < o.getStartTime()) + return -1; + + if(this.hashCode() > o.hashCode()) + return 1; + if(this.hashCode() < o.hashCode()) + return -1; + + return 0; + } + + public String toString() + { + return Long.toString(starttime)+"#"+ this.hashCode(); + } + + public boolean equals(Object obj) + { + if (this == obj) + return true; + + return (obj instanceof TestObject + && starttime == ((TestObject) obj).getStartTime() + && hashCode() == ((TestObject) obj).hashCode()); + } + } + + public SQLExecutionMonitor(SQLExecutionMonitorObserver parent) + { + this.parent = parent; + completionCounter = new AtomicLong(0L); + interval = parent.getInterval(); + initialDelay = parent.getInitialDelay(); + this.UNPROCESSED_FAILOVER_THRESHOLD = parent.getUnprocessedFailoverThreshold(); + this.EXPECTED_TIME_TO_COMPLETE = parent.getExpectedCompletionTime()*MILISECOND; + + innerSet = Collections.synchronizedSortedSet(new TreeSet()); + timer = new Timer(); + } + + public void cleanup() + { + timer.cancel(); + } + + // registerRequest + public TestObject registerRequest() + { + if(activeState) + { + TestObject test = new TestObject(); + if(innerSet.add(test)) + return test; + } + return null; + } + + // deregisterSuccessfulReguest + public boolean deregisterReguest(TestObject test) + { + if(test == null) + return false; + // remove from the collection + if(innerSet.remove(test) && activeState) + { + completionCounter.incrementAndGet(); + return true; + } + return false; + } + + public void terminate() { + timer.cancel(); + } + + /** + * @return the parent + */ + public final Object getParent() { + return parent; + } + + public void addObserver(Observer observer) + { + if(observer instanceof DBResourceObserver) + { + DBResourceObserver dbObserver = (DBResourceObserver)observer; + if(dbObserver.isMonitorDbResponse()) + { + if(countObservers() == 0) + { + TimerTask remindTask = new MonitoringTask(); + timer.schedule(remindTask, initialDelay, interval); + activeState = true; + } + } + } + super.addObserver(observer); + } + + public void deleteObserver(Observer observer) + { + super.deleteObserver(observer); + if(observer instanceof DBResourceObserver) + { + DBResourceObserver dbObserver = (DBResourceObserver)observer; + if(dbObserver.isMonitorDbResponse()) + { + if(countObservers() == 0) + { + timer.cancel(); + activeState = false; + } + } + } + } + + public final int getPorcessedConnectionsCount() { + return innerSet.size(); + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java new file mode 100644 index 000000000..c17696a80 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.pm; + +public interface SQLExecutionMonitorObserver { + public String getDbConnectionName(); + + public long getInterval(); + public void setInterval(long value); + + public long getInitialDelay(); + public void setInitialDelay(long value); + + public long getExpectedCompletionTime(); + public void setExpectedCompletionTime(long value); + + public long getUnprocessedFailoverThreshold(); + public void setUnprocessedFailoverThreshold(long value); +} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSource.java deleted file mode 100644 index 58a0aeb11..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSource.java +++ /dev/null @@ -1,616 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.io.Closeable; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.sql.Blob; -import java.sql.Connection; -import java.sql.Date; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Observer; - -import javax.sql.DataSource; -import javax.sql.rowset.CachedRowSet; -import javax.sql.rowset.RowSetProvider; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.tomcat.jdbc.pool.PoolExhaustedException; -import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitor; -import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitorObserver; -import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitor.TestObject; -import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; - - -/** - * @version $Revision: 1.13 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ - -public abstract class CachedDataSource implements DataSource, SQLExecutionMonitorObserver -{ - private static Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); - - protected static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; - - protected long CONN_REQ_TIMEOUT = 30L; - protected long DATA_REQ_TIMEOUT = 100L; - - private final SQLExecutionMonitor monitor; - protected DataSource ds = null; - protected String connectionName = null; - protected boolean initialized = false; - - private long interval = 1000; - private long initialDelay = 5000; - private long expectedCompletionTime = 50L; - private boolean canTakeOffLine = true; - private long unprocessedFailoverThreshold = 3L; - - private long nextErrorReportTime = 0L; - - private String globalHostName = null; - - - public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException - { - configure(jdbcElem); - monitor = new SQLExecutionMonitor(this); - } - - protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; - /* (non-Javadoc) - * @see javax.sql.DataSource#getConnection() - */ - public Connection getConnection() throws SQLException - { - return ds.getConnection(); - } - - public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable - { - TestObject testObject = null; - testObject = monitor.registerRequest(); - - Connection connection = null; - try { - connection = this.getConnection(); - if(connection == null ) { - throw new SQLException("Connection invalid"); - } - if(LOGGER.isDebugEnabled()) - LOGGER.debug("Obtained connection <" + connectionName + ">: "+connection.toString()); - return executePreparedStatement(connection, statement, arguments, true); - } finally { - try { - if(connection != null && !connection.isClosed()) { - connection.close(); - } - } catch(Throwable exc) { - // the exception not monitored - } finally { - connection = null; - } - - monitor.deregisterReguest(testObject); - } - } - - public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable - { - TestObject testObject = null; - testObject = monitor.registerRequest(); - - Connection connection = null; - try { - connection = this.getConnection(); - if(connection == null ) { - throw new SQLException("Connection invalid"); - } - if(LOGGER.isDebugEnabled()) - LOGGER.debug("Obtained connection <" + connectionName + ">: "+connection.toString()); - return executeUpdatePreparedStatement(connection, statement, arguments, true); - } finally { - try { - if(connection != null && !connection.isClosed()) { - connection.close(); - } - } catch(Throwable exc) { - // the exception not monitored - } finally { - connection = null; - } - - monitor.deregisterReguest(testObject); - } - } - - CachedRowSet executePreparedStatement(Connection conn, String statement, ArrayList arguments, boolean close) throws SQLException, Throwable - { - long time = System.currentTimeMillis(); - - CachedRowSet data = null; - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL Statement: "+ statement); - if(arguments != null && !arguments.isEmpty()) { - LOGGER.debug("Argunments: "+ Arrays.toString(arguments.toArray())); - } - } - - ResultSet rs = null; - try { - data = RowSetProvider.newFactory().createCachedRowSet(); - PreparedStatement ps = conn.prepareStatement(statement); - if(arguments != null) - { - for(int i = 0, max = arguments.size(); i < max; i++){ - ps.setObject(i+1, arguments.get(i)); - } - } - rs = ps.executeQuery(); - data.populate(rs); - // Point the rowset Cursor to the start - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL SUCCESS. rows returned: " + data.size()+ ", time(ms): "+ (System.currentTimeMillis() - time)); } - } catch(SQLException exc){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); - } - try { conn.rollback(); } catch(Throwable thr){} - if(arguments != null && !arguments.isEmpty()) { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); - } else { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); - } - throw exc; - } catch(Throwable exc){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); - } - if(arguments != null && !arguments.isEmpty()) { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); - } else { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); - } - throw exc; // new SQLException(exc); - } finally { - - try { - if(rs != null){ - rs.close(); - rs = null; - } - } catch(Exception exc){ - - } - try { - if(conn != null && close){ - conn.close(); - conn = null; - } - } catch(Exception exc){ - - } - } - - return data; - } - - boolean executeUpdatePreparedStatement(Connection conn, String statement, ArrayList arguments, boolean close) throws SQLException, Throwable { - long time = System.currentTimeMillis(); - - CachedRowSet data = null; - - int rs = -1; - try { - data = RowSetProvider.newFactory().createCachedRowSet(); - PreparedStatement ps = conn.prepareStatement(statement); - if(arguments != null) - { - for(int i = 0, max = arguments.size(); i < max; i++){ - if(arguments.get(i) instanceof Blob) { - ps.setBlob(i+1, (Blob)arguments.get(i)); - } else if(arguments.get(i) instanceof Timestamp) { - ps.setTimestamp(i+1, (Timestamp)arguments.get(i)); - } else if(arguments.get(i) instanceof Integer) { - ps.setInt(i+1, (Integer)arguments.get(i)); - } else if(arguments.get(i) instanceof Long) { - ps.setLong(i+1, (Long)arguments.get(i)); - } else if(arguments.get(i) instanceof Date) { - ps.setDate(i+1, (Date)arguments.get(i)); - } else { - ps.setObject(i+1, arguments.get(i)); - } - } - } - rs = ps.executeUpdate(); - // Point the rowset Cursor to the start - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL SUCCESS. rows returned: " + data.size()+ ", time(ms): "+ (System.currentTimeMillis() - time)); - } - } catch(SQLException exc){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); - } - try { conn.rollback(); } catch(Throwable thr){} - if(arguments != null && !arguments.isEmpty()) { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); - } else { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); - } - throw exc; - } catch(Throwable exc){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); - } - if(arguments != null && !arguments.isEmpty()) { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); - } else { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); - } - throw exc; // new SQLException(exc); - } finally { - try { - if(conn != null && close){ - conn.close(); - conn = null; - } - } catch(Exception exc){ - - } - } - - return true; - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) - */ - public Connection getConnection(String username, String password) - throws SQLException - { - return ds.getConnection(username, password); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getLogWriter() - */ - public PrintWriter getLogWriter() throws SQLException - { - return ds.getLogWriter(); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getLoginTimeout() - */ - public int getLoginTimeout() throws SQLException - { - return ds.getLoginTimeout(); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) - */ - public void setLogWriter(PrintWriter out) throws SQLException - { - ds.setLogWriter(out); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#setLoginTimeout(int) - */ - public void setLoginTimeout(int seconds) throws SQLException - { - ds.setLoginTimeout(seconds); - } - - - public final String getDbConnectionName(){ - return connectionName; - } - - protected final void setDbConnectionName(String name) { - this.connectionName = name; - } - - public void cleanUp(){ - if(ds != null && ds instanceof Closeable) { - try { - ((Closeable)ds).close(); - } catch (IOException e) { - LOGGER.warn(e.getMessage()); - } - } - ds = null; - monitor.deleteObservers(); - monitor.cleanup(); - } - - public boolean isInitialized() { - return initialized; - } - - protected boolean testConnection(){ - return testConnection(false); - } - - protected boolean testConnection(boolean error_level){ - Connection conn = null; - ResultSet rs = null; - Statement stmt = null; - try - { - Boolean readOnly = null; - String hostname = null; - conn = this.getConnection(); - stmt = conn.createStatement(); - rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); //("SELECT 1 FROM DUAL"); //"select BANNER from SYS.V_$VERSION" - while(rs.next()) - { - readOnly = rs.getBoolean(1); - hostname = rs.getString(2); - - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL DataSource <"+getDbConnectionName() + "> connected to " + hostname + ", read-only is " + readOnly + ", tested successfully "); - } - } - - } catch (Throwable exc) { - if(error_level) { - LOGGER.error("SQL DataSource <" + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); - } else { - LOGGER.info("SQL DataSource <" + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); - } - return false; - } finally { - if(rs != null) { - try { - rs.close(); - rs = null; - } catch (SQLException e) { - } - } - if(stmt != null) { - try { - stmt.close(); - stmt = null; - } catch (SQLException e) { - } - } - if(conn !=null){ - try { - conn.close(); - conn = null; - } catch (SQLException e) { - } - } - } - return true; - } - - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } - - public T unwrap(Class iface) throws SQLException { - return null; - } - - @SuppressWarnings("deprecation") - public void setConnectionCachingEnabled(boolean state) - { -// if(ds != null && ds instanceof OracleDataSource) -// try { -// ((OracleDataSource)ds).setConnectionCachingEnabled(true); -// } catch (SQLException exc) { -// LOGGER.warn("", exc); -// } - } - - public void addObserver(Observer observer) { - monitor.addObserver(observer); - } - - public void deleteObserver(Observer observer) { - monitor.deleteObserver(observer); - } - - public long getInterval() { - return interval; - } - - public long getInitialDelay() { - return initialDelay; - } - - public void setInterval(long value) { - interval = value; - } - - public void setInitialDelay(long value) { - initialDelay = value; - } - - public long getExpectedCompletionTime() { - return expectedCompletionTime; - } - - public void setExpectedCompletionTime(long value) { - expectedCompletionTime = value; - } - - public long getUnprocessedFailoverThreshold() { - return unprocessedFailoverThreshold; - } - - public void setUnprocessedFailoverThreshold(long value) { - this.unprocessedFailoverThreshold = value; - } - - public boolean canTakeOffLine() { - return canTakeOffLine; - } - - public void blockImmediateOffLine() { - canTakeOffLine = false; - final Thread offLineTimer = new Thread() - { - public void run(){ - try { - Thread.sleep(30000L); - }catch(Throwable exc){ - - }finally{ - canTakeOffLine = true; - } - } - }; - offLineTimer.setDaemon(true); - offLineTimer.start(); - } - - /** - * @return the monitor - */ - final SQLExecutionMonitor getMonitor() { - return monitor; - } - - protected boolean isSlave() throws PoolExhaustedException, MySQLNonTransientConnectionException { - CachedRowSet rs = null; - boolean isSlave = true; - String hostname = "UNDETERMINED"; - try { - boolean localSlave = true; - rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList()); - while(rs.next()) { - localSlave = rs.getBoolean(1); - hostname = rs.getString(2); - } - isSlave = localSlave; - } catch(PoolExhaustedException | MySQLNonTransientConnectionException peexc){ - throw peexc; - } catch (SQLException e) { - LOGGER.error("", e); - isSlave = true; - } catch (Throwable e) { - LOGGER.error("", e); - isSlave = true; - } - if(isSlave){ - LOGGER.debug("SQL SLAVE : "+connectionName + " on server " + hostname); - } else { - LOGGER.debug("SQL MASTER : "+connectionName + " on server " + hostname); - } - return isSlave; - } - - public boolean isFabric() { - return false; - } - - protected boolean lockTable(Connection conn, String tableName) { - boolean retValue = false; - Statement lock = null; - try { - if(tableName != null) { - if(LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); - if("SVC_LOGIC".equals(tableName)) { - Exception e = new Exception(); - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - LOGGER.debug(sw.toString()); - } - } - lock = conn.createStatement(); - lock.execute("LOCK TABLES " + tableName + " WRITE"); - retValue = true; - } - } catch(Exception exc){ - LOGGER.error("", exc); - retValue = false; - } finally { - try { - lock.close(); - } catch(Exception exc) { - - } - } - return retValue; - } - - protected boolean unlockTable(Connection conn) { - boolean retValue = false; - Statement lock = null; - try { - if(LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'UNLOCK TABLES' on connection " + conn.toString()); - } - lock = conn.createStatement(); - retValue = lock.execute("UNLOCK TABLES"); - } catch(Exception exc){ - LOGGER.error("", exc); - retValue = false; - } finally { - try { - lock.close(); - } catch(Exception exc) { - - } - } - return retValue; - } - - public void getPoolInfo(boolean allocation) { - - } - - public long getNextErrorReportTime() { - return nextErrorReportTime; - } - - public void setNextErrorReportTime(long nextTime) { - this.nextErrorReportTime = nextTime; - } - - public void setGlobalHostName(String hostname) { - this.globalHostName = hostname; - } - - public String getGlobalHostName() { - return globalHostName; - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java deleted file mode 100644 index 3e51ed942..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/CachedDataSourceFactory.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - - -import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.jdbc.JdbcDBCachedDataSource; -import org.openecomp.sdnc.sli.resource.dblib.jdbc.MySQLCachedDataSource; - -/** - * @version $Revision: 1.1 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public class CachedDataSourceFactory { - - public static CachedDataSource createDataSource(BaseDBConfiguration config) { - if(config instanceof JDBCConfiguration) - return JdbcDBCachedDataSource.createInstance(config); - - return (CachedDataSource)null; - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBConfigException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBConfigException.java deleted file mode 100644 index b324e6a2c..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBConfigException.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - - -/** - * @version $Revision: 1.1 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public class DBConfigException extends RuntimeException -{ - /** - * - */ - private static final long serialVersionUID = 4752405152537680257L; - - public DBConfigException(Exception e) - { - super(e.toString()); - } - - public DBConfigException(String msg) - { - super(msg); - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLIBResourceActivator.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLIBResourceActivator.java deleted file mode 100644 index 150a9a82f..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLIBResourceActivator.java +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.io.File; -import java.net.URL; -import java.util.Properties; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DBLIBResourceActivator implements BundleActivator { - - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - - private static final String DBLIB_PROP_PATH = "/dblib.properties"; - - private ServiceRegistration registration = null; - - private static final Logger LOG = LoggerFactory.getLogger(DBLIBResourceActivator.class); - - @Override - public void start(BundleContext ctx) throws Exception { - LOG.info("entering DBLIBResourceActivator.start"); - - DbLibService jdbcDataSource = null; - // Read properties - Properties props = new Properties(); - - File file = null; - URL propURL = null; - String propDir = System.getenv(SDNC_CONFIG_DIR); - if ((propDir == null) || (propDir.length() == 0)) { - propDir = "/opt/sdnc/data/properties"; - } - file = new File(propDir + DBLIB_PROP_PATH); - if(file.exists()) { - propURL = file.toURI().toURL(); - LOG.info("Using property file (1): " + file.toString()); - } else { - propURL = ctx.getBundle().getResource("dblib.properties"); - URL tmp = null; - if (propURL == null) { - file = new File(DBLIB_PROP_PATH); - tmp = this.getClass().getResource(DBLIB_PROP_PATH); -// if(!file.exists()) { - if(tmp == null) { - throw new DblibConfigurationException("Missing configuration properties resource(3) : " + DBLIB_PROP_PATH); - } else { - propURL = tmp; //file.toURI().toURL(); - LOG.info("Using property file (4): " + file.toString()); - } - } else { - LOG.info("Using property file (2): " + propURL.toString()); - } - } - - - try { - props.load(propURL.openStream()); - } catch (Exception e) { - throw new DblibConfigurationException("Could not load properties at URL " + propURL.toString(), e); - - } - - - - try { - jdbcDataSource = DBResourceManager.create(props); - } catch (Exception exc) { - throw new DblibConfigurationException("Could not get initialize database", exc); - } - - String regName = jdbcDataSource.getClass().getName(); - - LOG.info("Registering DBResourceManager service "+regName); - registration = ctx.registerService(new String[] { regName, DbLibService.class.getName(), "javax.sql.DataSource" }, jdbcDataSource, null); - } - - @Override - public void stop(BundleContext ctx) throws Exception { - LOG.info("entering DBLIBResourceActivator.stop"); - if (registration != null) - { - try { - ServiceReference sref = ctx.getServiceReference(DbLibService.class.getName()); - - if (sref == null) { - LOG.warn("Could not find service reference for DBLIB service (" + DbLibService.class.getName() + ")"); - } else { - DBResourceManager dblibSvc = (DBResourceManager) ctx.getService(sref); - if (dblibSvc == null) { - LOG.warn("Could not find service reference for DBLIB service (" + DbLibService.class.getName() + ")"); - } else { - dblibSvc.cleanUp(); - } - } - } catch(Throwable exc) { - LOG.warn("Cleanup", exc); - } - - registration.unregister(); - registration = null; - LOG.debug("Deregistering DBResourceManager service"); - } - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibConnection.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibConnection.java deleted file mode 100644 index 5c1f51040..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibConnection.java +++ /dev/null @@ -1,390 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.sql.Array; -import java.sql.Blob; -import java.sql.CallableStatement; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.NClob; -import java.sql.PreparedStatement; -import java.sql.SQLClientInfoException; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Savepoint; -import java.sql.Statement; -import java.sql.Struct; -import java.util.ArrayList; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.Executor; - -import javax.sql.rowset.CachedRowSet; - -import org.apache.tomcat.jdbc.pool.PooledConnection; -import org.apache.tomcat.jdbc.pool.ProxyConnection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DBLibConnection implements Connection { - - private static Logger LOGGER = LoggerFactory.getLogger(DBLibConnection.class); - - private final Connection connection; - private final CachedDataSource dataSource; - private boolean locked = false; - private String tableName = null; - - public DBLibConnection(Connection con, CachedDataSource dataSource){ - this.connection = con; - this.dataSource = dataSource; - locked = false; - dataSource.getPoolInfo(true); - } - - public boolean lockTable(String tablename) { - this.tableName = tablename; - return locked = dataSource.lockTable(connection, tableName); - } - - public void resetInactivityTimer() { - Class iface = PooledConnection.class; - try { - PooledConnection pc = connection.unwrap(iface); - pc.setTimestamp(System.currentTimeMillis()); - } catch (SQLException e) { - LOGGER.warn("Failed resetting timeout timer", e); - } - } - - public boolean unlock() { - dataSource.unlockTable(connection); - return locked = false; - } - - public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable - { - ArrayList newList=new ArrayList(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - resetInactivityTimer(); - return dataSource.executeUpdatePreparedStatement(connection, statement, newList, false); - } - - public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable - { - ArrayList newList=new ArrayList(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - resetInactivityTimer(); - return dataSource.executePreparedStatement(connection, statement, newList, false); - } - - @Override - public T unwrap(Class iface) throws SQLException { - return connection.unwrap(iface); - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return connection.isWrapperFor(iface); - } - - @Override - public Statement createStatement() throws SQLException { - return connection.createStatement(); - } - - @Override - public PreparedStatement prepareStatement(String sql) throws SQLException { - return connection.prepareStatement(sql); - } - - @Override - public CallableStatement prepareCall(String sql) throws SQLException { - return connection.prepareCall(sql); - } - - @Override - public String nativeSQL(String sql) throws SQLException { - return connection.nativeSQL(sql); - } - - @Override - public void setAutoCommit(boolean autoCommit) throws SQLException { - connection.setAutoCommit(autoCommit); - } - - @Override - public boolean getAutoCommit() throws SQLException { - return connection.getAutoCommit(); - } - - @Override - public void commit() throws SQLException { - connection.commit(); - } - - @Override - public void rollback() throws SQLException { - connection.rollback(); - } - - @Override - public void close() throws SQLException { - if(this.locked) { - try { - this.unlock(); - } catch(Throwable th) { - LOGGER.error("Failed unlocking",th); - } - } - if(connection != null && !connection.isClosed()) { - connection.close(); - } - dataSource.getPoolInfo(false); - } - - @Override - public boolean isClosed() throws SQLException { - return connection.isClosed(); - } - - @Override - public DatabaseMetaData getMetaData() throws SQLException { - return connection.getMetaData(); - } - - @Override - public void setReadOnly(boolean readOnly) throws SQLException { - connection.setReadOnly(readOnly); - } - - @Override - public boolean isReadOnly() throws SQLException { - return connection.isReadOnly(); - } - - @Override - public void setCatalog(String catalog) throws SQLException { - connection.setCatalog(catalog); - } - - @Override - public String getCatalog() throws SQLException { - return connection.getCatalog(); - } - - @Override - public void setTransactionIsolation(int level) throws SQLException { - connection.setTransactionIsolation(level); - } - - @Override - public int getTransactionIsolation() throws SQLException { - return connection.getTransactionIsolation(); - } - - @Override - public SQLWarning getWarnings() throws SQLException { - return connection.getWarnings(); - } - - @Override - public void clearWarnings() throws SQLException { - connection.clearWarnings(); - } - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { - return connection.createStatement(resultSetType, resultSetConcurrency); - } - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) - throws SQLException { - return connection.prepareStatement(sql, resultSetType, resultSetConcurrency); - } - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { - return connection.prepareCall(sql, resultSetType, resultSetConcurrency); - } - - @Override - public Map> getTypeMap() throws SQLException { - return connection.getTypeMap(); - } - - @Override - public void setTypeMap(Map> map) throws SQLException { - connection.setTypeMap(map); - } - - @Override - public void setHoldability(int holdability) throws SQLException { - connection.setHoldability(holdability); - } - - @Override - public int getHoldability() throws SQLException { - return connection.getHoldability(); - } - - @Override - public Savepoint setSavepoint() throws SQLException { - return connection.setSavepoint(); - } - - @Override - public Savepoint setSavepoint(String name) throws SQLException { - return connection.setSavepoint(name); - } - - @Override - public void rollback(Savepoint savepoint) throws SQLException { - connection.rollback(savepoint); - } - - @Override - public void releaseSavepoint(Savepoint savepoint) throws SQLException { - connection.releaseSavepoint(savepoint); - } - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) - throws SQLException { - return connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return connection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { - return connection.prepareStatement(sql, autoGeneratedKeys); - } - - @Override - public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { - return connection.prepareStatement(sql, columnIndexes); - } - - @Override - public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { - return connection.prepareStatement(sql, columnNames); - } - - @Override - public Clob createClob() throws SQLException { - return connection.createClob(); - } - - @Override - public Blob createBlob() throws SQLException { - return connection.createBlob(); - } - - @Override - public NClob createNClob() throws SQLException { - return connection.createNClob(); - } - - @Override - public SQLXML createSQLXML() throws SQLException { - return connection.createSQLXML(); - } - - @Override - public boolean isValid(int timeout) throws SQLException { - return connection.isValid(timeout); - } - - @Override - public void setClientInfo(String name, String value) throws SQLClientInfoException { - connection.setClientInfo(name, value); - } - - @Override - public void setClientInfo(Properties properties) throws SQLClientInfoException { - connection.setClientInfo(properties); - } - - @Override - public String getClientInfo(String name) throws SQLException { - return connection.getClientInfo(name); - } - - @Override - public Properties getClientInfo() throws SQLException { - return connection.getClientInfo(); - } - - @Override - public Array createArrayOf(String typeName, Object[] elements) throws SQLException { - return connection.createArrayOf(typeName, elements); - } - - @Override - public Struct createStruct(String typeName, Object[] attributes) throws SQLException { - return connection.createStruct(typeName, attributes); - } - - @Override - public void setSchema(String schema) throws SQLException { - connection.setSchema(schema); - } - - @Override - public String getSchema() throws SQLException { - return connection.getSchema(); - } - - @Override - public void abort(Executor executor) throws SQLException { - connection.abort(executor); - } - - @Override - public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { - connection.setNetworkTimeout(executor, milliseconds); - } - - @Override - public int getNetworkTimeout() throws SQLException { - return connection.getNetworkTimeout(); - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibException.java deleted file mode 100644 index cc80741dc..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBLibException.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.sql.SQLException; - -/** - * An exception time for handling DBLIB specific error handling. - */ -public class DBLibException extends SQLException { - - /** - * - */ - private static final long serialVersionUID = -5345059355083984696L; - - public DBLibException(String message){ - super(message); - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java deleted file mode 100644 index 5cf2953b7..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceManager.java +++ /dev/null @@ -1,862 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.SQLDataException; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.sql.SQLIntegrityConstraintViolationException; -import java.sql.SQLSyntaxErrorException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Observable; -import java.util.PriorityQueue; -import java.util.Properties; -import java.util.Queue; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.sql.DataSource; -import javax.sql.rowset.CachedRowSet; - -import org.apache.tomcat.jdbc.pool.PoolExhaustedException; -import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; -import org.openecomp.sdnc.sli.resource.dblib.factory.AbstractDBResourceManagerFactory; -import org.openecomp.sdnc.sli.resource.dblib.factory.AbstractResourceManagerFactory; -import org.openecomp.sdnc.sli.resource.dblib.factory.DBConfigFactory; -import org.openecomp.sdnc.sli.resource.dblib.pm.PollingWorker; -import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitor; -import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * @version $Revision: 1.15 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public class DBResourceManager implements DataSource, DataAccessor, DBResourceObserver, DbLibService { - private static Logger LOGGER = LoggerFactory.getLogger(DBResourceManager.class); - - transient boolean terminating = false; - transient protected long retryInterval = 10000L; - transient boolean recoveryMode = true; - - protected final AtomicBoolean dsSelector = new AtomicBoolean(); - -// Queue dsQueue = new ConcurrentLinkedQueue(); - Queue dsQueue = new PriorityQueue(4, new Comparator(){ - - @Override - public int compare(CachedDataSource left, CachedDataSource right) { - try { - if(!left.isSlave()) - return -1; - if(!right.isSlave()) - return 1; - - } catch (Throwable e) { - LOGGER.warn("", e); - } - return 0; - } - - }); - protected final Set broken = Collections.synchronizedSet(new HashSet()); - protected final Object monitor = new Object(); - protected final Properties configProps; - protected final Thread worker; - - protected final long terminationTimeOut; - protected final boolean monitorDbResponse; - protected final long monitoringInterval; - protected final long monitoringInitialDelay; - protected final long expectedCompletionTime; - protected final long unprocessedFailoverThreshold; - - public DBResourceManager(Properties props){ - this.configProps = props; - - // get retry interval value - retryInterval = getLongFromProperties(props, "org.openecomp.dblib.connection.retry", 10000L); - - // get recovery mode flag - recoveryMode = getBooleanFromProperties(props, "org.openecomp.dblib.connection.recovery", true); - if(!recoveryMode) - { - recoveryMode = false; - LOGGER.info("Recovery Mode disabled"); - } - // get time out value for thread cleanup - terminationTimeOut = getLongFromProperties(props, "org.openecomp.dblib.termination.timeout", 300000L); - // get properties for monitoring - monitorDbResponse = getBooleanFromProperties(props, "org.openecomp.dblib.connection.monitor", false); - monitoringInterval = getLongFromProperties(props, "org.openecomp.dblib.connection.monitor.interval", 1000L); - monitoringInitialDelay = getLongFromProperties(props, "org.openecomp.dblib.connection.monitor.startdelay", 5000L); - expectedCompletionTime = getLongFromProperties(props, "org.openecomp.dblib.connection.monitor.expectedcompletiontime", 5000L); - unprocessedFailoverThreshold = getLongFromProperties(props, "org.openecomp.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); - - // initialize performance monitor - PollingWorker.createInistance(props); - - // initialize recovery thread - worker = new RecoveryMgr(); - worker.setName("DBResourcemanagerWatchThread"); - worker.setDaemon(true); - worker.start(); - } - - private void config(Properties ctx) throws Exception { - - DbConfigPool dbConfig = DBConfigFactory.createConfig(this.configProps); - - try { - AbstractResourceManagerFactory factory = AbstractDBResourceManagerFactory.getFactory(dbConfig.getType()); - if(LOGGER.isInfoEnabled()){ - LOGGER.info("Default DB config is : " + dbConfig.getType()); - LOGGER.info("Using factory : " + factory.getClass().getName()); - } - CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, this); - if(cachedDS == null || cachedDS.length == 0) { - LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); - throw new Exception("Failed to initialize DB Library. No data source was created."); - } - - for(int i=0; i 1){ - handleGetConnectionException(dataSource, new Exception(data.toString())); - } - } - } - } - } - - public void testForceRecovery() - { - CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); - handleGetConnectionException(active, new Exception("test")); - } - - class RecoveryMgr extends Thread { - - public void run() { - while(!terminating) - { - try { - Thread.sleep(retryInterval); - } catch (InterruptedException e1) { } - CachedDataSource brokenSource = null; - try { - if (!broken.isEmpty()) { - CachedDataSource[] sourceArray = broken.toArray(new CachedDataSource[0]); - for (int i = 0; i < sourceArray.length; i++) - { - brokenSource = sourceArray[i]; - if (brokenSource instanceof TerminatingCachedDataSource) - break; - if (resetConnectionPool(brokenSource)) { - broken.remove(brokenSource); - brokenSource.blockImmediateOffLine(); - dsQueue.add(brokenSource); - LOGGER.info("DataSource <" - + brokenSource.getDbConnectionName() - + "> recovered."); - } - brokenSource = null; - } - } - } catch (Exception exc) { - LOGGER.warn(exc.getMessage()); - if(brokenSource != null){ - try { - if(!broken.contains(brokenSource)) - broken.add(brokenSource); - brokenSource = null; - } catch (Exception e1) { } - } - } - } - LOGGER.info("DBResourceManager.RecoveryMgr <"+this.toString() +"> terminated." ); - } - - private boolean resetConnectionPool(CachedDataSource dataSource){ - try { - return dataSource.testConnection(); - } catch (Exception exc) { - LOGGER.info("DataSource <" + dataSource.getDbConnectionName() + "> resetCache failed with error: "+ exc.getMessage()); - return false; - } - } - } - - /* (non-Javadoc) - * @see org.openecomp.sdnc.sli.resource.dblib.DbLibService#getData(java.lang.String, java.util.ArrayList, java.lang.String) - */ - @Override - public CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) throws SQLException { - ArrayList newList=new ArrayList(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - if(recoveryMode) - return requestDataWithRecovery(statement, newList, preferredDS); - else - return requestDataNoRecovery(statement, newList, preferredDS); - } - - private CachedRowSet requestDataWithRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { - Throwable lastException = null; - CachedDataSource active = null; - - // test if there are any connection pools available - LinkedList sources = new LinkedList(this.dsQueue); - if(sources.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); - throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); - } - if(preferredDS != null && !sources.peek().getDbConnectionName().equals(preferredDS)) { - Collections.reverse(sources); - } - - - // loop through available data sources to retrieve data. - while(!sources.isEmpty()) - { - active = sources.peek(); - - long time = System.currentTimeMillis(); - try { - if(!active.isFabric()) { - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - master = null; - } - } - sources.remove(active); - return active.getData(statement, arguments); - } catch(SQLDataException exc){ - throw exc; - } catch(SQLSyntaxErrorException exc){ - throw exc; - } catch(SQLIntegrityConstraintViolationException exc){ - throw exc; - } catch(Throwable exc){ - lastException = exc; - String message = exc.getMessage(); - if(message == null) { - if(exc.getCause() != null) { - message = exc.getCause().getMessage(); - } - if(message == null) - message = exc.getClass().getName(); - } - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); - handleGetConnectionException(active, exc); - } finally { - if(LOGGER.isDebugEnabled()){ - time = (System.currentTimeMillis() - time); - LOGGER.debug("getData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); - } - } - } - if(lastException instanceof SQLException){ - throw (SQLException)lastException; - } - // repackage the exception - // you are here because either you run out of available data sources - // or the last exception was not of SQLException type. - // repackage the exception - if(lastException == null) { - throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); - } else { - SQLException exception = new DBLibException(lastException.getMessage()); - exception.setStackTrace(lastException.getStackTrace()); - if(lastException.getCause() instanceof SQLException) { - throw (SQLException)lastException.getCause(); - } - throw exception; - } - } - - private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { - if(dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); - throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); - } - CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); - long time = System.currentTimeMillis(); - try { - if(!active.isFabric()) { - CachedDataSource master = findMaster(); - if(master != null) - active = master; - } - return active.getData(statement, arguments); -// } catch(SQLDataException exc){ -// throw exc; - } catch(Throwable exc){ - String message = exc.getMessage(); - if(message == null) - message = exc.getClass().getName(); - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); - if(exc instanceof SQLException) - throw (SQLException)exc; - else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } finally { - if(LOGGER.isDebugEnabled()){ - time = (System.currentTimeMillis() - time); - LOGGER.debug(">> getData : "+ active.getDbConnectionName()+" "+time+" miliseconds."); - } - } - } - - - /* (non-Javadoc) - * @see org.openecomp.sdnc.sli.resource.dblib.DbLibService#writeData(java.lang.String, java.util.ArrayList, java.lang.String) - */ - @Override - public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException - { - ArrayList newList=new ArrayList(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - - return writeDataNoRecovery(statement, newList, preferredDS); - } - - CachedDataSource findMaster() throws PoolExhaustedException, MySQLNonTransientConnectionException { - CachedDataSource master = null; - CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); - for(int i=0; i arguments, String preferredDS) throws SQLException { - if(dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); - throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); - } - - boolean initialRequest = true; - boolean retryAllowed = true; - CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); - long time = System.currentTimeMillis(); - while(initialRequest) { - initialRequest = false; - try { - if(!active.isFabric()) { - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - } - } - - return active.writeData(statement, arguments); - } catch(Throwable exc){ - String message = exc.getMessage(); - if(message == null) - message = exc.getClass().getName(); - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); - if(exc instanceof SQLException) { - SQLException sqlExc = SQLException.class.cast(exc); - // handle read-only exception - if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { - LOGGER.warn("retrying due to: " + sqlExc.getMessage()); - dsQueue.remove(active); - dsQueue.add(active); - if(retryAllowed){ - retryAllowed = false; - initialRequest = true; - continue; - } - } - throw (SQLException)exc; - } else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } finally { - if(LOGGER.isDebugEnabled()){ - time = (System.currentTimeMillis() - time); - LOGGER.debug("writeData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); - } - } - } - return true; - } - - private void setDataSource(CachedDataSource dataSource) { - if(dataSource.testConnection(true)){ - this.dsQueue.add(dataSource); - } else { - this.broken.add(dataSource); - } - } - - public Connection getConnection() throws SQLException { - Throwable lastException = null; - CachedDataSource active = null; - - if(dsQueue.isEmpty()){ - throw new DBLibException("No active DB connection pools are available in GetConnection call."); - } - - try { - active = dsQueue.peek(); - CachedDataSource tmpActive = findMaster(); - if(tmpActive != null) { - active = tmpActive; - } - return new DBLibConnection(active.getConnection(), active); - } catch(javax.sql.rowset.spi.SyncFactoryException exc){ - LOGGER.debug("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); - LOGGER.warn("CLASSPATH issue. Allowing retry", exc); - lastException = exc; - } catch(PoolExhaustedException exc) { - throw new NoAvailableConnectionsException(exc); - } catch(MySQLNonTransientConnectionException exc){ - throw new NoAvailableConnectionsException(exc); - } catch(Exception exc){ - lastException = exc; - if(recoveryMode){ - handleGetConnectionException(active, exc); - } else { - if(exc instanceof MySQLNonTransientConnectionException) { - throw new NoAvailableConnectionsException(exc); - } if(exc instanceof SQLException) { - throw (SQLException)exc; - } else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } - } catch (Throwable trwb) { - DBLibException excptn = new DBLibException(trwb.getMessage()); - excptn.setStackTrace(trwb.getStackTrace()); - throw excptn; - } finally { - if(LOGGER.isDebugEnabled()){ - displayState(); - } - } - - if(lastException instanceof SQLException){ - throw (SQLException)lastException; - } - // repackage the exception - if(lastException == null) { - throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); - } else { - SQLException exception = new DBLibException(lastException.getMessage()); - exception.setStackTrace(lastException.getStackTrace()); - if(lastException.getCause() instanceof SQLException) { -// exception.setNextException((SQLException)lastException.getCause()); - throw (SQLException)lastException.getCause(); - } - throw exception; - } - } - - public Connection getConnection(String username, String password) - throws SQLException { - CachedDataSource active = null; - - if(dsQueue.isEmpty()){ - throw new DBLibException("No active DB connection pools are available in GetConnection call."); - } - - - try { - active = dsQueue.peek(); - CachedDataSource tmpActive = findMaster(); - if(tmpActive != null) { - active = tmpActive; - } - return active.getConnection(username, password); - } catch(Throwable exc){ - if(recoveryMode){ - handleGetConnectionException(active, exc); - } else { - if(exc instanceof SQLException) - throw (SQLException)exc; - else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } - - } - - throw new DBLibException("No connections available in DBResourceManager in GetConnection call."); - } - - private void handleGetConnectionException(CachedDataSource source, Throwable exc) { - try { - if(!source.canTakeOffLine()) - { - LOGGER.error("Could not switch due to blocking"); - return; - } - - boolean removed = dsQueue.remove(source); - if(!broken.contains(source)) - { - if(broken.add(source)) - { - LOGGER.warn("DB Recovery: DataSource <" + source.getDbConnectionName() + "> put in the recovery mode. Reason : " + exc.getMessage()); - } else { - LOGGER.warn("Error putting DataSource <" +source.getDbConnectionName()+ "> in recovery mode."); - } - } else { - LOGGER.info("DB Recovery: DataSource <" + source.getDbConnectionName() + "> already in recovery queue"); - } - if(removed) - { - if(!dsQueue.isEmpty()) - { - LOGGER.warn("DB DataSource <" + dsQueue.peek().getDbConnectionName() + "> became active"); - } - } - } catch (Exception e) { - LOGGER.error("", e); - } - } - - public void cleanUp() { - for(Iterator it=dsQueue.iterator();it.hasNext();){ - CachedDataSource cds = (CachedDataSource)it.next(); - it.remove(); - cds.cleanUp(); - } - - try { - this.terminating = true; - if(broken != null) - { - try { - broken.add( new TerminatingCachedDataSource(null)); - } catch(Exception exc){ - LOGGER.error("Waiting for Worker to stop", exc); - } - } - worker.join(terminationTimeOut); - LOGGER.info("DBResourceManager.RecoveryMgr <"+worker.toString() +"> termination was successful: " + worker.getState()); - } catch(Exception exc){ - LOGGER.error("Waiting for Worker thread to terminate ", exc); - } - } - - public static DBResourceManager create(Properties props) throws Exception { - DBResourceManager dbmanager = new DBResourceManager(props); - dbmanager.config(props); - return dbmanager; - } - - public PrintWriter getLogWriter() throws SQLException { - return ((CachedDataSource)this.dsQueue.peek()).getLogWriter(); - } - - public int getLoginTimeout() throws SQLException { - return ((CachedDataSource)this.dsQueue.peek()).getLoginTimeout(); - } - - public void setLogWriter(PrintWriter out) throws SQLException { - ((CachedDataSource)this.dsQueue.peek()).setLogWriter(out); - } - - public void setLoginTimeout(int seconds) throws SQLException { - ((CachedDataSource)this.dsQueue.peek()).setLoginTimeout(seconds); - } - - public void displayState(){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); - CachedDataSource current = (CachedDataSource)dsQueue.peek(); - if(current != null) { - LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); - } - } - } - - /* (non-Javadoc) - * @see org.openecomp.sdnc.sli.resource.dblib.DbLibService#isActive() - */ - @Override - public boolean isActive() { - return this.dsQueue.size()>0; - } - - public String getActiveStatus(){ - return "Connected: " + dsQueue.size()+"\tIn-recovery: "+broken.size(); - } - - public String getDBStatus(boolean htmlFormat) { - StringBuilder buffer = new StringBuilder(); - - ArrayList list = new ArrayList(); - list.addAll(dsQueue); - list.addAll(broken); - if (htmlFormat) - { - buffer.append("") - .append("Name:").append(""); - for (int i = 0; i < list.size(); i++) { - buffer.append(""); - buffer.append(((CachedDataSource) list.get(i)).getDbConnectionName()).append(""); - } - buffer.append(""); - - buffer.append("State:"); - for (int i = 0; i < list.size(); i++) { - if (broken.contains(list.get(i))) { - buffer.append("in recovery"); - } - if (dsQueue.contains(list.get(i))) { - if (dsQueue.peek() == list.get(i)) - buffer.append("active"); - else - buffer.append("standby"); - } - } - buffer.append(""); - - } else { - for (int i = 0; i < list.size(); i++) { - buffer.append("Name: ").append(((CachedDataSource) list.get(i)).getDbConnectionName()); - buffer.append("\tState: "); - if (broken.contains(list.get(i))) { - buffer.append("in recovery"); - } else - if (dsQueue.contains(list.get(i))) { - if (dsQueue.peek() == list.get(i)) - buffer.append("active"); - else - buffer.append("standby"); - } - - buffer.append("\n"); - - } - } - return buffer.toString(); - } - - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } - - public T unwrap(Class iface) throws SQLException { - return null; - } - - /** - * @return the monitorDbResponse - */ - public final boolean isMonitorDbResponse() { - return recoveryMode && monitorDbResponse; - } - - public void test(){ - CachedDataSource obj = dsQueue.peek(); - Exception ption = new Exception(); - try { - for(int i=0; i<5; i++) - { - handleGetConnectionException(obj, ption); - } - } catch(Throwable exc){ - LOGGER.warn("", exc); - } - } - - public String getPreferredDSName(){ - if(isActive()){ - return getPreferredDataSourceName(dsSelector); - } - return ""; - } - - public String getPreferredDataSourceName(AtomicBoolean flipper) { - - LinkedList snapshot = new LinkedList(dsQueue); - if(snapshot.size() > 1){ - CachedDataSource first = snapshot.getFirst(); - CachedDataSource last = snapshot.getLast(); - - int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount(); - if(delta < 0) { - flipper.set(false); - } else if(delta > 0) { - flipper.set(true); - } else { - // check the last value and return !last - flipper.getAndSet(!flipper.get()); - } - - if (flipper.get()) - Collections.reverse(snapshot); - } - return snapshot.peek().getDbConnectionName(); - } - - public java.util.logging.Logger getParentLogger() - throws SQLFeatureNotSupportedException { - return null; - } - - public String getMasterName() { - if(isActive()){ - return getMasterDataSourceName(dsSelector); - } - return ""; - } - - - private String getMasterDataSourceName(AtomicBoolean flipper) { - - LinkedList snapshot = new LinkedList(dsQueue); - if(snapshot.size() > 1){ - CachedDataSource first = snapshot.getFirst(); - CachedDataSource last = snapshot.getLast(); - - int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount(); - if(delta < 0) { - flipper.set(false); - } else if(delta > 0) { - flipper.set(true); - } else { - // check the last value and return !last - flipper.getAndSet(!flipper.get()); - } - - if (flipper.get()) - Collections.reverse(snapshot); - } - return snapshot.peek().getDbConnectionName(); - } - - class RemindTask extends TimerTask { - public void run() { - CachedDataSource ds = dsQueue.peek(); - if(ds != null) - ds.getPoolInfo(false); - } - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceObserver.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceObserver.java deleted file mode 100644 index e06779f35..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DBResourceObserver.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.util.Observer; - -public interface DBResourceObserver extends Observer { - public boolean isMonitorDbResponse(); -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataAccessor.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataAccessor.java deleted file mode 100644 index cd054a51d..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataAccessor.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.sql.SQLException; -import java.util.ArrayList; - -import javax.sql.rowset.CachedRowSet; - -public interface DataAccessor { - - public abstract CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) - throws SQLException; - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataSourceComparator.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataSourceComparator.java deleted file mode 100644 index 37d625136..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DataSourceComparator.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.util.Comparator; - -public interface DataSourceComparator extends Comparator { - - public abstract CachedDataSource getLastUsed(); - - public abstract void setLastUsed(CachedDataSource lastUsed); - - public abstract int compare(CachedDataSource ds1, CachedDataSource ds2); - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DbLibService.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DbLibService.java deleted file mode 100644 index 25edd1f07..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DbLibService.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.sql.SQLException; -import java.util.ArrayList; - -import javax.sql.rowset.CachedRowSet; - -public interface DbLibService { - - /* (non-Javadoc) - * @see DataAccessor#getData(java.lang.String, java.util.ArrayList) - */ - public abstract CachedRowSet getData(String statement, - ArrayList arguments, String preferredDS) - throws SQLException; - - /* (non-Javadoc) - * @see DataAccessor#writeData(java.lang.String, java.util.ArrayList) - */ - public abstract boolean writeData(String statement, - ArrayList arguments, String preferredDS) - throws SQLException; - - public abstract boolean isActive(); - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DblibConfigurationException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DblibConfigurationException.java deleted file mode 100644 index 17700a5ee..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/DblibConfigurationException.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - - -public class DblibConfigurationException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public DblibConfigurationException() - { - super(); - } - - public DblibConfigurationException(String msg) - { - super(msg); - } - - public DblibConfigurationException(String msg, Throwable t) - { - super(msg, t); - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/NoAvailableConnectionsException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/NoAvailableConnectionsException.java deleted file mode 100644 index 16895b4d5..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/NoAvailableConnectionsException.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.sql.SQLException; - -public class NoAvailableConnectionsException extends SQLException { - - /** - * - */ - private static final long serialVersionUID = -6259205931674413018L; - - public NoAvailableConnectionsException(Exception exc) { - super(exc); - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/TerminatingCachedDataSource.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/TerminatingCachedDataSource.java deleted file mode 100644 index 234bbed0c..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/TerminatingCachedDataSource.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib; - -import java.sql.SQLFeatureNotSupportedException; -import java.util.logging.Logger; - -import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.pm.SQLExecutionMonitorObserver; - - -public class TerminatingCachedDataSource extends CachedDataSource implements SQLExecutionMonitorObserver { - - public TerminatingCachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { - super(jdbcElem); - } - - protected void configure(BaseDBConfiguration jdbcElem) throws DBConfigException { - // no action - } - - public long getInterval() { - return 1000; - } - - public long getInitialDelay() { - return 1000; - } - - public long getExpectedCompletionTime() { - return 50; - } - - public void setExpectedCompletionTime(long value) { - - } - - public void setInterval(long value) { - - } - - public void setInitialDelay(long value) { - - } - - public long getUnprocessedFailoverThreshold() { - return 3; - } - - public void setUnprocessedFailoverThreshold(long value) { - - } - - public int compareTo(CachedDataSource ods) - { - return 0; - } - - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/BaseDBConfiguration.java deleted file mode 100644 index 976b1cf2d..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/BaseDBConfiguration.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.config; - -import java.util.Properties; - -public abstract class BaseDBConfiguration { - public static final String DATABASE_TYPE = "org.openecomp.sdnc.sli.dbtype"; - public static final String DATABASE_URL = "org.openecomp.sdnc.sli.jdbc.url"; - public static final String DATABASE_NAME = "org.openecomp.sdnc.sli.jdbc.database"; - public static final String CONNECTION_NAME = "org.openecomp.sdnc.sli.jdbc.connection.name"; - public static final String DATABASE_USER = "org.openecomp.sdnc.sli.jdbc.user"; - public static final String DATABASE_PSSWD = "org.openecomp.sdnc.sli.jdbc.password"; - public static final String CONNECTION_TIMEOUT="org.openecomp.sdnc.sli.jdbc.connection.timeout"; - public static final String REQUEST_TIMEOUT = "org.openecomp.sdnc.sli.jdbc.request.timeout"; - public static final String MIN_LIMIT = "org.openecomp.sdnc.sli.jdbc.limit.min"; - public static final String MAX_LIMIT = "org.openecomp.sdnc.sli.jdbc.limit.max"; - public static final String INIT_LIMIT = "org.openecomp.sdnc.sli.jdbc.limit.init"; - public static final String DATABASE_HOSTS = "org.openecomp.sdnc.sli.jdbc.hosts"; - - - protected final Properties props; - - public BaseDBConfiguration(Properties properties) { - this.props = properties; - } - - public int getConnTimeout() { - try { - String value = props.getProperty(CONNECTION_TIMEOUT); - return Integer.parseInt(value); - } catch(Exception exc) { - return -1; - } - } - - public int getRequestTimeout() { - try { - String value = props.getProperty(REQUEST_TIMEOUT); - if(value == null) - return -1; - return Integer.parseInt(value); - } catch(Exception exc) { - return -1; - } - } - - public String getDbConnectionName() { - return props.getProperty(CONNECTION_NAME); - } - - public String getDatabaseName() { - return props.getProperty(DATABASE_NAME); - } - - public String getDbUserId() { - return props.getProperty(DATABASE_USER); - } - - public String getDbPasswd() { - return props.getProperty(DATABASE_PSSWD); - } - - public int getDbMinLimit() { - String value = props.getProperty(MIN_LIMIT); - return Integer.parseInt(value); - } - - public int getDbMaxLimit() { - String value = props.getProperty(MAX_LIMIT); - return Integer.parseInt(value); - } - - public int getDbInitialLimit() { - String value = props.getProperty(INIT_LIMIT); - return Integer.parseInt(value); - } - - public String getDbUrl() { - return props.getProperty(DATABASE_URL); - } - - public String getServerGroup() { - return null; - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java deleted file mode 100644 index 117f9321d..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/DbConfigPool.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.config; - -import java.util.ArrayList; -import java.util.Properties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DbConfigPool { - private static Logger LOGGER = LoggerFactory.getLogger(DbConfigPool.class); - - private final String type; - - private ArrayList configurations = new ArrayList(); - - public DbConfigPool(Properties properties) { - LOGGER.debug("Initializing DbConfigType"); - type = properties.getProperty(BaseDBConfiguration.DATABASE_TYPE, "JDBC").toUpperCase(); - } - - public int getTimeout() { - // TODO Auto-generated method stub - return 0; - } - - public String getType() { - return type; - } - - public JDBCConfiguration[] getJDBCbSourceArray() { - return configurations.toArray(new JDBCConfiguration[configurations.size()]); - } - - public void addConfiguration(BaseDBConfiguration config) { - configurations.add(config); - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/JDBCConfiguration.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/JDBCConfiguration.java deleted file mode 100644 index cb6ea3e5c..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/config/JDBCConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.config; - -import java.util.Properties; - -public class JDBCConfiguration extends BaseDBConfiguration { - - public JDBCConfiguration(Properties xmlElem) { - super(xmlElem); - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java deleted file mode 100644 index f4291a7dd..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractDBResourceManagerFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.factory; - -import org.openecomp.sdnc.sli.resource.dblib.jdbc.JdbcDbResourceManagerFactory; - -/** - * @version $Revision: 1.1 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public class AbstractDBResourceManagerFactory { - - public static AbstractResourceManagerFactory getFactory(String type) throws FactoryNotDefinedException { - - // JDBC - return JdbcDbResourceManagerFactory.createIntstance(); - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java deleted file mode 100644 index 0f58a3f03..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/AbstractResourceManagerFactory.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.factory; - - -import java.sql.SQLException; -import java.util.Set; -import java.util.concurrent.Callable; - -import org.openecomp.sdnc.sli.resource.dblib.CachedDataSource; -import org.openecomp.sdnc.sli.resource.dblib.CachedDataSourceFactory; -import org.openecomp.sdnc.sli.resource.dblib.DBConfigException; -import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager; -import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; -import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @version $Revision: 1.6 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public abstract class AbstractResourceManagerFactory { - private static Logger LOGGER = LoggerFactory.getLogger(AbstractResourceManagerFactory.class); - - public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager) throws Exception; - public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager dbResourceManager, String sourceName) throws SQLException ; - - - public static AbstractResourceManagerFactory createIntstance() throws FactoryNotDefinedException { - throw new FactoryNotDefinedException("Factory method 'createIntstance' needs to be overriden in DBResourceManagerFactory"); - } - - public class DBInitTask implements Callable - { - private BaseDBConfiguration config = null; - private Set activeTasks; - - public DBInitTask(JDBCConfiguration jdbcconfig, Set tasks) { - this.config = jdbcconfig; - this.activeTasks = tasks; - } - - public CachedDataSource call() throws Exception { - CachedDataSource ds = null; - try { - ds = CachedDataSourceFactory.createDataSource(config); - return ds; - } finally { - synchronized(activeTasks) { - activeTasks.remove(this); - if (activeTasks.isEmpty()) { - final Runnable closure = new Runnable() { - - public void run() { - try { - Thread.sleep(300); - } catch (Exception e) { - } - synchronized(activeTasks) { - activeTasks.notifyAll(); - } - } - }; - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Completed CachedDataSource.Call and notifyAll from " + ds.getDbConnectionName()); - } - Thread worker = new Thread(closure); - worker.setDaemon(true); - worker.start(); - } else { - if (LOGGER.isDebugEnabled()) { - if (ds != null) { - LOGGER.debug("Completed CachedDataSource.Call from " + ds.getDbConnectionName()); - } - } - } - } - } - } - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java deleted file mode 100644 index 8aadcae6b..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/DBConfigFactory.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.factory; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Properties; - -import org.slf4j.LoggerFactory; - -import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; -import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; - -/** - * @version $Revision: 1.1 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki 01/17/08 Initial version - */ -public class DBConfigFactory { - - public static DbConfigPool createConfig(Properties resource) { - return getConfigparams(resource); - } - - static DbConfigPool getConfigparams(Properties properties){ - DbConfigPool xmlConfig = new DbConfigPool(properties); - ArrayList propertySets = new ArrayList(); - - if("JDBC".equalsIgnoreCase(xmlConfig.getType())) { - String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS); - if(hosts == null || hosts.isEmpty()) { - propertySets.add(properties); - } else { - String[] newhost = hosts.split(","); - for(int i=0; i< newhost.length; i++) { - Properties localset = new Properties(); - localset.putAll(properties); - String url = localset.getProperty(BaseDBConfiguration.DATABASE_URL); - if(url.contains("DBHOST")) - url = url.replace("DBHOST", newhost[i]); - if(url.contains("dbhost")) - url = url.replace("dbhost", newhost[i]); - localset.setProperty(BaseDBConfiguration.DATABASE_URL, url); - localset.setProperty(BaseDBConfiguration.CONNECTION_NAME, newhost[i]); - propertySets.add(localset); - } - } - } else { - propertySets.add(properties); - } - try { - Iterator it = propertySets.iterator(); - while(it.hasNext()) { - BaseDBConfiguration config = parse(it.next()); - xmlConfig.addConfiguration(config); - } - - } catch (Exception e) { - LoggerFactory.getLogger(DBConfigFactory.class).warn("",e); - } - - return xmlConfig; - } - - public static BaseDBConfiguration parse(Properties props) throws Exception { - - String type = props.getProperty(BaseDBConfiguration.DATABASE_TYPE); - - BaseDBConfiguration config = null; - - if("JDBC".equalsIgnoreCase(type)) { - config = new JDBCConfiguration(props); - } - - return config; - - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/FactoryNotDefinedException.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/FactoryNotDefinedException.java deleted file mode 100644 index e38cd3519..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/factory/FactoryNotDefinedException.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.factory; - - -/** - * @version 1.3 - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki 01/16/08 Initial version - */ -public class FactoryNotDefinedException extends Exception { - - public FactoryNotDefinedException(String message) { - super(message); - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java deleted file mode 100644 index 90c76f637..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDBCachedDataSource.java +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.jdbc; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLFeatureNotSupportedException; - -import org.apache.tomcat.jdbc.pool.DataSource; -import org.apache.tomcat.jdbc.pool.PoolProperties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.openecomp.sdnc.sli.resource.dblib.CachedDataSource; -import org.openecomp.sdnc.sli.resource.dblib.DBConfigException; -import org.openecomp.sdnc.sli.resource.dblib.config.BaseDBConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; -import com.mysql.jdbc.Driver; - - -/** - * @version $Revision: 1.7 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ - -public class JdbcDBCachedDataSource extends CachedDataSource -{ - private String dbUserId; - private String dbPasswd; - private String dbUrl; - - private int minLimit; - private int maxLimit; - private int initialLimit; - - private static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; - - private static Logger LOGGER = LoggerFactory.getLogger(JdbcDBCachedDataSource.class); - - /** - * @param jdbcElem - */ - public JdbcDBCachedDataSource(BaseDBConfiguration jdbcElem) - { - super(jdbcElem); - } - - @Override - protected void configure(BaseDBConfiguration xmlElem) throws DBConfigException - { - BaseDBConfiguration jdbcConfig = (BaseDBConfiguration)xmlElem; - if(jdbcConfig.getConnTimeout() > 0){ - this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); - } - if(jdbcConfig.getRequestTimeout() > 0){ - this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); - } - - // set connection pool name - String dbConnectionName = jdbcConfig.getDbConnectionName(); - super.setDbConnectionName(dbConnectionName); - // Configure the JDBC connection - dbUserId = jdbcConfig.getDbUserId(); - if (dbUserId == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - - dbPasswd = jdbcConfig.getDbPasswd(); - if (dbPasswd == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - /* - dbDriver = jdbcConfig.getDbDriver(); - if (dbDriver == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new ScpTblUpdateError(errorMsg); - } - */ - - minLimit = jdbcConfig.getDbMinLimit(); -// if (minLimit == null) -// { -// String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); -// } - maxLimit = jdbcConfig.getDbMaxLimit(); -// if (maxLimit == null) -// { -// String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); -// } - initialLimit = jdbcConfig.getDbInitialLimit(); -// if (initialLimit == null) -// { -// String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); -// } - - dbUrl = jdbcConfig.getDbUrl(); - if(dbUrl == null){ - String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - - try { - Driver dr = new com.mysql.jdbc.Driver(); - Class clazz = Class.forName("com.mysql.jdbc.Driver") ; - - PoolProperties p = new PoolProperties(); - p.setDriverClassName("com.mysql.jdbc.Driver"); - p.setUrl(dbUrl); - p.setUsername(dbUserId); - p.setPassword(dbPasswd); - p.setJmxEnabled(true); - p.setTestWhileIdle(false); - p.setTestOnBorrow(true); - p.setValidationQuery("SELECT 1"); - p.setTestOnReturn(false); - p.setValidationInterval(30000); - p.setTimeBetweenEvictionRunsMillis(30000); - p.setInitialSize(initialLimit); - p.setMaxActive(maxLimit); - p.setMaxIdle(maxLimit); - p.setMaxWait(10000); - p.setRemoveAbandonedTimeout(60); - p.setMinEvictableIdleTimeMillis(30000); - p.setMinIdle(minLimit); - p.setLogAbandoned(true); - p.setRemoveAbandoned(true); - p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" - + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"); - - DataSource dataSource = new DataSource(p); - - synchronized(this) - { - this.ds = dataSource; - Connection con = null; - PreparedStatement st = null; - ResultSet rs = null; - - try { - con = dataSource.getConnection(); - st = con.prepareStatement("Select 1 FROM DUAL"); - rs = st.executeQuery(); - } catch(Exception exc) { - LOGGER.error(exc.getMessage()); - } finally { - if(rs != null) rs.close(); - if(st != null) st.close(); - if(con != null) con.close(); - } - - initialized = true; - LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); - } - -// } catch (SQLException exc) { -// initialized = false; -// StringBuffer sb = new StringBuffer(); -// sb.append("Failed to initialize MySQLDataSource<"); -// sb.append(dbConnectionName).append(">. Reason: "); -// sb.append(exc.getMessage()); -// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); -//// throw new DBConfigException(e.getMessage()); - } catch (Exception exc) { - initialized = false; - StringBuffer sb = new StringBuffer(); - sb.append("Failed to initialize MySQLCachedDataSource <"); - sb.append(dbConnectionName).append(">. Reason: "); - sb.append(exc.getMessage()); - LOGGER.error("AS_CONF_ERROR: " + sb.toString()); -// throw new DBConfigException(e.getMessage()); - } - } - - public final String getDbUrl() - { - return dbUrl; - } - - public final String getDbUserId() - { - return dbUserId; - } - - public final String getDbPasswd() - { - return dbPasswd; - } - - public static JdbcDBCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { - return new JdbcDBCachedDataSource(config); - } - - public String toString(){ - return getDbConnectionName(); - } - - public java.util.logging.Logger getParentLogger() - throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub - return null; - } - - public void cleanUp(){ - DataSource dataSource = (DataSource)ds; - dataSource.getPool().purge(); - int active = dataSource.getActive(); - int size = dataSource.getSize(); - dataSource.close(true); - super.cleanUp(); - } - -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDbResourceManagerFactory.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDbResourceManagerFactory.java deleted file mode 100644 index 84399dfd9..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/jdbc/JdbcDbResourceManagerFactory.java +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.jdbc; - - -import java.sql.SQLException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; - -import org.openecomp.sdnc.sli.resource.dblib.CachedDataSource; -import org.openecomp.sdnc.sli.resource.dblib.CachedDataSourceFactory; -import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager; -import org.openecomp.sdnc.sli.resource.dblib.DataSourceComparator; -import org.openecomp.sdnc.sli.resource.dblib.config.DbConfigPool; -import org.openecomp.sdnc.sli.resource.dblib.config.JDBCConfiguration; -import org.openecomp.sdnc.sli.resource.dblib.factory.AbstractResourceManagerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @version $Revision: 1.6 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public class JdbcDbResourceManagerFactory extends AbstractResourceManagerFactory { - private static Logger LOGGER = LoggerFactory.getLogger(JdbcDbResourceManagerFactory.class ); - private JdbcDbResourceManagerFactory(){ - - } - - class MyFutureTask extends FutureTask - { - - public MyFutureTask(Callable result) { - super(result); - } - - } - - public CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager, String sourceName) throws SQLException - { - // here create the data sources objects - JDBCConfiguration[] list = dbConfig.getJDBCbSourceArray(); - CachedDataSource[] cachedDS = new CachedDataSource[1]; - - for(int i=0, max=list.length; i tasks = new HashSet(); - if(LOGGER.isDebugEnabled()) { - LOGGER.debug("Creating " + list.length + " datasources."); - } - - for(int i=0, max=list.length; i 0){ - this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); - } - if(jdbcConfig.getRequestTimeout() > 0){ - this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); - } - - // set connection pool name - String dbConnectionName = jdbcConfig.getDbConnectionName(); - super.setDbConnectionName(dbConnectionName); - // Configure the JDBC connection - dbUserId = jdbcConfig.getDbUserId(); - if (dbUserId == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - - dbPasswd = jdbcConfig.getDbPasswd(); - if (dbPasswd == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - /* - dbDriver = jdbcConfig.getDbDriver(); - if (dbDriver == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new ScpTblUpdateError(errorMsg); - } - */ - - minLimit = Integer.toString(jdbcConfig.getDbMinLimit()); - if (minLimit == null) - { - String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - maxLimit = Integer.toString(jdbcConfig.getDbMaxLimit()); - if (maxLimit == null) - { - String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - initialLimit = Integer.toString(jdbcConfig.getDbInitialLimit()); - if (initialLimit == null) - { - String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - - dbUrl = jdbcConfig.getDbUrl(); - if(dbUrl == null){ - String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - - try { - - MysqlDataSource dataSource = new MysqlDataSource(); - dataSource.setUser(dbUserId); - dataSource.setPassword(dbPasswd); - dataSource.setURL(dbUrl); -// dataSource.setInitialSize(5); -// dataSource.setMaxTotal(60); -// dataSource.setMaxActive(100); -// dataSource.setMaxWait(10000); -// dataSource.setMaxIdle(10); - - Properties connAttr = new Properties(); - - connAttr.setProperty("MinLimit", minLimit); - connAttr.setProperty("MaxLimit", maxLimit); - connAttr.setProperty("InitialLimit", initialLimit); - connAttr.setProperty("TRANSACTION_ISOLATION","SERIALIZABLE"); - connAttr.setProperty("CONNECTION_TAG", dbConnectionName.toUpperCase()+"_CONNECTION"); - connAttr.setProperty("InactivityTimeout", "900"); - connAttr.setProperty("AbandonedConnectionTimeout", "600"); - connAttr.setProperty("PropertyCheckInterval", "60"); - connAttr.setProperty("ValidateConnection", "true"); - - - synchronized(this) - { - this.ds = dataSource; - - initialized = true; - LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); - } - -// } catch (SQLException exc) { -// initialized = false; -// StringBuffer sb = new StringBuffer(); -// sb.append("Failed to initialize MySQLDataSource<"); -// sb.append(dbConnectionName).append(">. Reason: "); -// sb.append(exc.getMessage()); -// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); -//// throw new DBConfigException(e.getMessage()); - } catch (Exception exc) { - initialized = false; - StringBuffer sb = new StringBuffer(); - sb.append("Failed to initialize MySQLCachedDataSource <"); - sb.append(dbConnectionName).append(">. Reason: "); - sb.append(exc.getMessage()); - LOGGER.error("AS_CONF_ERROR: " + sb.toString()); -// throw new DBConfigException(e.getMessage()); - } - } - - public final String getDbUrl() - { - return dbUrl; - } - - public final String getDbUserId() - { - return dbUserId; - } - - public final String getDbPasswd() - { - return dbPasswd; - } - - public static MySQLCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { - return new MySQLCachedDataSource(config); - } - - public String toString(){ - return getDbConnectionName(); - } - - public java.util.logging.Logger getParentLogger() - throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub - return null; - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/PollingWorker.java deleted file mode 100644 index de87fa7e8..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/PollingWorker.java +++ /dev/null @@ -1,217 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.pm; - -import java.util.Iterator; -import java.util.Properties; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -import java.util.TreeSet; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.atomic.AtomicLong; - -public class PollingWorker implements Runnable { - - private Logger LOGGER = LoggerFactory.getLogger(PollingWorker.class); - - private static PollingWorker self = null; - - private LinkedBlockingQueue tasks = new LinkedBlockingQueue(100); - private long interval = 1000L; - private Thread worker = null; - private AtomicLong[] counters = null; - private int[] bucketUnit = null; - private static boolean enabled = false; - private Timer timer = null; - - public static void post(long starttime){ - PollingWorker temp = self; - if(temp != null && enabled) { - temp.register(new TestSample(starttime)); - } - } - - public static void createInistance(Properties props){ - self = new PollingWorker(props); - } - - private PollingWorker(Properties ctxprops){ - if(ctxprops==null || ctxprops.getProperty("org.openecomp.sdnc.dblib.pm") == null){ - enabled = false; - } else { - if("true".equalsIgnoreCase((String)ctxprops.getProperty("org.openecomp.sdnc.dblib.pm"))){ - enabled = true; - } else { - enabled = false; - } - } - - interval = Long.parseLong(( ctxprops == null || ctxprops.getProperty("org.openecomp.sdnc.dblib.pm.interval") == null) ? "60" : (String)ctxprops.getProperty("org.openecomp.sdnc.dblib.pm.interval")); - // '0' bucket is to count exceptions - String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.openecomp.sdnc.dblib.pm.sampling")==null) ? "0,2,5,10,20,50,100" : (String)ctxprops.getProperty("org.openecomp.sdnc.dblib.pm.sampling")).split(","); - - if(enabled){ - bucketUnit = new int[sampling.length]; - for(int i=0, max = bucketUnit.length; i x.starttime) - return -1; - if(endtime > x.endtime) - return -1; - return 0; - } - return 1; - } - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitor.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitor.java deleted file mode 100644 index c58c9db7d..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitor.java +++ /dev/null @@ -1,237 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.pm; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.Collections; -import java.util.Observable; -import java.util.Observer; -import java.util.SortedSet; -import java.util.Timer; -import java.util.TimerTask; -import java.util.TreeSet; -import java.util.concurrent.atomic.AtomicLong; - -import org.openecomp.sdnc.sli.resource.dblib.DBResourceObserver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SQLExecutionMonitor extends Observable -{ - private static Logger LOGGER = LoggerFactory.getLogger(SQLExecutionMonitor.class); - - final static long MILISECOND = 1000000L; - final static long SECOND = 1000L*MILISECOND; - - private final Timer timer; - // collection - private final SortedSet innerSet; - private SQLExecutionMonitorObserver parent = null; - private final AtomicLong completionCounter; - private boolean activeState = false; - private final long interval; - private final long initialDelay; - private final long EXPECTED_TIME_TO_COMPLETE; - private final long UNPROCESSED_FAILOVER_THRESHOLD; - - private final class MonitoringTask extends TimerTask - { - - public void run() - { - try { - TestObject testObj = new TestObject(); - testObj.setStartTime(testObj.getStartTime() - EXPECTED_TIME_TO_COMPLETE); - - // take a snapshot of the current task list - TestObject[] array = innerSet.toArray(new TestObject[0]); - SortedSet copyCurrent = new TreeSet(Arrays.asList(array)); - // get the list of the tasks that are older than the specified - // interval. - SortedSet unprocessed = copyCurrent.headSet(testObj); - - long succesfulCount = completionCounter.get(); - int unprocessedCount = unprocessed.size(); - - if (!unprocessed.isEmpty() && unprocessedCount > UNPROCESSED_FAILOVER_THRESHOLD && succesfulCount == 0) - { - // switch the Connection Pool to passive - setChanged(); - notifyObservers("Open JDBC requests=" + unprocessedCount+" in "+SQLExecutionMonitor.this.parent.getDbConnectionName()); - } - } catch (Exception exc) { - LOGGER.error("", exc); - } finally { - completionCounter.set(0L); - } - } - } - - public static class TestObject implements Comparable, Serializable - { - - private static final long serialVersionUID = 1L; - private long starttime; - private long randId; - - public TestObject() - { - starttime = System.nanoTime(); - } - - public long getStartTime() - { - return starttime; - } - - public void setStartTime(long newTime) - { - starttime = newTime; - } - - public int compareTo(TestObject o) - { - if( this == o) - return 0; - if(this.starttime > o.getStartTime()) - return 1; - if(this.starttime < o.getStartTime()) - return -1; - - if(this.hashCode() > o.hashCode()) - return 1; - if(this.hashCode() < o.hashCode()) - return -1; - - return 0; - } - - public String toString() - { - return Long.toString(starttime)+"#"+ this.hashCode(); - } - - public boolean equals(Object obj) - { - if (this == obj) - return true; - - return (obj instanceof TestObject - && starttime == ((TestObject) obj).getStartTime() - && hashCode() == ((TestObject) obj).hashCode()); - } - } - - public SQLExecutionMonitor(SQLExecutionMonitorObserver parent) - { - this.parent = parent; - completionCounter = new AtomicLong(0L); - interval = parent.getInterval(); - initialDelay = parent.getInitialDelay(); - this.UNPROCESSED_FAILOVER_THRESHOLD = parent.getUnprocessedFailoverThreshold(); - this.EXPECTED_TIME_TO_COMPLETE = parent.getExpectedCompletionTime()*MILISECOND; - - innerSet = Collections.synchronizedSortedSet(new TreeSet()); - timer = new Timer(); - } - - public void cleanup() - { - timer.cancel(); - } - - // registerRequest - public TestObject registerRequest() - { - if(activeState) - { - TestObject test = new TestObject(); - if(innerSet.add(test)) - return test; - } - return null; - } - - // deregisterSuccessfulReguest - public boolean deregisterReguest(TestObject test) - { - if(test == null) - return false; - // remove from the collection - if(innerSet.remove(test) && activeState) - { - completionCounter.incrementAndGet(); - return true; - } - return false; - } - - public void terminate() { - timer.cancel(); - } - - /** - * @return the parent - */ - public final Object getParent() { - return parent; - } - - public void addObserver(Observer observer) - { - if(observer instanceof DBResourceObserver) - { - DBResourceObserver dbObserver = (DBResourceObserver)observer; - if(dbObserver.isMonitorDbResponse()) - { - if(countObservers() == 0) - { - TimerTask remindTask = new MonitoringTask(); - timer.schedule(remindTask, initialDelay, interval); - activeState = true; - } - } - } - super.addObserver(observer); - } - - public void deleteObserver(Observer observer) - { - super.deleteObserver(observer); - if(observer instanceof DBResourceObserver) - { - DBResourceObserver dbObserver = (DBResourceObserver)observer; - if(dbObserver.isMonitorDbResponse()) - { - if(countObservers() == 0) - { - timer.cancel(); - activeState = false; - } - } - } - } - - public final int getPorcessedConnectionsCount() { - return innerSet.size(); - } -} diff --git a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitorObserver.java b/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitorObserver.java deleted file mode 100644 index 1f329750b..000000000 --- a/dblib/provider/src/main/java/org/openecomp/sdnc/sli/resource/dblib/pm/SQLExecutionMonitorObserver.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openecomp - * ================================================================================ - * Copyright (C) 2016 - 2017 AT&T - * ================================================================================ - * 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.openecomp.sdnc.sli.resource.dblib.pm; - -public interface SQLExecutionMonitorObserver { - public String getDbConnectionName(); - - public long getInterval(); - public void setInterval(long value); - - public long getInitialDelay(); - public void setInitialDelay(long value); - - public long getExpectedCompletionTime(); - public void setExpectedCompletionTime(long value); - - public long getUnprocessedFailoverThreshold(); - public void setUnprocessedFailoverThreshold(long value); -} diff --git a/dblib/provider/src/main/resources/dblib.properties b/dblib/provider/src/main/resources/dblib.properties index ac295c78d..3e62308fc 100755 --- a/dblib/provider/src/main/resources/dblib.properties +++ b/dblib/provider/src/main/resources/dblib.properties @@ -1,13 +1,13 @@ -org.openecomp.sdnc.sli.dbtype=jdbc -org.openecomp.sdnc.sli.jdbc.hosts=sdnctldb01,sdnctldb02 -org.openecomp.sdnc.sli.jdbc.url=jdbc:mysql://DBHOST:3306/sdnctl -org.openecomp.sdnc.sli.jdbc.database=sdnctl -org.openecomp.sdnc.sli.jdbc.user={user for sdnctl} -org.openecomp.sdnc.sli.jdbc.password={password for sdnctl} -org.openecomp.sdnc.sli.jdbc.connection.name=sdnctldb01 +org.onap.ccsdk.sli.dbtype=jdbc +org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01,sdnctldb02 +org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://DBHOST:3306/sdnctl +org.onap.ccsdk.sli.jdbc.database=sdnctl +org.onap.ccsdk.sli.jdbc.user={user for sdnctl} +org.onap.ccsdk.sli.jdbc.password={password for sdnctl} +org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01 -org.openecomp.sdnc.sli.jdbc.connection.timeout=50 -org.openecomp.sdnc.sli.jdbc.request.timeout=100 -org.openecomp.sdnc.sli.jdbc.limit.init=10 -org.openecomp.sdnc.sli.jdbc.limit.min=10 -org.openecomp.sdnc.sli.jdbc.limit.max=20 +org.onap.ccsdk.sli.jdbc.connection.timeout=50 +org.onap.ccsdk.sli.jdbc.request.timeout=100 +org.onap.ccsdk.sli.jdbc.limit.init=10 +org.onap.ccsdk.sli.jdbc.limit.min=10 +org.onap.ccsdk.sli.jdbc.limit.max=20 diff --git a/filters/features/src/main/resources/features.xml b/filters/features/src/main/resources/features.xml index d0cadff25..6837553d5 100644 --- a/filters/features/src/main/resources/features.xml +++ b/filters/features/src/main/resources/features.xml @@ -1,10 +1,9 @@ true diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java new file mode 100644 index 000000000..c97142f1b --- /dev/null +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.filters; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class Activator implements BundleActivator { + + private ServiceRegistration registration = null; + + private static final Logger LOG = LoggerFactory.getLogger(Activator.class); + + @Override + public void start(BundleContext ctx) throws Exception { + + + + Object impl = new String(); + String regName = impl.getClass().getName(); + + if (registration == null) + { + LOG.debug("Registering Filters service "+regName); + registration = ctx.registerService(regName, impl, null); + } + + } + + @Override + public void stop(BundleContext ctx) throws Exception { + + if (registration != null) + { + registration.unregister(); + registration = null; + } + } + +} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java new file mode 100644 index 000000000..9df74c35a --- /dev/null +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java @@ -0,0 +1,221 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.filters; + +import java.io.IOException; +import java.util.UUID; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.codec.binary.Base64; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + + + +/** + * Logs IN request according ECOMP Logging Guidelines at https://tspace.web.att.com/viewer/app/lcfiles/ae5f7751-39da-4c6b-8a83-5836c8c815e1/content + */ +public class LogFilter implements Filter { + + //X-ECOMP is shared between audit and metric + public static final String BEGIN_TIMESTAMP = "AUDIT-BeginTimestamp"; + public static final String END_TIMESTAMP = "AUDIT-EndTimestamp"; + public static final String REQUEST_ID = "X-ECOMP-RequestID"; + public static final String SERVICE_INSTANCE = "X-ECOMP-ServiceInstanceID"; + public static final String THREAD_ID ="X-ECOMP-ThreadId"; //optional + public static final String PHYSICAL_SERVER_NAME="X-ECOMP-PhysicalServerName"; //optional + public static final String SERVICE_NAME="X-ECOMP-ServiceName"; + public static final String PARTNER_NAME="X-ECOMP-PartnerName"; + public static final String STATUS_CODE="AUDIT-StatusCode"; + public static final String RESP_CODE="AUDIT-ResponseCode"; + public static final String RESP_DESC="AUDIT-ResponseDescription"; + public static final String INSTANCE_UUID="AUDIT-InstanceUUID"; + public static final String CATEGORY="AUDIT-INFO"; + public static final String SEVERITY ="AUDIT-Severity"; //optional + public static final String SERVER_IP="AUDIT-ServerIP"; //by chef node['ip'] + public static final String ELAPSED_TIME="AUDIT-ElapsedTime"; + public static final String SERVER_HOST="AUDIT-Server";//by chef node['fqdn'] + public static final String CLIENT_IP="AUDIT-ClientIPaddress"; + public static final String CLASS="AUDIT-Classname"; //optional + public static final String UNUSED="AUDIT-Unused"; //empty + public static final String PROCESS_KEY="AUDIT-ProcessKey"; //optional + public static final String CUST_1="AUDIT-CustomField1";//optional + public static final String CUST_2="AUDIT-CustomField2"; //optional + public static final String CUST_3="AUDIT-CustomField3"; //optional + public static final String CUST_4="AUDIT-CustomField4"; //optional + public static final String DETAIL_MESSAGE="AUDIT-DetailMessage";//optional + + + private static final Logger log = LoggerFactory.getLogger(LogFilter.class); + private static final Logger AUDIT = LoggerFactory.getLogger("org.openecomp.sdnc.filters.audit"); + @Override + public void destroy() { + } + + @Override + public void doFilter(final ServletRequest request, final ServletResponse response, + final FilterChain filterChain) throws IOException, ServletException { + + long startTime = System.currentTimeMillis(); + try { + + if ( request != null && request instanceof HttpServletRequest ) { + pre((HttpServletRequest)request); + } + filterChain.doFilter(request, response); + + + } finally { + + if (request != null && request instanceof HttpServletRequest ) { + post((HttpServletRequest)request,(HttpServletResponse)response,startTime); + } + MDC.clear(); + } + + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + + + private void pre(HttpServletRequest request) { + + UUID uuid = UUID.randomUUID(); + // check if uuid is in header X-ECOMP-RequestID + + String ecompUUID = request.getHeader(REQUEST_ID); + + if (ecompUUID != null && ecompUUID.length() > 0) { + try { + uuid = UUID.fromString(ecompUUID); + log.info("UUID is ECOMP UUID " + uuid.toString()); + } catch (Exception ex){ + log.warn("Failed to convert ECOMP UUID to java.util.UUID format:" + ecompUUID,ex); + } + } + MDC.put(REQUEST_ID, uuid.toString()); + + String userName="unknown"; + + /* below returning org.opendaylight.aaa.shiro.realm.TokenAuthRealm$ODLPrincipal@745dfcfe + if ( request.getUserPrincipal() != null) { + userName = request.getUserPrincipal().getName(); + } + */ + // going directly after Authorization header + if (request.getHeader("Authorization") != null) { + String authzHeader = request.getHeader("Authorization"); + String usernameAndPassword = new String(Base64.decodeBase64(authzHeader.substring(6).getBytes())); + + int userNameIndex = usernameAndPassword.indexOf(":"); + String username = usernameAndPassword.substring(0, userNameIndex); + userName = username; + + } + + + MDC.put(PARTNER_NAME, userName); + //just to initilaze for metric logger (outbound calls) + MDC.put("X-ECOMP-TargetEntity",""); + MDC.put("X-ECOMP-TargetServiceName",""); + + MDC.put(SERVICE_NAME,request.getRequestURL().toString()); + MDC.put(SERVICE_INSTANCE,""); + + } + + + private void post(HttpServletRequest request,HttpServletResponse response,long startTime) { + + //AUDIT.info("{}|{}|{}{}",request.getRemoteHost(),request.getMethod(),request.getRequestURL().toString(),request.getQueryString()); + //AUDIT.info(request.getRemoteHost() + D + request.getMethod() + D + request.getRequestURL().toString() + D + request.getQueryString()); + //METRIC.info(request.getMethod() + D + response.getStatus() + D + request.getRequestURL().toString() + D + (System.currentTimeMillis() - startTime) + " ms"); + MDC.put(BEGIN_TIMESTAMP,asIso8601(startTime)); + MDC.put(END_TIMESTAMP,asIso8601(System.currentTimeMillis())); + //MDC.put(REQUEST_ID,"already done above"); + MDC.put(SERVICE_NAME,request.getRequestURL().toString()); + int idx = request.getPathInfo().toString().lastIndexOf(":"); + String instance = ""; + if ( idx != -1 ) { + instance = request.getPathInfo().substring(idx+1); + } + MDC.put(SERVICE_INSTANCE,instance); + MDC.put(THREAD_ID,""); + MDC.put(PHYSICAL_SERVER_NAME,""); + //MDC.put(PARTNER_NAME,"already done above"); + if ( response.getStatus() >= 400 ) { + MDC.put(STATUS_CODE,"ERROR"); + } else { + MDC.put(STATUS_CODE,"COMPLETE"); + } + + MDC.put(RESP_CODE,"" + response.getStatus()); + MDC.put(RESP_DESC,""); + MDC.put(INSTANCE_UUID,""); + MDC.put(CATEGORY,""); + MDC.put(SEVERITY,""); + //MDC.put(SERVER_IP,""); //by chef + MDC.put(ELAPSED_TIME,"" + (System.currentTimeMillis() - startTime)); + //MDC.put(SERVER_HOST,""); //by chef + MDC.put(CLIENT_IP,request.getRemoteHost()); + MDC.put(CLASS,""); + MDC.put(UNUSED,""); + MDC.put(PROCESS_KEY,""); + MDC.put(CUST_1,""); + MDC.put(CUST_2,""); + MDC.put(CUST_3,""); + MDC.put(CUST_4,""); + MDC.put(DETAIL_MESSAGE,request.getMethod()); + + AUDIT.info(""); + } + + private String asIso8601(Date date) { + TimeZone tz = TimeZone.getTimeZone("UTC"); + DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'hh:mm:ss:SS'+00:00'"); + df.setTimeZone(tz); + return df.format(date); + } + + private String asIso8601(long tsInMillis) { + return asIso8601(new Date(tsInMillis)); + } + + +} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java new file mode 100644 index 000000000..b187d9573 --- /dev/null +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java @@ -0,0 +1,297 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.filters; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.zip.GZIPInputStream; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; + +import org.onap.ccsdk.sli.core.sli.MessageWriter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RequestResponseDbLoggingFilter implements Filter { + + private static Logger log = LoggerFactory.getLogger(RequestResponseDbLoggingFilter.class); + + public static final String REQUEST_ID = "X-ECOMP-RequestID"; + + private static class ByteArrayServletStream extends ServletOutputStream { + + ByteArrayOutputStream baos; + + ByteArrayServletStream(ByteArrayOutputStream baos) { + this.baos = baos; + } + + @Override + public void write(int param) throws IOException { + baos.write(param); + } + } + + private static class ByteArrayPrintWriter { + + private ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + private PrintWriter pw = new PrintWriter(baos); + + private ServletOutputStream sos = new ByteArrayServletStream(baos); + + public PrintWriter getWriter() { + return pw; + } + + public ServletOutputStream getStream() { + return sos; + } + + byte[] toByteArray() { + return baos.toByteArray(); + } + } + + private class BufferedServletInputStream extends ServletInputStream { + + ByteArrayInputStream bais; + + public BufferedServletInputStream(ByteArrayInputStream bais) { + this.bais = bais; + } + + @Override + public int available() { + return bais.available(); + } + + @Override + public int read() { + return bais.read(); + } + + @Override + public int read(byte[] buf, int off, int len) { + return bais.read(buf, off, len); + } + + } + + private class BufferedRequestWrapper extends HttpServletRequestWrapper { + + ByteArrayInputStream bais; + + ByteArrayOutputStream baos; + + BufferedServletInputStream bsis; + + byte[] buffer; + + public BufferedRequestWrapper(HttpServletRequest req) throws IOException { + super(req); + + InputStream is = req.getInputStream(); + baos = new ByteArrayOutputStream(); + byte buf[] = new byte[1024]; + int letti; + while ((letti = is.read(buf)) > 0) { + baos.write(buf, 0, letti); + } + buffer = baos.toByteArray(); + + } + + @Override + public ServletInputStream getInputStream() { + try { + bais = new ByteArrayInputStream(buffer); + bsis = new BufferedServletInputStream(bais); + } catch (Exception ex) { + ex.printStackTrace(); + } + + return bsis; + } + + public byte[] getBuffer() { + return buffer; + } + + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + @Override + public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain) + throws IOException, ServletException { + + if (request == null || !(request instanceof HttpServletRequest)) { + filterChain.doFilter(request, response); + return; + } + + long t1 = System.currentTimeMillis(); + + final HttpServletRequest httpRequest = (HttpServletRequest) request; + BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); + + String requestId = httpRequest.getHeader(REQUEST_ID); + if (requestId == null || requestId.trim().length() == 0) { + log.warn("Could not write request in DB: " + REQUEST_ID + " is missing in the HTTP headers."); + return; + } + + String requestHost = request.getRemoteHost(); + if (requestHost == null) + requestHost = request.getRemoteAddr(); + + String requestStr = new String(bufferedRequest.getBuffer()); + + MessageWriter.saveIncomingRequest(requestId, null, requestHost, requestStr); + + long t2 = System.currentTimeMillis(); + + log.info("Request saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1)); + + final HttpServletResponse httpResponse = (HttpServletResponse) response; + + final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(); + HttpServletResponse wrappedResp = new HttpServletResponseWrapper(httpResponse) { + + @Override + public PrintWriter getWriter() { + return pw.getWriter(); + } + + @Override + public ServletOutputStream getOutputStream() { + return pw.getStream(); + } + }; + + try { + + filterChain.doFilter(bufferedRequest, wrappedResp); + + } finally { + + if (request != null && request instanceof HttpServletRequest) { + + t1 = System.currentTimeMillis(); + + byte[] bytes = pw.toByteArray(); + response.getOutputStream().write(bytes); + response.getOutputStream().flush(); + + String responseStr = null; + if ("gzip".equals(httpResponse.getHeader("Content-Encoding"))) { + responseStr = decompressGZIPByteArray(bytes); + } else { + responseStr = new String(bytes); + } + + MessageWriter.saveIncomingResponse(requestId, httpResponse.getStatus(), responseStr); + + t2 = System.currentTimeMillis(); + + log.info("Response saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1)); + } + } + + } + + @Override + public void destroy() { + } + + private String decompressGZIPByteArray(byte[] bytes) { + + BufferedReader in = null; + InputStreamReader inR = null; + ByteArrayInputStream byteS = null; + GZIPInputStream gzS = null; + StringBuilder str = new StringBuilder(); + try { + byteS = new ByteArrayInputStream(bytes); + gzS = new GZIPInputStream(byteS); + inR = new InputStreamReader(gzS); + in = new BufferedReader(inR); + + if (in != null) { + + String content; + + while ((content = in.readLine()) != null) { + str.append(content); + } + } + + } catch (Exception e) { + log.error("Failed get read GZIPInputStream", e); + } finally { + + if (byteS != null) + try { + byteS.close(); + } catch (IOException e1) { + log.error("Failed to close ByteStream", e1); + } + if (gzS != null) + try { + gzS.close(); + } catch (IOException e2) { + log.error("Failed to close GZStream", e2); + } + if (inR != null) + try { + inR.close(); + } catch (IOException e3) { + log.error("Failed to close InputReader", e3); + } + if (in != null) + try { + in.close(); + } catch (IOException e) { + log.error("Failed to close BufferedReader", e); + } + } + return str.toString(); + } +} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java new file mode 100644 index 000000000..e4b0b7d1f --- /dev/null +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -0,0 +1,288 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.filters; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.Enumeration; +import java.util.zip.GZIPInputStream; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; + +public class RequestResponseLoggingFilter implements Filter { + + private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("org.openecomp.sdnc.filters.request.response"); + + private static class ByteArrayServletStream extends ServletOutputStream { + + ByteArrayOutputStream baos; + + ByteArrayServletStream(ByteArrayOutputStream baos) { + this.baos = baos; + } + + @Override + public void write(int param) throws IOException { + baos.write(param); + } + } + + private static class ByteArrayPrintWriter { + + private ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + private PrintWriter pw = new PrintWriter(baos); + + private ServletOutputStream sos = new ByteArrayServletStream(baos); + + public PrintWriter getWriter() { + return pw; + } + + public ServletOutputStream getStream() { + return sos; + } + + byte[] toByteArray() { + return baos.toByteArray(); + } + } + + private class BufferedServletInputStream extends ServletInputStream { + + ByteArrayInputStream bais; + + public BufferedServletInputStream(ByteArrayInputStream bais) { + this.bais = bais; + } + + @Override + public int available() { + return bais.available(); + } + + @Override + public int read() { + return bais.read(); + } + + @Override + public int read(byte[] buf, int off, int len) { + return bais.read(buf, off, len); + } + + } + + private class BufferedRequestWrapper extends HttpServletRequestWrapper { + + ByteArrayInputStream bais; + + ByteArrayOutputStream baos; + + BufferedServletInputStream bsis; + + byte[] buffer; + + public BufferedRequestWrapper(HttpServletRequest req) throws IOException { + super(req); + + InputStream is = req.getInputStream(); + baos = new ByteArrayOutputStream(); + byte buf[] = new byte[1024]; + int letti; + while ((letti = is.read(buf)) > 0) { + baos.write(buf, 0, letti); + } + buffer = baos.toByteArray(); + + } + + @Override + public ServletInputStream getInputStream() { + try { + bais = new ByteArrayInputStream(buffer); + bsis = new BufferedServletInputStream(bais); + } catch (Exception ex) { + ex.printStackTrace(); + } + + return bsis; + } + + public byte[] getBuffer() { + return buffer; + } + + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + + final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; + BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); + + StringBuilder requestHeaders = new StringBuilder("REQUEST|"); + requestHeaders.append(httpRequest.getMethod()); + requestHeaders.append(":"); + requestHeaders.append(httpRequest.getRequestURL().toString()); + requestHeaders.append("|"); + String header; + for (Enumeration e = httpRequest.getHeaderNames(); e.hasMoreElements();) { + header = e.nextElement(); + requestHeaders.append(header); + requestHeaders.append(":"); + requestHeaders.append(httpRequest.getHeader(header)); + requestHeaders.append(";"); + + } + log.info(requestHeaders.toString()); + + log.info("REQUEST BODY|" + new String(bufferedRequest.getBuffer())); + + final HttpServletResponse response = (HttpServletResponse) servletResponse; + + final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(); + HttpServletResponse wrappedResp = new HttpServletResponseWrapper(response) { + @Override + public PrintWriter getWriter() { + return pw.getWriter(); + } + + @Override + public ServletOutputStream getOutputStream() { + return pw.getStream(); + } + + }; + + try { + + filterChain.doFilter(bufferedRequest, wrappedResp); + + }catch (Exception e){ + log.error("Chain Exception",e); + throw e; + } finally { + byte[] bytes = pw.toByteArray(); + response.getOutputStream().write(bytes); + response.getOutputStream().flush(); + + StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|"); + + for (String headerName : response.getHeaderNames()) { + responseHeaders.append(headerName); + responseHeaders.append(":"); + responseHeaders.append(response.getHeader(headerName)); + responseHeaders.append(";"); + + } + log.info(responseHeaders.toString()); + + if ("gzip".equals(response.getHeader("Content-Encoding"))) { + + log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes)); + + } else { + + log.info("RESPONSE BODY|" + new String(bytes)); + } + } + } + + @Override + public void destroy() { + } + + private String decompressGZIPByteArray(byte[] bytes) { + + BufferedReader in = null; + InputStreamReader inR = null; + ByteArrayInputStream byteS = null; + GZIPInputStream gzS = null; + StringBuilder str = new StringBuilder(); + try { + byteS = new ByteArrayInputStream(bytes); + gzS = new GZIPInputStream(byteS); + inR = new InputStreamReader(gzS); + in = new BufferedReader(inR); + + if (in != null) { + + String content; + + while ((content = in.readLine()) != null) { + str.append(content); + } + } + + } catch (Exception e) { + log.error("Failed get read GZIPInputStream", e); + } finally { + + if (byteS != null) + try { + byteS.close(); + } catch (IOException e1) { + log.error("Failed to close ByteStream", e1); + } + if (gzS != null) + try { + gzS.close(); + } catch (IOException e2) { + log.error("Failed to close GZStream", e2); + } + if (inR != null) + try { + inR.close(); + } catch (IOException e3) { + log.error("Failed to close InputReader", e3); + } + if (in != null) + try { + in.close(); + } catch (IOException e) { + log.error("Failed to close BufferedReader", e); + } + } + return str.toString(); + } +} diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java deleted file mode 100644 index d21b30992..000000000 --- a/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.filters; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class Activator implements BundleActivator { - - private ServiceRegistration registration = null; - - private static final Logger LOG = LoggerFactory.getLogger(Activator.class); - - @Override - public void start(BundleContext ctx) throws Exception { - - - - Object impl = new String(); - String regName = impl.getClass().getName(); - - if (registration == null) - { - LOG.debug("Registering Filters service "+regName); - registration = ctx.registerService(regName, impl, null); - } - - } - - @Override - public void stop(BundleContext ctx) throws Exception { - - if (registration != null) - { - registration.unregister(); - registration = null; - } - } - -} diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java deleted file mode 100644 index 809cfb287..000000000 --- a/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java +++ /dev/null @@ -1,222 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.filters; - -import java.io.IOException; -import java.util.UUID; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.codec.binary.Base64; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - - - -/** - * Logs IN request according ECOMP Logging Guidelines at https://tspace.web.att.com/viewer/app/lcfiles/ae5f7751-39da-4c6b-8a83-5836c8c815e1/content - */ -public class LogFilter implements Filter { - - //X-ECOMP is shared between audit and metric - public static final String BEGIN_TIMESTAMP = "AUDIT-BeginTimestamp"; - public static final String END_TIMESTAMP = "AUDIT-EndTimestamp"; - public static final String REQUEST_ID = "X-ECOMP-RequestID"; - public static final String SERVICE_INSTANCE = "X-ECOMP-ServiceInstanceID"; - public static final String THREAD_ID ="X-ECOMP-ThreadId"; //optional - public static final String PHYSICAL_SERVER_NAME="X-ECOMP-PhysicalServerName"; //optional - public static final String SERVICE_NAME="X-ECOMP-ServiceName"; - public static final String PARTNER_NAME="X-ECOMP-PartnerName"; - public static final String STATUS_CODE="AUDIT-StatusCode"; - public static final String RESP_CODE="AUDIT-ResponseCode"; - public static final String RESP_DESC="AUDIT-ResponseDescription"; - public static final String INSTANCE_UUID="AUDIT-InstanceUUID"; - public static final String CATEGORY="AUDIT-INFO"; - public static final String SEVERITY ="AUDIT-Severity"; //optional - public static final String SERVER_IP="AUDIT-ServerIP"; //by chef node['ip'] - public static final String ELAPSED_TIME="AUDIT-ElapsedTime"; - public static final String SERVER_HOST="AUDIT-Server";//by chef node['fqdn'] - public static final String CLIENT_IP="AUDIT-ClientIPaddress"; - public static final String CLASS="AUDIT-Classname"; //optional - public static final String UNUSED="AUDIT-Unused"; //empty - public static final String PROCESS_KEY="AUDIT-ProcessKey"; //optional - public static final String CUST_1="AUDIT-CustomField1";//optional - public static final String CUST_2="AUDIT-CustomField2"; //optional - public static final String CUST_3="AUDIT-CustomField3"; //optional - public static final String CUST_4="AUDIT-CustomField4"; //optional - public static final String DETAIL_MESSAGE="AUDIT-DetailMessage";//optional - - - private static final Logger log = LoggerFactory.getLogger(LogFilter.class); - private static final Logger AUDIT = LoggerFactory.getLogger("org.openecomp.sdnc.filters.audit"); - @Override - public void destroy() { - } - - @Override - public void doFilter(final ServletRequest request, final ServletResponse response, - final FilterChain filterChain) throws IOException, ServletException { - - long startTime = System.currentTimeMillis(); - try { - - if ( request != null && request instanceof HttpServletRequest ) { - pre((HttpServletRequest)request); - } - filterChain.doFilter(request, response); - - - } finally { - - if (request != null && request instanceof HttpServletRequest ) { - post((HttpServletRequest)request,(HttpServletResponse)response,startTime); - } - MDC.clear(); - } - - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } - - - - private void pre(HttpServletRequest request) { - - UUID uuid = UUID.randomUUID(); - // check if uuid is in header X-ECOMP-RequestID - - String ecompUUID = request.getHeader(REQUEST_ID); - - if (ecompUUID != null && ecompUUID.length() > 0) { - try { - uuid = UUID.fromString(ecompUUID); - log.info("UUID is ECOMP UUID " + uuid.toString()); - } catch (Exception ex){ - log.warn("Failed to convert ECOMP UUID to java.util.UUID format:" + ecompUUID,ex); - } - } - MDC.put(REQUEST_ID, uuid.toString()); - - String userName="unknown"; - - /* below returning org.opendaylight.aaa.shiro.realm.TokenAuthRealm$ODLPrincipal@745dfcfe - if ( request.getUserPrincipal() != null) { - userName = request.getUserPrincipal().getName(); - } - */ - // going directly after Authorization header - if (request.getHeader("Authorization") != null) { - String authzHeader = request.getHeader("Authorization"); - String usernameAndPassword = new String(Base64.decodeBase64(authzHeader.substring(6).getBytes())); - - int userNameIndex = usernameAndPassword.indexOf(":"); - String username = usernameAndPassword.substring(0, userNameIndex); - userName = username; - - } - - - MDC.put(PARTNER_NAME, userName); - //just to initilaze for metric logger (outbound calls) - MDC.put("X-ECOMP-TargetEntity",""); - MDC.put("X-ECOMP-TargetServiceName",""); - - MDC.put(SERVICE_NAME,request.getRequestURL().toString()); - MDC.put(SERVICE_INSTANCE,""); - - } - - - private void post(HttpServletRequest request,HttpServletResponse response,long startTime) { - - //AUDIT.info("{}|{}|{}{}",request.getRemoteHost(),request.getMethod(),request.getRequestURL().toString(),request.getQueryString()); - //AUDIT.info(request.getRemoteHost() + D + request.getMethod() + D + request.getRequestURL().toString() + D + request.getQueryString()); - //METRIC.info(request.getMethod() + D + response.getStatus() + D + request.getRequestURL().toString() + D + (System.currentTimeMillis() - startTime) + " ms"); - MDC.put(BEGIN_TIMESTAMP,asIso8601(startTime)); - MDC.put(END_TIMESTAMP,asIso8601(System.currentTimeMillis())); - //MDC.put(REQUEST_ID,"already done above"); - MDC.put(SERVICE_NAME,request.getRequestURL().toString()); - int idx = request.getPathInfo().toString().lastIndexOf(":"); - String instance = ""; - if ( idx != -1 ) { - instance = request.getPathInfo().substring(idx+1); - } - MDC.put(SERVICE_INSTANCE,instance); - MDC.put(THREAD_ID,""); - MDC.put(PHYSICAL_SERVER_NAME,""); - //MDC.put(PARTNER_NAME,"already done above"); - if ( response.getStatus() >= 400 ) { - MDC.put(STATUS_CODE,"ERROR"); - } else { - MDC.put(STATUS_CODE,"COMPLETE"); - } - - MDC.put(RESP_CODE,"" + response.getStatus()); - MDC.put(RESP_DESC,""); - MDC.put(INSTANCE_UUID,""); - MDC.put(CATEGORY,""); - MDC.put(SEVERITY,""); - //MDC.put(SERVER_IP,""); //by chef - MDC.put(ELAPSED_TIME,"" + (System.currentTimeMillis() - startTime)); - //MDC.put(SERVER_HOST,""); //by chef - MDC.put(CLIENT_IP,request.getRemoteHost()); - MDC.put(CLASS,""); - MDC.put(UNUSED,""); - MDC.put(PROCESS_KEY,""); - MDC.put(CUST_1,""); - MDC.put(CUST_2,""); - MDC.put(CUST_3,""); - MDC.put(CUST_4,""); - MDC.put(DETAIL_MESSAGE,request.getMethod()); - - AUDIT.info(""); - } - - private String asIso8601(Date date) { - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'hh:mm:ss:SS'+00:00'"); - df.setTimeZone(tz); - return df.format(date); - } - - private String asIso8601(long tsInMillis) { - return asIso8601(new Date(tsInMillis)); - } - - -} diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java deleted file mode 100644 index 183301be5..000000000 --- a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseDbLoggingFilter.java +++ /dev/null @@ -1,297 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.filters; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.zip.GZIPInputStream; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletOutputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.openecomp.sdnc.sli.MessageWriter; - -public class RequestResponseDbLoggingFilter implements Filter { - - private static Logger log = LoggerFactory.getLogger(RequestResponseDbLoggingFilter.class); - - public static final String REQUEST_ID = "X-ECOMP-RequestID"; - - private static class ByteArrayServletStream extends ServletOutputStream { - - ByteArrayOutputStream baos; - - ByteArrayServletStream(ByteArrayOutputStream baos) { - this.baos = baos; - } - - @Override - public void write(int param) throws IOException { - baos.write(param); - } - } - - private static class ByteArrayPrintWriter { - - private ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - private PrintWriter pw = new PrintWriter(baos); - - private ServletOutputStream sos = new ByteArrayServletStream(baos); - - public PrintWriter getWriter() { - return pw; - } - - public ServletOutputStream getStream() { - return sos; - } - - byte[] toByteArray() { - return baos.toByteArray(); - } - } - - private class BufferedServletInputStream extends ServletInputStream { - - ByteArrayInputStream bais; - - public BufferedServletInputStream(ByteArrayInputStream bais) { - this.bais = bais; - } - - @Override - public int available() { - return bais.available(); - } - - @Override - public int read() { - return bais.read(); - } - - @Override - public int read(byte[] buf, int off, int len) { - return bais.read(buf, off, len); - } - - } - - private class BufferedRequestWrapper extends HttpServletRequestWrapper { - - ByteArrayInputStream bais; - - ByteArrayOutputStream baos; - - BufferedServletInputStream bsis; - - byte[] buffer; - - public BufferedRequestWrapper(HttpServletRequest req) throws IOException { - super(req); - - InputStream is = req.getInputStream(); - baos = new ByteArrayOutputStream(); - byte buf[] = new byte[1024]; - int letti; - while ((letti = is.read(buf)) > 0) { - baos.write(buf, 0, letti); - } - buffer = baos.toByteArray(); - - } - - @Override - public ServletInputStream getInputStream() { - try { - bais = new ByteArrayInputStream(buffer); - bsis = new BufferedServletInputStream(bais); - } catch (Exception ex) { - ex.printStackTrace(); - } - - return bsis; - } - - public byte[] getBuffer() { - return buffer; - } - - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } - - @Override - public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain) - throws IOException, ServletException { - - if (request == null || !(request instanceof HttpServletRequest)) { - filterChain.doFilter(request, response); - return; - } - - long t1 = System.currentTimeMillis(); - - final HttpServletRequest httpRequest = (HttpServletRequest) request; - BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); - - String requestId = httpRequest.getHeader(REQUEST_ID); - if (requestId == null || requestId.trim().length() == 0) { - log.warn("Could not write request in DB: " + REQUEST_ID + " is missing in the HTTP headers."); - return; - } - - String requestHost = request.getRemoteHost(); - if (requestHost == null) - requestHost = request.getRemoteAddr(); - - String requestStr = new String(bufferedRequest.getBuffer()); - - MessageWriter.saveIncomingRequest(requestId, null, requestHost, requestStr); - - long t2 = System.currentTimeMillis(); - - log.info("Request saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1)); - - final HttpServletResponse httpResponse = (HttpServletResponse) response; - - final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(); - HttpServletResponse wrappedResp = new HttpServletResponseWrapper(httpResponse) { - - @Override - public PrintWriter getWriter() { - return pw.getWriter(); - } - - @Override - public ServletOutputStream getOutputStream() { - return pw.getStream(); - } - }; - - try { - - filterChain.doFilter(bufferedRequest, wrappedResp); - - } finally { - - if (request != null && request instanceof HttpServletRequest) { - - t1 = System.currentTimeMillis(); - - byte[] bytes = pw.toByteArray(); - response.getOutputStream().write(bytes); - response.getOutputStream().flush(); - - String responseStr = null; - if ("gzip".equals(httpResponse.getHeader("Content-Encoding"))) { - responseStr = decompressGZIPByteArray(bytes); - } else { - responseStr = new String(bytes); - } - - MessageWriter.saveIncomingResponse(requestId, httpResponse.getStatus(), responseStr); - - t2 = System.currentTimeMillis(); - - log.info("Response saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1)); - } - } - - } - - @Override - public void destroy() { - } - - private String decompressGZIPByteArray(byte[] bytes) { - - BufferedReader in = null; - InputStreamReader inR = null; - ByteArrayInputStream byteS = null; - GZIPInputStream gzS = null; - StringBuilder str = new StringBuilder(); - try { - byteS = new ByteArrayInputStream(bytes); - gzS = new GZIPInputStream(byteS); - inR = new InputStreamReader(gzS); - in = new BufferedReader(inR); - - if (in != null) { - - String content; - - while ((content = in.readLine()) != null) { - str.append(content); - } - } - - } catch (Exception e) { - log.error("Failed get read GZIPInputStream", e); - } finally { - - if (byteS != null) - try { - byteS.close(); - } catch (IOException e1) { - log.error("Failed to close ByteStream", e1); - } - if (gzS != null) - try { - gzS.close(); - } catch (IOException e2) { - log.error("Failed to close GZStream", e2); - } - if (inR != null) - try { - inR.close(); - } catch (IOException e3) { - log.error("Failed to close InputReader", e3); - } - if (in != null) - try { - in.close(); - } catch (IOException e) { - log.error("Failed to close BufferedReader", e); - } - } - return str.toString(); - } -} diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java deleted file mode 100644 index b15932f09..000000000 --- a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java +++ /dev/null @@ -1,289 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.filters; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.zip.GZIPInputStream; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletOutputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; - -public class RequestResponseLoggingFilter implements Filter { - - private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("org.openecomp.sdnc.filters.request.response"); - - private static class ByteArrayServletStream extends ServletOutputStream { - - ByteArrayOutputStream baos; - - ByteArrayServletStream(ByteArrayOutputStream baos) { - this.baos = baos; - } - - @Override - public void write(int param) throws IOException { - baos.write(param); - } - } - - private static class ByteArrayPrintWriter { - - private ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - private PrintWriter pw = new PrintWriter(baos); - - private ServletOutputStream sos = new ByteArrayServletStream(baos); - - public PrintWriter getWriter() { - return pw; - } - - public ServletOutputStream getStream() { - return sos; - } - - byte[] toByteArray() { - return baos.toByteArray(); - } - } - - private class BufferedServletInputStream extends ServletInputStream { - - ByteArrayInputStream bais; - - public BufferedServletInputStream(ByteArrayInputStream bais) { - this.bais = bais; - } - - @Override - public int available() { - return bais.available(); - } - - @Override - public int read() { - return bais.read(); - } - - @Override - public int read(byte[] buf, int off, int len) { - return bais.read(buf, off, len); - } - - } - - private class BufferedRequestWrapper extends HttpServletRequestWrapper { - - ByteArrayInputStream bais; - - ByteArrayOutputStream baos; - - BufferedServletInputStream bsis; - - byte[] buffer; - - public BufferedRequestWrapper(HttpServletRequest req) throws IOException { - super(req); - - InputStream is = req.getInputStream(); - baos = new ByteArrayOutputStream(); - byte buf[] = new byte[1024]; - int letti; - while ((letti = is.read(buf)) > 0) { - baos.write(buf, 0, letti); - } - buffer = baos.toByteArray(); - - } - - @Override - public ServletInputStream getInputStream() { - try { - bais = new ByteArrayInputStream(buffer); - bsis = new BufferedServletInputStream(bais); - } catch (Exception ex) { - ex.printStackTrace(); - } - - return bsis; - } - - public byte[] getBuffer() { - return buffer; - } - - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } - - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) - throws IOException, ServletException { - - final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; - BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); - - StringBuilder requestHeaders = new StringBuilder("REQUEST|"); - requestHeaders.append(httpRequest.getMethod()); - requestHeaders.append(":"); - requestHeaders.append(httpRequest.getRequestURL().toString()); - requestHeaders.append("|"); - String header; - for (Enumeration e = httpRequest.getHeaderNames(); e.hasMoreElements();) { - header = e.nextElement(); - requestHeaders.append(header); - requestHeaders.append(":"); - requestHeaders.append(httpRequest.getHeader(header)); - requestHeaders.append(";"); - - } - log.info(requestHeaders.toString()); - - log.info("REQUEST BODY|" + new String(bufferedRequest.getBuffer())); - - final HttpServletResponse response = (HttpServletResponse) servletResponse; - - final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(); - HttpServletResponse wrappedResp = new HttpServletResponseWrapper(response) { - @Override - public PrintWriter getWriter() { - return pw.getWriter(); - } - - @Override - public ServletOutputStream getOutputStream() { - return pw.getStream(); - } - - }; - - try { - - filterChain.doFilter(bufferedRequest, wrappedResp); - - }catch (Exception e){ - log.error("Chain Exception",e); - throw e; - } finally { - byte[] bytes = pw.toByteArray(); - response.getOutputStream().write(bytes); - response.getOutputStream().flush(); - - StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|"); - - for (String headerName : response.getHeaderNames()) { - responseHeaders.append(headerName); - responseHeaders.append(":"); - responseHeaders.append(response.getHeader(headerName)); - responseHeaders.append(";"); - - } - log.info(responseHeaders.toString()); - - if ("gzip".equals(response.getHeader("Content-Encoding"))) { - - log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes)); - - } else { - - log.info("RESPONSE BODY|" + new String(bytes)); - } - } - } - - @Override - public void destroy() { - } - - private String decompressGZIPByteArray(byte[] bytes) { - - BufferedReader in = null; - InputStreamReader inR = null; - ByteArrayInputStream byteS = null; - GZIPInputStream gzS = null; - StringBuilder str = new StringBuilder(); - try { - byteS = new ByteArrayInputStream(bytes); - gzS = new GZIPInputStream(byteS); - inR = new InputStreamReader(gzS); - in = new BufferedReader(inR); - - if (in != null) { - - String content; - - while ((content = in.readLine()) != null) { - str.append(content); - } - } - - } catch (Exception e) { - log.error("Failed get read GZIPInputStream", e); - } finally { - - if (byteS != null) - try { - byteS.close(); - } catch (IOException e1) { - log.error("Failed to close ByteStream", e1); - } - if (gzS != null) - try { - gzS.close(); - } catch (IOException e2) { - log.error("Failed to close GZStream", e2); - } - if (inR != null) - try { - inR.close(); - } catch (IOException e3) { - log.error("Failed to close InputReader", e3); - } - if (in != null) - try { - in.close(); - } catch (IOException e) { - log.error("Failed to close BufferedReader", e); - } - } - return str.toString(); - } -} diff --git a/pom.xml b/pom.xml index 8e9d10b60..4a1a25010 100755 --- a/pom.xml +++ b/pom.xml @@ -118,10 +118,9 @@ 2017 - AT&T Intellectual Property. All rights - reserved. + ONAP - openECOMP : SDN-C + ONAP : CCSDK true diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 9a49e69e4..8b19891f0 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -108,8 +108,8 @@ **/*.xsd - org.openecomp.sdnc.sli.SvcLogicParser - org.openecomp.sdnc.sli + org.onap.ccsdk.sli.core.sli.SvcLogicParser + org.onap.ccsdk.sli.core.sli true @@ -121,7 +121,7 @@ true - org.openecomp.sdnc.sli;version=${project.version} + org.onap.ccsdk.sli.core.sli;version=${project.version} * *;scope=compile;artifactId=commons-lang|commons-lang3 true diff --git a/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 b/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 new file mode 100755 index 000000000..1b026bb1a --- /dev/null +++ b/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 @@ -0,0 +1,67 @@ + +grammar ExprGrammar; + +options { + language = Java; +} + + +COMPAREOP : '==' | '!=' | '>' | '<' | '>=' | '<='; + +RELOP : 'and' | 'or'; + +ADDOP : '+' | '-'; + +MULTOP : '/' | '*'; + +NUMBER : ('0'..'9')+; + +STRING : '\'' ~[\']* '\''; + +IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*; + +// CONTEXT_VAR : '$' IDENTIFIER; + +WS: [ \n\t\r]+ -> skip; + +constant : NUMBER | STRING ; + +variableLead : ('$')? variableTerm ; + +variableTerm : IDENTIFIER ('[' expr ']')? ; + +variable : variableLead ('.' variableTerm)* ('.')?; + +// variable : CONTEXT_VAR ( '[' expr ']' )? ('.' IDENTIFIER )? ; + +atom : constant | variable; + + +expr : atom + | parenExpr + | multExpr + | addExpr + | compareExpr + | relExpr + | funcExpr; + +parenExpr : '(' expr ')'; + +term : atom | parenExpr | funcExpr; + +multExpr : term (MULTOP term)*; + +addExpr : multExpr (ADDOP multExpr)*; + +compareExpr : addExpr COMPAREOP addExpr; + +relExpr : compareExpr (RELOP expr)*; + +funcExpr : IDENTIFIER '(' expr (',' expr)* ')'; + + + + + + + diff --git a/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 b/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 deleted file mode 100755 index 51f401690..000000000 --- a/sli/common/src/main/antlr4/org/openecomp/sdnc/sli/ExprGrammar.g4 +++ /dev/null @@ -1,66 +0,0 @@ -grammar ExprGrammar; - -options { - language = Java; -} - - -COMPAREOP : '==' | '!=' | '>' | '<' | '>=' | '<='; - -RELOP : 'and' | 'or'; - -ADDOP : '+' | '-'; - -MULTOP : '/' | '*'; - -NUMBER : ('0'..'9')+; - -STRING : '\'' ~[\']* '\''; - -IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*; - -// CONTEXT_VAR : '$' IDENTIFIER; - -WS: [ \n\t\r]+ -> skip; - -constant : NUMBER | STRING ; - -variableLead : ('$')? variableTerm ; - -variableTerm : IDENTIFIER ('[' expr ']')? ; - -variable : variableLead ('.' variableTerm)* ('.')?; - -// variable : CONTEXT_VAR ( '[' expr ']' )? ('.' IDENTIFIER )? ; - -atom : constant | variable; - - -expr : atom - | parenExpr - | multExpr - | addExpr - | compareExpr - | relExpr - | funcExpr; - -parenExpr : '(' expr ')'; - -term : atom | parenExpr | funcExpr; - -multExpr : term (MULTOP term)*; - -addExpr : multExpr (ADDOP multExpr)*; - -compareExpr : addExpr COMPAREOP addExpr; - -relExpr : compareExpr (RELOP expr)*; - -funcExpr : IDENTIFIER '(' expr (',' expr)* ')'; - - - - - - - diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java new file mode 100644 index 000000000..d85514cbc --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +public class BreakNodeException extends SvcLogicException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public BreakNodeException() + { + super(); + } + + public BreakNodeException(String message) + { + super(message); + } + + public BreakNodeException(String message, Throwable t) + { + super(message, t); + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java new file mode 100644 index 000000000..7a8531008 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +public class ConfigurationException extends SvcLogicException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public ConfigurationException() + { + super(); + } + + public ConfigurationException(String msg) + { + super(msg); + } + + public ConfigurationException(String msg, Throwable t) + { + super(msg, t); + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java new file mode 100644 index 000000000..24d06a211 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +public class DuplicateValueException extends SvcLogicException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public DuplicateValueException() + { + super(); + } + + public DuplicateValueException(String message) + { + super(message); + } + + public DuplicateValueException(String message, Throwable t) + { + super(message, t); + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java new file mode 100644 index 000000000..b9f9e5347 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java @@ -0,0 +1,301 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.File; +import java.io.FileInputStream; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Properties; + +import javax.sql.rowset.CachedRowSet; + +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class MessageWriter { + + private static final Logger LOG = LoggerFactory.getLogger(MessageWriter.class); + + private static final String DBLIB_SERVICE = "org.onap.ccsdk.sli.core.dblib.DBResourceManager"; + private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final String INCOMING_PROPERTY_NAME = "org.onap.ccsdk.sli.MessageWriter.writeIncomingRequests"; + private static final String OUTGOING_PROPERTY_NAME = "org.onap.ccsdk.sli.MessageWriter.writeOutgoingRequests"; + + private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + + private static DbLibService dbLibService = null; + + private static boolean incomingEnabled = false; + private static boolean outgoingEnabled = false; + + private static boolean initialized = false; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static void init() { + if (initialized) + return; + + initialized = true; + + // Read properties + Properties props = new Properties(); + String propPath = System.getenv(SVCLOGIC_PROP_VAR); + + if (propPath == null) { + String propDir = System.getenv(SDNC_CONFIG_DIR); + if (propDir == null) { + propDir = "/opt/sdnc/data/properties"; + } + propPath = propDir + "/svclogic.properties"; + LOG.warn("Environment variable " + SVCLOGIC_PROP_VAR + " unset - defaulting to " + propPath); + } + + File propFile = new File(propPath); + + if (!propFile.exists()) { + LOG.warn("Property file does not exist: " + propPath); + } + + try { + props.load(new FileInputStream(propFile)); + } catch (Exception e) { + LOG.warn("Error loading property file: " + propPath, e); + } + + incomingEnabled = Boolean.valueOf(props.getProperty(INCOMING_PROPERTY_NAME, "false")); + outgoingEnabled = Boolean.valueOf(props.getProperty(OUTGOING_PROPERTY_NAME, "false")); + + LOG.info(INCOMING_PROPERTY_NAME + ": " + incomingEnabled); + LOG.info(OUTGOING_PROPERTY_NAME + ": " + outgoingEnabled); + + if (dbLibService != null) + return; + + BundleContext bctx = FrameworkUtil.getBundle(MessageWriter.class).getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(DBLIB_SERVICE); + + if (sref == null) { + LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")"); + } else { + dbLibService = (DbLibService) bctx.getService(sref); + if (dbLibService == null) { + LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")"); + } + } + } + + public static void saveOutgoingRequest( + String requestId, + String serviceInstanceId, + String targetUrl, + String request) { + try { + init(); + + if (!outgoingEnabled) + return; + + if (serviceInstanceId == null || serviceInstanceId.trim().length() == 0) + serviceInstanceId = "NA"; + + int seqnum = getLastSequenceNumber("OUTGOING_MESSAGE", requestId) + 1; + String now = df.format(new Date()); + + String sql = "INSERT INTO OUTGOING_MESSAGE (\n" + + " request_id, sequence_number, service_instance_id, target_url, request, start_time)\n" + + "VALUES (?, ?, ?, ?, ?, ?)"; + + ArrayList data = new ArrayList<>(); + data.add(requestId); + data.add(String.valueOf(seqnum)); + data.add(serviceInstanceId); + data.add(targetUrl); + data.add(request); + data.add(now); + + dbLibService.writeData(sql, data, null); + + } catch (Exception e) { + LOG.warn("Failed to save outgoing request for request-id: " + requestId, e); + } + } + + public static void saveOutgoingResponse(String requestId, int httpResponseCode, String response) { + try { + init(); + + if (!outgoingEnabled) + return; + + int seqnum = getLastSequenceNumber("OUTGOING_MESSAGE", requestId); + if (seqnum == 0) { + LOG.warn("Failed to save outgoing response for request-id: " + requestId + + ": Request record not found in OUTGOING_MESSAGE"); + return; + } + + String now = df.format(new Date()); + + String sql = "UPDATE OUTGOING_MESSAGE SET http_response_code = ?, response = ?,\n" + + " duration = timestampdiff(MICROSECOND, start_time, ?) / 1000\n" + + "WHERE request_id = ? AND sequence_number = ?"; + + ArrayList data = new ArrayList<>(); + data.add(String.valueOf(httpResponseCode)); + data.add(response); + data.add(now); + data.add(requestId); + data.add(String.valueOf(seqnum)); + + dbLibService.writeData(sql, data, null); + + } catch (Exception e) { + LOG.warn("Failed to save outgoing response for request-id: " + requestId, e); + } + } + + public static void saveIncomingRequest( + String requestId, + String serviceInstanceId, + String requestHost, + String request) { + try { + init(); + + if (!incomingEnabled) + return; + + if (serviceInstanceId == null || serviceInstanceId.trim().length() == 0) + serviceInstanceId = "NA"; + + int seqnum = getLastSequenceNumber("INCOMING_MESSAGE", requestId) + 1; + String now = df.format(new Date()); + + String sql = "INSERT INTO INCOMING_MESSAGE (\n" + + " request_id, sequence_number, service_instance_id, request_host, request, start_time)\n" + + "VALUES (?, ?, ?, ?, ?, ?)"; + + ArrayList data = new ArrayList<>(); + data.add(requestId); + data.add(String.valueOf(seqnum)); + data.add(serviceInstanceId); + data.add(requestHost); + data.add(request); + data.add(now); + + dbLibService.writeData(sql, data, null); + + } catch (Exception e) { + LOG.warn("Failed to save incoming request for request-id: " + requestId, e); + } + } + + public static void saveIncomingResponse(String requestId, int httpResponseCode, String response) { + try { + init(); + + if (!incomingEnabled) + return; + + int seqnum = getLastSequenceNumber("INCOMING_MESSAGE", requestId); + if (seqnum == 0) { + LOG.warn("Failed to save response for request-id: " + requestId + + ": Request record not found in INCOMING_MESSAGE"); + return; + } + + String now = df.format(new Date()); + + String sql = "UPDATE INCOMING_MESSAGE SET http_response_code = ?, response = ?,\n" + + " duration = timestampdiff(MICROSECOND, start_time, ?) / 1000\n" + + "WHERE request_id = ? AND sequence_number = ?"; + + ArrayList data = new ArrayList<>(); + data.add(String.valueOf(httpResponseCode)); + data.add(response); + data.add(now); + data.add(requestId); + data.add(String.valueOf(seqnum)); + + dbLibService.writeData(sql, data, null); + + } catch (Exception e) { + LOG.warn("Failed to save response for request-id: " + requestId, e); + } + } + + public static String getServiceInstanceId(String requestId) throws SQLException { + init(); + + String sql = "SELECT service_instance_id FROM OUTGOING_MESSAGE WHERE request_id = '" + requestId + + "' ORDER BY sequence_number DESC"; + + CachedRowSet rs = null; + try { + rs = dbLibService.getData(sql, null, null); + if (rs.next()) { + return rs.getString("service_instance_id"); + } + } finally { + if (rs != null) { + try { + rs.close(); + } catch (Exception e) { + LOG.warn("Failed to close CachedRowSet", e); + } + } + } + return null; + } + + private static int getLastSequenceNumber(String tableName, String requestId) throws SQLException { + String sql = "SELECT sequence_number FROM " + tableName + " WHERE request_id = '" + requestId + + "' ORDER BY sequence_number DESC"; + + CachedRowSet rs = null; + try { + rs = dbLibService.getData(sql, null, null); + if (rs.next()) { + return rs.getInt("sequence_number"); + } + } finally { + if (rs != null) { + try { + rs.close(); + } catch (Exception e) { + LOG.warn("Failed to close CachedRowSet", e); + } + } + } + return 0; + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java new file mode 100644 index 000000000..7d1250c03 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -0,0 +1,300 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.net.InetAddress; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +/** + * @author dt5972 + * + */ +public class MetricLogger { + + private static final Logger KARAF = LoggerFactory.getLogger(MetricLogger.class); + private static final Logger METRIC = LoggerFactory.getLogger("org.onap.ccsdk.sli.filters.metric"); + + public static final String BEGIN_TIMESTAMP = "X-ECOMP-BeginTimestamp"; + public static final String END_TIMESTAMP = "X-ECOMP-EndTimestamp"; + public static final String REQUEST_ID = "X-ECOMP-RequestID"; + public static final String SERVICE_INSTANCE_ID = "X-ECOMP-ServiceInstanceID"; + public static final String SERVICE_NAME = "X-ECOMP-ServiceName"; + public static final String PARTNER_NAME = "X-ECOMP-PartnerName"; + public static final String TARGET_ENTITY = "X-ECOMP-TargetEntity"; + public static final String TARGET_SERVICE_NAME = "X-ECOMP-TargetServiceName"; + public static final String STATUS_CODE = "X-ECOMP-StatusCode"; + public static final String RESPONSE_CODE = "X-ECOMP-ResponseCode"; + public static final String RESPONSE_DESCRIPTION = "X-ECOMP-ResponseDescription"; + public static final String INSTANCE_UUID = "X-ECOMP-InstanceUUID"; + public static final String CATEGORY_LOG_LEVEL = "X-ECOMP-CategoryLogLevel"; + public static final String SEVERITY = "X-ECOMP-Severity"; + public static final String SERVER_IP_ADDRESS = "X-ECOMP-ServerIpAddress"; + public static final String ELAPSED_TIME = "X-ECOMP-ElapsedTime"; + public static final String SERVER = "X-ECOMP-Server"; + public static final String CLIENT_IP = "X-ECOMP-ClientIp"; + public static final String CLASS_NAME = "X-ECOMP-ClassName"; + public static final String TARGET_VIRTUAL_ENTITY = "X-ECOMP-TargetVirtualEntity"; + + private long beginTimestamp; + private String lastMsg = null; + + public MetricLogger() { + beginTimestamp = System.currentTimeMillis(); + + try { + InetAddress localhost = InetAddress.getLocalHost(); + setServerIpAddress(localhost.getHostAddress()); + setServer(localhost.getCanonicalHostName()); + } catch (Exception e) { + KARAF.error("Could not get localhost", e); + } + + } + + + public String getBeginTimestamp() { + return MDC.get(BEGIN_TIMESTAMP); + } + + private void setBeginTimestamp(long beginTimestamp) { + this.beginTimestamp = beginTimestamp; + MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(beginTimestamp)); + } + + public String getEndTimestamp() { + return MDC.get(END_TIMESTAMP); + } + + private void setEndTimestamp(long endTimestamp) { + // Set MDC with formatted time stamp + MDC.put(END_TIMESTAMP, MetricLogger.asIso8601(endTimestamp)); + + // Set elapsed time + setElapsedTime(endTimestamp - beginTimestamp); + + } + + public String getRequestID() { + return MDC.get(REQUEST_ID); + } + + + public String getServiceInstanceID() { + return MDC.get(SERVICE_INSTANCE_ID); + } + + private void setServiceInstanceID(String svcInstanceId) { + MDC.put(SERVICE_INSTANCE_ID, svcInstanceId); + } + + public String getServiceName() { + return MDC.get(SERVICE_NAME); + } + + private void setServiceName(String svcName) { + MDC.put(SERVICE_NAME, svcName); + } + + public String getPartnerName() { + return MDC.get(PARTNER_NAME); + } + + private void setPartnerName(String partnerName) { + MDC.put(PARTNER_NAME, partnerName); + } + + public String getTargetEntity() { + return MDC.get(TARGET_ENTITY); + } + + private void setTargetEntity(String targetEntity) { + MDC.put(TARGET_ENTITY, targetEntity); + } + + public String getTargetServiceName() { + return MDC.get(TARGET_SERVICE_NAME); + } + + private void setTargetServiceName(String targetServiceName) { + MDC.put(TARGET_SERVICE_NAME, targetServiceName); + } + + public String getStatusCode() { + return MDC.get(STATUS_CODE); + } + + private void setStatusCode(String statusCode) { + MDC.put(STATUS_CODE, statusCode); + } + + public String getResponseCode() { + return MDC.get(RESPONSE_CODE); + } + + private void setResponseCode(String responseCode) { + MDC.put(RESPONSE_CODE, responseCode); + } + + public String getResponseDescription() { + return MDC.get(RESPONSE_DESCRIPTION); + } + + private void setResponseDescription(String responseDesc) { + MDC.put(RESPONSE_DESCRIPTION, responseDesc); + } + + public String getInstanceUUID() { + return MDC.get(INSTANCE_UUID); + } + + private void setInstanceUUID(String instanceUUID) { + MDC.put(INSTANCE_UUID, instanceUUID); + } + + public String getCategoryLogLevel() { + return MDC.get(CATEGORY_LOG_LEVEL); + } + + private void setCategoryLogLevel(String categoryLogLevel) { + MDC.put(CATEGORY_LOG_LEVEL, categoryLogLevel); + } + + public String getSeverity() { + return MDC.get(SEVERITY); + } + + private void setSeverity(String severity) { + MDC.put(SEVERITY, severity); + } + + public String getServerIpAddress() { + return MDC.get(SERVER_IP_ADDRESS); + } + + private void setServerIpAddress(String serverIpAddress) { + MDC.put(SERVER_IP_ADDRESS, serverIpAddress); + } + + public String getElapsedTime() { + return MDC.get(ELAPSED_TIME); + } + + private void setElapsedTime(long elapsedTime) { + MDC.put(ELAPSED_TIME, ""+elapsedTime); + } + + public String getServer() { + return MDC.get(SERVER); + } + + private void setServer(String server) { + MDC.put(SERVER, server); + } + + public String getClientIp() { + return MDC.get(CLIENT_IP); + } + + private void setClientIp(String clientIp) { + MDC.put(CLIENT_IP, clientIp); + } + + public String getClassName() { + return MDC.get(CLASS_NAME); + } + + private void setClassName(String className) { + MDC.put(CLASS_NAME, className); + } + + public String getTargetVirtualEntity() { + return MDC.get(TARGET_VIRTUAL_ENTITY); + } + + private void setTargetVirtualEntity(String targetVirtualEntity) { + MDC.put(TARGET_VIRTUAL_ENTITY, targetVirtualEntity); + } + + public static String asIso8601(Date date) { + TimeZone tz = TimeZone.getTimeZone("UTC"); + DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); + df.setTimeZone(tz); + return df.format(date); + } + + public static String asIso8601(long tsInMillis) { + return MetricLogger.asIso8601(new Date(tsInMillis)); + } + + public void logRequest(String svcInstanceId, String svcName, String partnerName, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) { + + setBeginTimestamp(System.currentTimeMillis()); + + if (svcInstanceId != null) { + setServiceInstanceID(svcInstanceId); + } + + if (svcName != null) { + setServiceName(svcName); + } + + if (partnerName != null) { + setPartnerName(partnerName); + } + + if (targetEntity != null) { + setTargetEntity(targetEntity); + } + + if (targetServiceName != null) { + setTargetServiceName(targetServiceName); + } + + if (targetVirtualEntity != null) { + setTargetVirtualEntity(targetVirtualEntity); + } + + this.lastMsg = msg; + + + } + + public void logResponse(String statusCode, String responseCode, String responseDescription) { + setEndTimestamp(System.currentTimeMillis()); + + setStatusCode(statusCode); + setResponseCode(responseCode); + setResponseDescription(responseDescription); + + METRIC.info(lastMsg); + + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java new file mode 100644 index 000000000..3a3dd75d3 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.util.Map; + +public interface SvcLogicAdaptor { + + public enum ConfigStatus { + SUCCESS, + ALREADY_ACTIVE, + NOT_FOUND, + NOT_READY, + FAILURE + } + + public ConfigStatus configure(String key, Map parameters, SvcLogicContext ctx); + + public ConfigStatus activate(String key, SvcLogicContext ctx); + + public ConfigStatus deactivate(String key, SvcLogicContext ctx); + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java new file mode 100644 index 000000000..47912397c --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java @@ -0,0 +1,173 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class SvcLogicAtom extends SvcLogicExpression { + + public enum AtomType { + NUMBER, + STRING, + IDENTIFIER, + CONTEXT_VAR + + } + + private AtomType atomType; + private String atom; + + + public SvcLogicAtom(String atomType, String atom) + { + this.atomType = AtomType.valueOf(atomType); + this.atom = atom; + + } + + public SvcLogicAtom(String atom) + { + + if (atom == null) + { + this.atomType = null; + this.atom = null; + } + else + { + if (atom.startsWith("$")) + { + this.atomType = AtomType.CONTEXT_VAR; + this.atom = atom.substring(1); + } + else + { + if (Character.isDigit(atom.charAt(0))) + { + this.atomType = AtomType.NUMBER; + this.atom = atom; + } + else if (atom.charAt(0) == '\'') + { + this.atomType = AtomType.STRING; + this.atom = atom.substring(1, atom.length()-1); + } + else + { + this.atomType = AtomType.IDENTIFIER; + this.atom = atom; + + } + + } + } + } + + public AtomType getAtomType() { + return atomType; + } + + public void setAtomType(String newType) + { + atomType = AtomType.valueOf(newType); + } + + public String getAtom() { + return atom; + } + + + + public void setAtomType(AtomType atomType) { + this.atomType = atomType; + } + + public void setAtom(String atom) { + this.atom = atom; + } + + + + public String toString() + { + StringBuffer sbuff = new StringBuffer(); + switch(getAtomType()) + { + case CONTEXT_VAR: + sbuff.append("$"); + case IDENTIFIER: + boolean needDot = false; + for (SvcLogicExpression term: this.getOperands()) + { + if (needDot) + { + sbuff.append("."); + } + sbuff.append(term.toString()); + needDot = true; + } + return(sbuff.toString()); + case STRING: + case NUMBER: + default: + return(atom); + } + } + + public String asParsedExpr() + { + // simplify debugging output for NUMBER type + if (atomType == AtomType.NUMBER) { + return atom; + } + + StringBuffer sbuff = new StringBuffer(); + + sbuff.append("(atom"); + sbuff.append("<"); + sbuff.append(atomType.toString()); + sbuff.append(">"); + + switch(atomType) + { + case IDENTIFIER: + case CONTEXT_VAR: + for (SvcLogicExpression term : getOperands()) + { + sbuff.append(" "); + sbuff.append(term.asParsedExpr()); + + } + break; + default: + sbuff.append(" "); + sbuff.append(atom); + } + + sbuff.append(")"); + return(sbuff.toString()); + } + + + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java new file mode 100644 index 000000000..ee2a24358 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.util.LinkedList; +import java.util.List; + +public class SvcLogicBinaryExpression extends SvcLogicExpression { + + + public enum OperatorType { + addOp("+"), + subOp("-"), + multOp("*"), + divOp("/"), + equalOp("=="), + ltOp("<"), + leOp("<="), + gtOp(">"), + geOp(">="), + neOp("!="), + andOp("and"), + orOp("or"); + + private String text; + + private OperatorType(String text) + { + this.text = text; + } + + public String getText() + { + return(text); + } + + public static OperatorType fromString(String text) + { + if (text != null) + { + for (OperatorType t : OperatorType.values()) + { + if (text.equalsIgnoreCase(t.getText())) { + + return(t); + } + } + } + return(null); + } + + public String toString() + { + return(text); + } + } + private List operators; + + public List getOperators() { + return operators; + } + + public SvcLogicBinaryExpression() + { + operators = new LinkedList(); + } + + public void addOperator(String operator) + { + operators.add(OperatorType.fromString(operator)); + } + + + public String toString() + { + + Listoperands = getOperands(); + StringBuffer sbuff = new StringBuffer(); + + sbuff.append(operands.get(0).toString()); + for (int i = 0 ; i < operators.size(); i++) + { + sbuff.append(" "); + sbuff.append(operators.get(i)); + sbuff.append(" "); + if (i + 1 < operands.size()) { + sbuff.append(operands.get(i + 1).toString()); + } else { + // expression incomplete; operand not bound yet + sbuff.append("?"); + } + } + + return(sbuff.toString()); + + } + + public String asParsedExpr() { + + List operands = getOperands(); + + if (operators.isEmpty()) { + return operands.get(0).asParsedExpr(); + } else { + StringBuffer sbuff = new StringBuffer(); + // operators in reverse order for left associativity + for (int i = operators.size() - 1; i >= 0; --i) { + sbuff.append("("); + sbuff.append(operators.get(i).getText()); + sbuff.append(" "); + } + for (int i = 0; i < operators.size() + 1; ++i) { + if (i < operands.size()) { + sbuff.append(operands.get(i).asParsedExpr()); + } else { + // expression incomplete; operand not bound yet + sbuff.append("?"); + } + if (i != 0) { + sbuff.append(")"); + } + if (i < operators.size()) { + sbuff.append(" "); + } + } + return sbuff.toString(); + } + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java new file mode 100644 index 000000000..b5892eff5 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -0,0 +1,247 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + + +public class SvcLogicContext { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicContext.class); + + private HashMap attributes; + + private DOMDataBroker domDataBroker; + + private String status = "success"; + + public SvcLogicContext() + { + this.attributes = new HashMap (); + + } + + public SvcLogicContext(Properties props) + { + this.attributes = new HashMap (); + + if (props.containsKey("SvcLogic.status")) + { + this.status = props.getProperty("SvcLogic.status"); + } + + for (Object nameObj : props.keySet()) + { + String propName = (String) nameObj; + attributes.put(propName, props.getProperty(propName)); + } + } + + + + public DOMDataBroker getDomDataBroker() { + return domDataBroker; + } + + public void setDomDataBroker(DOMDataBroker domDataBroker) { + this.domDataBroker = domDataBroker; + } + + public String getAttribute(String name) + { + if (attributes.containsKey(name)) + { + return(attributes.get(name)); + } + else + { + return(null); + } + } + + public void setAttribute(String name, String value) + { + if (value == null) { + if (attributes.containsKey(name)) { + attributes.remove(name); + } + } else { + attributes.put(name, value); + } + } + + public Set getAttributeKeySet() + { + return(attributes.keySet()); + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Properties toProperties() + { + Properties props = new Properties(); + + if (status != null) + { + props.setProperty("SvcLogic.status", status); + } + + for (String attrName : attributes.keySet()) + { + String attrVal = attributes.get(attrName); + if (attrVal == null) { + LOG.warn("attribute " + attrName + + "null - setting to empty string"); + props.setProperty(attrName, ""); + } else { + props.setProperty(attrName, attributes.get(attrName)); + } + } + + return(props); + } + + public void mergeDocument(String pfx, Document doc) { + String prefix = ""; + + if (pfx != null) { + prefix = pfx; + } + + Element root = doc.getDocumentElement(); + + mergeElement(prefix, root, null); + } + + public void mergeElement(String pfx, Element element, Map nodeMap) { + + // In XML, cannot tell the difference between containers and lists. + // So, have to treat each element as both (ugly but necessary). + // We do this by passing a nodeMap to be used to count instance of each tag, + // which will be used to set _length and to set index + + LOG.trace("mergeElement("+pfx+","+element.getTagName()+","+nodeMap+")"); + + String curTagName = element.getTagName(); + String prefix = curTagName; + + if (pfx != null) { + prefix = pfx + "." + prefix; + } + + int myIdx = 0; + + if (nodeMap != null) { + if (nodeMap.containsKey(curTagName)) { + myIdx = nodeMap.get(curTagName).intValue(); + } + + nodeMap.put(curTagName, new Integer(myIdx+1)); + this.setAttribute(prefix+"_length", ""+(myIdx+1)); + } + + NodeList children = element.getChildNodes(); + + int numChildren = children.getLength(); + + Map childMap = new HashMap(); + Map idxChildMap = new HashMap(); + + for (int i = 0 ; i < numChildren ; i++) { + Node curNode = children.item(i); + + if (curNode instanceof Text) { + Text curText = (Text) curNode; + String curTextValue = curText.getTextContent(); + LOG.trace("Setting ctx variable "+prefix+" = "+curTextValue); + this.setAttribute(prefix, curText.getTextContent()); + + + } else if (curNode instanceof Element) { + mergeElement(prefix, (Element) curNode, childMap); + if (nodeMap != null) { + + mergeElement(prefix+"["+myIdx+"]", (Element)curNode, idxChildMap); + + } + } + } + + } + + public String resolve(String ctxVarName) { + + if (ctxVarName.indexOf('[') == -1) { + // Ctx variable contains no arrays + return (this.getAttribute(ctxVarName)); + } + + // Resolve any array references + StringBuffer sbuff = new StringBuffer(); + String[] ctxVarParts = ctxVarName.split("\\["); + sbuff.append(ctxVarParts[0]); + for (int i = 1; i < ctxVarParts.length; i++) { + if (ctxVarParts[i].startsWith("$")) { + int endBracketLoc = ctxVarParts[i].indexOf("]"); + if (endBracketLoc == -1) { + // Missing end bracket ... give up parsing + LOG.warn("Variable reference " + ctxVarName + + " seems to be missing a ']'"); + return (this.getAttribute(ctxVarName)); + } + + String idxVarName = ctxVarParts[i].substring(1, endBracketLoc); + String remainder = ctxVarParts[i].substring(endBracketLoc); + + sbuff.append("["); + sbuff.append(this.getAttribute(idxVarName)); + sbuff.append(remainder); + + } else { + // Index is not a variable reference + sbuff.append("["); + sbuff.append(ctxVarParts[i]); + } + } + + return (this.getAttribute(sbuff.toString())); + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java new file mode 100644 index 000000000..ac656ffa8 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -0,0 +1,532 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.sql.Blob; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import javax.sql.rowset.CachedRowSet; + +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicDblibStore implements SvcLogicStore { + + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicDblibStore.class); + + private static final String DBLIB_SERVICE = + // "org.openecomp.sdnc.sli.resource.dblib.DBLibService"; + "org.openecomp.sdnc.sli.resource.dblib.DBResourceManager"; + + Properties props = null; + + public void init(Properties props) throws ConfigurationException { + + DbLibService dbSvc = getDbLibService(); + if(dbSvc == null) { + LOG.error("SvcLogic cannot acquire DBLIB_SERVICE"); + return; + } + try { + dbSvc.getData("select 1 from DUAL", new ArrayList(), null); + LOG.debug("SQL test was successful"); + } catch (SQLException e) { + LOG.error("Failed SQL test", e); + } + } + + public boolean hasGraph(String module, String rpc, String version, + String mode) throws SvcLogicException { + + DbLibService dbSvc = getDbLibService(); + + boolean retval = false; + CachedRowSet results = null; + String hasVersionGraphSql = "SELECT count(*) FROM SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + String hasActiveGraphSql = "SELECT count(*) FROM SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + + PreparedStatement hasGraphStmt = null; + + ArrayList args = new ArrayList(); + args.add(module); + args.add(rpc); + args.add(mode); + + try { + + if (version == null) { + results = dbSvc.getData(hasActiveGraphSql, args, null); + } else { + args.add(version); + results = dbSvc.getData(hasVersionGraphSql, args, null); + } + + if (results.next()) { + int cnt = results.getInt(1); + + if (cnt > 0) { + retval = true; + } + + } + } catch (Exception e) { + throw new ConfigurationException("SQL query failed", e); + } finally { + if (results != null) { + try { + + results.close(); + } catch (SQLException x) { + } + } + + } + + return (retval); + + } + + public SvcLogicGraph fetch(String module, String rpc, String version, + String mode) throws SvcLogicException { + + DbLibService dbSvc = getDbLibService(); + + Connection dbConn = null; + SvcLogicGraph retval = null; + ResultSet results = null; + + String fetchVersionGraphSql = "SELECT graph FROM SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + String fetchActiveGraphSql = "SELECT graph FROM SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + + + try { + dbConn = ((DBResourceManager) dbSvc).getConnection(); + PreparedStatement fetchGraphStmt; + + ArrayList args = new ArrayList(); + args.add(module); + args.add(rpc); + args.add(mode); + + if (version == null) { + fetchGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); + } else { + fetchGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); + } + + fetchGraphStmt.setString(1, module); + fetchGraphStmt.setString(2, rpc); + fetchGraphStmt.setString(3, mode); + if (version != null) { + fetchGraphStmt.setString(4,version); + } + + results = fetchGraphStmt.executeQuery(); + + if (results.next()) { + Blob graphBlob = results.getBlob("graph"); + + ObjectInputStream gStream = new ObjectInputStream( + graphBlob.getBinaryStream()); + + Object graphObj = gStream.readObject(); + gStream.close(); + + if (graphObj instanceof SvcLogicGraph) { + retval = (SvcLogicGraph) graphObj; + } else { + throw new ConfigurationException("invalid type for graph (" + + graphObj.getClass().getName()); + + } + + } else { + return (null); + } + } catch (SQLException e) { + throw new ConfigurationException("SQL query failed", e); + } catch (Exception e) { + throw new ConfigurationException("Graph processing failed", e); + } finally { + if (results != null) { + try { + results.close(); + } catch (SQLException x) { + } + } + try { + if (dbConn != null && !dbConn.isClosed()) { + dbConn.close(); + } + } catch (Throwable exc) { + // the exception not monitored + } finally { + dbConn = null; + } + + } + + return (retval); + + } + + public void store(SvcLogicGraph graph) throws SvcLogicException { + + DbLibService dbSvc = getDbLibService(); + + String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph)" + + " VALUES(?, ?, ?, ?, ?, ?)"; + + if (graph == null) { + throw new SvcLogicException("graph cannot be null"); + } + + byte[] graphBytes = null; + + ByteArrayOutputStream byteStr = null; + ObjectOutputStream goutStr = null; + + try { + byteStr = new ByteArrayOutputStream(); + goutStr = new ObjectOutputStream(byteStr); + goutStr.writeObject(graph); + + graphBytes = byteStr.toByteArray(); + + } catch (Exception e) { + throw new SvcLogicException("could not serialize graph", e); + } finally { + + if (goutStr != null) { + try { + goutStr.close(); + } catch (IOException e) { + + } + } + + if (byteStr != null) { + try { + byteStr.close(); + } catch (IOException e) { + + } + } + } + + // If object already stored in database, delete it + if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), + graph.getMode())) { + delete(graph.getModule(), graph.getRpc(), graph.getVersion(), + graph.getMode()); + } + + Connection dbConn = null; + + try { + dbConn = ((DBResourceManager) dbSvc).getConnection(); + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + PreparedStatement storeGraphStmt = dbConn + .prepareStatement(storeGraphSql); + storeGraphStmt.setString(1, graph.getModule()); + storeGraphStmt.setString(2, graph.getRpc()); + storeGraphStmt.setString(3, graph.getVersion()); + storeGraphStmt.setString(4, graph.getMode()); + storeGraphStmt.setString(5, "N"); + storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); + + storeGraphStmt.executeUpdate(); + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + } catch (Exception e) { + throw new SvcLogicException("Could not write object to database", e); + } finally { + try { + if (dbConn != null && !dbConn.isClosed()) { + dbConn.close(); + } + } catch (Throwable exc) { + // the exception not monitored + } finally { + dbConn = null; + } + + } + } + + public void delete(String module, String rpc, String version, String mode) + throws SvcLogicException { + + DbLibService dbSvc = getDbLibService(); + + String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + + ArrayList args = new ArrayList(); + + args.add(module); + args.add(rpc); + args.add(version); + args.add(mode); + + try { + dbSvc.writeData(deleteGraphSql, args, null); + } catch (Exception e) { + throw new SvcLogicException( + "Could not delete object from database", e); + } + } + + public void activate(SvcLogicGraph graph) throws SvcLogicException { + DbLibService dbSvc = getDbLibService(); + + String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; + + String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + ArrayList args = new ArrayList(); + + args.add(graph.getModule()); + args.add(graph.getRpc()); + args.add(graph.getMode()); + + try { + + dbSvc.writeData(deactivateSql, args, null); + + args.add(graph.getVersion()); + dbSvc.writeData(activateSql, args, null); + + } catch (Exception e) { + throw new SvcLogicException("Could not activate graph", e); + } + } + + @Override + public void registerNodeType(String nodeType) throws SvcLogicException { + + String registerNodeSql = "INSERT INTO NODE_TYPES (nodetype) VALUES(?)"; + + if (isValidNodeType(nodeType)) { + return; + } + + DbLibService dbSvc = getDbLibService(); + ArrayList args = new ArrayList(); + + args.add(nodeType); + + try { + dbSvc.writeData(registerNodeSql, args, null); + } catch (Exception e) { + throw new SvcLogicException("Could not add node type to database", + e); + } + + } + + @Override + public void unregisterNodeType(String nodeType) throws SvcLogicException { + + if (!isValidNodeType(nodeType)) { + return; + } + + String unregisterNodeSql = "DELETE FROM NODE_TYPES WHERE nodetype = ?"; + + DbLibService dbSvc = getDbLibService(); + ArrayList args = new ArrayList(); + + args.add(nodeType); + + try { + dbSvc.writeData(unregisterNodeSql, args, null); + } catch (Exception e) { + throw new SvcLogicException( + "Could not delete node type from database", e); + } + + } + + @Override + public boolean isValidNodeType(String nodeType) throws SvcLogicException { + + String validateNodeSql = "SELECT count(*) FROM NODE_TYPES WHERE nodetype = ?"; + + DbLibService dbSvc = getDbLibService(); + + ArrayList args = new ArrayList(); + + args.add(nodeType); + + boolean isValid = false; + + CachedRowSet results = null; + try { + results = dbSvc.getData(validateNodeSql, args, null); + if (results != null) { + if (results.next()) { + int cnt = results.getInt(1); + + if (cnt > 0) { + isValid = true; + } + } + } + } catch (Exception e) { + throw new SvcLogicException( + "Cannot select node type from database", e); + } finally { + if (results != null) { + try { + results.close(); + } catch (SQLException x) { + } + } + + } + + return (isValid); + } + + private DbLibService getDbLibService() { + + // Get DbLibService interface object. + DbLibService dblibSvc = null; + ServiceReference sref = null; + BundleContext bctx = null; + + Bundle bundle = FrameworkUtil.getBundle(SvcLogicDblibStore.class); + + if (bundle != null) { + bctx = bundle.getBundleContext(); + + if (bctx != null) { + sref = bctx.getServiceReference(DBLIB_SERVICE); + } + + if (sref == null) { + LOG.warn("Could not find service reference for DBLIB service (" + + DBLIB_SERVICE + ")"); + } else { + dblibSvc = (DbLibService) bctx.getService(sref); + if (dblibSvc == null) { + + LOG.warn("Could not find service reference for DBLIB service (" + + DBLIB_SERVICE + ")"); + } + } + } + + // initialize a stand-alone instance of dblib resource + else { + // Try to create a DbLibService object from dblib properties + if(JavaSingleton.getInstance() == null){ + Properties dblibProps = new Properties(); + + String propDir = System.getenv(SDNC_CONFIG_DIR); + if (propDir == null) { + + propDir = "/opt/sdnc/data/properties"; + } + String propPath = propDir + "/dblib.properties"; + + File propFile = new File(propPath); + + if (!propFile.exists()) { + + LOG.warn( + "Missing configuration properties file : " + + propFile); + return(null); + } + + try { + + dblibProps.load(new FileInputStream(propFile)); + } catch (Exception e) { + LOG.warn( + "Could not load properties file " + propPath, e); + return(null); + + } + + try { + dblibSvc = DBResourceManager.create(dblibProps); + JavaSingleton.setInstance(dblibSvc); + } catch (Exception e) { + LOG.warn("Caught exception trying to create DBResourceManager", e); + } + } else { + dblibSvc = JavaSingleton.getInstance(); + } + } + return (dblibSvc); + } + + + static class JavaSingleton { + /* Private constructor */ + private JavaSingleton() { + /* the body of the constructor here */ + } + + /* instance of the singleton declaration */ + private static volatile DbLibService INSTANCE ; + + /* Access point to the unique instance of the singleton */ + public static DbLibService getInstance() { + return INSTANCE; + } + + public static void setInstance(DbLibService dbresource) { + INSTANCE = dbresource; + } + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java new file mode 100644 index 000000000..198f8d577 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +public class SvcLogicException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public SvcLogicException() + { + super(); + } + + public SvcLogicException(String message) + { + super(message); + } + + public SvcLogicException(String message, Throwable t) + { + super(message, t); + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java new file mode 100644 index 000000000..0dda84697 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java @@ -0,0 +1,315 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.util.LinkedList; +import java.util.List; + +import org.antlr.v4.runtime.tree.TerminalNode; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.AddExprContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.AtomContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.CompareExprContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.ConstantContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.ExprContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.FuncExprContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.MultExprContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.ParenExprContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.RelExprContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.VariableContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.VariableLeadContext; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.VariableTermContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicExprListener extends ExprGrammarBaseListener +{ + + + + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExprListener.class); + + private SvcLogicExpression curExpr; + private SvcLogicExpression topExpr; + private LinkedList exprStack; + + public SvcLogicExprListener() + { + exprStack = new LinkedList(); + } + + public SvcLogicExpression getParsedExpr() + { + return(curExpr); + } + + private void pushOperand(SvcLogicExpression operand) + { + if (curExpr == null) + { + curExpr = operand; + } + else + { + curExpr.addOperand(operand); + } + } + + private void pushExpr(SvcLogicExpression expr) + { + LOG.trace("Pushing expression ["+expr.getClass().getName()+"]"); + if (curExpr != null) + { + exprStack.push(curExpr); + } + curExpr = expr; + } + + private void popExpr() + { + if (exprStack.isEmpty()) + { + LOG.trace("Popping last expression"); + topExpr = curExpr; + } + else + { + SvcLogicExpression lastExpr = curExpr; + curExpr = exprStack.pop(); + curExpr.addOperand(lastExpr); + LOG.trace("New curExpr is ["+curExpr.getClass().getName()+"]"); + } + + } + + @Override + public void enterAtom(AtomContext ctx) { + + String atomText = ctx.getText(); + + LOG.trace("enterAtom: text = "+atomText); + + + SvcLogicAtom newAtom = new SvcLogicAtom(atomText); + + pushExpr(newAtom); + } + + + @Override + public void enterMultExpr(MultExprContext ctx) { + LOG.trace("enterMultExpr: text = "+ctx.getText()); + + SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); + pushExpr(curBinExpr); + + List opList = ctx.MULTOP(); + + for (TerminalNode nd : opList) + { + LOG.trace("enterMultExpr: operator - "+nd.getText()); + curBinExpr.addOperator(nd.getText()); + } + + } + + @Override + public void exitMultExpr(MultExprContext ctx) { + + LOG.trace("exitMultExpr: text = "+ctx.getText()); + + popExpr(); + + } + + @Override + public void exitAtom(AtomContext ctx) { + LOG.trace("exitAtom: text = "+ctx.getText()); + popExpr(); + } + + @Override + public void enterAddExpr(AddExprContext ctx) { + LOG.trace("enterAddExpr: text = "+ctx.getText()); + List opList = ctx.ADDOP(); + + + SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); + pushExpr(curBinExpr); + + + for (TerminalNode nd : opList) + { + LOG.trace("enterAddExpr: operator - "+nd.getText()); + curBinExpr.addOperator(nd.getText()); + } + + } + + @Override + public void exitAddExpr(AddExprContext ctx) { + LOG.trace("exitAddExpr: text = "+ctx.getText()); + + popExpr(); + } + + @Override + public void enterFuncExpr(FuncExprContext ctx) { + LOG.trace("enterFuncExpr: text = "+ctx.getText()); + LOG.trace("enterFuncExpr - IDENTIFIER : "+ctx.IDENTIFIER().getText()); + + for (ExprContext expr: ctx.expr()) + { + LOG.trace("enterFuncExpr - expr = "+expr.getText()); + } + + + pushExpr(new SvcLogicFunctionCall(ctx.IDENTIFIER().getText())); + } + + @Override + public void exitFuncExpr(FuncExprContext ctx) { + LOG.trace("exitFuncExpr: text = "+ctx.getText()); + + popExpr(); + } + + @Override + public void enterParenExpr(ParenExprContext ctx) { + LOG.trace("enterParenExpr: text = "+ctx.getText()); + LOG.trace("enterParenExpr: expr = "+ctx.expr().getText()); + } + + @Override + public void exitParenExpr(ParenExprContext ctx) { + LOG.trace("exitParenExpr: text = "+ctx.getText()); + } + + @Override + public void enterRelExpr(RelExprContext ctx) { + LOG.trace("enterRelExpr: text = "+ctx.getText()); + + List opList = ctx.RELOP(); + + + SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); + pushExpr(curBinExpr); + + + for (TerminalNode nd : opList) + { + LOG.trace("enterRelExpr: operator - "+nd.getText()); + curBinExpr.addOperator(nd.getText()); + } + + } + + @Override + public void exitRelExpr(RelExprContext ctx) { + LOG.trace("exitRelExpr: text = "+ctx.getText()); + + popExpr(); + } + + @Override + public void enterCompareExpr(CompareExprContext ctx) { + LOG.trace("enterCompareExpr: text = "+ctx.getText()); + + TerminalNode nd = ctx.COMPAREOP(); + + SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); + pushExpr(curBinExpr); + + LOG.trace("enterCompareExpr: operator - "+nd.getText()); + curBinExpr.addOperator(nd.getText()); + + } + + @Override + public void exitCompareExpr(CompareExprContext ctx) { + LOG.trace("exitCompareExpr : text = "+ctx.getText()); + + popExpr(); + } + + + + @Override + public void enterConstant(ConstantContext ctx) { + LOG.trace("enterConstant: text = "+ctx.getText()); + } + + @Override + public void exitConstant(ConstantContext ctx) { + LOG.trace("exitConstant: text = "+ctx.getText()); + } + + + @Override + public void enterVariable(VariableContext ctx) { + LOG.trace("enterVariable: text = "+ctx.getText()); + + + } + + @Override + public void exitVariable(VariableContext ctx) { + LOG.debug("exitVariable: text ="+ctx.getText()); + + } + + + @Override + public void enterVariableLead(VariableLeadContext ctx) { + + LOG.debug("enterVariableLead: text ="+ctx.getText()); + + + } + + @Override + public void exitVariableLead(VariableLeadContext ctx) { + + LOG.trace("exitVariableLead: text ="+ctx.getText()); + } + + @Override + public void enterVariableTerm(VariableTermContext ctx) { + LOG.trace("enterVariableTerm: text ="+ctx.getText()); + + String name = ctx.getText(); + + int subscrStart = name.indexOf("["); + if (subscrStart > -1) + { + name = name.substring(0, subscrStart); + } + SvcLogicVariableTerm vterm = new SvcLogicVariableTerm(name); + pushExpr(vterm); + } + + @Override + public void exitVariableTerm(VariableTermContext ctx) { + LOG.trace("exitVariableTerm: text="+ctx.getText()); + popExpr(); + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java new file mode 100644 index 000000000..79979e75f --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import org.antlr.v4.runtime.BaseErrorListener; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.Recognizer; +import org.antlr.v4.runtime.misc.ParseCancellationException; + +public class SvcLogicExprParserErrorListener extends BaseErrorListener { + + private static final SvcLogicExprParserErrorListener instance = new SvcLogicExprParserErrorListener(); + + public static SvcLogicExprParserErrorListener getInstance() { + return(instance); + } + + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, + String msg, RecognitionException e) throws ParseCancellationException { + throw new ParseCancellationException(msg); + } + + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java new file mode 100644 index 000000000..72a438454 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + + +public abstract class SvcLogicExpression implements Serializable { + + private List operands = new LinkedList(); + + + public void addOperand(SvcLogicExpression expr) + { + operands.add(expr); + } + + public List getOperands() { + return operands; + } + + public int numOperands() + { + return(operands.size()); + } + + public abstract String asParsedExpr(); + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java new file mode 100644 index 000000000..18a433f64 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.antlr.v4.runtime.ANTLRInputStream; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.tree.ParseTreeWalker; +import org.onap.ccsdk.sli.core.sli.ExprGrammarParser.ExprContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class SvcLogicExpressionFactory { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExpressionFactory.class); + + + public static SvcLogicExpression parse(String exprStr) throws IOException + { + LOG.trace("parse("+exprStr+")"); + InputStream exprStream = new ByteArrayInputStream(exprStr.getBytes()); + CharStream input = new ANTLRInputStream(exprStream); + ExprGrammarLexer lexer = new ExprGrammarLexer(input); + CommonTokenStream tokens = new CommonTokenStream(lexer); + ExprGrammarParser parser = new ExprGrammarParser(tokens); + + lexer.removeErrorListeners(); + lexer.addErrorListener(SvcLogicExprParserErrorListener.getInstance()); + parser.removeErrorListeners(); + parser.addErrorListener(SvcLogicExprParserErrorListener.getInstance()); + + ExprContext expression = null; + + try { + expression = parser.expr(); + } catch (Exception e) { + String errorMsg = e.getMessage(); + + LOG.error(errorMsg); + throw new SvcLogicParserException(errorMsg); + } + + + ParseTreeWalker walker = new ParseTreeWalker(); + SvcLogicExprListener listener = new SvcLogicExprListener(); + walker.walk(listener, expression); + + + return(listener.getParsedExpr()); + } + + public static void main(String argv[]) { + + + System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug"); + + StringBuffer sbuff = new StringBuffer(); + + for (int i = 0 ; i < argv.length ; i++) + { + if (sbuff.length() > 0) + { + sbuff.append(" "); + } + sbuff.append(argv[i]); + } + + try { + SvcLogicExpressionFactory.parse(sbuff.toString()); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java new file mode 100644 index 000000000..fc899704f --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +public class SvcLogicFunctionCall extends SvcLogicExpression { + + private String functionName; + + public SvcLogicFunctionCall(String functionName) + { + this.functionName = functionName; + } + + public String getFunctionName() { + return functionName; + } + + public void setFunctionName(String functionName) { + this.functionName = functionName; + } + + public String toString() + { + StringBuffer sbuff = new StringBuffer(); + + sbuff.append(functionName); + sbuff.append("("); + boolean needComma = false; + for (SvcLogicExpression operand: getOperands()) + { + if (needComma) + { + sbuff.append(","); + } + else + { + needComma = true; + } + sbuff.append(operand.toString()); + + } + sbuff.append(")"); + return(sbuff.toString()); + } + + public String asParsedExpr() + { + StringBuffer sbuff = new StringBuffer(); + + sbuff.append("("); + sbuff.append(functionName); + for (SvcLogicExpression operand: getOperands()) + { + sbuff.append(" "); + sbuff.append(operand.asParsedExpr()); + } + sbuff.append(")"); + return(sbuff.toString()); + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java new file mode 100644 index 000000000..158d815b0 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.PrintStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class SvcLogicGraph implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private String module = null; + private String rpc = null; + private String mode = null; + private String version = null; + + private Map attributes; + private Map namedNodes; + private SvcLogicNode rootNode; + + public SvcLogicGraph() + { + attributes = new HashMap(); + namedNodes = new HashMap(); + rootNode = null; + } + + + public String getModule() { + return module; + } + + + public void setModule(String module) { + this.module = module; + } + + + public String getRpc() { + return rpc; + } + + + public void setRpc(String rpc) { + this.rpc = rpc; + } + + + + + public String getMode() { + return mode; + } + + + public void setMode(String mode) { + this.mode = mode; + } + + + public String getVersion() { + return version; + } + + + public void setVersion(String version) { + this.version = version; + } + + + public void setRootNode(SvcLogicNode rootNode) + { + this.rootNode = rootNode; + } + + public SvcLogicNode getRootNode() + { + return(rootNode); + } + + public Serializable getAttribute(String name) + { + if (attributes.containsKey(name)) + { + return(attributes.get(name)); + } + else + { + return(null); + } + + } + + public void setAttribute(String name, Serializable value) throws DuplicateValueException + { + if (attributes.containsKey(name)) + { + throw new DuplicateValueException("Duplicate attribute "+name); + } + + attributes.put(name, value); + } + + public SvcLogicNode getNamedNode(String nodeName) + { + if (namedNodes.containsKey(nodeName)) + { + return(namedNodes.get(nodeName)); + } + else + { + return(null); + } + } + + public void setNamedNode(String nodeName, SvcLogicNode node) throws DuplicateValueException + { + if (namedNodes.containsKey(nodeName)) + { + throw new DuplicateValueException("Duplicate node name "+nodeName); + } + + namedNodes.put(nodeName, node); + } + + + + public void printAsGv(PrintStream pstr) + { + pstr.println("digraph g {"); + pstr.println("START [label=\"START\\n"+module+":"+rpc+"\"];"); + + if (rootNode != null) + { + pstr.println("START -> node"+rootNode.getNodeId()+";"); + rootNode.setVisited(false, true); + rootNode.printAsGv(pstr); + } + pstr.println("}"); + } + + public void printAsXml(PrintStream pstr) + { + pstr.println(""); + pstr.println(" "); + if (rootNode != null) + { + rootNode.setVisited(false, true); + rootNode.printAsXml(pstr, 2); + } + pstr.println(" "); + pstr.println(""); + } + + @Override + public String toString() { + return "SvcLogicGraph [module=" + module + ", rpc=" + rpc + ", mode=" + mode + ", version=" + version + "]"; + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java new file mode 100644 index 000000000..eaf4c7196 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.util.Map; + +public interface SvcLogicJavaPlugin { + + /** + * A marker interface, used to indicate that a class exposes methods that can be + * called from an node. Such methods must have the signature: + * void methodName(Map, SvcLogicContext) + */ + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java new file mode 100644 index 000000000..9aa0ddfb5 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -0,0 +1,894 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.sql.Blob; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.Driver; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class SvcLogicJdbcStore implements SvcLogicStore { + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicJdbcStore.class); + + private String dbUrl = null; + private String dbName = null; + private String dbUser = null; + private String dbPasswd = null; + private String dbDriver = null; + + private Connection dbConn; + private PreparedStatement hasActiveGraphStmt = null; + private PreparedStatement hasVersionGraphStmt = null; + private PreparedStatement fetchActiveGraphStmt = null; + private PreparedStatement fetchVersionGraphStmt = null; + private PreparedStatement storeGraphStmt = null; + private PreparedStatement deleteGraphStmt = null; + + private PreparedStatement deactivateStmt = null; + private PreparedStatement activateStmt = null; + + private PreparedStatement registerNodeStmt = null; + private PreparedStatement unregisterNodeStmt = null; + private PreparedStatement validateNodeStmt = null; + + private void getConnection() throws ConfigurationException + { + + Properties jdbcProps = new Properties(); + + jdbcProps.setProperty("user", dbUser); + jdbcProps.setProperty("password", dbPasswd); + + try { + Driver dvr = new com.mysql.jdbc.Driver(); + if (dvr.acceptsURL(dbUrl)) + { + LOG.debug("Driver com.mysql.jdbc.Driver accepts "+dbUrl); + } + else + { + LOG.warn("Driver com.mysql.jdbc.Driver does not accept "+dbUrl); + } + } catch (SQLException e1) { + LOG.error("Caught exception trying to load com.mysql.jdbc.Driver", e1); + + + } + + + try + { + this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps); + } + catch (Exception e) + { + throw new ConfigurationException("failed to get database connection ["+dbUrl+"]", e); + } + + } + + private void createTable() throws ConfigurationException + { + + + DatabaseMetaData dbm = null; + + + try { + dbm = dbConn.getMetaData(); + } catch (SQLException e) { + + throw new ConfigurationException("could not get databse metadata", e); + } + + // See if table SVC_LOGIC exists. If not, create it. + try + { + + + ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null); + if (tables.next()) { + // Table exists + } + else { + + String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC (" + + "module varchar(80) NOT NULL," + + "rpc varchar(80) NOT NULL," + + "version varchar(40) NOT NULL," + + "mode varchar(5) NOT NULL," + + "active varchar(1) NOT NULL," + + "graph BLOB," + + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; + + Statement stmt = null; + ConfigurationException myExc = null; + try + { + stmt = dbConn.createStatement(); + stmt.executeUpdate(crTableCmd); + } + catch (SQLException e1) + { + myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1); + } + finally + { + if (stmt != null) + { + stmt.close(); + } + } + + if (myExc != null) + { + throw myExc; + } + } + } + catch (Exception e) + { + throw new ConfigurationException("could not create SVC_LOGIC table", e); + } + + // See if NODE_TYPES table exists and, if not, create it + + try + { + + + ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null); + if (tables.next()) { + // Table exists + } + else { + + String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES (" + + "nodetype varchar(80) NOT NULL," + + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))"; + + Statement stmt = null; + ConfigurationException myExc = null; + try + { + stmt = dbConn.createStatement(); + stmt.executeUpdate(crTableCmd); + } + catch (SQLException e1) + { + myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1); + } + finally + { + if (stmt != null) + { + stmt.close(); + } + } + + if (myExc != null) + { + throw myExc; + } + } + } + catch (Exception e) + { + throw new ConfigurationException("could not create SVC_LOGIC table", e); + } + } + + private void prepStatements() throws ConfigurationException + { + + // Prepare statements + String hasVersionGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + try + { + hasVersionGraphStmt = dbConn.prepareStatement(hasVersionGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); + + } + + String hasActiveGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + + try + { + hasActiveGraphStmt = dbConn.prepareStatement(hasActiveGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); + + } + + String fetchVersionGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + try + { + fetchVersionGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); + + } + + String fetchActiveGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" + + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + + try + { + fetchActiveGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); + + } + + String storeGraphSql = "INSERT INTO "+dbName+".SVC_LOGIC (module, rpc, version, mode, active, graph)" + + " VALUES(?, ?, ?, ?, ?, ?)"; + + try + { + storeGraphStmt = dbConn.prepareStatement(storeGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+storeGraphSql, e); + } + + String deleteGraphSql = "DELETE FROM "+dbName+".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + + try + { + deleteGraphStmt = dbConn.prepareStatement(deleteGraphSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+deleteGraphSql, e); + } + + String deactivateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; + + try + { + deactivateStmt = dbConn.prepareStatement(deactivateSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+deactivateSql, e); + } + + String activateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + + try + { + activateStmt = dbConn.prepareStatement(activateSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+activateSql, e); + } + + String registerNodeSql = "INSERT INTO "+dbName+".NODE_TYPES (nodetype) VALUES(?)"; + try + { + registerNodeStmt = dbConn.prepareStatement(registerNodeSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+registerNodeSql, e); + } + + String unregisterNodeSql = "DELETE FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; + try + { + unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+unregisterNodeSql, e); + } + + String validateNodeSql = "SELECT count(*) FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; + try + { + validateNodeStmt = dbConn.prepareStatement(validateNodeSql); + } + catch (Exception e) + { + throw new ConfigurationException("could not prepare statement "+validateNodeSql, e); + } + } + + private void initDbResources() throws ConfigurationException + { + if ((dbDriver != null) && (dbDriver.length() > 0)) + { + + try + { + Class.forName(dbDriver); + } + catch (Exception e) + { + throw new ConfigurationException("could not load driver class "+dbDriver, e); + } + } + getConnection(); + createTable(); + prepStatements(); + } + + + public void init(Properties props) throws ConfigurationException { + + + dbUrl = props.getProperty("org.openecomp.sdnc.sli.jdbc.url"); + if ((dbUrl == null) || (dbUrl.length() == 0)) + { + throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.url unset"); + } + + dbName = props.getProperty("org.openecomp.sdnc.sli.jdbc.database"); + if ((dbName == null) || (dbName.length() == 0)) + { + throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.database unset"); + } + + dbUser = props.getProperty("org.openecomp.sdnc.sli.jdbc.user"); + if ((dbUser == null) || (dbUser.length() == 0)) + { + throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.user unset"); + } + + + dbPasswd = props.getProperty("org.openecomp.sdnc.sli.jdbc.password"); + if ((dbPasswd == null) || (dbPasswd.length() == 0)) + { + throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.password unset"); + } + + dbDriver = props.getProperty("org.openecomp.sdnc.sli.jdbc.driver"); + + + initDbResources(); + + } + + private boolean isDbConnValid() + { + + boolean isValid = false; + + try + { + if (dbConn != null) + { + isValid = dbConn.isValid(1); + } + } + catch (SQLException e) + {} + + return(isValid); + } +public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { + + + + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + + + boolean retval = false; + ResultSet results = null; + + PreparedStatement hasGraphStmt = null; + if (version == null) + { + hasGraphStmt = hasActiveGraphStmt; + } + else + { + hasGraphStmt = hasVersionGraphStmt; + } + + + + try + { + hasGraphStmt.setString(1, module); + hasGraphStmt.setString(2, rpc); + hasGraphStmt.setString(3, mode); + + + if (version != null) + { + hasGraphStmt.setString(4, version); + } + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + results = hasGraphStmt.executeQuery(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + + if (results.next()) + { + int cnt = results.getInt(1); + + if (cnt > 0) + { + retval = true; + } + + } + } + catch (Exception e) + { + throw new ConfigurationException("SQL query failed", e); + } + finally + { + if (results != null) + { + try + { + + results.close(); + } + catch (SQLException x) + {} + } + + } + + + return(retval); + + + } + + public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { + + + + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + + + SvcLogicGraph retval = null; + ResultSet results = null; + + PreparedStatement fetchGraphStmt = null; + if (version == null) + { + fetchGraphStmt = fetchActiveGraphStmt; + } + else + { + fetchGraphStmt = fetchVersionGraphStmt; + } + try + { + fetchGraphStmt.setString(1, module); + fetchGraphStmt.setString(2, rpc); + fetchGraphStmt.setString(3, mode); + + + if (version != null) + { + fetchGraphStmt.setString(4, version); + } + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + results = fetchGraphStmt.executeQuery(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + + if (results.next()) + { + Blob graphBlob = results.getBlob("graph"); + + ObjectInputStream gStream = new ObjectInputStream(graphBlob.getBinaryStream()); + + Object graphObj = gStream.readObject(); + gStream.close(); + + if (graphObj instanceof SvcLogicGraph) + { + retval = (SvcLogicGraph) graphObj; + } + else + { + throw new ConfigurationException("invalid type for graph ("+graphObj.getClass().getName()); + + } + + } + else + { + return(null); + } + } + catch (Exception e) + { + throw new ConfigurationException("SQL query failed", e); + } + finally + { + if (results != null) + { + try + { + results.close(); + } + catch (SQLException x) + {} + } + + } + + + return(retval); + + + } + + public void store(SvcLogicGraph graph) throws SvcLogicException { + + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + if (graph == null) + { + throw new SvcLogicException("graph cannot be null"); + } + + byte[] graphBytes = null; + + ByteArrayOutputStream byteStr = null; + ObjectOutputStream goutStr = null; + + try + { + byteStr = new ByteArrayOutputStream(); + goutStr = new ObjectOutputStream(byteStr); + goutStr.writeObject(graph); + + graphBytes = byteStr.toByteArray(); + + } + catch (Exception e) + { + throw new SvcLogicException("could not serialize graph", e); + } + finally + { + + if (goutStr != null) + { + try { + goutStr.close(); + } catch (IOException e) { + + } + } + + if (byteStr != null) + { + try { + byteStr.close(); + } catch (IOException e) { + + } + } + } + + + // If object already stored in database, delete it + if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode())) + { + delete(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode()); + } + + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + storeGraphStmt.setString(1, graph.getModule()); + storeGraphStmt.setString(2, graph.getRpc()); + storeGraphStmt.setString(3, graph.getVersion()); + storeGraphStmt.setString(4, graph.getMode()); + storeGraphStmt.setString(5, "N"); + storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); + + storeGraphStmt.executeUpdate(); + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + } + catch (Exception e) + { + throw new SvcLogicException("Could not write object to database", e); + } + } + + public void delete(String module, String rpc, String version, String mode) throws SvcLogicException + { + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + deleteGraphStmt.setString(1, module); + deleteGraphStmt.setString(2, rpc); + deleteGraphStmt.setString(3, version); + deleteGraphStmt.setString(4, mode); + + + deleteGraphStmt.executeUpdate(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + } + catch (Exception e) + { + throw new SvcLogicException("Could not delete object from database", e); + } + } + + public void activate(SvcLogicGraph graph) throws SvcLogicException + { + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + + dbConn.setAutoCommit(false); + + // Deactivate any current active version + deactivateStmt.setString(1, graph.getModule()); + deactivateStmt.setString(2, graph.getRpc()); + deactivateStmt.setString(3, graph.getMode()); + deactivateStmt.executeUpdate(); + + // Activate this version + activateStmt.setString(1, graph.getModule()); + activateStmt.setString(2, graph.getRpc()); + activateStmt.setString(3, graph.getVersion()); + activateStmt.setString(4, graph.getMode()); + activateStmt.executeUpdate(); + + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + + } + catch (Exception e) + { + throw new SvcLogicException("Could not activate graph", e); + } + } + + @Override + public void registerNodeType(String nodeType) throws SvcLogicException { + + if (isValidNodeType(nodeType)) + { + return; + } + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + registerNodeStmt.setString(1, nodeType); + registerNodeStmt.executeUpdate(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + } + catch (Exception e) + { + throw new SvcLogicException("Could not add node type to database", e); + } + + } + + @Override + public void unregisterNodeType(String nodeType) throws SvcLogicException { + + if (!isValidNodeType(nodeType)) + { + return; + } + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + try + { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + unregisterNodeStmt.setString(1, nodeType); + unregisterNodeStmt.executeUpdate(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + } + catch (Exception e) + { + throw new SvcLogicException("Could not delete node type from database", e); + } + + } + + @Override + public boolean isValidNodeType(String nodeType) throws SvcLogicException { + + boolean isValid = false; + + if (!isDbConnValid()) + { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) + { + throw new ConfigurationException("no jdbc connection"); + } + } + + ResultSet results = null; + try + { + validateNodeStmt.setString(1, nodeType); + + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + results = validateNodeStmt.executeQuery(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + + if (results != null) + { + if (results.next()) + { + int cnt = results.getInt(1); + + if (cnt > 0) + { + isValid = true; + } + } + } + + } + catch (Exception e) + { + throw new SvcLogicException("Cannot select node type from database", e); + } + finally + { + if (results != null) + { + try + { + results.close(); + } + catch (SQLException x) + {} + } + + } + + return(isValid); + } + + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java new file mode 100644 index 000000000..3aab21f2f --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java @@ -0,0 +1,455 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.IOException; +import java.io.PrintStream; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +import org.apache.commons.lang3.StringEscapeUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.Locator; + + +public class SvcLogicNode implements Serializable { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExprListener.class); + + private static final long serialVersionUID = 2L; + + private String nodeName; + private int nodeId; + private String nodeType; + private boolean visited; + private SvcLogicGraph graph; + + + private HashMap attributes; + private HashMap outcomes; + private HashMap parameters; + + public SvcLogicNode(int nodeId, String nodeType, SvcLogicGraph graph) + { + this.nodeId = nodeId; + nodeName = ""; + this.nodeType = nodeType; + this.graph = graph; + attributes = new HashMap (); + parameters = new HashMap (); + outcomes = null; + + } + + public SvcLogicNode(int nodeId, String nodeType, String nodeName, SvcLogicGraph graph) throws DuplicateValueException + { + this.nodeId = nodeId; + this.nodeName = nodeName; + this.nodeType = nodeType; + this.graph = graph; + attributes = new HashMap (); + parameters = new HashMap (); + outcomes = null; + graph.setNamedNode(nodeName, this); + } + + + public int getNodeId() + { + return nodeId; + } + + public String getNodeName() + { + return(nodeName); + } + + public String getNodeType() + { + return(nodeType); + } + + public SvcLogicGraph getGraph() + { + return(graph); + } + + public int getNumOutcomes() + { + if (outcomes == null) + { + return(0); + } + else + { + return(outcomes.size()); + } + } + + public SvcLogicExpression getAttribute(String name) + { + if (attributes.containsKey(name)) + { + return(attributes.get(name)); + } + else + { + return(null); + } + + } + + public void setAttribute(String name, String value) throws SvcLogicException + { + setAttribute(name, new SvcLogicAtom("STRING", value)); + } + + public void setAttribute(String name, SvcLogicExpression value) throws SvcLogicException + { + if (attributes.containsKey(name)) + { + throw new DuplicateValueException("Duplicate attribute "+name); + } + + attributes.put(name, value); + } + + + public void mapParameter(String name, String value) throws SvcLogicException + { + + if (parameters.containsKey(name)) + { + throw new DuplicateValueException("Duplicate parameter "+name); + } + try + { + SvcLogicExpression parmValue; + if ((value == null) || (value.length() == 0)) + { + parmValue = new SvcLogicAtom("STRING", ""); + } + else if (value.trim().startsWith("`")) + { + int lastParen = value.lastIndexOf("`"); + String evalExpr = value.trim().substring(1, lastParen); + parmValue = SvcLogicExpressionFactory.parse(evalExpr); + + } + else + { + if (Character.isDigit(value.charAt(0))) + { + parmValue = new SvcLogicAtom("NUMBER", value); + } + else + { + parmValue = new SvcLogicAtom("STRING", value); + } + } + LOG.debug("Setting parameter "+name+" = "+value+" = "+parmValue.asParsedExpr()); + parameters.put(name, parmValue); + } + catch (IOException e) { + + LOG.error("Invalid parameter value expression ("+value+")"); + throw new SvcLogicException(e.getMessage()); + } + } + + public SvcLogicExpression getParameter(String name) + { + if (parameters.containsKey(name)) + { + return(parameters.get(name)); + } + else + { + return(null); + } + } + + public boolean isVisited() { + return visited; + } + + public void setVisited(boolean visited, boolean recursive) { + this.visited = visited; + + if (recursive) + { + Set> outcomeSet = getOutcomeSet(); + + if (outcomeSet == null) + { + return; + } + + for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) + { + Map.Entry curOutcome = iter.next(); + SvcLogicNode outNode = curOutcome.getValue(); + outNode.setVisited(visited, recursive); + } + } + } + + public void addOutcome(String outcomeValue, SvcLogicNode node) throws SvcLogicException + { + if (outcomes == null) + { + outcomes = new HashMap(); + } + + if (outcomeValue.length() == 0) { + outcomeValue = "\"\""; + } + if (outcomes.containsKey(outcomeValue)) + { + throw new DuplicateValueException("Duplicate outcome value "+outcomeValue); + } + + outcomes.put(outcomeValue, node); + } + + public Set> getOutcomeSet() + { + if (outcomes == null) + { + return null; + } + + return(outcomes.entrySet()); + + } + + public Set> getParameterSet() + { + if (parameters == null) + { + return null; + } + + return(parameters.entrySet()); + + } + + public void printAsGv(PrintStream pstr) + { + + if (visited) + { + return; + } + else + { + visited = true; + } + + StringBuffer sbuff = new StringBuffer(); + + sbuff.append("node"); + sbuff.append(nodeId); + sbuff.append(" [ shape=none, margin=0, label=<"); + sbuff.append(""); + + if (nodeName.length() > 0) + { + sbuff.append(""); + } + + Set> attrSet = attributes.entrySet(); + for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) + { + Map.Entry curAttr = iter.next(); + sbuff.append(""); + } + sbuff.append("
"); + sbuff.append(nodeId); + sbuff.append(" : "); + sbuff.append(nodeType); + sbuff.append("
AttributeValue
name"); + sbuff.append(nodeName); + sbuff.append("
"); + sbuff.append(curAttr.getKey()); + sbuff.append(""); + sbuff.append(StringEscapeUtils.escapeHtml3(curAttr.getValue().toString())); + sbuff.append("
>];"); + + pstr.println(sbuff.toString()); + + + if (outcomes != null) + { + TreeMap sortedOutcomes = new TreeMap(outcomes); + Set> outcomeSet = sortedOutcomes.entrySet(); + + for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) + { + Map.Entry curOutcome = iter.next(); + String outValue = curOutcome.getKey(); + SvcLogicNode outNode = curOutcome.getValue(); + pstr.println("node"+nodeId+" -> node"+outNode.getNodeId()+" [label=\""+outValue+"\"];"); + outNode.printAsGv(pstr); + } + } + } + + public void printAsXml(PrintStream pstr, int indentLvl) + { + if (visited) + { + return; + } + // Print node tag + for (int i = 0 ; i < indentLvl ; i++) + { + pstr.print(" "); + } + pstr.print("<"); + pstr.print(this.getNodeType()); + + Set> attrSet = attributes.entrySet(); + for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) + { + Map.Entry curAttr = iter.next(); + pstr.print(" "); + pstr.print(curAttr.getKey()); + pstr.print("='`"); + pstr.print(curAttr.getValue()); + pstr.print("'`"); + } + + if (((parameters == null) || (parameters.isEmpty())) && + ((outcomes == null) || outcomes.isEmpty())) + { + pstr.print("/>\n"); + pstr.flush(); + return; + } + else + { + pstr.print(">\n"); + } + + // Print parameters (if any) + if (parameters != null) + { + Set> paramSet = parameters.entrySet(); + for (Iterator> iter = paramSet.iterator() ; iter.hasNext();) + { + for (int i = 0 ; i < indentLvl+1 ; i++) + { + pstr.print(" "); + } + pstr.print(" curAttr = iter.next(); + pstr.print(" name='"); + pstr.print(curAttr.getKey()); + pstr.print("' value='`"); + pstr.print(curAttr.getValue().toString()); + pstr.print("`'/>\n"); + } + } + + // Print outcomes (if any) + if (outcomes != null) + { + Set> outcomeSet = outcomes.entrySet(); + for (Iterator> iter = outcomeSet.iterator() ; iter.hasNext();) + { + for (int i = 0 ; i < indentLvl+1 ; i++) + { + pstr.print(" "); + } + pstr.print(" curAttr = iter.next(); + pstr.print(" value='"); + pstr.print(curAttr.getKey()); + pstr.print("'>\n"); + SvcLogicNode outNode = curAttr.getValue(); + outNode.printAsXml(pstr, indentLvl+2); + for (int i = 0 ; i < indentLvl+1 ; i++) + { + pstr.print(" "); + } + pstr.print("\n"); + } + } + + // Print node end tag + for (int i = 0 ; i < indentLvl ; i++) + { + pstr.print(" "); + } + pstr.print("\n"); + pstr.flush(); + + } + + + public SvcLogicNode getOutcomeValue(String value) + { + + if (value.length() == 0) { + value = "\"\""; + } + if (outcomes == null) + { + return(null); + } + + if (outcomes.containsKey(value)) + { + return(outcomes.get(value)); + } + else + { + StringBuffer keyBuffer = new StringBuffer(); + keyBuffer.append("{"); + for (String key : outcomes.keySet()) { + keyBuffer.append(" ("+key+")"); + } + keyBuffer.append("}"); + LOG.info("Outcome (" + value + ") not found, keys are " + keyBuffer.toString()); + + if (outcomes.containsKey("Other")) + { + return(outcomes.get("Other")); + } + else + { + return(null); + } + } + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java new file mode 100644 index 000000000..9ba502666 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -0,0 +1,597 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; +import java.util.LinkedList; + +import javax.xml.XMLConstants; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.Attributes; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * @author dt5972 + * + */ +public class SvcLogicParser { + + SvcLogicStore store = null; + static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; + static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; + static final String JAXP_DYNAMIC_VALIDATION = "http://apache.org/xml/features/validation/dynamic"; + static final String JAXP_SCHEMA_VALIDATION = "http://apache.org/xml/features/validation/schema"; + + private static final String LOAD_MESSAGE = "Getting SvcLogicGraph from database - "; + private static final String LOAD_ERROR_MESSAGE = "SvcLogicGraph not found - "; + private static final String ACTIVATION_ERROR_MESSAGE = "Could not activate SvcLogicGraph - "; + private static final String PRINT_ERROR_MESSAGE = "Could not print SvcLogicGraph - "; + private static final String SVC_LOGIC_STORE_ERROR = "Could not get service logic store"; + + private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicParser.class); + private static final String SLI_VALIDATING_PARSER = "org.openecomp.sdnc.sli.parser.validate"; + private static final String SVCLOGIC_XSD = "/svclogic.xsd"; + + private class SvcLogicHandler extends DefaultHandler { + private Locator locator = null; + private String module = null; + private String version = null; + private LinkedList graphs = null; + private SvcLogicGraph curGraph = null; + private SvcLogicNode curNode = null; + private LinkedList nodeStack = null; + private int curNodeId = 0; + private String outcomeValue = null; + private LinkedList outcomeStack = null; + private SvcLogicStore svcLogicStore = null; + + public SvcLogicHandler(LinkedList graphs, SvcLogicStore store) { + this.graphs = graphs; + this.curNode = null; + this.nodeStack = new LinkedList<>(); + this.outcomeStack = new LinkedList<>(); + this.curNodeId = 1; + this.outcomeValue = null; + this.svcLogicStore = store; + + } + + @Override + public void setDocumentLocator(Locator locator) { + this.locator = locator; + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + + // Handle service-logic (graph) tag + if ("service-logic".equalsIgnoreCase(qName)) { + + module = attributes.getValue("module"); + if (module == null || module.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'module' attribute from service-logic tag"); + } + + version = attributes.getValue("version"); + if (version == null || version.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'version' attribute from service-logic tag"); + } + + return; + } + + if ("method".equalsIgnoreCase(qName)) { + if (curGraph != null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot nest module tags"); + } + curGraph = new SvcLogicGraph(); + curGraph.setModule(module); + curGraph.setVersion(version); + this.curNodeId = 1; + + String attrValue = attributes.getValue("rpc"); + if (attrValue == null || attrValue.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'rpc' attribute for method tag"); + } + curGraph.setRpc(attrValue); + + attrValue = attributes.getValue("mode"); + if (attrValue == null || attrValue.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'mode' attribute for method tag"); + } + curGraph.setMode(attrValue); + + return; + + } + + // Handle outcome (edge) tag + if ("outcome".equalsIgnoreCase(qName)) { + String refValue = attributes.getValue("ref"); + + if (refValue != null) { + SvcLogicNode refNode = curGraph.getNamedNode(refValue); + + if (refNode != null) { + try { + curNode.addOutcome(attributes.getValue("value"), refNode); + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot add outcome", e); + } + } else { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "ref to unknown node " + refValue); + } + return; + } + + if (outcomeValue != null) { + outcomeStack.push(outcomeValue); + } + outcomeValue = attributes.getValue("value"); + + return; + } + + // Handle parameter tag + if ("parameter".equalsIgnoreCase(qName)) { + String parmName = attributes.getValue("name"); + String parmValue = attributes.getValue("value"); + + if (parmName != null && parmName.length() > 0 && parmValue != null) { + try { + + curNode.mapParameter(parmName, parmValue); + } catch (Exception e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + " cannot set parameter " + parmName + " to " + parmValue + " [" + e.getMessage() + "]"); + } + } + + return; + } + + // Handle node tags + + String nodeName = attributes.getValue("name"); + SvcLogicNode thisNode = null; + + try { + if (!svcLogicStore.isValidNodeType(qName)) { + throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Unknown tag " + qName); + } + } catch (Exception e) { + throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot validate node type " + qName); + } + + try { + if (nodeName != null && nodeName.length() > 0) { + thisNode = new SvcLogicNode(curNodeId++, qName, nodeName, curGraph); + } else { + thisNode = new SvcLogicNode(curNodeId++, qName, curGraph); + } + + if (curGraph.getRootNode() == null) { + curGraph.setRootNode(thisNode); + } + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); + + } + + int numAttributes = attributes.getLength(); + + for (int i = 0; i < numAttributes; i++) { + String attrName = attributes.getQName(i); + if (!"name".equalsIgnoreCase(attrName)) { + try { + + String attrValueStr = attributes.getValue(i); + SvcLogicExpression attrValue = null; + if (attrValueStr.trim().startsWith("`")) { + int lastParen = attrValueStr.lastIndexOf("`"); + String evalExpr = attrValueStr.trim().substring(1, lastParen); + attrValue = SvcLogicExpressionFactory.parse(evalExpr); + + } else { + if (Character.isDigit(attrValueStr.charAt(0))) { + attrValue = new SvcLogicAtom("NUMBER", attrValueStr); + } else { + attrValue = new SvcLogicAtom("STRING", attrValueStr); + } + } + thisNode.setAttribute(attrName, attrValue); + } catch (Exception e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot set attribute " + attrName, e); + } + } + } + + if (curNode != null) { + try { + if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) || "while".equalsIgnoreCase(curNode.getNodeType())) { + curNode.addOutcome("" + (curNode.getNumOutcomes() + 1), thisNode); + } else { + if (outcomeValue == null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType()); + } + curNode.addOutcome(outcomeValue, thisNode); + } + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); + } + nodeStack.push(curNode); + } + curNode = thisNode; + + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + + // Handle close of service-logic tag + if ("service-logic".equalsIgnoreCase(qName)) { + // Nothing more to do + return; + } + + // Handle close of method tag + if ("method".equalsIgnoreCase(qName)) { + graphs.add(curGraph); + curGraph = null; + return; + } + + // Handle close of outcome tag + if ("outcome".equalsIgnoreCase(qName)) { + // Finished this outcome - pop the outcome stack + if (outcomeStack.isEmpty()) { + outcomeValue = null; + } else { + outcomeValue = outcomeStack.pop(); + } + return; + } + + // Handle close of parameter tag - do nothing + if ("parameter".equalsIgnoreCase(qName)) { + return; + } + + // Handle close of a node tag + if (nodeStack.isEmpty()) { + curNode = null; + } else { + curNode = nodeStack.pop(); + } + } + + @Override + public void error(SAXParseException arg0) throws SAXException { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + arg0.getMessage()); + } + + } + + public SvcLogicParser(SvcLogicStore store) { + this.store = store; + } + + public SvcLogicParser(String propFile) { + + try { + this.store = SvcLogicStoreFactory.getSvcLogicStore(propFile); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + + } + + } + + public SvcLogicParser(InputStream propStr) { + + try { + this.store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + + } + + } + + public LinkedList parse(String fileName) throws SvcLogicException { + LinkedList graphs = null; + + URL xsdUrl = null; + Schema schema = null; + String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true"); + + if (validateSchema != null || validateSchema.equalsIgnoreCase("true")) { + xsdUrl = getClass().getResource(SVCLOGIC_XSD); + + } + + if (xsdUrl != null) { + try { + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + schema = schemaFactory.newSchema(xsdUrl); + } catch (Exception e) { + LOGGER.warn("Could not validate using schema " + xsdUrl.getPath(), e); + } + } else { + LOGGER.warn("Could not find resource " + SVCLOGIC_XSD); + } + + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + + if (schema != null) { + factory.setNamespaceAware(true); + factory.setSchema(schema); + } + SAXParser saxParser = factory.newSAXParser(); + + if (saxParser.isValidating()) { + LOGGER.info("Validating against schema " + xsdUrl.getPath()); + } + graphs = new LinkedList<>(); + + saxParser.parse(fileName, new SvcLogicHandler(graphs, store)); + + } catch (Exception e) { + String msg = e.getMessage(); + if (msg != null) { + LOGGER.error(msg); + throw new SvcLogicException("Compiler error: " + fileName + " @ " + msg); + } else { + LOGGER.info("Caught exception parsing " + fileName, e); + throw new SvcLogicException("Compiler error: " + fileName, e); + } + } + + return graphs; + } + + public static void main(String argv[]) { + + if (argv.length == 0) { + SvcLogicParser.usage(); + } + + if ("load".equalsIgnoreCase(argv[0])) { + if (argv.length == 3) { + String xmlfile = argv[1]; + String propfile = argv[2]; + + SvcLogicStore store = SvcLogicParser.getStore(propfile); + try { + SvcLogicParser.load(xmlfile, store); + } catch (Exception e) { + LOGGER.error(e.getMessage(), e); + } + } else { + SvcLogicParser.usage(); + } + } else if ("print".equalsIgnoreCase(argv[0])) { + String version = null; + String propfile = null; + + switch (argv.length) { + case 6: + version = argv[4]; + propfile = argv[5]; + case 5: + if (propfile == null) { + propfile = argv[4]; + } + SvcLogicStore store = SvcLogicParser.getStore(propfile); + SvcLogicParser.print(argv[1], argv[2], argv[3], version, store); + break; + default: + SvcLogicParser.usage(); + } + } else if ("get-source".equalsIgnoreCase(argv[0])) { + + switch (argv.length) { + case 6: + SvcLogicStore store = SvcLogicParser.getStore(argv[5]); + SvcLogicParser.getSource(argv[1], argv[2], argv[3], argv[4], store); + break; + default: + SvcLogicParser.usage(); + } + } else if ("activate".equalsIgnoreCase(argv[0])) { + if (argv.length == 6) { + SvcLogicStore store = SvcLogicParser.getStore(argv[5]); + SvcLogicParser.activate(argv[1], argv[2], argv[3], argv[4], store); + } else { + SvcLogicParser.usage(); + } + } else if ("validate".equalsIgnoreCase(argv[0])) { + if (argv.length == 3) { + String xmlfile = argv[1]; + String propfile = argv[2]; + + System.setProperty(SLI_VALIDATING_PARSER, "true"); + SvcLogicStore store = SvcLogicParser.getStore(propfile); + try { + SvcLogicParser.validate(xmlfile, store); + } catch (Exception e) { + LOGGER.error(e.getMessage(), e); + } + } else { + SvcLogicParser.usage(); + } + } + + System.exit(0); + } + + private static SvcLogicStore getStore(String propfile) { + + SvcLogicStore store = null; + + try { + store = SvcLogicStoreFactory.getSvcLogicStore(propfile); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + System.exit(1); + } + + return store; + + } + + public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException { + File xmlFile = new File(xmlfile); + if (!xmlFile.canRead()) { + throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); + } + + SvcLogicParser parser = new SvcLogicParser(store); + LinkedList graphs = null; + try { + graphs = parser.parse(xmlfile); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + if (graphs == null) { + throw new SvcLogicException("Could not parse " + xmlfile); + } + + for (SvcLogicGraph graph : graphs) { + + String module = graph.getModule(); + String rpc = graph.getRpc(); + String version = graph.getVersion(); + String mode = graph.getMode(); + try { + LOGGER.info("Saving SvcLogicGraph to database (module:" + module + ",rpc:" + rpc + ",version:" + version + ",mode:" + mode + ")"); + store.store(graph); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + } + + } + + public static void validate(String xmlfile, SvcLogicStore store) throws SvcLogicException { + File xmlFile = new File(xmlfile); + if (!xmlFile.canRead()) { + throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); + } + + SvcLogicParser parser = new SvcLogicParser(store); + LinkedList graphs = null; + try { + LOGGER.info("Validating " + xmlfile); + graphs = parser.parse(xmlfile); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + if (graphs == null) { + throw new SvcLogicException("Could not parse " + xmlfile); + } else { + LOGGER.info("Compilation successful for " + xmlfile); + } + + } + + private static void print(String module, String rpc, String mode, String version, SvcLogicStore store) { + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + + try { + LOGGER.info(LOAD_MESSAGE + details); + + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE + details); + System.exit(1); + } + graph.printAsGv(System.out); + } catch (Exception e) { + LOGGER.error(PRINT_ERROR_MESSAGE + details, e); + System.exit(1); + } + + } + + private static void getSource(String module, String rpc, String mode, String version, SvcLogicStore store) { + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + + try { + LOGGER.info(LOAD_MESSAGE + details); + + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE + details); + System.exit(1); + } + graph.printAsXml(System.out); + } catch (Exception e) { + LOGGER.error(PRINT_ERROR_MESSAGE + details, e); + System.exit(1); + } + + } + + private static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) { + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + + try { + LOGGER.info(LOAD_MESSAGE + details); + + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE + details); + System.exit(1); + } + store.activate(graph); + } catch (Exception e) { + LOGGER.error(ACTIVATION_ERROR_MESSAGE + details, e); + System.exit(1); + } + + } + + private static void usage() { + System.err.println("Usage: SvcLogicParser load "); + System.err.println(" OR SvcLogicParser print [] "); + System.err.println(" OR SvcLogicParser get-source "); + System.err.println(" OR SvcLogicParser activate "); + System.exit(1); + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java new file mode 100644 index 000000000..a2d2ac4c4 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.IOException; + +public class SvcLogicParserException extends IOException { + + public SvcLogicParserException() { + super(); + } + + public SvcLogicParserException(String msg) { + super(msg); + } + + public SvcLogicParserException(Throwable t) { + super(t); + } + + public SvcLogicParserException(String msg, Throwable t) { + super(msg, t); + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java new file mode 100644 index 000000000..1c85394b2 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.util.Map; + +public interface SvcLogicRecorder { + + void record(Map parmMap) throws SvcLogicException; + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java new file mode 100644 index 000000000..10d31f56e --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.sql.SQLException; +import java.util.Map; + +public interface SvcLogicResource { + + public enum QueryStatus { + SUCCESS, + NOT_FOUND, + FAILURE + } + + public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, String orderBy, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map parms, String prefix, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) throws SvcLogicException; + + public QueryStatus update(String resource, String key, Map parms, String prefix, SvcLogicContext ctx) throws SvcLogicException; + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java new file mode 100644 index 000000000..6d2b99c57 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.util.Properties; + +public interface SvcLogicStore { + + public void init(Properties props) throws SvcLogicException; + public void registerNodeType(String nodeType) throws SvcLogicException; + public void unregisterNodeType(String nodeType) throws SvcLogicException; + public boolean isValidNodeType(String nodeType) throws SvcLogicException; + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; + public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException; + public void store(SvcLogicGraph graph) throws SvcLogicException; + public void delete(String module, String rpc, String version, String mode) throws SvcLogicException; + public void activate(SvcLogicGraph graph) throws SvcLogicException; +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java new file mode 100644 index 000000000..38b5b69d6 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicStoreFactory { + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicStoreFactory.class); + + public static SvcLogicStore getSvcLogicStore(String propfile) + throws SvcLogicException { + File propFile = new File(propfile); + if (!propFile.canRead()) { + throw new ConfigurationException("Cannot read property file " + + propfile); + + } + + try { + return (getSvcLogicStore(new FileInputStream(propFile))); + } catch (Exception e) { + throw new ConfigurationException( + "Could load service store from properties file " + propfile, + e); + } + + } + + public static SvcLogicStore getSvcLogicStore(InputStream inStr) throws SvcLogicException + { + Properties props = new Properties(); + + try { + props.load(inStr); + } catch (Exception e) { + throw new ConfigurationException("Could not get load properties from input stream", e); + } + + return(getSvcLogicStore(props)); + } + + public static SvcLogicStore getSvcLogicStore(Properties props) + throws SvcLogicException { + String storeType = props.getProperty("org.openecomp.sdnc.sli.dbtype"); + if ((storeType == null) || (storeType.length() == 0)) { + throw new ConfigurationException( + "property org.openecomp.sdnc.sli.dbtype unset"); + + } + + SvcLogicStore retval = null; + LOG.debug(String.format("Using org.openecomp.sdnc.sli.dbtype=%s", storeType)); + + if ("jdbc".equalsIgnoreCase(storeType)) { + retval = new SvcLogicJdbcStore(); + + } else if ("dblib".equalsIgnoreCase(storeType)) { + retval = new SvcLogicDblibStore(); + } else { + throw new ConfigurationException("unsupported dbtype (" + storeType + + ")"); + + } + + + retval.init(props); + return (retval); + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java new file mode 100644 index 000000000..ac642a2d9 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +public class SvcLogicVariableTerm extends SvcLogicExpression { + + private String name = null; + + public String getName() { + return name; + } + + + public SvcLogicVariableTerm(String identifier) + { + this.name = identifier; + } + + public SvcLogicExpression getSubscript() + { + if (numOperands() > 0) + { + return(getOperands().get(0)); + } + else + { + return(null); + } + } + + + public String toString() + { + String retval = ""; + + if (numOperands() > 0) + { + retval = name + "[" + getSubscript().toString() + "]"; + } + else + { + retval = name; + } + return(retval); + } + + @Override + public String asParsedExpr() { + if (numOperands() == 0) { + return("(variable-term "+name+")"); + } + else + { + return("(variable-term "+name+" "+getSubscript().asParsedExpr()+")"); + } + } + +} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java deleted file mode 100644 index 3e355baad..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/BreakNodeException.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -public class BreakNodeException extends SvcLogicException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public BreakNodeException() - { - super(); - } - - public BreakNodeException(String message) - { - super(message); - } - - public BreakNodeException(String message, Throwable t) - { - super(message, t); - } - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java deleted file mode 100644 index fa1308f0e..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/ConfigurationException.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -public class ConfigurationException extends SvcLogicException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public ConfigurationException() - { - super(); - } - - public ConfigurationException(String msg) - { - super(msg); - } - - public ConfigurationException(String msg, Throwable t) - { - super(msg, t); - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java deleted file mode 100644 index beb22b0b8..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/DuplicateValueException.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -public class DuplicateValueException extends SvcLogicException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public DuplicateValueException() - { - super(); - } - - public DuplicateValueException(String message) - { - super(message); - } - - public DuplicateValueException(String message, Throwable t) - { - super(message, t); - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java deleted file mode 100644 index 5e5b621b0..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/MessageWriter.java +++ /dev/null @@ -1,302 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.File; -import java.io.FileInputStream; -import java.sql.SQLException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.Properties; - -import javax.sql.rowset.CachedRowSet; - -import org.openecomp.sdnc.sli.resource.dblib.DbLibService; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class MessageWriter { - - private static final Logger LOG = LoggerFactory.getLogger(MessageWriter.class); - - private static final String DBLIB_SERVICE = "org.openecomp.sdnc.sli.resource.dblib.DBResourceManager"; - private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - - private static final String INCOMING_PROPERTY_NAME = "org.openecomp.sdnc.sli.MessageWriter.writeIncomingRequests"; - private static final String OUTGOING_PROPERTY_NAME = "org.openecomp.sdnc.sli.MessageWriter.writeOutgoingRequests"; - - private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - - private static DbLibService dbLibService = null; - - private static boolean incomingEnabled = false; - private static boolean outgoingEnabled = false; - - private static boolean initialized = false; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private static void init() { - if (initialized) - return; - - initialized = true; - - // Read properties - Properties props = new Properties(); - String propPath = System.getenv(SVCLOGIC_PROP_VAR); - - if (propPath == null) { - String propDir = System.getenv(SDNC_CONFIG_DIR); - if (propDir == null) { - propDir = "/opt/sdnc/data/properties"; - } - propPath = propDir + "/svclogic.properties"; - LOG.warn("Environment variable " + SVCLOGIC_PROP_VAR + " unset - defaulting to " + propPath); - } - - File propFile = new File(propPath); - - if (!propFile.exists()) { - LOG.warn("Property file does not exist: " + propPath); - } - - try { - props.load(new FileInputStream(propFile)); - } catch (Exception e) { - LOG.warn("Error loading property file: " + propPath, e); - } - - incomingEnabled = Boolean.valueOf(props.getProperty(INCOMING_PROPERTY_NAME, "false")); - outgoingEnabled = Boolean.valueOf(props.getProperty(OUTGOING_PROPERTY_NAME, "false")); - - LOG.info(INCOMING_PROPERTY_NAME + ": " + incomingEnabled); - LOG.info(OUTGOING_PROPERTY_NAME + ": " + outgoingEnabled); - - if (dbLibService != null) - return; - - BundleContext bctx = FrameworkUtil.getBundle(MessageWriter.class).getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(DBLIB_SERVICE); - - if (sref == null) { - LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")"); - } else { - dbLibService = (DbLibService) bctx.getService(sref); - if (dbLibService == null) { - LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")"); - } - } - } - - public static void saveOutgoingRequest( - String requestId, - String serviceInstanceId, - String targetUrl, - String request) { - try { - init(); - - if (!outgoingEnabled) - return; - - if (serviceInstanceId == null || serviceInstanceId.trim().length() == 0) - serviceInstanceId = "NA"; - - int seqnum = getLastSequenceNumber("OUTGOING_MESSAGE", requestId) + 1; - String now = df.format(new Date()); - - String sql = "INSERT INTO OUTGOING_MESSAGE (\n" + - " request_id, sequence_number, service_instance_id, target_url, request, start_time)\n" + - "VALUES (?, ?, ?, ?, ?, ?)"; - - ArrayList data = new ArrayList<>(); - data.add(requestId); - data.add(String.valueOf(seqnum)); - data.add(serviceInstanceId); - data.add(targetUrl); - data.add(request); - data.add(now); - - dbLibService.writeData(sql, data, null); - - } catch (Exception e) { - LOG.warn("Failed to save outgoing request for request-id: " + requestId, e); - } - } - - public static void saveOutgoingResponse(String requestId, int httpResponseCode, String response) { - try { - init(); - - if (!outgoingEnabled) - return; - - int seqnum = getLastSequenceNumber("OUTGOING_MESSAGE", requestId); - if (seqnum == 0) { - LOG.warn("Failed to save outgoing response for request-id: " + requestId + - ": Request record not found in OUTGOING_MESSAGE"); - return; - } - - String now = df.format(new Date()); - - String sql = "UPDATE OUTGOING_MESSAGE SET http_response_code = ?, response = ?,\n" + - " duration = timestampdiff(MICROSECOND, start_time, ?) / 1000\n" + - "WHERE request_id = ? AND sequence_number = ?"; - - ArrayList data = new ArrayList<>(); - data.add(String.valueOf(httpResponseCode)); - data.add(response); - data.add(now); - data.add(requestId); - data.add(String.valueOf(seqnum)); - - dbLibService.writeData(sql, data, null); - - } catch (Exception e) { - LOG.warn("Failed to save outgoing response for request-id: " + requestId, e); - } - } - - public static void saveIncomingRequest( - String requestId, - String serviceInstanceId, - String requestHost, - String request) { - try { - init(); - - if (!incomingEnabled) - return; - - if (serviceInstanceId == null || serviceInstanceId.trim().length() == 0) - serviceInstanceId = "NA"; - - int seqnum = getLastSequenceNumber("INCOMING_MESSAGE", requestId) + 1; - String now = df.format(new Date()); - - String sql = "INSERT INTO INCOMING_MESSAGE (\n" + - " request_id, sequence_number, service_instance_id, request_host, request, start_time)\n" + - "VALUES (?, ?, ?, ?, ?, ?)"; - - ArrayList data = new ArrayList<>(); - data.add(requestId); - data.add(String.valueOf(seqnum)); - data.add(serviceInstanceId); - data.add(requestHost); - data.add(request); - data.add(now); - - dbLibService.writeData(sql, data, null); - - } catch (Exception e) { - LOG.warn("Failed to save incoming request for request-id: " + requestId, e); - } - } - - public static void saveIncomingResponse(String requestId, int httpResponseCode, String response) { - try { - init(); - - if (!incomingEnabled) - return; - - int seqnum = getLastSequenceNumber("INCOMING_MESSAGE", requestId); - if (seqnum == 0) { - LOG.warn("Failed to save response for request-id: " + requestId + - ": Request record not found in INCOMING_MESSAGE"); - return; - } - - String now = df.format(new Date()); - - String sql = "UPDATE INCOMING_MESSAGE SET http_response_code = ?, response = ?,\n" + - " duration = timestampdiff(MICROSECOND, start_time, ?) / 1000\n" + - "WHERE request_id = ? AND sequence_number = ?"; - - ArrayList data = new ArrayList<>(); - data.add(String.valueOf(httpResponseCode)); - data.add(response); - data.add(now); - data.add(requestId); - data.add(String.valueOf(seqnum)); - - dbLibService.writeData(sql, data, null); - - } catch (Exception e) { - LOG.warn("Failed to save response for request-id: " + requestId, e); - } - } - - public static String getServiceInstanceId(String requestId) throws SQLException { - init(); - - String sql = "SELECT service_instance_id FROM OUTGOING_MESSAGE WHERE request_id = '" + requestId + - "' ORDER BY sequence_number DESC"; - - CachedRowSet rs = null; - try { - rs = dbLibService.getData(sql, null, null); - if (rs.next()) { - return rs.getString("service_instance_id"); - } - } finally { - if (rs != null) { - try { - rs.close(); - } catch (Exception e) { - LOG.warn("Failed to close CachedRowSet", e); - } - } - } - return null; - } - - private static int getLastSequenceNumber(String tableName, String requestId) throws SQLException { - String sql = "SELECT sequence_number FROM " + tableName + " WHERE request_id = '" + requestId + - "' ORDER BY sequence_number DESC"; - - CachedRowSet rs = null; - try { - rs = dbLibService.getData(sql, null, null); - if (rs.next()) { - return rs.getInt("sequence_number"); - } - } finally { - if (rs != null) { - try { - rs.close(); - } catch (Exception e) { - LOG.warn("Failed to close CachedRowSet", e); - } - } - } - return 0; - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java deleted file mode 100644 index 14b1f008b..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/MetricLogger.java +++ /dev/null @@ -1,301 +0,0 @@ -/*- - * ============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========================================================= - */ - -/** - * - */ -package org.openecomp.sdnc.sli; - -import java.net.InetAddress; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -/** - * @author dt5972 - * - */ -public class MetricLogger { - - private static final Logger KARAF = LoggerFactory.getLogger(MetricLogger.class); - private static final Logger METRIC = LoggerFactory.getLogger("org.openecomp.sdnc.filters.metric"); - - public static final String BEGIN_TIMESTAMP = "X-ECOMP-BeginTimestamp"; - public static final String END_TIMESTAMP = "X-ECOMP-EndTimestamp"; - public static final String REQUEST_ID = "X-ECOMP-RequestID"; - public static final String SERVICE_INSTANCE_ID = "X-ECOMP-ServiceInstanceID"; - public static final String SERVICE_NAME = "X-ECOMP-ServiceName"; - public static final String PARTNER_NAME = "X-ECOMP-PartnerName"; - public static final String TARGET_ENTITY = "X-ECOMP-TargetEntity"; - public static final String TARGET_SERVICE_NAME = "X-ECOMP-TargetServiceName"; - public static final String STATUS_CODE = "X-ECOMP-StatusCode"; - public static final String RESPONSE_CODE = "X-ECOMP-ResponseCode"; - public static final String RESPONSE_DESCRIPTION = "X-ECOMP-ResponseDescription"; - public static final String INSTANCE_UUID = "X-ECOMP-InstanceUUID"; - public static final String CATEGORY_LOG_LEVEL = "X-ECOMP-CategoryLogLevel"; - public static final String SEVERITY = "X-ECOMP-Severity"; - public static final String SERVER_IP_ADDRESS = "X-ECOMP-ServerIpAddress"; - public static final String ELAPSED_TIME = "X-ECOMP-ElapsedTime"; - public static final String SERVER = "X-ECOMP-Server"; - public static final String CLIENT_IP = "X-ECOMP-ClientIp"; - public static final String CLASS_NAME = "X-ECOMP-ClassName"; - public static final String TARGET_VIRTUAL_ENTITY = "X-ECOMP-TargetVirtualEntity"; - - private long beginTimestamp; - private String lastMsg = null; - - public MetricLogger() { - beginTimestamp = System.currentTimeMillis(); - - try { - InetAddress localhost = InetAddress.getLocalHost(); - setServerIpAddress(localhost.getHostAddress()); - setServer(localhost.getCanonicalHostName()); - } catch (Exception e) { - KARAF.error("Could not get localhost", e); - } - - } - - - public String getBeginTimestamp() { - return MDC.get(BEGIN_TIMESTAMP); - } - - private void setBeginTimestamp(long beginTimestamp) { - this.beginTimestamp = beginTimestamp; - MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(beginTimestamp)); - } - - public String getEndTimestamp() { - return MDC.get(END_TIMESTAMP); - } - - private void setEndTimestamp(long endTimestamp) { - // Set MDC with formatted time stamp - MDC.put(END_TIMESTAMP, MetricLogger.asIso8601(endTimestamp)); - - // Set elapsed time - setElapsedTime(endTimestamp - beginTimestamp); - - } - - public String getRequestID() { - return MDC.get(REQUEST_ID); - } - - - public String getServiceInstanceID() { - return MDC.get(SERVICE_INSTANCE_ID); - } - - private void setServiceInstanceID(String svcInstanceId) { - MDC.put(SERVICE_INSTANCE_ID, svcInstanceId); - } - - public String getServiceName() { - return MDC.get(SERVICE_NAME); - } - - private void setServiceName(String svcName) { - MDC.put(SERVICE_NAME, svcName); - } - - public String getPartnerName() { - return MDC.get(PARTNER_NAME); - } - - private void setPartnerName(String partnerName) { - MDC.put(PARTNER_NAME, partnerName); - } - - public String getTargetEntity() { - return MDC.get(TARGET_ENTITY); - } - - private void setTargetEntity(String targetEntity) { - MDC.put(TARGET_ENTITY, targetEntity); - } - - public String getTargetServiceName() { - return MDC.get(TARGET_SERVICE_NAME); - } - - private void setTargetServiceName(String targetServiceName) { - MDC.put(TARGET_SERVICE_NAME, targetServiceName); - } - - public String getStatusCode() { - return MDC.get(STATUS_CODE); - } - - private void setStatusCode(String statusCode) { - MDC.put(STATUS_CODE, statusCode); - } - - public String getResponseCode() { - return MDC.get(RESPONSE_CODE); - } - - private void setResponseCode(String responseCode) { - MDC.put(RESPONSE_CODE, responseCode); - } - - public String getResponseDescription() { - return MDC.get(RESPONSE_DESCRIPTION); - } - - private void setResponseDescription(String responseDesc) { - MDC.put(RESPONSE_DESCRIPTION, responseDesc); - } - - public String getInstanceUUID() { - return MDC.get(INSTANCE_UUID); - } - - private void setInstanceUUID(String instanceUUID) { - MDC.put(INSTANCE_UUID, instanceUUID); - } - - public String getCategoryLogLevel() { - return MDC.get(CATEGORY_LOG_LEVEL); - } - - private void setCategoryLogLevel(String categoryLogLevel) { - MDC.put(CATEGORY_LOG_LEVEL, categoryLogLevel); - } - - public String getSeverity() { - return MDC.get(SEVERITY); - } - - private void setSeverity(String severity) { - MDC.put(SEVERITY, severity); - } - - public String getServerIpAddress() { - return MDC.get(SERVER_IP_ADDRESS); - } - - private void setServerIpAddress(String serverIpAddress) { - MDC.put(SERVER_IP_ADDRESS, serverIpAddress); - } - - public String getElapsedTime() { - return MDC.get(ELAPSED_TIME); - } - - private void setElapsedTime(long elapsedTime) { - MDC.put(ELAPSED_TIME, ""+elapsedTime); - } - - public String getServer() { - return MDC.get(SERVER); - } - - private void setServer(String server) { - MDC.put(SERVER, server); - } - - public String getClientIp() { - return MDC.get(CLIENT_IP); - } - - private void setClientIp(String clientIp) { - MDC.put(CLIENT_IP, clientIp); - } - - public String getClassName() { - return MDC.get(CLASS_NAME); - } - - private void setClassName(String className) { - MDC.put(CLASS_NAME, className); - } - - public String getTargetVirtualEntity() { - return MDC.get(TARGET_VIRTUAL_ENTITY); - } - - private void setTargetVirtualEntity(String targetVirtualEntity) { - MDC.put(TARGET_VIRTUAL_ENTITY, targetVirtualEntity); - } - - public static String asIso8601(Date date) { - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); - df.setTimeZone(tz); - return df.format(date); - } - - public static String asIso8601(long tsInMillis) { - return MetricLogger.asIso8601(new Date(tsInMillis)); - } - - public void logRequest(String svcInstanceId, String svcName, String partnerName, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) { - - setBeginTimestamp(System.currentTimeMillis()); - - if (svcInstanceId != null) { - setServiceInstanceID(svcInstanceId); - } - - if (svcName != null) { - setServiceName(svcName); - } - - if (partnerName != null) { - setPartnerName(partnerName); - } - - if (targetEntity != null) { - setTargetEntity(targetEntity); - } - - if (targetServiceName != null) { - setTargetServiceName(targetServiceName); - } - - if (targetVirtualEntity != null) { - setTargetVirtualEntity(targetVirtualEntity); - } - - this.lastMsg = msg; - - - } - - public void logResponse(String statusCode, String responseCode, String responseDescription) { - setEndTimestamp(System.currentTimeMillis()); - - setStatusCode(statusCode); - setResponseCode(responseCode); - setResponseDescription(responseDescription); - - METRIC.info(lastMsg); - - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java deleted file mode 100644 index b4d62ab48..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAdaptor.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.util.Map; - -public interface SvcLogicAdaptor { - - public enum ConfigStatus { - SUCCESS, - ALREADY_ACTIVE, - NOT_FOUND, - NOT_READY, - FAILURE - } - - public ConfigStatus configure(String key, Map parameters, SvcLogicContext ctx); - - public ConfigStatus activate(String key, SvcLogicContext ctx); - - public ConfigStatus deactivate(String key, SvcLogicContext ctx); - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java deleted file mode 100644 index 9ac648933..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicAtom.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class SvcLogicAtom extends SvcLogicExpression { - - public enum AtomType { - NUMBER, - STRING, - IDENTIFIER, - CONTEXT_VAR - - } - - private AtomType atomType; - private String atom; - - - public SvcLogicAtom(String atomType, String atom) - { - this.atomType = AtomType.valueOf(atomType); - this.atom = atom; - - } - - public SvcLogicAtom(String atom) - { - - if (atom == null) - { - this.atomType = null; - this.atom = null; - } - else - { - if (atom.startsWith("$")) - { - this.atomType = AtomType.CONTEXT_VAR; - this.atom = atom.substring(1); - } - else - { - if (Character.isDigit(atom.charAt(0))) - { - this.atomType = AtomType.NUMBER; - this.atom = atom; - } - else if (atom.charAt(0) == '\'') - { - this.atomType = AtomType.STRING; - this.atom = atom.substring(1, atom.length()-1); - } - else - { - this.atomType = AtomType.IDENTIFIER; - this.atom = atom; - - } - - } - } - } - - public AtomType getAtomType() { - return atomType; - } - - public void setAtomType(String newType) - { - atomType = AtomType.valueOf(newType); - } - - public String getAtom() { - return atom; - } - - - - public void setAtomType(AtomType atomType) { - this.atomType = atomType; - } - - public void setAtom(String atom) { - this.atom = atom; - } - - - - public String toString() - { - StringBuffer sbuff = new StringBuffer(); - switch(getAtomType()) - { - case CONTEXT_VAR: - sbuff.append("$"); - case IDENTIFIER: - boolean needDot = false; - for (SvcLogicExpression term: this.getOperands()) - { - if (needDot) - { - sbuff.append("."); - } - sbuff.append(term.toString()); - needDot = true; - } - return(sbuff.toString()); - case STRING: - case NUMBER: - default: - return(atom); - } - } - - public String asParsedExpr() - { - // simplify debugging output for NUMBER type - if (atomType == AtomType.NUMBER) { - return atom; - } - - StringBuffer sbuff = new StringBuffer(); - - sbuff.append("(atom"); - sbuff.append("<"); - sbuff.append(atomType.toString()); - sbuff.append(">"); - - switch(atomType) - { - case IDENTIFIER: - case CONTEXT_VAR: - for (SvcLogicExpression term : getOperands()) - { - sbuff.append(" "); - sbuff.append(term.asParsedExpr()); - - } - break; - default: - sbuff.append(" "); - sbuff.append(atom); - } - - sbuff.append(")"); - return(sbuff.toString()); - } - - - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java deleted file mode 100644 index 1d780d7e7..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicBinaryExpression.java +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.util.LinkedList; -import java.util.List; - -public class SvcLogicBinaryExpression extends SvcLogicExpression { - - - public enum OperatorType { - addOp("+"), - subOp("-"), - multOp("*"), - divOp("/"), - equalOp("=="), - ltOp("<"), - leOp("<="), - gtOp(">"), - geOp(">="), - neOp("!="), - andOp("and"), - orOp("or"); - - private String text; - - private OperatorType(String text) - { - this.text = text; - } - - public String getText() - { - return(text); - } - - public static OperatorType fromString(String text) - { - if (text != null) - { - for (OperatorType t : OperatorType.values()) - { - if (text.equalsIgnoreCase(t.getText())) { - - return(t); - } - } - } - return(null); - } - - public String toString() - { - return(text); - } - } - private List operators; - - public List getOperators() { - return operators; - } - - public SvcLogicBinaryExpression() - { - operators = new LinkedList(); - } - - public void addOperator(String operator) - { - operators.add(OperatorType.fromString(operator)); - } - - - public String toString() - { - - Listoperands = getOperands(); - StringBuffer sbuff = new StringBuffer(); - - sbuff.append(operands.get(0).toString()); - for (int i = 0 ; i < operators.size(); i++) - { - sbuff.append(" "); - sbuff.append(operators.get(i)); - sbuff.append(" "); - if (i + 1 < operands.size()) { - sbuff.append(operands.get(i + 1).toString()); - } else { - // expression incomplete; operand not bound yet - sbuff.append("?"); - } - } - - return(sbuff.toString()); - - } - - public String asParsedExpr() { - - List operands = getOperands(); - - if (operators.isEmpty()) { - return operands.get(0).asParsedExpr(); - } else { - StringBuffer sbuff = new StringBuffer(); - // operators in reverse order for left associativity - for (int i = operators.size() - 1; i >= 0; --i) { - sbuff.append("("); - sbuff.append(operators.get(i).getText()); - sbuff.append(" "); - } - for (int i = 0; i < operators.size() + 1; ++i) { - if (i < operands.size()) { - sbuff.append(operands.get(i).asParsedExpr()); - } else { - // expression incomplete; operand not bound yet - sbuff.append("?"); - } - if (i != 0) { - sbuff.append(")"); - } - if (i < operators.size()) { - sbuff.append(" "); - } - } - return sbuff.toString(); - } - } - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java deleted file mode 100644 index 79082af29..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicContext.java +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - - -public class SvcLogicContext { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicContext.class); - - private HashMap attributes; - - private DOMDataBroker domDataBroker; - - private String status = "success"; - - public SvcLogicContext() - { - this.attributes = new HashMap (); - - } - - public SvcLogicContext(Properties props) - { - this.attributes = new HashMap (); - - if (props.containsKey("SvcLogic.status")) - { - this.status = props.getProperty("SvcLogic.status"); - } - - for (Object nameObj : props.keySet()) - { - String propName = (String) nameObj; - attributes.put(propName, props.getProperty(propName)); - } - } - - - - public DOMDataBroker getDomDataBroker() { - return domDataBroker; - } - - public void setDomDataBroker(DOMDataBroker domDataBroker) { - this.domDataBroker = domDataBroker; - } - - public String getAttribute(String name) - { - if (attributes.containsKey(name)) - { - return(attributes.get(name)); - } - else - { - return(null); - } - } - - public void setAttribute(String name, String value) - { - if (value == null) { - if (attributes.containsKey(name)) { - attributes.remove(name); - } - } else { - attributes.put(name, value); - } - } - - public Set getAttributeKeySet() - { - return(attributes.keySet()); - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Properties toProperties() - { - Properties props = new Properties(); - - if (status != null) - { - props.setProperty("SvcLogic.status", status); - } - - for (String attrName : attributes.keySet()) - { - String attrVal = attributes.get(attrName); - if (attrVal == null) { - LOG.warn("attribute " + attrName - + "null - setting to empty string"); - props.setProperty(attrName, ""); - } else { - props.setProperty(attrName, attributes.get(attrName)); - } - } - - return(props); - } - - public void mergeDocument(String pfx, Document doc) { - String prefix = ""; - - if (pfx != null) { - prefix = pfx; - } - - Element root = doc.getDocumentElement(); - - mergeElement(prefix, root, null); - } - - public void mergeElement(String pfx, Element element, Map nodeMap) { - - // In XML, cannot tell the difference between containers and lists. - // So, have to treat each element as both (ugly but necessary). - // We do this by passing a nodeMap to be used to count instance of each tag, - // which will be used to set _length and to set index - - LOG.trace("mergeElement("+pfx+","+element.getTagName()+","+nodeMap+")"); - - String curTagName = element.getTagName(); - String prefix = curTagName; - - if (pfx != null) { - prefix = pfx + "." + prefix; - } - - int myIdx = 0; - - if (nodeMap != null) { - if (nodeMap.containsKey(curTagName)) { - myIdx = nodeMap.get(curTagName).intValue(); - } - - nodeMap.put(curTagName, new Integer(myIdx+1)); - this.setAttribute(prefix+"_length", ""+(myIdx+1)); - } - - NodeList children = element.getChildNodes(); - - int numChildren = children.getLength(); - - Map childMap = new HashMap(); - Map idxChildMap = new HashMap(); - - for (int i = 0 ; i < numChildren ; i++) { - Node curNode = children.item(i); - - if (curNode instanceof Text) { - Text curText = (Text) curNode; - String curTextValue = curText.getTextContent(); - LOG.trace("Setting ctx variable "+prefix+" = "+curTextValue); - this.setAttribute(prefix, curText.getTextContent()); - - - } else if (curNode instanceof Element) { - mergeElement(prefix, (Element) curNode, childMap); - if (nodeMap != null) { - - mergeElement(prefix+"["+myIdx+"]", (Element)curNode, idxChildMap); - - } - } - } - - } - - public String resolve(String ctxVarName) { - - if (ctxVarName.indexOf('[') == -1) { - // Ctx variable contains no arrays - return (this.getAttribute(ctxVarName)); - } - - // Resolve any array references - StringBuffer sbuff = new StringBuffer(); - String[] ctxVarParts = ctxVarName.split("\\["); - sbuff.append(ctxVarParts[0]); - for (int i = 1; i < ctxVarParts.length; i++) { - if (ctxVarParts[i].startsWith("$")) { - int endBracketLoc = ctxVarParts[i].indexOf("]"); - if (endBracketLoc == -1) { - // Missing end bracket ... give up parsing - LOG.warn("Variable reference " + ctxVarName - + " seems to be missing a ']'"); - return (this.getAttribute(ctxVarName)); - } - - String idxVarName = ctxVarParts[i].substring(1, endBracketLoc); - String remainder = ctxVarParts[i].substring(endBracketLoc); - - sbuff.append("["); - sbuff.append(this.getAttribute(idxVarName)); - sbuff.append(remainder); - - } else { - // Index is not a variable reference - sbuff.append("["); - sbuff.append(ctxVarParts[i]); - } - } - - return (this.getAttribute(sbuff.toString())); - } - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java deleted file mode 100644 index d494eaab2..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicDblibStore.java +++ /dev/null @@ -1,533 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.Blob; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Properties; - -import javax.sql.rowset.CachedRowSet; - -import org.openecomp.sdnc.sli.resource.dblib.DBResourceManager; -import org.openecomp.sdnc.sli.resource.dblib.DbLibService; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SvcLogicDblibStore implements SvcLogicStore { - - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicDblibStore.class); - - private static final String DBLIB_SERVICE = - // "org.openecomp.sdnc.sli.resource.dblib.DBLibService"; - "org.openecomp.sdnc.sli.resource.dblib.DBResourceManager"; - - Properties props = null; - - public void init(Properties props) throws ConfigurationException { - - DbLibService dbSvc = getDbLibService(); - if(dbSvc == null) { - LOG.error("SvcLogic cannot acquire DBLIB_SERVICE"); - return; - } - try { - dbSvc.getData("select 1 from DUAL", new ArrayList(), null); - LOG.debug("SQL test was successful"); - } catch (SQLException e) { - LOG.error("Failed SQL test", e); - } - } - - public boolean hasGraph(String module, String rpc, String version, - String mode) throws SvcLogicException { - - DbLibService dbSvc = getDbLibService(); - - boolean retval = false; - CachedRowSet results = null; - String hasVersionGraphSql = "SELECT count(*) FROM SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - - String hasActiveGraphSql = "SELECT count(*) FROM SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; - - PreparedStatement hasGraphStmt = null; - - ArrayList args = new ArrayList(); - args.add(module); - args.add(rpc); - args.add(mode); - - try { - - if (version == null) { - results = dbSvc.getData(hasActiveGraphSql, args, null); - } else { - args.add(version); - results = dbSvc.getData(hasVersionGraphSql, args, null); - } - - if (results.next()) { - int cnt = results.getInt(1); - - if (cnt > 0) { - retval = true; - } - - } - } catch (Exception e) { - throw new ConfigurationException("SQL query failed", e); - } finally { - if (results != null) { - try { - - results.close(); - } catch (SQLException x) { - } - } - - } - - return (retval); - - } - - public SvcLogicGraph fetch(String module, String rpc, String version, - String mode) throws SvcLogicException { - - DbLibService dbSvc = getDbLibService(); - - Connection dbConn = null; - SvcLogicGraph retval = null; - ResultSet results = null; - - String fetchVersionGraphSql = "SELECT graph FROM SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - - String fetchActiveGraphSql = "SELECT graph FROM SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; - - - try { - dbConn = ((DBResourceManager) dbSvc).getConnection(); - PreparedStatement fetchGraphStmt; - - ArrayList args = new ArrayList(); - args.add(module); - args.add(rpc); - args.add(mode); - - if (version == null) { - fetchGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); - } else { - fetchGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); - } - - fetchGraphStmt.setString(1, module); - fetchGraphStmt.setString(2, rpc); - fetchGraphStmt.setString(3, mode); - if (version != null) { - fetchGraphStmt.setString(4,version); - } - - results = fetchGraphStmt.executeQuery(); - - if (results.next()) { - Blob graphBlob = results.getBlob("graph"); - - ObjectInputStream gStream = new ObjectInputStream( - graphBlob.getBinaryStream()); - - Object graphObj = gStream.readObject(); - gStream.close(); - - if (graphObj instanceof SvcLogicGraph) { - retval = (SvcLogicGraph) graphObj; - } else { - throw new ConfigurationException("invalid type for graph (" - + graphObj.getClass().getName()); - - } - - } else { - return (null); - } - } catch (SQLException e) { - throw new ConfigurationException("SQL query failed", e); - } catch (Exception e) { - throw new ConfigurationException("Graph processing failed", e); - } finally { - if (results != null) { - try { - results.close(); - } catch (SQLException x) { - } - } - try { - if (dbConn != null && !dbConn.isClosed()) { - dbConn.close(); - } - } catch (Throwable exc) { - // the exception not monitored - } finally { - dbConn = null; - } - - } - - return (retval); - - } - - public void store(SvcLogicGraph graph) throws SvcLogicException { - - DbLibService dbSvc = getDbLibService(); - - String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph)" - + " VALUES(?, ?, ?, ?, ?, ?)"; - - if (graph == null) { - throw new SvcLogicException("graph cannot be null"); - } - - byte[] graphBytes = null; - - ByteArrayOutputStream byteStr = null; - ObjectOutputStream goutStr = null; - - try { - byteStr = new ByteArrayOutputStream(); - goutStr = new ObjectOutputStream(byteStr); - goutStr.writeObject(graph); - - graphBytes = byteStr.toByteArray(); - - } catch (Exception e) { - throw new SvcLogicException("could not serialize graph", e); - } finally { - - if (goutStr != null) { - try { - goutStr.close(); - } catch (IOException e) { - - } - } - - if (byteStr != null) { - try { - byteStr.close(); - } catch (IOException e) { - - } - } - } - - // If object already stored in database, delete it - if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), - graph.getMode())) { - delete(graph.getModule(), graph.getRpc(), graph.getVersion(), - graph.getMode()); - } - - Connection dbConn = null; - - try { - dbConn = ((DBResourceManager) dbSvc).getConnection(); - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - PreparedStatement storeGraphStmt = dbConn - .prepareStatement(storeGraphSql); - storeGraphStmt.setString(1, graph.getModule()); - storeGraphStmt.setString(2, graph.getRpc()); - storeGraphStmt.setString(3, graph.getVersion()); - storeGraphStmt.setString(4, graph.getMode()); - storeGraphStmt.setString(5, "N"); - storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); - - storeGraphStmt.executeUpdate(); - dbConn.commit(); - - dbConn.setAutoCommit(oldAutoCommit); - } catch (Exception e) { - throw new SvcLogicException("Could not write object to database", e); - } finally { - try { - if (dbConn != null && !dbConn.isClosed()) { - dbConn.close(); - } - } catch (Throwable exc) { - // the exception not monitored - } finally { - dbConn = null; - } - - } - } - - public void delete(String module, String rpc, String version, String mode) - throws SvcLogicException { - - DbLibService dbSvc = getDbLibService(); - - String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - - ArrayList args = new ArrayList(); - - args.add(module); - args.add(rpc); - args.add(version); - args.add(mode); - - try { - dbSvc.writeData(deleteGraphSql, args, null); - } catch (Exception e) { - throw new SvcLogicException( - "Could not delete object from database", e); - } - } - - public void activate(SvcLogicGraph graph) throws SvcLogicException { - DbLibService dbSvc = getDbLibService(); - - String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; - - String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - - ArrayList args = new ArrayList(); - - args.add(graph.getModule()); - args.add(graph.getRpc()); - args.add(graph.getMode()); - - try { - - dbSvc.writeData(deactivateSql, args, null); - - args.add(graph.getVersion()); - dbSvc.writeData(activateSql, args, null); - - } catch (Exception e) { - throw new SvcLogicException("Could not activate graph", e); - } - } - - @Override - public void registerNodeType(String nodeType) throws SvcLogicException { - - String registerNodeSql = "INSERT INTO NODE_TYPES (nodetype) VALUES(?)"; - - if (isValidNodeType(nodeType)) { - return; - } - - DbLibService dbSvc = getDbLibService(); - ArrayList args = new ArrayList(); - - args.add(nodeType); - - try { - dbSvc.writeData(registerNodeSql, args, null); - } catch (Exception e) { - throw new SvcLogicException("Could not add node type to database", - e); - } - - } - - @Override - public void unregisterNodeType(String nodeType) throws SvcLogicException { - - if (!isValidNodeType(nodeType)) { - return; - } - - String unregisterNodeSql = "DELETE FROM NODE_TYPES WHERE nodetype = ?"; - - DbLibService dbSvc = getDbLibService(); - ArrayList args = new ArrayList(); - - args.add(nodeType); - - try { - dbSvc.writeData(unregisterNodeSql, args, null); - } catch (Exception e) { - throw new SvcLogicException( - "Could not delete node type from database", e); - } - - } - - @Override - public boolean isValidNodeType(String nodeType) throws SvcLogicException { - - String validateNodeSql = "SELECT count(*) FROM NODE_TYPES WHERE nodetype = ?"; - - DbLibService dbSvc = getDbLibService(); - - ArrayList args = new ArrayList(); - - args.add(nodeType); - - boolean isValid = false; - - CachedRowSet results = null; - try { - results = dbSvc.getData(validateNodeSql, args, null); - if (results != null) { - if (results.next()) { - int cnt = results.getInt(1); - - if (cnt > 0) { - isValid = true; - } - } - } - } catch (Exception e) { - throw new SvcLogicException( - "Cannot select node type from database", e); - } finally { - if (results != null) { - try { - results.close(); - } catch (SQLException x) { - } - } - - } - - return (isValid); - } - - private DbLibService getDbLibService() { - - // Get DbLibService interface object. - DbLibService dblibSvc = null; - ServiceReference sref = null; - BundleContext bctx = null; - - Bundle bundle = FrameworkUtil.getBundle(SvcLogicDblibStore.class); - - if (bundle != null) { - bctx = bundle.getBundleContext(); - - if (bctx != null) { - sref = bctx.getServiceReference(DBLIB_SERVICE); - } - - if (sref == null) { - LOG.warn("Could not find service reference for DBLIB service (" - + DBLIB_SERVICE + ")"); - } else { - dblibSvc = (DbLibService) bctx.getService(sref); - if (dblibSvc == null) { - - LOG.warn("Could not find service reference for DBLIB service (" - + DBLIB_SERVICE + ")"); - } - } - } - - // initialize a stand-alone instance of dblib resource - else { - // Try to create a DbLibService object from dblib properties - if(JavaSingleton.getInstance() == null){ - Properties dblibProps = new Properties(); - - String propDir = System.getenv(SDNC_CONFIG_DIR); - if (propDir == null) { - - propDir = "/opt/sdnc/data/properties"; - } - String propPath = propDir + "/dblib.properties"; - - File propFile = new File(propPath); - - if (!propFile.exists()) { - - LOG.warn( - "Missing configuration properties file : " - + propFile); - return(null); - } - - try { - - dblibProps.load(new FileInputStream(propFile)); - } catch (Exception e) { - LOG.warn( - "Could not load properties file " + propPath, e); - return(null); - - } - - try { - dblibSvc = DBResourceManager.create(dblibProps); - JavaSingleton.setInstance(dblibSvc); - } catch (Exception e) { - LOG.warn("Caught exception trying to create DBResourceManager", e); - } - } else { - dblibSvc = JavaSingleton.getInstance(); - } - } - return (dblibSvc); - } - - - static class JavaSingleton { - /* Private constructor */ - private JavaSingleton() { - /* the body of the constructor here */ - } - - /* instance of the singleton declaration */ - private static volatile DbLibService INSTANCE ; - - /* Access point to the unique instance of the singleton */ - public static DbLibService getInstance() { - return INSTANCE; - } - - public static void setInstance(DbLibService dbresource) { - INSTANCE = dbresource; - } - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java deleted file mode 100644 index c087b8ad8..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicException.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -public class SvcLogicException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public SvcLogicException() - { - super(); - } - - public SvcLogicException(String message) - { - super(message); - } - - public SvcLogicException(String message, Throwable t) - { - super(message, t); - } - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java deleted file mode 100644 index 4fef12fbc..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprListener.java +++ /dev/null @@ -1,316 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.util.LinkedList; -import java.util.List; - -import org.antlr.v4.runtime.tree.TerminalNode; -import org.openecomp.sdnc.sli.ExprGrammarParser.AddExprContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.AtomContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.CompareExprContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.ConstantContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.ExprContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.FuncExprContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.MultExprContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.ParenExprContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.RelExprContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.VariableContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.VariableLeadContext; -import org.openecomp.sdnc.sli.ExprGrammarParser.VariableTermContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SvcLogicExprListener extends ExprGrammarBaseListener -{ - - - - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicExprListener.class); - - private SvcLogicExpression curExpr; - private SvcLogicExpression topExpr; - private LinkedList exprStack; - - public SvcLogicExprListener() - { - exprStack = new LinkedList(); - } - - public SvcLogicExpression getParsedExpr() - { - return(curExpr); - } - - private void pushOperand(SvcLogicExpression operand) - { - if (curExpr == null) - { - curExpr = operand; - } - else - { - curExpr.addOperand(operand); - } - } - - private void pushExpr(SvcLogicExpression expr) - { - LOG.trace("Pushing expression ["+expr.getClass().getName()+"]"); - if (curExpr != null) - { - exprStack.push(curExpr); - } - curExpr = expr; - } - - private void popExpr() - { - if (exprStack.isEmpty()) - { - LOG.trace("Popping last expression"); - topExpr = curExpr; - } - else - { - SvcLogicExpression lastExpr = curExpr; - curExpr = exprStack.pop(); - curExpr.addOperand(lastExpr); - LOG.trace("New curExpr is ["+curExpr.getClass().getName()+"]"); - } - - } - - @Override - public void enterAtom(AtomContext ctx) { - - String atomText = ctx.getText(); - - LOG.trace("enterAtom: text = "+atomText); - - - SvcLogicAtom newAtom = new SvcLogicAtom(atomText); - - pushExpr(newAtom); - } - - - @Override - public void enterMultExpr(MultExprContext ctx) { - LOG.trace("enterMultExpr: text = "+ctx.getText()); - - SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); - pushExpr(curBinExpr); - - List opList = ctx.MULTOP(); - - for (TerminalNode nd : opList) - { - LOG.trace("enterMultExpr: operator - "+nd.getText()); - curBinExpr.addOperator(nd.getText()); - } - - } - - @Override - public void exitMultExpr(MultExprContext ctx) { - - LOG.trace("exitMultExpr: text = "+ctx.getText()); - - popExpr(); - - } - - @Override - public void exitAtom(AtomContext ctx) { - LOG.trace("exitAtom: text = "+ctx.getText()); - popExpr(); - } - - @Override - public void enterAddExpr(AddExprContext ctx) { - LOG.trace("enterAddExpr: text = "+ctx.getText()); - List opList = ctx.ADDOP(); - - - SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); - pushExpr(curBinExpr); - - - for (TerminalNode nd : opList) - { - LOG.trace("enterAddExpr: operator - "+nd.getText()); - curBinExpr.addOperator(nd.getText()); - } - - } - - @Override - public void exitAddExpr(AddExprContext ctx) { - LOG.trace("exitAddExpr: text = "+ctx.getText()); - - popExpr(); - } - - @Override - public void enterFuncExpr(FuncExprContext ctx) { - LOG.trace("enterFuncExpr: text = "+ctx.getText()); - LOG.trace("enterFuncExpr - IDENTIFIER : "+ctx.IDENTIFIER().getText()); - - for (ExprContext expr: ctx.expr()) - { - LOG.trace("enterFuncExpr - expr = "+expr.getText()); - } - - - pushExpr(new SvcLogicFunctionCall(ctx.IDENTIFIER().getText())); - } - - @Override - public void exitFuncExpr(FuncExprContext ctx) { - LOG.trace("exitFuncExpr: text = "+ctx.getText()); - - popExpr(); - } - - @Override - public void enterParenExpr(ParenExprContext ctx) { - LOG.trace("enterParenExpr: text = "+ctx.getText()); - LOG.trace("enterParenExpr: expr = "+ctx.expr().getText()); - } - - @Override - public void exitParenExpr(ParenExprContext ctx) { - LOG.trace("exitParenExpr: text = "+ctx.getText()); - } - - @Override - public void enterRelExpr(RelExprContext ctx) { - LOG.trace("enterRelExpr: text = "+ctx.getText()); - - List opList = ctx.RELOP(); - - - SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); - pushExpr(curBinExpr); - - - for (TerminalNode nd : opList) - { - LOG.trace("enterRelExpr: operator - "+nd.getText()); - curBinExpr.addOperator(nd.getText()); - } - - } - - @Override - public void exitRelExpr(RelExprContext ctx) { - LOG.trace("exitRelExpr: text = "+ctx.getText()); - - popExpr(); - } - - @Override - public void enterCompareExpr(CompareExprContext ctx) { - LOG.trace("enterCompareExpr: text = "+ctx.getText()); - - TerminalNode nd = ctx.COMPAREOP(); - - SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); - pushExpr(curBinExpr); - - LOG.trace("enterCompareExpr: operator - "+nd.getText()); - curBinExpr.addOperator(nd.getText()); - - } - - @Override - public void exitCompareExpr(CompareExprContext ctx) { - LOG.trace("exitCompareExpr : text = "+ctx.getText()); - - popExpr(); - } - - - - @Override - public void enterConstant(ConstantContext ctx) { - LOG.trace("enterConstant: text = "+ctx.getText()); - } - - @Override - public void exitConstant(ConstantContext ctx) { - LOG.trace("exitConstant: text = "+ctx.getText()); - } - - - @Override - public void enterVariable(VariableContext ctx) { - LOG.trace("enterVariable: text = "+ctx.getText()); - - - } - - @Override - public void exitVariable(VariableContext ctx) { - LOG.debug("exitVariable: text ="+ctx.getText()); - - } - - - @Override - public void enterVariableLead(VariableLeadContext ctx) { - - LOG.debug("enterVariableLead: text ="+ctx.getText()); - - - } - - @Override - public void exitVariableLead(VariableLeadContext ctx) { - - LOG.trace("exitVariableLead: text ="+ctx.getText()); - } - - @Override - public void enterVariableTerm(VariableTermContext ctx) { - LOG.trace("enterVariableTerm: text ="+ctx.getText()); - - String name = ctx.getText(); - - int subscrStart = name.indexOf("["); - if (subscrStart > -1) - { - name = name.substring(0, subscrStart); - } - SvcLogicVariableTerm vterm = new SvcLogicVariableTerm(name); - pushExpr(vterm); - } - - @Override - public void exitVariableTerm(VariableTermContext ctx) { - LOG.trace("exitVariableTerm: text="+ctx.getText()); - popExpr(); - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java deleted file mode 100644 index 4c7dd22be..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExprParserErrorListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import org.antlr.v4.runtime.BaseErrorListener; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.Recognizer; -import org.antlr.v4.runtime.misc.ParseCancellationException; - -public class SvcLogicExprParserErrorListener extends BaseErrorListener { - - private static final SvcLogicExprParserErrorListener instance = new SvcLogicExprParserErrorListener(); - - public static SvcLogicExprParserErrorListener getInstance() { - return(instance); - } - - @Override - public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, - String msg, RecognitionException e) throws ParseCancellationException { - throw new ParseCancellationException(msg); - } - - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java deleted file mode 100644 index a6af82018..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpression.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.Serializable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - - -public abstract class SvcLogicExpression implements Serializable { - - private List operands = new LinkedList(); - - - public void addOperand(SvcLogicExpression expr) - { - operands.add(expr); - } - - public List getOperands() { - return operands; - } - - public int numOperands() - { - return(operands.size()); - } - - public abstract String asParsedExpr(); - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java deleted file mode 100644 index cce8e044d..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicExpressionFactory.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.antlr.v4.runtime.ANTLRInputStream; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.tree.ParseTreeWalker; -import org.openecomp.sdnc.sli.ExprGrammarParser.ExprContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class SvcLogicExpressionFactory { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicExpressionFactory.class); - - - public static SvcLogicExpression parse(String exprStr) throws IOException - { - LOG.trace("parse("+exprStr+")"); - InputStream exprStream = new ByteArrayInputStream(exprStr.getBytes()); - CharStream input = new ANTLRInputStream(exprStream); - ExprGrammarLexer lexer = new ExprGrammarLexer(input); - CommonTokenStream tokens = new CommonTokenStream(lexer); - ExprGrammarParser parser = new ExprGrammarParser(tokens); - - lexer.removeErrorListeners(); - lexer.addErrorListener(SvcLogicExprParserErrorListener.getInstance()); - parser.removeErrorListeners(); - parser.addErrorListener(SvcLogicExprParserErrorListener.getInstance()); - - ExprContext expression = null; - - try { - expression = parser.expr(); - } catch (Exception e) { - String errorMsg = e.getMessage(); - - LOG.error(errorMsg); - throw new SvcLogicParserException(errorMsg); - } - - - ParseTreeWalker walker = new ParseTreeWalker(); - SvcLogicExprListener listener = new SvcLogicExprListener(); - walker.walk(listener, expression); - - - return(listener.getParsedExpr()); - } - - public static void main(String argv[]) { - - - System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug"); - - StringBuffer sbuff = new StringBuffer(); - - for (int i = 0 ; i < argv.length ; i++) - { - if (sbuff.length() > 0) - { - sbuff.append(" "); - } - sbuff.append(argv[i]); - } - - try { - SvcLogicExpressionFactory.parse(sbuff.toString()); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java deleted file mode 100644 index a98cf6b22..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicFunctionCall.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -public class SvcLogicFunctionCall extends SvcLogicExpression { - - private String functionName; - - public SvcLogicFunctionCall(String functionName) - { - this.functionName = functionName; - } - - public String getFunctionName() { - return functionName; - } - - public void setFunctionName(String functionName) { - this.functionName = functionName; - } - - public String toString() - { - StringBuffer sbuff = new StringBuffer(); - - sbuff.append(functionName); - sbuff.append("("); - boolean needComma = false; - for (SvcLogicExpression operand: getOperands()) - { - if (needComma) - { - sbuff.append(","); - } - else - { - needComma = true; - } - sbuff.append(operand.toString()); - - } - sbuff.append(")"); - return(sbuff.toString()); - } - - public String asParsedExpr() - { - StringBuffer sbuff = new StringBuffer(); - - sbuff.append("("); - sbuff.append(functionName); - for (SvcLogicExpression operand: getOperands()) - { - sbuff.append(" "); - sbuff.append(operand.asParsedExpr()); - } - sbuff.append(")"); - return(sbuff.toString()); - } - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java deleted file mode 100644 index d3d6d9504..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicGraph.java +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.PrintStream; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -public class SvcLogicGraph implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - - private String module = null; - private String rpc = null; - private String mode = null; - private String version = null; - - private Map attributes; - private Map namedNodes; - private SvcLogicNode rootNode; - - public SvcLogicGraph() - { - attributes = new HashMap(); - namedNodes = new HashMap(); - rootNode = null; - } - - - public String getModule() { - return module; - } - - - public void setModule(String module) { - this.module = module; - } - - - public String getRpc() { - return rpc; - } - - - public void setRpc(String rpc) { - this.rpc = rpc; - } - - - - - public String getMode() { - return mode; - } - - - public void setMode(String mode) { - this.mode = mode; - } - - - public String getVersion() { - return version; - } - - - public void setVersion(String version) { - this.version = version; - } - - - public void setRootNode(SvcLogicNode rootNode) - { - this.rootNode = rootNode; - } - - public SvcLogicNode getRootNode() - { - return(rootNode); - } - - public Serializable getAttribute(String name) - { - if (attributes.containsKey(name)) - { - return(attributes.get(name)); - } - else - { - return(null); - } - - } - - public void setAttribute(String name, Serializable value) throws DuplicateValueException - { - if (attributes.containsKey(name)) - { - throw new DuplicateValueException("Duplicate attribute "+name); - } - - attributes.put(name, value); - } - - public SvcLogicNode getNamedNode(String nodeName) - { - if (namedNodes.containsKey(nodeName)) - { - return(namedNodes.get(nodeName)); - } - else - { - return(null); - } - } - - public void setNamedNode(String nodeName, SvcLogicNode node) throws DuplicateValueException - { - if (namedNodes.containsKey(nodeName)) - { - throw new DuplicateValueException("Duplicate node name "+nodeName); - } - - namedNodes.put(nodeName, node); - } - - - - public void printAsGv(PrintStream pstr) - { - pstr.println("digraph g {"); - pstr.println("START [label=\"START\\n"+module+":"+rpc+"\"];"); - - if (rootNode != null) - { - pstr.println("START -> node"+rootNode.getNodeId()+";"); - rootNode.setVisited(false, true); - rootNode.printAsGv(pstr); - } - pstr.println("}"); - } - - public void printAsXml(PrintStream pstr) - { - pstr.println(""); - pstr.println(" "); - if (rootNode != null) - { - rootNode.setVisited(false, true); - rootNode.printAsXml(pstr, 2); - } - pstr.println(" "); - pstr.println(""); - } - - @Override - public String toString() { - return "SvcLogicGraph [module=" + module + ", rpc=" + rpc + ", mode=" + mode + ", version=" + version + "]"; - } - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java deleted file mode 100644 index ac14cacc1..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJavaPlugin.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.util.Map; - -public interface SvcLogicJavaPlugin { - - /** - * A marker interface, used to indicate that a class exposes methods that can be - * called from an node. Such methods must have the signature: - * void methodName(Map, SvcLogicContext) - */ - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java deleted file mode 100644 index b9e7f80ec..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicJdbcStore.java +++ /dev/null @@ -1,895 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.Blob; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.Driver; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Properties; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class SvcLogicJdbcStore implements SvcLogicStore { - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicJdbcStore.class); - - private String dbUrl = null; - private String dbName = null; - private String dbUser = null; - private String dbPasswd = null; - private String dbDriver = null; - - private Connection dbConn; - private PreparedStatement hasActiveGraphStmt = null; - private PreparedStatement hasVersionGraphStmt = null; - private PreparedStatement fetchActiveGraphStmt = null; - private PreparedStatement fetchVersionGraphStmt = null; - private PreparedStatement storeGraphStmt = null; - private PreparedStatement deleteGraphStmt = null; - - private PreparedStatement deactivateStmt = null; - private PreparedStatement activateStmt = null; - - private PreparedStatement registerNodeStmt = null; - private PreparedStatement unregisterNodeStmt = null; - private PreparedStatement validateNodeStmt = null; - - private void getConnection() throws ConfigurationException - { - - Properties jdbcProps = new Properties(); - - jdbcProps.setProperty("user", dbUser); - jdbcProps.setProperty("password", dbPasswd); - - try { - Driver dvr = new com.mysql.jdbc.Driver(); - if (dvr.acceptsURL(dbUrl)) - { - LOG.debug("Driver com.mysql.jdbc.Driver accepts "+dbUrl); - } - else - { - LOG.warn("Driver com.mysql.jdbc.Driver does not accept "+dbUrl); - } - } catch (SQLException e1) { - LOG.error("Caught exception trying to load com.mysql.jdbc.Driver", e1); - - - } - - - try - { - this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps); - } - catch (Exception e) - { - throw new ConfigurationException("failed to get database connection ["+dbUrl+"]", e); - } - - } - - private void createTable() throws ConfigurationException - { - - - DatabaseMetaData dbm = null; - - - try { - dbm = dbConn.getMetaData(); - } catch (SQLException e) { - - throw new ConfigurationException("could not get databse metadata", e); - } - - // See if table SVC_LOGIC exists. If not, create it. - try - { - - - ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null); - if (tables.next()) { - // Table exists - } - else { - - String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC (" - + "module varchar(80) NOT NULL," - + "rpc varchar(80) NOT NULL," - + "version varchar(40) NOT NULL," - + "mode varchar(5) NOT NULL," - + "active varchar(1) NOT NULL," - + "graph BLOB," - + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; - - Statement stmt = null; - ConfigurationException myExc = null; - try - { - stmt = dbConn.createStatement(); - stmt.executeUpdate(crTableCmd); - } - catch (SQLException e1) - { - myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1); - } - finally - { - if (stmt != null) - { - stmt.close(); - } - } - - if (myExc != null) - { - throw myExc; - } - } - } - catch (Exception e) - { - throw new ConfigurationException("could not create SVC_LOGIC table", e); - } - - // See if NODE_TYPES table exists and, if not, create it - - try - { - - - ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null); - if (tables.next()) { - // Table exists - } - else { - - String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES (" - + "nodetype varchar(80) NOT NULL," - + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))"; - - Statement stmt = null; - ConfigurationException myExc = null; - try - { - stmt = dbConn.createStatement(); - stmt.executeUpdate(crTableCmd); - } - catch (SQLException e1) - { - myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1); - } - finally - { - if (stmt != null) - { - stmt.close(); - } - } - - if (myExc != null) - { - throw myExc; - } - } - } - catch (Exception e) - { - throw new ConfigurationException("could not create SVC_LOGIC table", e); - } - } - - private void prepStatements() throws ConfigurationException - { - - // Prepare statements - String hasVersionGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - - try - { - hasVersionGraphStmt = dbConn.prepareStatement(hasVersionGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); - - } - - String hasActiveGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; - - try - { - hasActiveGraphStmt = dbConn.prepareStatement(hasActiveGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); - - } - - String fetchVersionGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - - try - { - fetchVersionGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); - - } - - String fetchActiveGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; - - try - { - fetchActiveGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); - - } - - String storeGraphSql = "INSERT INTO "+dbName+".SVC_LOGIC (module, rpc, version, mode, active, graph)" - + " VALUES(?, ?, ?, ?, ?, ?)"; - - try - { - storeGraphStmt = dbConn.prepareStatement(storeGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+storeGraphSql, e); - } - - String deleteGraphSql = "DELETE FROM "+dbName+".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - - try - { - deleteGraphStmt = dbConn.prepareStatement(deleteGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+deleteGraphSql, e); - } - - String deactivateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; - - try - { - deactivateStmt = dbConn.prepareStatement(deactivateSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+deactivateSql, e); - } - - String activateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - - try - { - activateStmt = dbConn.prepareStatement(activateSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+activateSql, e); - } - - String registerNodeSql = "INSERT INTO "+dbName+".NODE_TYPES (nodetype) VALUES(?)"; - try - { - registerNodeStmt = dbConn.prepareStatement(registerNodeSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+registerNodeSql, e); - } - - String unregisterNodeSql = "DELETE FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; - try - { - unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+unregisterNodeSql, e); - } - - String validateNodeSql = "SELECT count(*) FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; - try - { - validateNodeStmt = dbConn.prepareStatement(validateNodeSql); - } - catch (Exception e) - { - throw new ConfigurationException("could not prepare statement "+validateNodeSql, e); - } - } - - private void initDbResources() throws ConfigurationException - { - if ((dbDriver != null) && (dbDriver.length() > 0)) - { - - try - { - Class.forName(dbDriver); - } - catch (Exception e) - { - throw new ConfigurationException("could not load driver class "+dbDriver, e); - } - } - getConnection(); - createTable(); - prepStatements(); - } - - - public void init(Properties props) throws ConfigurationException { - - - dbUrl = props.getProperty("org.openecomp.sdnc.sli.jdbc.url"); - if ((dbUrl == null) || (dbUrl.length() == 0)) - { - throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.url unset"); - } - - dbName = props.getProperty("org.openecomp.sdnc.sli.jdbc.database"); - if ((dbName == null) || (dbName.length() == 0)) - { - throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.database unset"); - } - - dbUser = props.getProperty("org.openecomp.sdnc.sli.jdbc.user"); - if ((dbUser == null) || (dbUser.length() == 0)) - { - throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.user unset"); - } - - - dbPasswd = props.getProperty("org.openecomp.sdnc.sli.jdbc.password"); - if ((dbPasswd == null) || (dbPasswd.length() == 0)) - { - throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.password unset"); - } - - dbDriver = props.getProperty("org.openecomp.sdnc.sli.jdbc.driver"); - - - initDbResources(); - - } - - private boolean isDbConnValid() - { - - boolean isValid = false; - - try - { - if (dbConn != null) - { - isValid = dbConn.isValid(1); - } - } - catch (SQLException e) - {} - - return(isValid); - } -public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - - - - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException("no jdbc connection"); - } - } - - - - boolean retval = false; - ResultSet results = null; - - PreparedStatement hasGraphStmt = null; - if (version == null) - { - hasGraphStmt = hasActiveGraphStmt; - } - else - { - hasGraphStmt = hasVersionGraphStmt; - } - - - - try - { - hasGraphStmt.setString(1, module); - hasGraphStmt.setString(2, rpc); - hasGraphStmt.setString(3, mode); - - - if (version != null) - { - hasGraphStmt.setString(4, version); - } - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - results = hasGraphStmt.executeQuery(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - - if (results.next()) - { - int cnt = results.getInt(1); - - if (cnt > 0) - { - retval = true; - } - - } - } - catch (Exception e) - { - throw new ConfigurationException("SQL query failed", e); - } - finally - { - if (results != null) - { - try - { - - results.close(); - } - catch (SQLException x) - {} - } - - } - - - return(retval); - - - } - - public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { - - - - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException("no jdbc connection"); - } - } - - - - SvcLogicGraph retval = null; - ResultSet results = null; - - PreparedStatement fetchGraphStmt = null; - if (version == null) - { - fetchGraphStmt = fetchActiveGraphStmt; - } - else - { - fetchGraphStmt = fetchVersionGraphStmt; - } - try - { - fetchGraphStmt.setString(1, module); - fetchGraphStmt.setString(2, rpc); - fetchGraphStmt.setString(3, mode); - - - if (version != null) - { - fetchGraphStmt.setString(4, version); - } - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - results = fetchGraphStmt.executeQuery(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - - if (results.next()) - { - Blob graphBlob = results.getBlob("graph"); - - ObjectInputStream gStream = new ObjectInputStream(graphBlob.getBinaryStream()); - - Object graphObj = gStream.readObject(); - gStream.close(); - - if (graphObj instanceof SvcLogicGraph) - { - retval = (SvcLogicGraph) graphObj; - } - else - { - throw new ConfigurationException("invalid type for graph ("+graphObj.getClass().getName()); - - } - - } - else - { - return(null); - } - } - catch (Exception e) - { - throw new ConfigurationException("SQL query failed", e); - } - finally - { - if (results != null) - { - try - { - results.close(); - } - catch (SQLException x) - {} - } - - } - - - return(retval); - - - } - - public void store(SvcLogicGraph graph) throws SvcLogicException { - - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException("no jdbc connection"); - } - } - - if (graph == null) - { - throw new SvcLogicException("graph cannot be null"); - } - - byte[] graphBytes = null; - - ByteArrayOutputStream byteStr = null; - ObjectOutputStream goutStr = null; - - try - { - byteStr = new ByteArrayOutputStream(); - goutStr = new ObjectOutputStream(byteStr); - goutStr.writeObject(graph); - - graphBytes = byteStr.toByteArray(); - - } - catch (Exception e) - { - throw new SvcLogicException("could not serialize graph", e); - } - finally - { - - if (goutStr != null) - { - try { - goutStr.close(); - } catch (IOException e) { - - } - } - - if (byteStr != null) - { - try { - byteStr.close(); - } catch (IOException e) { - - } - } - } - - - // If object already stored in database, delete it - if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode())) - { - delete(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode()); - } - - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - storeGraphStmt.setString(1, graph.getModule()); - storeGraphStmt.setString(2, graph.getRpc()); - storeGraphStmt.setString(3, graph.getVersion()); - storeGraphStmt.setString(4, graph.getMode()); - storeGraphStmt.setString(5, "N"); - storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); - - storeGraphStmt.executeUpdate(); - dbConn.commit(); - - dbConn.setAutoCommit(oldAutoCommit); - } - catch (Exception e) - { - throw new SvcLogicException("Could not write object to database", e); - } - } - - public void delete(String module, String rpc, String version, String mode) throws SvcLogicException - { - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException("no jdbc connection"); - } - } - - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - deleteGraphStmt.setString(1, module); - deleteGraphStmt.setString(2, rpc); - deleteGraphStmt.setString(3, version); - deleteGraphStmt.setString(4, mode); - - - deleteGraphStmt.executeUpdate(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - } - catch (Exception e) - { - throw new SvcLogicException("Could not delete object from database", e); - } - } - - public void activate(SvcLogicGraph graph) throws SvcLogicException - { - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - - dbConn.setAutoCommit(false); - - // Deactivate any current active version - deactivateStmt.setString(1, graph.getModule()); - deactivateStmt.setString(2, graph.getRpc()); - deactivateStmt.setString(3, graph.getMode()); - deactivateStmt.executeUpdate(); - - // Activate this version - activateStmt.setString(1, graph.getModule()); - activateStmt.setString(2, graph.getRpc()); - activateStmt.setString(3, graph.getVersion()); - activateStmt.setString(4, graph.getMode()); - activateStmt.executeUpdate(); - - dbConn.commit(); - - dbConn.setAutoCommit(oldAutoCommit); - - } - catch (Exception e) - { - throw new SvcLogicException("Could not activate graph", e); - } - } - - @Override - public void registerNodeType(String nodeType) throws SvcLogicException { - - if (isValidNodeType(nodeType)) - { - return; - } - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException("no jdbc connection"); - } - } - - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - registerNodeStmt.setString(1, nodeType); - registerNodeStmt.executeUpdate(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - } - catch (Exception e) - { - throw new SvcLogicException("Could not add node type to database", e); - } - - } - - @Override - public void unregisterNodeType(String nodeType) throws SvcLogicException { - - if (!isValidNodeType(nodeType)) - { - return; - } - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException("no jdbc connection"); - } - } - - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - unregisterNodeStmt.setString(1, nodeType); - unregisterNodeStmt.executeUpdate(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - } - catch (Exception e) - { - throw new SvcLogicException("Could not delete node type from database", e); - } - - } - - @Override - public boolean isValidNodeType(String nodeType) throws SvcLogicException { - - boolean isValid = false; - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException("no jdbc connection"); - } - } - - ResultSet results = null; - try - { - validateNodeStmt.setString(1, nodeType); - - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - results = validateNodeStmt.executeQuery(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - - if (results != null) - { - if (results.next()) - { - int cnt = results.getInt(1); - - if (cnt > 0) - { - isValid = true; - } - } - } - - } - catch (Exception e) - { - throw new SvcLogicException("Cannot select node type from database", e); - } - finally - { - if (results != null) - { - try - { - results.close(); - } - catch (SQLException x) - {} - } - - } - - return(isValid); - } - - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java deleted file mode 100644 index 6828e9ad1..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicNode.java +++ /dev/null @@ -1,456 +0,0 @@ -/*- - * ============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========================================================= - */ - -/** - * - */ -package org.openecomp.sdnc.sli; - -import java.io.IOException; -import java.io.PrintStream; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import org.apache.commons.lang3.StringEscapeUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xml.sax.Locator; - - -public class SvcLogicNode implements Serializable { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicExprListener.class); - - private static final long serialVersionUID = 2L; - - private String nodeName; - private int nodeId; - private String nodeType; - private boolean visited; - private SvcLogicGraph graph; - - - private HashMap attributes; - private HashMap outcomes; - private HashMap parameters; - - public SvcLogicNode(int nodeId, String nodeType, SvcLogicGraph graph) - { - this.nodeId = nodeId; - nodeName = ""; - this.nodeType = nodeType; - this.graph = graph; - attributes = new HashMap (); - parameters = new HashMap (); - outcomes = null; - - } - - public SvcLogicNode(int nodeId, String nodeType, String nodeName, SvcLogicGraph graph) throws DuplicateValueException - { - this.nodeId = nodeId; - this.nodeName = nodeName; - this.nodeType = nodeType; - this.graph = graph; - attributes = new HashMap (); - parameters = new HashMap (); - outcomes = null; - graph.setNamedNode(nodeName, this); - } - - - public int getNodeId() - { - return nodeId; - } - - public String getNodeName() - { - return(nodeName); - } - - public String getNodeType() - { - return(nodeType); - } - - public SvcLogicGraph getGraph() - { - return(graph); - } - - public int getNumOutcomes() - { - if (outcomes == null) - { - return(0); - } - else - { - return(outcomes.size()); - } - } - - public SvcLogicExpression getAttribute(String name) - { - if (attributes.containsKey(name)) - { - return(attributes.get(name)); - } - else - { - return(null); - } - - } - - public void setAttribute(String name, String value) throws SvcLogicException - { - setAttribute(name, new SvcLogicAtom("STRING", value)); - } - - public void setAttribute(String name, SvcLogicExpression value) throws SvcLogicException - { - if (attributes.containsKey(name)) - { - throw new DuplicateValueException("Duplicate attribute "+name); - } - - attributes.put(name, value); - } - - - public void mapParameter(String name, String value) throws SvcLogicException - { - - if (parameters.containsKey(name)) - { - throw new DuplicateValueException("Duplicate parameter "+name); - } - try - { - SvcLogicExpression parmValue; - if ((value == null) || (value.length() == 0)) - { - parmValue = new SvcLogicAtom("STRING", ""); - } - else if (value.trim().startsWith("`")) - { - int lastParen = value.lastIndexOf("`"); - String evalExpr = value.trim().substring(1, lastParen); - parmValue = SvcLogicExpressionFactory.parse(evalExpr); - - } - else - { - if (Character.isDigit(value.charAt(0))) - { - parmValue = new SvcLogicAtom("NUMBER", value); - } - else - { - parmValue = new SvcLogicAtom("STRING", value); - } - } - LOG.debug("Setting parameter "+name+" = "+value+" = "+parmValue.asParsedExpr()); - parameters.put(name, parmValue); - } - catch (IOException e) { - - LOG.error("Invalid parameter value expression ("+value+")"); - throw new SvcLogicException(e.getMessage()); - } - } - - public SvcLogicExpression getParameter(String name) - { - if (parameters.containsKey(name)) - { - return(parameters.get(name)); - } - else - { - return(null); - } - } - - public boolean isVisited() { - return visited; - } - - public void setVisited(boolean visited, boolean recursive) { - this.visited = visited; - - if (recursive) - { - Set> outcomeSet = getOutcomeSet(); - - if (outcomeSet == null) - { - return; - } - - for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) - { - Map.Entry curOutcome = iter.next(); - SvcLogicNode outNode = curOutcome.getValue(); - outNode.setVisited(visited, recursive); - } - } - } - - public void addOutcome(String outcomeValue, SvcLogicNode node) throws SvcLogicException - { - if (outcomes == null) - { - outcomes = new HashMap(); - } - - if (outcomeValue.length() == 0) { - outcomeValue = "\"\""; - } - if (outcomes.containsKey(outcomeValue)) - { - throw new DuplicateValueException("Duplicate outcome value "+outcomeValue); - } - - outcomes.put(outcomeValue, node); - } - - public Set> getOutcomeSet() - { - if (outcomes == null) - { - return null; - } - - return(outcomes.entrySet()); - - } - - public Set> getParameterSet() - { - if (parameters == null) - { - return null; - } - - return(parameters.entrySet()); - - } - - public void printAsGv(PrintStream pstr) - { - - if (visited) - { - return; - } - else - { - visited = true; - } - - StringBuffer sbuff = new StringBuffer(); - - sbuff.append("node"); - sbuff.append(nodeId); - sbuff.append(" [ shape=none, margin=0, label=<"); - sbuff.append(""); - - if (nodeName.length() > 0) - { - sbuff.append(""); - } - - Set> attrSet = attributes.entrySet(); - for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) - { - Map.Entry curAttr = iter.next(); - sbuff.append(""); - } - sbuff.append("
"); - sbuff.append(nodeId); - sbuff.append(" : "); - sbuff.append(nodeType); - sbuff.append("
AttributeValue
name"); - sbuff.append(nodeName); - sbuff.append("
"); - sbuff.append(curAttr.getKey()); - sbuff.append(""); - sbuff.append(StringEscapeUtils.escapeHtml3(curAttr.getValue().toString())); - sbuff.append("
>];"); - - pstr.println(sbuff.toString()); - - - if (outcomes != null) - { - TreeMap sortedOutcomes = new TreeMap(outcomes); - Set> outcomeSet = sortedOutcomes.entrySet(); - - for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) - { - Map.Entry curOutcome = iter.next(); - String outValue = curOutcome.getKey(); - SvcLogicNode outNode = curOutcome.getValue(); - pstr.println("node"+nodeId+" -> node"+outNode.getNodeId()+" [label=\""+outValue+"\"];"); - outNode.printAsGv(pstr); - } - } - } - - public void printAsXml(PrintStream pstr, int indentLvl) - { - if (visited) - { - return; - } - // Print node tag - for (int i = 0 ; i < indentLvl ; i++) - { - pstr.print(" "); - } - pstr.print("<"); - pstr.print(this.getNodeType()); - - Set> attrSet = attributes.entrySet(); - for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) - { - Map.Entry curAttr = iter.next(); - pstr.print(" "); - pstr.print(curAttr.getKey()); - pstr.print("='`"); - pstr.print(curAttr.getValue()); - pstr.print("'`"); - } - - if (((parameters == null) || (parameters.isEmpty())) && - ((outcomes == null) || outcomes.isEmpty())) - { - pstr.print("/>\n"); - pstr.flush(); - return; - } - else - { - pstr.print(">\n"); - } - - // Print parameters (if any) - if (parameters != null) - { - Set> paramSet = parameters.entrySet(); - for (Iterator> iter = paramSet.iterator() ; iter.hasNext();) - { - for (int i = 0 ; i < indentLvl+1 ; i++) - { - pstr.print(" "); - } - pstr.print(" curAttr = iter.next(); - pstr.print(" name='"); - pstr.print(curAttr.getKey()); - pstr.print("' value='`"); - pstr.print(curAttr.getValue().toString()); - pstr.print("`'/>\n"); - } - } - - // Print outcomes (if any) - if (outcomes != null) - { - Set> outcomeSet = outcomes.entrySet(); - for (Iterator> iter = outcomeSet.iterator() ; iter.hasNext();) - { - for (int i = 0 ; i < indentLvl+1 ; i++) - { - pstr.print(" "); - } - pstr.print(" curAttr = iter.next(); - pstr.print(" value='"); - pstr.print(curAttr.getKey()); - pstr.print("'>\n"); - SvcLogicNode outNode = curAttr.getValue(); - outNode.printAsXml(pstr, indentLvl+2); - for (int i = 0 ; i < indentLvl+1 ; i++) - { - pstr.print(" "); - } - pstr.print("\n"); - } - } - - // Print node end tag - for (int i = 0 ; i < indentLvl ; i++) - { - pstr.print(" "); - } - pstr.print("\n"); - pstr.flush(); - - } - - - public SvcLogicNode getOutcomeValue(String value) - { - - if (value.length() == 0) { - value = "\"\""; - } - if (outcomes == null) - { - return(null); - } - - if (outcomes.containsKey(value)) - { - return(outcomes.get(value)); - } - else - { - StringBuffer keyBuffer = new StringBuffer(); - keyBuffer.append("{"); - for (String key : outcomes.keySet()) { - keyBuffer.append(" ("+key+")"); - } - keyBuffer.append("}"); - LOG.info("Outcome (" + value + ") not found, keys are " + keyBuffer.toString()); - - if (outcomes.containsKey("Other")) - { - return(outcomes.get("Other")); - } - else - { - return(null); - } - } - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java deleted file mode 100644 index 398c28de7..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParser.java +++ /dev/null @@ -1,598 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.util.LinkedList; - -import javax.xml.XMLConstants; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xml.sax.Attributes; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXParseException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * @author dt5972 - * - */ -public class SvcLogicParser { - - SvcLogicStore store = null; - static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; - static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; - static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; - static final String JAXP_DYNAMIC_VALIDATION = "http://apache.org/xml/features/validation/dynamic"; - static final String JAXP_SCHEMA_VALIDATION = "http://apache.org/xml/features/validation/schema"; - - private static final String LOAD_MESSAGE = "Getting SvcLogicGraph from database - "; - private static final String LOAD_ERROR_MESSAGE = "SvcLogicGraph not found - "; - private static final String ACTIVATION_ERROR_MESSAGE = "Could not activate SvcLogicGraph - "; - private static final String PRINT_ERROR_MESSAGE = "Could not print SvcLogicGraph - "; - private static final String SVC_LOGIC_STORE_ERROR = "Could not get service logic store"; - - private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicParser.class); - private static final String SLI_VALIDATING_PARSER = "org.openecomp.sdnc.sli.parser.validate"; - private static final String SVCLOGIC_XSD = "/svclogic.xsd"; - - private class SvcLogicHandler extends DefaultHandler { - private Locator locator = null; - private String module = null; - private String version = null; - private LinkedList graphs = null; - private SvcLogicGraph curGraph = null; - private SvcLogicNode curNode = null; - private LinkedList nodeStack = null; - private int curNodeId = 0; - private String outcomeValue = null; - private LinkedList outcomeStack = null; - private SvcLogicStore svcLogicStore = null; - - public SvcLogicHandler(LinkedList graphs, SvcLogicStore store) { - this.graphs = graphs; - this.curNode = null; - this.nodeStack = new LinkedList<>(); - this.outcomeStack = new LinkedList<>(); - this.curNodeId = 1; - this.outcomeValue = null; - this.svcLogicStore = store; - - } - - @Override - public void setDocumentLocator(Locator locator) { - this.locator = locator; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - - // Handle service-logic (graph) tag - if ("service-logic".equalsIgnoreCase(qName)) { - - module = attributes.getValue("module"); - if (module == null || module.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'module' attribute from service-logic tag"); - } - - version = attributes.getValue("version"); - if (version == null || version.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'version' attribute from service-logic tag"); - } - - return; - } - - if ("method".equalsIgnoreCase(qName)) { - if (curGraph != null) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot nest module tags"); - } - curGraph = new SvcLogicGraph(); - curGraph.setModule(module); - curGraph.setVersion(version); - this.curNodeId = 1; - - String attrValue = attributes.getValue("rpc"); - if (attrValue == null || attrValue.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'rpc' attribute for method tag"); - } - curGraph.setRpc(attrValue); - - attrValue = attributes.getValue("mode"); - if (attrValue == null || attrValue.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'mode' attribute for method tag"); - } - curGraph.setMode(attrValue); - - return; - - } - - // Handle outcome (edge) tag - if ("outcome".equalsIgnoreCase(qName)) { - String refValue = attributes.getValue("ref"); - - if (refValue != null) { - SvcLogicNode refNode = curGraph.getNamedNode(refValue); - - if (refNode != null) { - try { - curNode.addOutcome(attributes.getValue("value"), refNode); - } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot add outcome", e); - } - } else { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "ref to unknown node " + refValue); - } - return; - } - - if (outcomeValue != null) { - outcomeStack.push(outcomeValue); - } - outcomeValue = attributes.getValue("value"); - - return; - } - - // Handle parameter tag - if ("parameter".equalsIgnoreCase(qName)) { - String parmName = attributes.getValue("name"); - String parmValue = attributes.getValue("value"); - - if (parmName != null && parmName.length() > 0 && parmValue != null) { - try { - - curNode.mapParameter(parmName, parmValue); - } catch (Exception e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + " cannot set parameter " + parmName + " to " + parmValue + " [" + e.getMessage() + "]"); - } - } - - return; - } - - // Handle node tags - - String nodeName = attributes.getValue("name"); - SvcLogicNode thisNode = null; - - try { - if (!svcLogicStore.isValidNodeType(qName)) { - throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Unknown tag " + qName); - } - } catch (Exception e) { - throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot validate node type " + qName); - } - - try { - if (nodeName != null && nodeName.length() > 0) { - thisNode = new SvcLogicNode(curNodeId++, qName, nodeName, curGraph); - } else { - thisNode = new SvcLogicNode(curNodeId++, qName, curGraph); - } - - if (curGraph.getRootNode() == null) { - curGraph.setRootNode(thisNode); - } - } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); - - } - - int numAttributes = attributes.getLength(); - - for (int i = 0; i < numAttributes; i++) { - String attrName = attributes.getQName(i); - if (!"name".equalsIgnoreCase(attrName)) { - try { - - String attrValueStr = attributes.getValue(i); - SvcLogicExpression attrValue = null; - if (attrValueStr.trim().startsWith("`")) { - int lastParen = attrValueStr.lastIndexOf("`"); - String evalExpr = attrValueStr.trim().substring(1, lastParen); - attrValue = SvcLogicExpressionFactory.parse(evalExpr); - - } else { - if (Character.isDigit(attrValueStr.charAt(0))) { - attrValue = new SvcLogicAtom("NUMBER", attrValueStr); - } else { - attrValue = new SvcLogicAtom("STRING", attrValueStr); - } - } - thisNode.setAttribute(attrName, attrValue); - } catch (Exception e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot set attribute " + attrName, e); - } - } - } - - if (curNode != null) { - try { - if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) || "while".equalsIgnoreCase(curNode.getNodeType())) { - curNode.addOutcome("" + (curNode.getNumOutcomes() + 1), thisNode); - } else { - if (outcomeValue == null) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType()); - } - curNode.addOutcome(outcomeValue, thisNode); - } - } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); - } - nodeStack.push(curNode); - } - curNode = thisNode; - - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - - // Handle close of service-logic tag - if ("service-logic".equalsIgnoreCase(qName)) { - // Nothing more to do - return; - } - - // Handle close of method tag - if ("method".equalsIgnoreCase(qName)) { - graphs.add(curGraph); - curGraph = null; - return; - } - - // Handle close of outcome tag - if ("outcome".equalsIgnoreCase(qName)) { - // Finished this outcome - pop the outcome stack - if (outcomeStack.isEmpty()) { - outcomeValue = null; - } else { - outcomeValue = outcomeStack.pop(); - } - return; - } - - // Handle close of parameter tag - do nothing - if ("parameter".equalsIgnoreCase(qName)) { - return; - } - - // Handle close of a node tag - if (nodeStack.isEmpty()) { - curNode = null; - } else { - curNode = nodeStack.pop(); - } - } - - @Override - public void error(SAXParseException arg0) throws SAXException { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + arg0.getMessage()); - } - - } - - public SvcLogicParser(SvcLogicStore store) { - this.store = store; - } - - public SvcLogicParser(String propFile) { - - try { - this.store = SvcLogicStoreFactory.getSvcLogicStore(propFile); - } catch (Exception e) { - LOGGER.error(SVC_LOGIC_STORE_ERROR, e); - - } - - } - - public SvcLogicParser(InputStream propStr) { - - try { - this.store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - } catch (Exception e) { - LOGGER.error(SVC_LOGIC_STORE_ERROR, e); - - } - - } - - public LinkedList parse(String fileName) throws SvcLogicException { - LinkedList graphs = null; - - URL xsdUrl = null; - Schema schema = null; - String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true"); - - if (validateSchema != null || validateSchema.equalsIgnoreCase("true")) { - xsdUrl = getClass().getResource(SVCLOGIC_XSD); - - } - - if (xsdUrl != null) { - try { - SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - schema = schemaFactory.newSchema(xsdUrl); - } catch (Exception e) { - LOGGER.warn("Could not validate using schema " + xsdUrl.getPath(), e); - } - } else { - LOGGER.warn("Could not find resource " + SVCLOGIC_XSD); - } - - try { - SAXParserFactory factory = SAXParserFactory.newInstance(); - - if (schema != null) { - factory.setNamespaceAware(true); - factory.setSchema(schema); - } - SAXParser saxParser = factory.newSAXParser(); - - if (saxParser.isValidating()) { - LOGGER.info("Validating against schema " + xsdUrl.getPath()); - } - graphs = new LinkedList<>(); - - saxParser.parse(fileName, new SvcLogicHandler(graphs, store)); - - } catch (Exception e) { - String msg = e.getMessage(); - if (msg != null) { - LOGGER.error(msg); - throw new SvcLogicException("Compiler error: " + fileName + " @ " + msg); - } else { - LOGGER.info("Caught exception parsing " + fileName, e); - throw new SvcLogicException("Compiler error: " + fileName, e); - } - } - - return graphs; - } - - public static void main(String argv[]) { - - if (argv.length == 0) { - SvcLogicParser.usage(); - } - - if ("load".equalsIgnoreCase(argv[0])) { - if (argv.length == 3) { - String xmlfile = argv[1]; - String propfile = argv[2]; - - SvcLogicStore store = SvcLogicParser.getStore(propfile); - try { - SvcLogicParser.load(xmlfile, store); - } catch (Exception e) { - LOGGER.error(e.getMessage(), e); - } - } else { - SvcLogicParser.usage(); - } - } else if ("print".equalsIgnoreCase(argv[0])) { - String version = null; - String propfile = null; - - switch (argv.length) { - case 6: - version = argv[4]; - propfile = argv[5]; - case 5: - if (propfile == null) { - propfile = argv[4]; - } - SvcLogicStore store = SvcLogicParser.getStore(propfile); - SvcLogicParser.print(argv[1], argv[2], argv[3], version, store); - break; - default: - SvcLogicParser.usage(); - } - } else if ("get-source".equalsIgnoreCase(argv[0])) { - - switch (argv.length) { - case 6: - SvcLogicStore store = SvcLogicParser.getStore(argv[5]); - SvcLogicParser.getSource(argv[1], argv[2], argv[3], argv[4], store); - break; - default: - SvcLogicParser.usage(); - } - } else if ("activate".equalsIgnoreCase(argv[0])) { - if (argv.length == 6) { - SvcLogicStore store = SvcLogicParser.getStore(argv[5]); - SvcLogicParser.activate(argv[1], argv[2], argv[3], argv[4], store); - } else { - SvcLogicParser.usage(); - } - } else if ("validate".equalsIgnoreCase(argv[0])) { - if (argv.length == 3) { - String xmlfile = argv[1]; - String propfile = argv[2]; - - System.setProperty(SLI_VALIDATING_PARSER, "true"); - SvcLogicStore store = SvcLogicParser.getStore(propfile); - try { - SvcLogicParser.validate(xmlfile, store); - } catch (Exception e) { - LOGGER.error(e.getMessage(), e); - } - } else { - SvcLogicParser.usage(); - } - } - - System.exit(0); - } - - private static SvcLogicStore getStore(String propfile) { - - SvcLogicStore store = null; - - try { - store = SvcLogicStoreFactory.getSvcLogicStore(propfile); - } catch (Exception e) { - LOGGER.error(SVC_LOGIC_STORE_ERROR, e); - System.exit(1); - } - - return store; - - } - - public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException { - File xmlFile = new File(xmlfile); - if (!xmlFile.canRead()) { - throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); - } - - SvcLogicParser parser = new SvcLogicParser(store); - LinkedList graphs = null; - try { - graphs = parser.parse(xmlfile); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); - } - - if (graphs == null) { - throw new SvcLogicException("Could not parse " + xmlfile); - } - - for (SvcLogicGraph graph : graphs) { - - String module = graph.getModule(); - String rpc = graph.getRpc(); - String version = graph.getVersion(); - String mode = graph.getMode(); - try { - LOGGER.info("Saving SvcLogicGraph to database (module:" + module + ",rpc:" + rpc + ",version:" + version + ",mode:" + mode + ")"); - store.store(graph); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); - } - - } - - } - - public static void validate(String xmlfile, SvcLogicStore store) throws SvcLogicException { - File xmlFile = new File(xmlfile); - if (!xmlFile.canRead()) { - throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); - } - - SvcLogicParser parser = new SvcLogicParser(store); - LinkedList graphs = null; - try { - LOGGER.info("Validating " + xmlfile); - graphs = parser.parse(xmlfile); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); - } - - if (graphs == null) { - throw new SvcLogicException("Could not parse " + xmlfile); - } else { - LOGGER.info("Compilation successful for " + xmlfile); - } - - } - - private static void print(String module, String rpc, String mode, String version, SvcLogicStore store) { - String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; - - try { - LOGGER.info(LOAD_MESSAGE + details); - - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - if (graph == null) { - LOGGER.error(LOAD_ERROR_MESSAGE + details); - System.exit(1); - } - graph.printAsGv(System.out); - } catch (Exception e) { - LOGGER.error(PRINT_ERROR_MESSAGE + details, e); - System.exit(1); - } - - } - - private static void getSource(String module, String rpc, String mode, String version, SvcLogicStore store) { - String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; - - try { - LOGGER.info(LOAD_MESSAGE + details); - - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - if (graph == null) { - LOGGER.error(LOAD_ERROR_MESSAGE + details); - System.exit(1); - } - graph.printAsXml(System.out); - } catch (Exception e) { - LOGGER.error(PRINT_ERROR_MESSAGE + details, e); - System.exit(1); - } - - } - - private static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) { - String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; - - try { - LOGGER.info(LOAD_MESSAGE + details); - - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - if (graph == null) { - LOGGER.error(LOAD_ERROR_MESSAGE + details); - System.exit(1); - } - store.activate(graph); - } catch (Exception e) { - LOGGER.error(ACTIVATION_ERROR_MESSAGE + details, e); - System.exit(1); - } - - } - - private static void usage() { - System.err.println("Usage: SvcLogicParser load "); - System.err.println(" OR SvcLogicParser print [] "); - System.err.println(" OR SvcLogicParser get-source "); - System.err.println(" OR SvcLogicParser activate "); - System.exit(1); - } - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java deleted file mode 100644 index ac9c515e9..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicParserException.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.IOException; - -public class SvcLogicParserException extends IOException { - - public SvcLogicParserException() { - super(); - } - - public SvcLogicParserException(String msg) { - super(msg); - } - - public SvcLogicParserException(Throwable t) { - super(t); - } - - public SvcLogicParserException(String msg, Throwable t) { - super(msg, t); - } -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java deleted file mode 100644 index 8a23adf1a..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicRecorder.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.util.Map; - -public interface SvcLogicRecorder { - - void record(Map parmMap) throws SvcLogicException; - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java deleted file mode 100644 index 5fc00f87b..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicResource.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.sql.SQLException; -import java.util.Map; - -public interface SvcLogicResource { - - public enum QueryStatus { - SUCCESS, - NOT_FOUND, - FAILURE - } - - public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; - - public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; - - public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, String orderBy, SvcLogicContext ctx) throws SvcLogicException; - - public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException; - - public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map parms, String prefix, SvcLogicContext ctx) throws SvcLogicException; - - public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException; - - public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException; - - public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) throws SvcLogicException; - - public QueryStatus update(String resource, String key, Map parms, String prefix, SvcLogicContext ctx) throws SvcLogicException; - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java deleted file mode 100644 index 6959c86a8..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStore.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.util.Properties; - -public interface SvcLogicStore { - - public void init(Properties props) throws SvcLogicException; - public void registerNodeType(String nodeType) throws SvcLogicException; - public void unregisterNodeType(String nodeType) throws SvcLogicException; - public boolean isValidNodeType(String nodeType) throws SvcLogicException; - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; - public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException; - public void store(SvcLogicGraph graph) throws SvcLogicException; - public void delete(String module, String rpc, String version, String mode) throws SvcLogicException; - public void activate(SvcLogicGraph graph) throws SvcLogicException; -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java deleted file mode 100644 index 8b6618bef..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicStoreFactory.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.Properties; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SvcLogicStoreFactory { - - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicStoreFactory.class); - - public static SvcLogicStore getSvcLogicStore(String propfile) - throws SvcLogicException { - File propFile = new File(propfile); - if (!propFile.canRead()) { - throw new ConfigurationException("Cannot read property file " - + propfile); - - } - - try { - return (getSvcLogicStore(new FileInputStream(propFile))); - } catch (Exception e) { - throw new ConfigurationException( - "Could load service store from properties file " + propfile, - e); - } - - } - - public static SvcLogicStore getSvcLogicStore(InputStream inStr) throws SvcLogicException - { - Properties props = new Properties(); - - try { - props.load(inStr); - } catch (Exception e) { - throw new ConfigurationException("Could not get load properties from input stream", e); - } - - return(getSvcLogicStore(props)); - } - - public static SvcLogicStore getSvcLogicStore(Properties props) - throws SvcLogicException { - String storeType = props.getProperty("org.openecomp.sdnc.sli.dbtype"); - if ((storeType == null) || (storeType.length() == 0)) { - throw new ConfigurationException( - "property org.openecomp.sdnc.sli.dbtype unset"); - - } - - SvcLogicStore retval = null; - LOG.debug(String.format("Using org.openecomp.sdnc.sli.dbtype=%s", storeType)); - - if ("jdbc".equalsIgnoreCase(storeType)) { - retval = new SvcLogicJdbcStore(); - - } else if ("dblib".equalsIgnoreCase(storeType)) { - retval = new SvcLogicDblibStore(); - } else { - throw new ConfigurationException("unsupported dbtype (" + storeType - + ")"); - - } - - - retval.init(props); - return (retval); - } - -} diff --git a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java b/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java deleted file mode 100644 index 9ddc3c0b8..000000000 --- a/sli/common/src/main/java/org/openecomp/sdnc/sli/SvcLogicVariableTerm.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -public class SvcLogicVariableTerm extends SvcLogicExpression { - - private String name = null; - - public String getName() { - return name; - } - - - public SvcLogicVariableTerm(String identifier) - { - this.name = identifier; - } - - public SvcLogicExpression getSubscript() - { - if (numOperands() > 0) - { - return(getOperands().get(0)); - } - else - { - return(null); - } - } - - - public String toString() - { - String retval = ""; - - if (numOperands() > 0) - { - retval = name + "[" + getSubscript().toString() + "]"; - } - else - { - retval = name; - } - return(retval); - } - - @Override - public String asParsedExpr() { - if (numOperands() == 0) { - return("(variable-term "+name+")"); - } - else - { - return("(variable-term "+name+" "+getSubscript().asParsedExpr()+")"); - } - } - -} diff --git a/sli/common/src/main/resources/crAseNetwork.sql b/sli/common/src/main/resources/crAseNetwork.sql index 412311761..d95891ae1 100644 --- a/sli/common/src/main/resources/crAseNetwork.sql +++ b/sli/common/src/main/resources/crAseNetwork.sql @@ -1,9 +1,8 @@ --- -- ============LICENSE_START======================================================= --- openECOMP : SDN-C +-- ONAP : CCSDK -- ================================================================================ --- Copyright (C) 2017 AT&T Intellectual Property. All rights --- reserved. +-- Copyright (C) 2017 ONAP -- ================================================================================ -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java new file mode 100644 index 000000000..123083a74 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Enumeration; +import java.util.Properties; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; + +import junit.framework.TestCase; + +public class SvcLogicContextTest extends TestCase { + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicContext.class); + + public void testMerge() { + + try { + InputStream testStr = getClass().getResourceAsStream("/mergetest.xml"); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + Document theDocument = db.parse(testStr); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.mergeDocument("test-merge", theDocument); + Properties props = ctx.toProperties(); + LOG.info("SvcLogicContext contains the following : "); + for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) { + String propName = (String) e.nextElement(); + LOG.info(propName+" = "+props.getProperty(propName)); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to merge", e); + fail("Caught exception trying to merge"); + } + + } + +} diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java new file mode 100644 index 000000000..543bb1be3 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.onap.ccsdk.sli.core.sli.SvcLogicExprListener; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.TestCase; + +public class SvcLogicExpressionParserTest extends TestCase { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExprListener.class); + + public void testParse() { + try + { + InputStream testStr = getClass().getResourceAsStream("/expression.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + String testExpr = null; + while ((testExpr = testsReader.readLine()) != null) { + + SvcLogicExpression parsedExpr = SvcLogicExpressionFactory.parse(testExpr); + if (parsedExpr == null) + { + fail("parse("+testExpr+") returned null"); + } + else + { + LOG.info("test expression = ["+testExpr+"] ; parsed expression = ["+parsedExpr.asParsedExpr()+"]"); + + } + } + } + catch (Exception e) + { + e.printStackTrace(); + fail("Caught exception processing test cases"); + } + } + +} diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java new file mode 100644 index 000000000..2da8dd4f8 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.LinkedList; + +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.SvcLogicParserException; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; + +import junit.framework.TestCase; + +/** + * @author dt5972 + * + */ +public class SvcLogicParserTest extends TestCase { + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}. + */ + + + public void testParse() { + + + try + { + + URL propUrl = getClass().getResource("/svclogic.properties"); + + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + + assertNotNull(store); + + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + + + InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + String testCaseFile = null; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) + { + if (!testCaseFile.startsWith("/")) + { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) + { + fail("Could not resolve test case file "+testCaseFile); + } + + try { + SvcLogicParser.validate(testCaseUrl.getPath(), store); + } catch (Exception e) { + fail("Validation failure ["+e.getMessage()+"]"); + + } + + + + + + } + } + + testStr = getClass().getResourceAsStream("/parser-bad.tests"); + testsReader = new BufferedReader(new InputStreamReader(testStr)); + testCaseFile = null; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) + { + if (!testCaseFile.startsWith("/")) + { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) + { + fail("Could not resolve test case file "+testCaseFile); + } + + boolean valid = true; + try { + SvcLogicParser.load(testCaseUrl.getPath(), store); + } catch (Exception e) { + System.out.println(e.getMessage()); + valid = false; + } + + if (valid) { + fail("Expected compiler error on "+testCaseFile+", but got success"); + } + + + } + } + } + catch (SvcLogicParserException e) + { + fail("Parser error : "+e.getMessage()); + } + catch (Exception e) + { + e.printStackTrace(); + fail("Caught exception processing test cases"); + } + + + } + + + +} diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java deleted file mode 100644 index 6e6656e89..000000000 --- a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicContextTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Enumeration; -import java.util.Properties; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; - -import junit.framework.TestCase; - -public class SvcLogicContextTest extends TestCase { - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicContext.class); - - public void testMerge() { - - try { - InputStream testStr = getClass().getResourceAsStream("/mergetest.xml"); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - - Document theDocument = db.parse(testStr); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.mergeDocument("test-merge", theDocument); - Properties props = ctx.toProperties(); - LOG.info("SvcLogicContext contains the following : "); - for (Enumeration e = props.propertyNames(); e.hasMoreElements() ; ) { - String propName = (String) e.nextElement(); - LOG.info(propName+" = "+props.getProperty(propName)); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to merge", e); - fail("Caught exception trying to merge"); - } - - } - -} diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java deleted file mode 100644 index d6503b60c..000000000 --- a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicExpressionParserTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; - -import org.openecomp.sdnc.sli.SvcLogicExprListener; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicExpressionFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import junit.framework.TestCase; - -public class SvcLogicExpressionParserTest extends TestCase { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicExprListener.class); - - public void testParse() { - try - { - InputStream testStr = getClass().getResourceAsStream("/expression.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - - String testExpr = null; - while ((testExpr = testsReader.readLine()) != null) { - - SvcLogicExpression parsedExpr = SvcLogicExpressionFactory.parse(testExpr); - if (parsedExpr == null) - { - fail("parse("+testExpr+") returned null"); - } - else - { - LOG.info("test expression = ["+testExpr+"] ; parsed expression = ["+parsedExpr.asParsedExpr()+"]"); - - } - } - } - catch (Exception e) - { - e.printStackTrace(); - fail("Caught exception processing test cases"); - } - } - -} diff --git a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java b/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java deleted file mode 100644 index e8ff2feeb..000000000 --- a/sli/common/src/test/java/org/openecomp/sdnc/sli/SvcLogicParserTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * ============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========================================================= - */ - -/** - * - */ -package org.openecomp.sdnc.sli; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.LinkedList; - -import org.openecomp.sdnc.sli.SvcLogicParser; -import org.openecomp.sdnc.sli.SvcLogicParserException; -import org.openecomp.sdnc.sli.SvcLogicStore; -import org.openecomp.sdnc.sli.SvcLogicStoreFactory; - -import junit.framework.TestCase; - -/** - * @author dt5972 - * - */ -public class SvcLogicParserTest extends TestCase { - - /** - * Test method for {@link org.openecomp.sdnc.sli.SvcLogicParser#parse(java.lang.String)}. - */ - - - public void testParse() { - - - try - { - - URL propUrl = getClass().getResource("/svclogic.properties"); - - InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - - assertNotNull(store); - - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); - - - InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - String testCaseFile = null; - while ((testCaseFile = testsReader.readLine()) != null) { - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) - { - if (!testCaseFile.startsWith("/")) - { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) - { - fail("Could not resolve test case file "+testCaseFile); - } - - try { - SvcLogicParser.validate(testCaseUrl.getPath(), store); - } catch (Exception e) { - fail("Validation failure ["+e.getMessage()+"]"); - - } - - - - - - } - } - - testStr = getClass().getResourceAsStream("/parser-bad.tests"); - testsReader = new BufferedReader(new InputStreamReader(testStr)); - testCaseFile = null; - while ((testCaseFile = testsReader.readLine()) != null) { - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) - { - if (!testCaseFile.startsWith("/")) - { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) - { - fail("Could not resolve test case file "+testCaseFile); - } - - boolean valid = true; - try { - SvcLogicParser.load(testCaseUrl.getPath(), store); - } catch (Exception e) { - System.out.println(e.getMessage()); - valid = false; - } - - if (valid) { - fail("Expected compiler error on "+testCaseFile+", but got success"); - } - - - } - } - } - catch (SvcLogicParserException e) - { - fail("Parser error : "+e.getMessage()); - } - catch (Exception e) - { - e.printStackTrace(); - fail("Caught exception processing test cases"); - } - - - } - - - -} diff --git a/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml index 097078a8a..308bda1e9 100644 --- a/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml +++ b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml @@ -1,10 +1,9 @@ - org.openecomp.sdnc.sli;version="${project.version}",* + org.onap.ccsdk.sli.core.sli;version="${project.version}",* diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java new file mode 100644 index 000000000..7132950f3 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BlockNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(BlockNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + SvcLogicExpression atomicExpr = node.getAttribute("atomic"); + String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); + boolean isAtomic = "true".equalsIgnoreCase(atomicStr); + + // Initialize status to success so that at least one outcome will execute + ctx.setStatus("success"); + + int numOutcomes = node.getNumOutcomes(); + + for (int i = 0; i < numOutcomes; i++) { + if ("failure".equals(ctx.getStatus()) && isAtomic) { + LOG.info("Block - stopped executing nodes due to failure status"); + return(null); + } + + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Block - executing outcome " + (i + 1)); + } + while (nextNode != null) + { + nextNode = svc.executeNode(nextNode, ctx); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("Block - done: no outcome " + (i + 1)); + } + } + } + + return (null); + } + + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java new file mode 100644 index 000000000..ec0a5daa0 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.BreakNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BreakNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(BreakNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + String message = "BreakNodeExecutor encountered break with nodeId " + node.getNodeId(); + LOG.debug(message); + throw new BreakNodeException(message); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java new file mode 100644 index 000000000..9498d6768 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java @@ -0,0 +1,164 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CallNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(CallNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String outValue = "not-found"; + + SvcLogicGraph myGraph = node.getGraph(); + + if (myGraph == null) + { + LOG.debug("execute: getGraph returned null"); + } + else + { + LOG.debug("execute: got SvcLogicGraph"); + } + + SvcLogicExpression moduleExpr = null; + + String module = null; + + moduleExpr = node.getAttribute("module"); + if (moduleExpr != null) + { + module = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + if ((module == null) || (module.length() == 0)) + { + if (myGraph != null) + { + module = myGraph.getModule(); + LOG.debug("myGraph.getModule() returned "+module); + } + } + + SvcLogicExpression rpcExpr = null; + String rpc = null; + rpcExpr = node.getAttribute("rpc"); + if (rpcExpr != null) + { + rpc = SvcLogicExpressionResolver.evaluate(rpcExpr, node, ctx); + } + + if ((rpc == null) || (rpc.length() == 0)) + { + if (myGraph != null) + { + rpc = myGraph.getRpc(); + LOG.debug("myGraph.getRpc() returned "+rpc); + } + } + + String mode = null; + + moduleExpr = node.getAttribute("mode"); + if (moduleExpr != null) + { + mode = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + if ((mode == null) || (mode.length() == 0)) + { + if (myGraph != null) + { + mode = myGraph.getMode(); + + LOG.debug("myGraph.getMode() returned "+mode); + } + } + + String version = null; + + moduleExpr = node.getAttribute("version"); + if (moduleExpr != null) + { + version = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + String parentGraph = ctx.getAttribute("currentGraph"); + ctx.setAttribute("parentGraph", parentGraph); + + SvcLogicStore store = getStore(); + + if (store != null) { + SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); + LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); + ctx.setAttribute("currentGraph", calledGraph.toString()); + if (calledGraph != null) { + svc.execute(calledGraph, ctx); + + outValue = ctx.getStatus(); + } else { + LOG.error("Could not find service logic for [" + module + "," + rpc + "," + version + "," + mode + "]"); + } + } + else + { + LOG.debug("Could not get SvcLogicStore reference"); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + ctx.setAttribute("currentGraph", parentGraph); + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + ctx.setAttribute("currentGraph", parentGraph); + ctx.setAttribute("parentGraph", null); + + return (nextNode); + + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java new file mode 100644 index 000000000..21b63d4fa --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java @@ -0,0 +1,247 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConfigureNodeExecutor extends SvcLogicNodeExecutor { + private static final Logger LOG = LoggerFactory + .getLogger(ConfigureNodeExecutor.class); + + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String adaptorName = SvcLogicExpressionResolver.evaluate( + node.getAttribute("adaptor"), node, ctx); + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("configure node encountered - looking for adaptor " + + adaptorName); + } + + SvcLogicAdaptor adaptor = getAdaptor(adaptorName); + + if (adaptor != null) { + String activate = SvcLogicExpressionResolver.evaluate( + node.getAttribute("activate"), node, ctx); + String key = SvcLogicExpressionResolver.evaluate( + node.getAttribute("key"), node, ctx); + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); + + parmMap.put(curName,curExprValue); + } + + if (hasParms) { + SvcLogicAdaptor.ConfigStatus confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + confStatus = adaptor.configure(key, parmMap, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".configure", e); + confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + + switch (confStatus) { + case SUCCESS: + outValue = "success"; + if ((activate != null) && (activate.length() > 0)) { + if ("true".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + activateStatus = adaptor.activate(key, ctx); + } catch (Exception e) { + + LOG.warn("Caught exception from "+adaptorName+".activate", e); + activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (activateStatus) { + case SUCCESS: + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else if ("false".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + deactivateStatus = adaptor.deactivate(key, ctx); + } catch (Exception e) { + + LOG.warn("Caught exception from "+adaptorName+".deactivate", e); + deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (deactivateStatus) { + case SUCCESS: + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } + } + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else { + if ((activate != null) && (activate.length() > 0)) { + if ("true".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + try { + activateStatus = adaptor.activate(key, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".activate", e); + activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (activateStatus) { + case SUCCESS: + outValue = "success"; + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else if ("false".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + deactivateStatus = adaptor.deactivate(key, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".deactivate", e); + deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (deactivateStatus) { + case SUCCESS: + outValue = "success"; + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } + } else { + LOG.warn("Nothing to configure - no parameters passed, and activate attribute is not set"); + outValue = "success"; + } + } + } else { + if (LOG.isWarnEnabled()) { + LOG.warn("Adaptor for " + adaptorName + " not found"); + } + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java new file mode 100644 index 000000000..caba0943f --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DeleteNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(DeleteNodeExecutor.class); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("delete node encountered - looking for resource class " + + plugin); + } + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + + try { + + switch (resourcePlugin.delete(resourceType, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java new file mode 100644 index 000000000..19868ed75 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExecuteNodeExecutor extends SvcLogicNodeExecutor { + private static final Logger LOG = LoggerFactory + .getLogger(ExecuteNodeExecutor.class); + + private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure."; + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String pluginName = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("execute node encountered - looking for plugin " + + pluginName); + } + + SvcLogicJavaPlugin plugin = getSvcLogicJavaPlugin(pluginName); + + if (plugin == null) { + outValue = "not-found"; + } else { + + String methodName = evaluate(node.getAttribute("method"), node, ctx); + + Class pluginClass = plugin.getClass(); + + Method pluginMethod = null; + + try { + pluginMethod = pluginClass.getMethod(methodName, Map.class, SvcLogicContext.class); + } catch (NoSuchMethodException e) { + LOG.error(pluginErrorMessage, e); + } + + if (pluginMethod == null) { + outValue = "unsupported-method"; + } else { + try { + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); + + parmMap.put(curName,curExprValue); + } + + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + + outValue = mapOutcome(o, emitsOutcome); + + } catch (InvocationTargetException e) { + if(e.getCause() != null){ + LOG.error(pluginErrorMessage, e.getCause()); + }else{ + LOG.error(pluginErrorMessage, e); + } + outValue = "failure"; + ctx.setStatus("failure"); + } catch (IllegalAccessException e) { + LOG.error(pluginErrorMessage, e); + outValue = "failure"; + ctx.setStatus("failure"); + } catch (IllegalArgumentException e) { + LOG.error(pluginErrorMessage, e); + outValue = "failure"; + ctx.setStatus("failure"); + } + } + + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + return (nextNode); + } + + protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + return SvcLogicExpressionResolver.evaluate(node.getAttribute("method"), node, ctx); + } + + public String mapOutcome(Object o, String emitsOutcome) { + if (emitsOutcome != null) { + Boolean nodeEmitsOutcome = Boolean.valueOf(emitsOutcome); + if (nodeEmitsOutcome) { + return (String) o; + } else { + return "success"; + } + + } else { + return "success"; + } + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java new file mode 100644 index 000000000..1798d50a9 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExistsNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ExistsNodeExecutor.class); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("exists node encountered - looking for resource class " + + plugin); + } + + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + + switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) { + case SUCCESS: + outValue = "true"; + break; + case NOT_FOUND: + outValue = "false"; + break; + case FAILURE: + default: + outValue = "false"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java new file mode 100644 index 000000000..a9ee00768 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.BreakNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ForNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ForNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + SvcLogicExpression atomicExpr = node.getAttribute("atomic"); + String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); + boolean isAtomic = !("false".equalsIgnoreCase(atomicStr)); + + int numOutcomes = node.getNumOutcomes(); + String idxVar = SvcLogicExpressionResolver.evaluate( + node.getAttribute("index"), node, ctx); + String startVal = SvcLogicExpressionResolver.evaluate( + node.getAttribute("start"), node, ctx); + String endVal = SvcLogicExpressionResolver.evaluate( + node.getAttribute("end"), node, ctx); + + LOG.debug("Executing "+ (isAtomic ? "atomic" : "non-atomic") + " for loop - for (int " + idxVar + " = " + startVal + + "; " + idxVar + " < " + endVal + "; " + idxVar + "++)"); + + int startIdx = 0; + int endIdx = 0; + + try { + startIdx = Integer.parseInt(startVal); + endIdx = Integer.parseInt(endVal); + } catch (NumberFormatException e) { + SvcLogicExpression silentFailureExpr = node.getAttribute("silentFailure"); + String silentFailure = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); + boolean isSilentFailure = Boolean.parseBoolean(silentFailure); + String message = "Invalid index values [" + startVal + "," + endVal + "]"; + if(!isSilentFailure){ + throw new SvcLogicException(message); + }else{ + LOG.debug(message + ". Not exiting because silentFailure was set to true."); + return(null); + } + } + + try { + for (int ctr = startIdx; ctr < endIdx; ctr++) { + + ctx.setAttribute(idxVar, "" + ctr); + + for (int i = 0; i < numOutcomes; i++) { + + if ("failure".equals(ctx.getStatus()) && isAtomic) { + LOG.info("For - stopped executing nodes due to failure status"); + return(null); + } + + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("For - executing outcome " + (i + 1)); + } + SvcLogicNode innerNextNode = nextNode; + while (innerNextNode != null) { + innerNextNode = svc.executeNode(innerNextNode, ctx); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("For - done: no outcome " + (i + 1)); + } + } + } + } + } catch (BreakNodeException br) { + LOG.debug("ForNodeExecutor caught break"); + } + return (null); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java new file mode 100644 index 000000000..7ecc76c51 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java @@ -0,0 +1,133 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GetResourceNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(GetResourceNodeExecutor.class); + + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + String localOnlyStr = SvcLogicExpressionResolver.evaluate( + node.getAttribute("local-only"), node, ctx); + + // Note: for get-resource, only refresh from A&AI if the DG explicitly set + // local-only to false. Otherwise, just read from local database. + boolean localOnly = true; + + if ("false".equalsIgnoreCase(localOnlyStr)) { + localOnly = false; + } + + SvcLogicExpression selectExpr = node.getAttribute("select"); + String select = null; + + if (selectExpr != null) { + select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, + ctx); + } + + SvcLogicExpression orderByExpr = node.getAttribute("order-by"); + String orderBy = null; + + if (orderByExpr != null) { + orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, + ctx); + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug(node.getNodeType() + + " node encountered - looking for resource class " + + plugin); + } + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.query(resourceType, localOnly, select, key, + pfx, orderBy, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java new file mode 100644 index 000000000..7bc15d8a2 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(IsAvailableNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("is-available node encountered - looking for resource class " + + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + + if (resourcePlugin != null) { + try { + switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) { + case SUCCESS: + outValue = "true"; + break; + case NOT_FOUND: + outValue = "false"; + break; + case FAILURE: + default: + outValue = "false"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java new file mode 100644 index 000000000..a35c05243 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -0,0 +1,1185 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yangtools.yang.binding.Identifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MdsalHelper { + + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); + private static Properties yangMappingProperties = new Properties(); + + @Deprecated + public static void setProperties(Properties input) { + setYangMappingProperties(input); + } + + public static void setYangMappingProperties(Properties properties) { + for (Object propNameObj : properties.keySet()) { + String propName = (String) propNameObj; + MdsalHelper.yangMappingProperties.setProperty(propName, properties.getProperty(propName)); + } + } + + public static void loadProperties(String propertiesFile) { + File file = new File(propertiesFile); + Properties properties = new Properties(); + InputStream input = null; + if (file.isFile() && file.canRead()) { + try { + input = new FileInputStream(file); + properties.load(input); + MdsalHelper.setYangMappingProperties(properties); + LOG.info("Loaded properties from " + propertiesFile); + } catch (Exception e) { + LOG.error("Failed to load properties " + propertiesFile + "\n", e); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + LOG.error("Failed to close properties file " + propertiesFile + "\n", e); + } + } + } + }else{ + LOG.error("Failed to load the properties file " + propertiesFile + "\n"); + LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); + } + } + + public static Properties toProperties(Properties props, Object fromObj) { + Class fromClass = null; + + if (fromObj != null) { + fromClass = fromObj.getClass(); + } + return (toProperties(props, "", fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj) { + Class fromClass = null; + + if (fromObj != null) { + fromClass = fromObj.getClass(); + } + + return (toProperties(props, pfx, fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { + + if (fromObj == null) { + return (props); + } + + String simpleName = fromClass.getSimpleName(); + + LOG.trace("Extracting properties from " + fromClass.getName() + " class"); + if (fromObj instanceof List) { + + // Class is a List. List should contain yang-generated classes. + LOG.trace(fromClass.getName() + " is a List"); + + List fromList = (List) fromObj; + + for (int i = 0; i < fromList.size(); i++) { + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); + } + props.setProperty(pfx + "_length", "" + fromList.size()); + + } else if (isYangGenerated(fromClass)) { + // Class is yang generated. + LOG.trace(fromClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + + // If called from a list (so prefix ends in ']'), don't + // add class name again + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx; + } else { + propNamePfx = toLowerHyphen(fromClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // save from + + int numGetters = 0; + String lastGetterName = null; + String propVal = null; + + for (Method m : fromClass.getMethods()) { + if (isGetter(m)) { + + numGetters++; + lastGetterName = m.getName(); + + Class returnType = m.getReturnType(); + String fieldName; + if (m.getName().startsWith("get")) { + fieldName = toLowerHyphen(m.getName().substring(3)); + } else { + + fieldName = toLowerHyphen(m.getName().substring(2)); + } + + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + // Is the return type a yang generated class? + if (isYangGenerated(returnType)) { + // Is it an enum? + if (returnType.isEnum()) { + // Return type is a typedef. Save its value. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + Object retValue = m.invoke(fromObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + String propName = propNamePfx + "." + fieldName; + propVal = retValue.toString(); + props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert Yang-generated enum returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpv4Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = retValue.getValue().toString(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpv6Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = retValue.getValue().toString(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpAddress(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + IpAddress retValue = (IpAddress) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = new String(retValue.getValue()); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpPrefix(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + IpPrefix retValue = (IpPrefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = new String(retValue.getValue()); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + + if (retValue instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + retValue = new String((byte[]) retValue, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + retValue); + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); + } + } catch (Exception e) { + + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert Yang-generated class returned by" + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } else if (returnType.equals(Class.class)) { + + LOG.trace(m.getName() + " returns a Class object - not interested"); + + } else if (List.class.isAssignableFrom(returnType)) { + + // This getter method returns a list. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retList = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + // Figure out what type of elements are stored in + // this array. + Type paramType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + + } else { + + // Method returns something that is not a List and not + // yang-generated. + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object propValObj = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (propValObj != null) { + if (propValObj instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + propVal = new String((byte[]) propValObj, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + propVal); + + } else { + propVal = propValObj.toString(); + } + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + + } + } + + // End of method loop. If there was only one getter, named + // "getValue", then + // set value identified by "prefix" to that one value. + if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { + LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + " = " + propVal); + props.setProperty(propNamePfx, propVal); + } else { + LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " + lastGetterName); + + } + + } else { + // Class is not yang generated and not a list + // It must be an element of a leaf list - set "prefix" to value + String fromVal = null; + if (fromObj instanceof byte[]) { + try { + fromVal = new String((byte[]) fromObj, "UTF-8"); + LOG.trace("Converted byte array " + pfx + "to string " + fromVal); + } catch (Exception e) { + LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); + fromVal = fromObj.toString(); + } + + } else { + fromVal = fromObj.toString(); + } + LOG.debug("Setting property " + pfx + " to " + fromVal); + props.setProperty(pfx, fromVal); + } + + return (props); + } + + public static Object toBuilder(Properties props, Object toObj) { + + return (toBuilder(props, "", toObj)); + } + + public static List toList(Properties props, String pfx, List toObj, Class elemType) { + + int maxIdx = -1; + boolean foundValue = false; + + LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); + + if (props.contains(pfx + "_length")) { + try { + int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); + + if (listLength > 0) { + maxIdx = listLength - 1; + } + } catch (Exception e) { + // Ignore exception + } + } + + if (maxIdx == -1) { + // Figure out array size + for (Object pNameObj : props.keySet()) { + String key = (String) pNameObj; + + if (key.startsWith(pfx + "[")) { + String idxStr = key.substring(pfx.length() + 1); + int endloc = idxStr.indexOf("]"); + if (endloc != -1) { + idxStr = idxStr.substring(0, endloc); + } + + try { + int curIdx = Integer.parseInt(idxStr); + if (curIdx > maxIdx) { + maxIdx = curIdx; + } + } catch (Exception e) { + LOG.error("Illegal subscript in property " + key); + } + + } + } + } + + LOG.trace(pfx + " has max index of " + maxIdx); + for (int i = 0; i <= maxIdx; i++) { + + String curBase = pfx + "[" + i + "]"; + + if (isYangGenerated(elemType)) { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + LOG.trace("Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class " + builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from " + pfx); + } + } else { + // Must be a leaf list + String curValue = props.getProperty(curBase, ""); + + toObj.add(curValue); + + if ((curValue != null) && (curValue.length() > 0)) { + foundValue = true; + } + } + + } + + if (foundValue) { + return (toObj); + } else { + return (null); + } + + } + + public static Object toBuilder(Properties props, String pfx, Object toObj) { + return (toBuilder(props, pfx, toObj, false)); + } + + public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { + Class toClass = toObj.getClass(); + boolean foundValue = false; + + LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); + + Ipv4Address addr; + + if (isYangGenerated(toClass)) { + // Class is yang generated. + LOG.trace(toClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + if (preservePfx) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + if (toObj instanceof Identifier) { + LOG.trace(toClass.getName() + " is a Key - skipping"); + return (toObj); + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + if (isSetter(m)) { + Class paramTypes[] = m.getParameterTypes(); + Class paramClass = paramTypes[0]; + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + String paramValue = props.getProperty(propName); + if (paramValue == null) { + LOG.trace(propName + " is unset"); + } else { + LOG.trace(propName + " = " + paramValue); + } + + // Is the return type a yang generated class? + if (isYangGenerated(paramClass)) { + // Is it an enum? + if (paramClass.isEnum()) { + + LOG.trace(m.getName() + " expects an Enum"); + // Param type is a typedef. + if ((paramValue != null) && (paramValue.length() > 0)) { + Object paramObj = null; + + try { + paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); + } catch (Exception e) { + LOG.error("Caught exception trying to convert field " + propName + " to enum " + paramClass.getName(), e); + } + + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to create Yang-generated enum expected by" + toClass.getName() + "." + m.getName() + "() from Properties entry", e); + } + } + } else { + + String simpleName = paramClass.getSimpleName(); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName)) { + + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); + + if ("Ipv4Address".equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv4Address()); + } else if ("Ipv6Address".equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv6Address()); + + } else { + m.invoke(toObj, ipAddr); + } + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + paramValue + ")", e); + + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to call " + toClass.getName() + "." + m.getName() + "() with Properties entry", e); + } + } + } else if ("IpPrefix".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); + m.invoke(toObj, ipPrefix); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + paramValue + ")", e); + } + } + } else { + // setter expects a yang-generated class. Need + // to + // create a builder to set it. + + String builderName = paramClass.getName() + "Builder"; + Class builderClass = null; + Object builderObj = null; + Object paramObj = null; + + Object constObj = null; + + LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " + builderName); + try { + builderClass = Class.forName(builderName); + builderObj = builderClass.newInstance(); + paramObj = toBuilder(props, propNamePfx, builderObj); + } catch (ClassNotFoundException e) { + + if (paramValue == null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(null)"); + m.invoke(toObj, new Object[] { null }); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e1) { + LOG.error("Caught exception trying to cally" + toClass.getName() + "." + m.getName() + "() with Properties entry", e1); + } + } else { + try { + // See if I can find a constructor I + // can + // use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj == null) { + + // Last chance - see if + // parameter class has a static + // method + // getDefaultInstance(String) + try { + Method gm = paramClass.getMethod("getDefaultInstance", String.class); + + int gmodifier = gm.getModifiers(); + if (Modifier.isStatic(gmodifier)) { + // Invoke static + // getDefaultInstance(String) + paramObj = gm.invoke(null, paramValue); + } + + } catch (Exception gme) { + // Ignore exceptions + } + } + + } catch (Exception e1) { + LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); + } + + if (constObj == null) { + LOG.warn("Could not find builder class " + builderName + " and could not find a String or Long constructor or static getDefaultInstance(String) - trying just to set passing paramValue"); + + } + } + } catch (Exception e) { + LOG.error("Caught exception trying to create builder " + builderName, e); + } + + if (paramObj != null) { + + try { + + Method buildMethod = builderClass.getMethod("build"); + LOG.trace("Calling " + paramObj.getClass().getName() + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(paramObj); + + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); + m.invoke(toObj, builtObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to set Yang-generated class expected by" + toClass.getName() + "." + m.getName() + "() from Properties entry", e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + if (constObj != null) { + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + constObj.toString() + ")"); + m.invoke(toObj, constObj); + } else { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramValue); + + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(paramClass)) { + + LOG.trace("Parameter class " + paramClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type paramType = m.getGenericParameterTypes()[0]; + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + Object paramObj = new LinkedList(); + try { + paramObj = toList(props, propName, (List) paramObj, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to create list expected as argument to " + toClass.getName() + "." + m.getName()); + } + + if (paramObj != null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert List returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } else { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace("Parameter class " + paramClass.getName() + " is not a yang-generated class or a List"); + + if ((paramValue != null) && (paramValue.length() > 0)) { + + Object constObj = null; + + try { + // See if I can find a constructor I can use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + constObj + ")"); + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error("Caught exception trying to call " + m.getName(), e2); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } catch (Exception e1) { + LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); + } + + } + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + if (foundValue) { + return (toObj); + } else { + return (null); + } + } + + public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { + boolean foundValue = false; + + LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); + + if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { + // Class is yang generated. + LOG.trace(toClass.getName() + " is a Yang-generated class"); + + if (toClass.getName().endsWith("Key")) { + if (Identifier.class.isAssignableFrom(toClass)) { + LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); + } else { + + LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); + } + } + + String propNamePfx = null; + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + LOG.trace("Is " + m.getName() + " method a getter?"); + if (isGetter(m)) { + LOG.trace(m.getName() + " is a getter"); + Class returnClass = m.getReturnType(); + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + // Is the return type a yang generated class? + if (isYangGenerated(returnClass)) { + // Is it an enum? + if (returnClass.isEnum()) { + + LOG.trace(m.getName() + " is an Enum"); + pstr.print("\n\n * " + propName); + + } else { + + String simpleName = returnClass.getSimpleName(); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName)) { + LOG.trace(m.getName() + " is an " + simpleName); + pstr.print("\n\n * " + propName); + } else { + printPropertyList(pstr, propNamePfx, returnClass); + } + + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(returnClass)) { + + LOG.trace("Parameter class " + returnClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type returnType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + Class elementClass = (Class) elementType; + LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); + printPropertyList(pstr, propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", elementClass); + + } else if (!returnClass.equals(Class.class)) { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace("Parameter class " + returnClass.getName() + " is not a yang-generated class or a List"); + + pstr.print("\n\n * " + propName); + + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + } + + public static boolean isYangGenerated(Class c) { + if (c == null) { + return (false); + } else { + return (c.getName().startsWith("org.opendaylight.yang.gen.")); + } + } + + public static boolean isIpPrefix(Class c) { + + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("IpPrefix".equals(simpleName)); + } + + public static boolean isIpv4Address(Class c) { + + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv4Address".equals(simpleName)); + } + + public static boolean isIpv6Address(Class c) { + + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv6Address".equals(simpleName)); + } + + public static boolean isIpAddress(Class c) { + + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("IpAddress".equals(simpleName)); + } + + public static String toLowerHyphen(String inStr) { + if (inStr == null) { + return (null); + } + + String str = inStr.substring(0, 1).toLowerCase(); + if (inStr.length() > 1) { + str = str + inStr.substring(1); + } + + String regex = "(([a-z0-9])([A-Z]))"; + String replacement = "$2-$3"; + + String retval = str.replaceAll(regex, replacement).toLowerCase(); + + LOG.trace("Converting " + inStr + " => " + str + " => " + retval); + return (retval); + } + + //This is called when mapping the yang value back to a valid java enumeration + public static String toJavaEnum(String inStr) { + if (inStr == null) { + return (null); + } else if (inStr.length() == 0) { + return (inStr); + } + + //This will strip out all periods, which cannot be in a java enum + inStr = inStr.replaceAll("\\.", ""); + + String[] terms = inStr.split("-"); + StringBuffer sbuff = new StringBuffer(); + + //appends an _ if the string starts with a digit to make it a valid java enum + if (Character.isDigit(inStr.charAt(0))) { + sbuff.append('_'); + } + //If the string contains hyphens it will convert the string to upperCamelCase without hyphens + for (String term : terms) { + sbuff.append(term.substring(0, 1).toUpperCase()); + if (term.length() > 1) { + sbuff.append(term.substring(1)); + } + } + return (sbuff.toString()); + + } + + public static boolean isGetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { + if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { + if (!"getClass".equals(m.getName())) { + return (true); + } + } + + if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { + return (true); + } + + if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { + return (true); + } + } + + return (false); + } + + public static boolean isSetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { + if (m.getName().matches("^set[A-Z].*")) { + Class[] paramTypes = m.getParameterTypes(); + if (paramTypes[0].isAssignableFrom(Identifier.class) || Identifier.class.isAssignableFrom(paramTypes[0])) { + return (false); + } else { + return (true); + } + } + + } + + return (false); + } + + public static String getFullPropertiesPath(String propertiesFileName) { + return "/opt/bvc/controller/configuration/" + propertiesFileName; + } + + //This is called when mapping a valid java enumeration back to the yang model value + public static String mapEnumeratedValue(String propertyName, String propertyValue) { + LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); + String mappingKey = "yang." + propertyName + "." + propertyValue; + if (yangMappingProperties.containsKey(mappingKey)) { + return (yangMappingProperties.getProperty(mappingKey)); + } else { + LOG.info("yangMappingProperties did not contain the key " + mappingKey + " returning the original value."); + return propertyValue; + } + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java new file mode 100644 index 000000000..9f50547bd --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NotifyNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(NotifyNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String action = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("action"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("release node encountered - looking for resource class " + + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + + try { + + switch (resourcePlugin.notify(resourceType, action, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java new file mode 100644 index 000000000..3c8c4c06d --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java @@ -0,0 +1,118 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RecordNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(RecordNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String outValue = "failure"; + + if (LOG.isTraceEnabled()) { + LOG.trace(node.getNodeType() + + " node encountered - looking for recorder class " + + plugin); + } + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, + node, ctx); + + if (LOG.isTraceEnabled()) { + LOG.trace("executeRecordNode : parameter " + curName + " = " + + curExpr + " => " + curExprValue); + } + parmMap.put(curName, curExprValue); + } + + + SvcLogicRecorder recorder = getSvcLogicRecorder(plugin); + + if (recorder != null) { + + try { + recorder.record(parmMap); + } catch (SvcLogicException e) { + LOG.error("Caught exception from recorder plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicRecorder object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isTraceEnabled()) { + LOG.trace("no failure or Other branch found"); + } + } + return (nextNode); + } + + + + + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java new file mode 100644 index 000000000..4fee9aa8c --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReleaseNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ReleaseNodeExecutor.class); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("release node encountered - looking for resource class " + + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + + try { + + switch (resourcePlugin.release(resourceType, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java new file mode 100644 index 000000000..6d8035e2a --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReserveNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ReserveNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"),node,ctx); + + + SvcLogicExpression selectExpr = node.getAttribute("select"); + String select = null; + + if (selectExpr != null) + { + select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("reserve node encountered - looking for resource class " + + plugin); + } + + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java new file mode 100644 index 000000000..b1a2b9020 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReturnNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ReturnNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String status = SvcLogicExpressionResolver.evaluate( + node.getAttribute("status"), node, ctx); + + if (status != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Returning status " + status); + } + ctx.setStatus(status); + } else { + if (LOG.isWarnEnabled()) { + LOG.warn("Return node has no status attribute set"); + } + } + + Set> parameterSet = node + .getParameterSet(); + + for (Iterator> iter = parameterSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + String curValue = SvcLogicExpressionResolver.evaluate( + curEnt.getValue(), node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.debug("Setting context attribute " + curName + " to " + + curValue); + } + ctx.setAttribute(curName, curValue); + } + return null; + } + + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java new file mode 100644 index 000000000..0dd555250 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SaveNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(SaveNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String forceStr = SvcLogicExpressionResolver.evaluate( + node.getAttribute("force"), node, ctx); + String localOnlyStr = SvcLogicExpressionResolver.evaluate( + node.getAttribute("local-only"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + boolean force = "true".equalsIgnoreCase(forceStr); + boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate( + curExpr, node, ctx); + + LOG.debug("Parameter " + curName + " = " + + curExpr.asParsedExpr() + " resolves to " + + curExprValue); + + parmMap.put(curName, curExprValue); + } + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + + plugin); + } + + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.save(resourceType, force, localOnly, key, + parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java new file mode 100644 index 000000000..18ca3d0d2 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SetNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(SetNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String ifunsetStr = SvcLogicExpressionResolver.evaluate( + node.getAttribute("only-if-unset"), node, ctx); + + boolean ifunset = "true".equalsIgnoreCase(ifunsetStr); + + Set> parameterSet = node + .getParameterSet(); + + for (Iterator> iter = parameterSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + String lhsVarName = curName; + + // Resolve LHS of assignment (could contain index variables) + try { + SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); + lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); + } catch (Exception e) { + LOG.warn("Caught exception trying to resolve variable name ("+curName+")", e); + } + + + boolean setValue = true; + + if (curName.endsWith(".")) { + + // Copy subtree - value should be a variable name + SvcLogicExpression curValue = curEnt.getValue(); + + if (curValue != null) { + String rhsRoot = curValue.toString(); + + if ((rhsRoot != null) && (rhsRoot.length() > 0)) { + if (rhsRoot.endsWith(".")) { + rhsRoot = rhsRoot + .substring(0, rhsRoot.length() - 1); + } + + + // SDNGC-2321 : rhsRoot is variable name, possibly with subscript(s) to be resolved + try { + SvcLogicExpression rhsExpr = SvcLogicExpressionFactory.parse(rhsRoot); + rhsRoot = SvcLogicExpressionResolver.resolveVariableName(rhsExpr, node, ctx); + } catch (Exception e) { + LOG.warn("Caught exception trying to resolve variable name ("+rhsRoot+")", e); + } + + // See if the parameters are reversed (copying service-data to input) .. this + // was done as a workaround to earlier issue + if (curName.endsWith("-input.") && rhsRoot.startsWith("service-data")) { + LOG.warn("Arguments appear to be reversed .. will copy input to service-data instead"); + lhsVarName = rhsRoot + "."; + rhsRoot = curName.substring(0, curName.length()-1); + } + + rhsRoot = rhsRoot + "."; + String lhsPrefix = lhsVarName; + + if (lhsPrefix.endsWith(".")) { + lhsPrefix = lhsPrefix.substring(0, + lhsPrefix.length()-1); + } + int lhsPfxLength = lhsPrefix.length(); + HashMap parmsToAdd = new HashMap(); + + for (String sourceVarName : ctx.getAttributeKeySet()) { + + if (sourceVarName.startsWith(rhsRoot)) { + + String targetVar = lhsPrefix + + "." + + sourceVarName + .substring(rhsRoot.length()); + + LOG.debug("Copying " + sourceVarName + + " value to " + targetVar); + + parmsToAdd.put(targetVar, + ctx.getAttribute(sourceVarName)); + } + } + + for (String newParmName : parmsToAdd.keySet()) { + ctx.setAttribute(newParmName, parmsToAdd.get(newParmName)); + } + + } else { + // If RHS is empty, unset attributes in LHS + String lhsPrefix = lhsVarName.substring(0, + lhsVarName.length() - 1); + int lhsPfxLength = lhsPrefix.length(); + + LinkedList parmsToRemove = new LinkedList (); + + for (String curCtxVarname : ctx.getAttributeKeySet()) { + + if (curCtxVarname.startsWith(lhsPrefix)) { + LOG.debug("Unsetting " + curCtxVarname); + parmsToRemove.add(curCtxVarname); + } + } + + for (String parmName : parmsToRemove) { + ctx.setAttribute(parmName, null); + } + + } + } + + } else { + + if (ifunset) { + String ctxValue = ctx.getAttribute(lhsVarName); + + if ((ctxValue != null) && (ctxValue.length() > 0)) { + setValue = false; + LOG.debug("Attribute " + + lhsVarName + + " already set and only-if-unset is true, so not overriding"); + } + } + + if (setValue) { + String curValue = SvcLogicExpressionResolver.evaluate( + curEnt.getValue(), node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.trace("Parameter value " + + curEnt.getValue().asParsedExpr() + + " resolves to " + curValue); + LOG.debug("Setting context attribute " + lhsVarName + + " to " + curValue); + } + ctx.setAttribute(lhsVarName, curValue); + } + } + } + + return null; + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java new file mode 100644 index 000000000..3bc8f0922 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java @@ -0,0 +1,224 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.io.File; +import java.io.FileInputStream; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.Map; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.mysql.jdbc.Driver; + +public class SvcLogicActivator implements BundleActivator { + + private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + put("break", new BreakNodeExecutor()); + + } + }; + + private static LinkedList registrations = new LinkedList(); + + private static HashMap adaptorMap = null; + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicActivator.class); + + private static Properties props = null; + + private static BundleContext bundleCtx = null; + + private static SvcLogicService svcLogicServiceImpl = null; + + @Override + public void start(BundleContext ctx) throws Exception { + + LOG.info("Activating SLI"); + + bundleCtx = ctx; + + // Read properties + props = new Properties(); + String propPath = System.getenv(SVCLOGIC_PROP_VAR); + + if (propPath == null) { + String propDir = System.getenv(SDNC_CONFIG_DIR); + if (propDir == null) { + + propDir = "/opt/sdnc/data/properties"; + } + propPath = propDir + "/svclogic.properties"; + LOG.warn("Environment variable "+SVCLOGIC_PROP_VAR+" unset - defaulting to "+propPath); + } + + File propFile = new File(propPath); + + if (!propFile.exists()) { + + throw new ConfigurationException( + "Missing configuration properties file : " + + propFile); + } + try { + + props.load(new FileInputStream(propFile)); + } catch (Exception e) { + throw new ConfigurationException( + "Could not load properties file " + propPath, e); + + } + + + if (registrations == null) { + + registrations = new LinkedList(); + } + + // Advertise SvcLogicService + svcLogicServiceImpl = new SvcLogicServiceImpl(); + + LOG.info("SLI: Registering service " + SvcLogicService.NAME + + " in bundle " + ctx.getBundle().getSymbolicName()); + ServiceRegistration reg = ctx.registerService(SvcLogicService.NAME, + svcLogicServiceImpl, null); + registrations.add(reg); + + // Initialize SvcLogicStore + try { + SvcLogicStore store = getStore(); + registerNodeTypes(store); + } catch (ConfigurationException e) { + LOG.warn("Could not initialize SvcLogicScore", e); + } + + LOG.info("SLI - done registering services"); + } + + @Override + public void stop(BundleContext ctx) throws Exception { + + if (registrations != null) { + for (ServiceRegistration reg : registrations) { + ServiceReference regRef = reg.getReference(); + /* Don't bother to remove node types from table + String nodeType = (String) regRef.getProperty("nodeType"); + if (nodeType != null) { + LOG.info("SLI - unregistering node type " + nodeType); + store.unregisterNodeType(nodeType); + } + */ + reg.unregister(); + } + registrations = null; + } + } + + public static SvcLogicStore getStore() throws SvcLogicException { + // Create and initialize SvcLogicStore object - used to access + // saved service logic. + + SvcLogicStore store = null; + + try { + Driver dvr = new Driver(); + store = SvcLogicStoreFactory.getSvcLogicStore(props); + } catch (Exception e) { + throw new ConfigurationException( + "Could not get service logic store", e); + + } + + try { + store.init(props); + } catch (Exception e) { + throw new ConfigurationException( + "Could not get service logic store", e); + } + + return(store); + } + + private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException { + + if (store == null) { + return; + } + // Advertise built-in node executors + LOG.info("SLI : Registering built-in node executors"); + Hashtable propTable = new Hashtable(); + + for (String nodeType : BUILTIN_NODES.keySet()) { + LOG.info("SLI - registering node type " + nodeType); + propTable.clear(); + propTable.put("nodeType", nodeType); + + ServiceRegistration reg = bundleCtx.registerService(SvcLogicNodeExecutor.class.getName(), + BUILTIN_NODES.get(nodeType), propTable); + registrations.add(reg); + + store.registerNodeType(nodeType); + + LOG.info("SLI - registering node executor"); + + ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + + } + + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java new file mode 100644 index 000000000..1bc8e0f8d --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.HashMap; + +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicAdaptorFactory { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicAdaptorFactory.class); + + private static HashMap adaptorMap = new HashMap(); + + public static void registerAdaptor(SvcLogicAdaptor adaptor) { + String name = adaptor.getClass().getName(); + LOG.info("Registering adaptor " + name); + adaptorMap.put(name, adaptor); + + } + + public static void unregisterAdaptor(String name) { + if (adaptorMap.containsKey(name)) { + LOG.info("Unregistering " + name); + adaptorMap.remove(name); + } + } + + public static SvcLogicAdaptor getInstance(String name) { + if (adaptorMap.containsKey(name)) { + return (adaptorMap.get(name)); + } else { + BundleContext bctx = null; + try + { + bctx = FrameworkUtil.getBundle(SvcLogicAdaptorFactory.class) + .getBundleContext(); + } + catch (Exception e) + { + LOG.debug("Caught exception trying to locate device adaptor "+name, e); + return(null); + } + + ServiceReference sref = bctx.getServiceReference(name); + + if (sref != null) { + SvcLogicAdaptor adaptor = (SvcLogicAdaptor) bctx + .getService(sref); + + if (adaptor != null) { + registerAdaptor(adaptor); + + return (adaptor); + } + return (null); + } + } + return(null); + } +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java new file mode 100644 index 000000000..01851cc62 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java @@ -0,0 +1,604 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicAtom; +import org.onap.ccsdk.sli.core.sli.SvcLogicBinaryExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicFunctionCall; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicVariableTerm; +import org.onap.ccsdk.sli.core.sli.SvcLogicAtom.AtomType; +import org.onap.ccsdk.sli.core.sli.SvcLogicBinaryExpression.OperatorType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicExpressionResolver { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExpressionResolver.class); + + public static String evaluate(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + if (expr == null) { + return (null); + } + + + + if (expr instanceof SvcLogicAtom) { + SvcLogicAtom atom = (SvcLogicAtom) expr; + + AtomType atomType = atom.getAtomType(); + switch (atomType) { + case NUMBER: + case STRING: + return (atom.toString()); + case CONTEXT_VAR: + case IDENTIFIER: + + String varName = resolveVariableName(atom, node, ctx); + + if (atomType == AtomType.CONTEXT_VAR) + { + LOG.trace("Evaluating context variable $"+varName); + + String varValue = ctx.getAttribute(varName); + + if (varValue == null) { + LOG.trace("Context variable $"+varName+" unset - treating as empty string"); + varValue = ""; + } + + return (varValue); + } + SvcLogicExpression parm = node.getParameter(varName); + if (parm != null) { + LOG.trace("Evaluating value of parameter "+varName+": "+parm.asParsedExpr()); + + return (evaluate(parm, node, ctx)); + } + else + { + return(varName); + } + default: + return(null); + } + + } else if (expr instanceof SvcLogicBinaryExpression) { + SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; + List operators = binExpr.getOperators(); + if (operators.isEmpty()) + { + List operands = binExpr.getOperands(); + if (operands.size() == 1) + { + LOG.trace("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); + return(evaluate(operands.get(0), node, ctx)); + } + else + { + if (operands.isEmpty()) + { + LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); + } + else + { + LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); + } + return(null); + } + } + switch (operators.get(0)) { + case addOp: + case subOp: + case multOp: + case divOp: + return(evalArithExpression(binExpr, node, ctx)); + case equalOp: + case neOp: + case ltOp: + case leOp: + case gtOp: + case geOp: + return (evalCompareExpression(binExpr, node, ctx)); + case andOp: + case orOp: + return(evalLogicExpression(binExpr, node, ctx)); + + default: + return(null); + } + } + else if (expr instanceof SvcLogicFunctionCall) + { + return(evalFunctionCall((SvcLogicFunctionCall)expr, node, ctx)); + } + else + { + throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); + } + } + + private static String evalArithExpression(SvcLogicBinaryExpression binExpr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + List operands = binExpr.getOperands(); + List operators = binExpr.getOperators(); + if (operands.size() != (operators.size()+1)) + { + throw new SvcLogicException("Invalid expression ("+binExpr+")"); + } + String retval = evaluate(operands.get(0), node, ctx); + String retsval = retval; + long retlval = 0; + boolean valueIsLong = false; + + int i = 1; + try + { + + if ((retval.length() > 0) && StringUtils.isNumeric(retval)) + { + retlval = Long.parseLong(retval); + valueIsLong = true; + } + for (OperatorType operator: operators) + { + String curOperandValue = evaluate(operands.get(i++), node, ctx); + switch(operator) { + case addOp: + retsval = retsval + curOperandValue; + if (valueIsLong) + { + if ((curOperandValue.length() > 0) && StringUtils.isNumeric(curOperandValue) ) + { + retlval = retlval + Long.parseLong(curOperandValue); + } + else + { + valueIsLong = false; + } + } + break; + case subOp: + retlval = retlval - Long.parseLong(curOperandValue); + break; + case multOp: + retlval = retlval * Long.parseLong(curOperandValue); + break; + case divOp: + retlval = retlval / Long.parseLong(curOperandValue); + break; + } + + } + } + catch (NumberFormatException e1) + { + throw new SvcLogicException("Illegal value in arithmetic expression", e1); + } + + if (valueIsLong) + { + return("" + retlval); + } + else + { + return(retsval); + } + + } + + + + private static String evalCompareExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + + List operators = expr.getOperators(); + List operands = expr.getOperands(); + + if ((operators.size() != 1) || (operands.size() != 2)) + { + throw new SvcLogicException ("Invalid comparison expression : "+expr); + } + + OperatorType operator = operators.get(0); + String op1Value = evaluate(operands.get(0), node, ctx); + String op2Value = evaluate(operands.get(1), node, ctx); + + if ((StringUtils.isNotEmpty(op1Value) && StringUtils.isNumeric(op1Value) && StringUtils.isNotEmpty(op2Value) && StringUtils.isNumeric(op2Value))) + { + try + { + double op1dbl = Double.parseDouble(op1Value); + double op2dbl = Double.parseDouble(op2Value); + + switch(operator) + { + case equalOp: + return(Boolean.toString(op1dbl == op2dbl)); + case neOp: + return(Boolean.toString(op1dbl != op2dbl)); + case ltOp: + return(Boolean.toString(op1dbl < op2dbl)); + case leOp: + return(Boolean.toString(op1dbl <= op2dbl)); + case gtOp: + return(Boolean.toString(op1dbl > op2dbl)); + case geOp: + return(Boolean.toString(op1dbl >= op2dbl)); + default: + return(null); + } + } + catch (NumberFormatException e) + { + throw new SvcLogicException("Caught exception trying to compare numeric values", e); + } + } + else + { + + int compResult = 0; + + if (op1Value == null) { + compResult = -1; + } else if (op2Value == null ) { + compResult = 1; + } else { + compResult = op1Value.compareToIgnoreCase(op2Value); + } + + switch(operator) + { + case equalOp: + return(Boolean.toString(compResult == 0)); + case neOp: + return(Boolean.toString(compResult != 0)); + case ltOp: + return(Boolean.toString(compResult < 0)); + case leOp: + return(Boolean.toString(compResult <= 0)); + case gtOp: + return(Boolean.toString(compResult > 0)); + case geOp: + return(Boolean.toString(compResult >= 0)); + default: + return(null); + } + } + + } + + private static String evalLogicExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + boolean retval; + + List operands = expr.getOperands(); + List operators = expr.getOperators(); + + if (operands.size() != (operators.size()+1)) + { + throw new SvcLogicException("Invalid expression ("+expr+")"); + } + + try + { + retval = Boolean.parseBoolean(evaluate(operands.get(0), node, ctx)); + int i = 1; + for (OperatorType operator : operators) + { + if (operator == OperatorType.andOp) + { + retval = retval && Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); + } + else + { + + retval = retval || Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); + } + + } + } + catch (Exception e) + { + throw new SvcLogicException("Invalid expression ("+expr+")"); + } + + + return(Boolean.toString(retval)); + } + + private static String evalFunctionCall(SvcLogicFunctionCall func, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + String funcName = func.getFunctionName(); + List operands = func.getOperands(); + + if ("length".equalsIgnoreCase(funcName)) + { + + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + return(""+opValue.length()); + } + else + { + throw new SvcLogicException("Invalid call to length() function"); + } + } + else if ("substr".equalsIgnoreCase(funcName)) + { + if (operands.size() == 3) + { + String op1Value = evaluate(operands.get(0), node, ctx); + String op2Value = evaluate(operands.get(1), node, ctx); + String op3Value = evaluate(operands.get(2), node, ctx); + + if (!StringUtils.isNumeric(op2Value) || !StringUtils.isNumeric(op3Value)) + { + throw new SvcLogicException("Invalid arguments to substr() function"); + } + + try + { + return(op1Value.substring(Integer.parseInt(op2Value), Integer.parseInt(op3Value))); + } + catch (Exception e) + { + throw new SvcLogicException("Caught exception trying to take substring", e); + } + } + else + { + + throw new SvcLogicException("Invalid call to substr() function"); + } + + } + else if ("toUpperCase".equalsIgnoreCase(funcName)) + { + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + if (opValue != null) { + return(opValue.toUpperCase()); + } else { + return(""); + } + } + else + { + throw new SvcLogicException("Invalid call to toUpperCase() function"); + } + } + else if ("toLowerCase".equalsIgnoreCase(funcName)) + { + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + if (opValue != null) { + return(opValue.toLowerCase()); + } else { + return(""); + } + } + else + { + throw new SvcLogicException("Invalid call to toLowerCase() function"); + } + } + else if ("convertBase".equalsIgnoreCase(funcName)) { + int fromBase = 10; + int toBase = 10; + String srcString = ""; + + if (operands.size() == 2) + { + fromBase = 10; + srcString = evaluate(operands.get(0), node, ctx); + toBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); + } else if (operands.size() == 3) { + + srcString = evaluate(operands.get(0), node, ctx); + fromBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); + toBase = Integer.parseInt(evaluate(operands.get(2), node, ctx)); + } else { + throw new SvcLogicException("Invalid call to convertBase() function"); + } + + long srcValue = Long.parseLong(srcString, fromBase); + return(Long.toString(srcValue, toBase)); + } + else + { + throw new SvcLogicException("Unrecognized function ("+funcName+")"); + } + + } + + public static String evaluateAsKey(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + if (expr == null) { + return (null); + } + + + + if (expr instanceof SvcLogicAtom) { + SvcLogicAtom atom = (SvcLogicAtom) expr; + + AtomType atomType = atom.getAtomType(); + StringBuffer varNameBuff = new StringBuffer(); + switch (atomType) { + case NUMBER: + return (atom.toString()); + case STRING: + return("'"+atom.toString()+"'"); + case CONTEXT_VAR: + case IDENTIFIER: + boolean needDot = false; + for (SvcLogicExpression term : atom.getOperands()) + { + if (needDot) + { + varNameBuff.append("."); + } + if (term instanceof SvcLogicVariableTerm) + { + SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; + varNameBuff.append(vterm.getName()); + if (vterm.numOperands() > 0) + { + varNameBuff.append("["); + varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); + varNameBuff.append("]"); + + } + } + else + { + varNameBuff.append(term.toString()); + } + needDot = true; + } + + String varName = varNameBuff.toString(); + LOG.debug("Evaluating context variable $"+varName); + String ctxValue = ctx.getAttribute(varName); + if (ctxValue == null) + { + return(null); + } + if (StringUtils.isNumeric(ctxValue)) + { + return(ctxValue); + } + else + { + return("'"+ctxValue+"'"); + } + + default: + return(null); + } + + } else if (expr instanceof SvcLogicBinaryExpression) { + SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; + List operators = binExpr.getOperators(); + List operands = binExpr.getOperands(); + if (operators.isEmpty()) + { + if (operands.size() == 1) + { + LOG.debug("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); + return(evaluateAsKey(operands.get(0), node, ctx)); + } + else + { + if (operands.isEmpty()) + { + LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); + } + else + { + LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); + } + return(null); + } + } + StringBuffer sbuff = new StringBuffer(); + sbuff.append(evaluateAsKey(operands.get(0), node, ctx)); + int i = 1; + for (OperatorType operator : operators) + { + sbuff.append(" "); + sbuff.append(operator.toString()); + sbuff.append(" "); + sbuff.append(evaluateAsKey(operands.get(i++), node,ctx)); + } + return(sbuff.toString()); + } + else if (expr instanceof SvcLogicFunctionCall) + { + StringBuffer sbuff = new StringBuffer(); + SvcLogicFunctionCall funcCall = (SvcLogicFunctionCall) expr; + sbuff.append(funcCall.getFunctionName()); + sbuff.append("("); + boolean needComma = false; + for (SvcLogicExpression operand : funcCall.getOperands()) + { + if (needComma) + { + sbuff.append(","); + } + else + { + needComma = true; + } + sbuff.append(evaluateAsKey(operand, node, ctx)); + } + sbuff.append(")"); + return(sbuff.toString()); + } + else + { + throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); + } + } + + public static String resolveVariableName(SvcLogicExpression atom, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + StringBuffer varNameBuff = new StringBuffer(); + + boolean needDot = false; + for (SvcLogicExpression term : atom.getOperands()) + { + if (needDot) + { + varNameBuff.append("."); + } + if (term instanceof SvcLogicVariableTerm) + { + SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; + varNameBuff.append(vterm.getName()); + if (vterm.numOperands() > 0) + { + varNameBuff.append("["); + varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); + varNameBuff.append("]"); + } + } + else + { + varNameBuff.append(term.toString()); + } + needDot = true; + } + return(varNameBuff.toString()); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java new file mode 100644 index 000000000..8d72f7a8b --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class SvcLogicNodeExecutor { + + public abstract SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class); + + protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + if (node == null) { + return null; + } + + return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"), + node, ctx)); + + } + + protected SvcLogicStore getStore() throws SvcLogicException { + return SvcLogicActivator.getStore(); + } + + protected SvcLogicAdaptor getAdaptor(String adaptorName) { + return SvcLogicAdaptorFactory.getInstance(adaptorName); + } + + protected SvcLogicResource getSvcLogicResource(String plugin) { + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) + .getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(plugin); + if (sref != null) { + SvcLogicResource resourcePlugin = (SvcLogicResource) bctx + .getService(sref); + return resourcePlugin; + } + else { + LOG.warn("Could not find service reference object for plugin " + plugin); + return null; + } + } + + protected SvcLogicRecorder getSvcLogicRecorder(String plugin) { + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) + .getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(plugin); + if (sref != null) { + SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx + .getService(sref); + return resourcePlugin; + } + else { + return null; + } + } + + protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){ + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) + .getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(pluginName); + + if (sref == null) { + LOG.warn("Could not find service reference object for plugin " + pluginName); + return null; + } else { + SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx + .getService(sref); + return plugin; + } + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java new file mode 100644 index 000000000..cfba5866e --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; + +public interface SvcLogicService { + + public static final String NAME = "org.openecomp.sdnc.sli.provider.SvcLogicService"; + + // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException; + /** + * Check for existence of a directed graph + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, looks for active version + * @param mode - mode (sync/async) + * @return true if directed graph found, false otherwise + * @throws SvcLogicException + */ + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; + + /** + * Execute a directed graph + * + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, use active version + * @param mode - mode (sync/async) + * @param parms - parameters, used to set SvcLogicContext attributes + * @return final values of attributes from SvcLogicContext, as Properties + * @throws SvcLogicException + * + * + * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead + */ + @Deprecated + public Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; + + /** + * Execute a directed graph + * + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, use active version + * @param mode - mode (sync/async) + * @param parms - parameters, used to set SvcLogicContext attributes + * @param domDataBroker - DOMDataBroker object + * @return final values of attributes from SvcLogicContext, as Properties + * @throws SvcLogicException + */ + public Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException; + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java new file mode 100644 index 000000000..c0ee4c2c1 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -0,0 +1,272 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.HashMap; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.MetricLogger; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTracker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +public class SvcLogicServiceImpl implements SvcLogicService { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicServiceImpl.class); + + private HashMap nodeExecutors = null; + + private BundleContext bctx = null; + + private void registerExecutors() { + + LOG.info("Entered register executors"); + if (bctx == null) { + bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + } + + if (nodeExecutors == null) { + nodeExecutors = new HashMap(); + } + + LOG.info("Opening service tracker"); + ServiceTracker tracker = new ServiceTracker(bctx, + SvcLogicNodeExecutor.class.getName(), null); + + tracker.open(); + + ServiceListener listener = new ServiceListener() { + + public void serviceChanged(ServiceEvent ev) { + ServiceReference sr = ev.getServiceReference(); + switch (ev.getType()) { + case ServiceEvent.REGISTERED: { + registerExecutor(sr); + } + break; + case ServiceEvent.UNREGISTERING: { + unregisterExecutor(sr); + } + break; + } + } + }; + + LOG.info("Adding service listener"); + String filter = "(objectclass=" + SvcLogicNodeExecutor.class.getName() + + ")"; + try { + bctx.addServiceListener(listener, filter); + ServiceReference[] srl = bctx.getServiceReferences( + SvcLogicNodeExecutor.class.getName(), null); + for (int i = 0; srl != null && i < srl.length; i++) { + listener.serviceChanged(new ServiceEvent( + ServiceEvent.REGISTERED, srl[i])); + } + } catch (InvalidSyntaxException e) { + e.printStackTrace(); + } + LOG.info("Done registerExecutors"); + } + + public void registerExecutor(ServiceReference sr) { + + String nodeName = (String) sr.getProperty("nodeType"); + if (nodeName != null) { + + SvcLogicNodeExecutor executor = null; + + try { + executor = (SvcLogicNodeExecutor) bctx.getService(sr); + } catch (Exception e) { + LOG.error("Cannot get service executor for " + nodeName); + return; + } + + registerExecutor(nodeName, executor); + + } + } + + public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) + { + if (nodeExecutors == null) { + nodeExecutors = new HashMap(); + } + LOG.info("SLI - registering executor for node type "+nodeName); + nodeExecutors.put(nodeName, executor); + } + + public void unregisterExecutor(ServiceReference sr) { + String nodeName = (String) sr.getProperty("nodeType"); + + if (nodeName != null) { + + unregisterExecutor(nodeName); + + } + + } + + public void unregisterExecutor(String nodeName) + { + + LOG.info("SLI - unregistering executor for node type "+nodeName); + nodeExecutors.remove(nodeName); + } + + + + + public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) + throws SvcLogicException { + + if (nodeExecutors == null) { + registerExecutors(); + } + + // Set service name in MDC to reference current working directed graph + MDC.put(MetricLogger.SERVICE_NAME, graph.getModule()+":"+graph.getRpc()+"/v"+graph.getVersion()); + + SvcLogicNode curNode = graph.getRootNode(); + LOG.info("About to execute graph " + graph.toString()); + + + + while (curNode != null) { + LOG.info("About to execute node # "+curNode.getNodeId()+" ("+curNode.getNodeType()+")"); + + SvcLogicNode nextNode = executeNode(curNode, ctx); + curNode = nextNode; + } + + return (ctx); + } + + + public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + if (node == null) { + return (null); + } + + if (LOG.isDebugEnabled()) { + LOG.debug("Executing node " + node.getNodeId()); + } + + SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); + + if (executor != null) { + LOG.debug("Executing node executor for node type "+node.getNodeType()+" - "+executor.getClass().getName()); + return (executor.execute(this, node, ctx)); + } else { + if (LOG.isDebugEnabled()) { + LOG.debug(node.getNodeType() + " node not implemented"); + } + SvcLogicNode nextNode = node.getOutcomeValue("failure"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute failure branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no failure or Other branch found"); + } + } + return (nextNode); + } + + } + + @Override + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException + { + SvcLogicStore store = SvcLogicActivator.getStore(); + + return (store.hasGraph(module, rpc, version, mode)); + } + + @Override + public Properties execute(String module, String rpc, String version, String mode, Properties props) + throws SvcLogicException { + return(execute(module, rpc, version, mode, props, null)); + } + + + @Override + public Properties execute(String module, String rpc, String version, String mode, + Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { + + + // See if there is a service logic defined + // + SvcLogicStore store = SvcLogicActivator.getStore(); + + LOG.info("Fetching service logic from data store"); + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + + + + if (graph == null) + { + Properties retProps = new Properties(); + retProps.setProperty("error-code", "401"); + retProps.setProperty("error-message", "No service logic found for ["+module+","+rpc+","+version+","+mode+"]"); + return(retProps); + + } + + SvcLogicContext ctx = new SvcLogicContext(props); + ctx.setAttribute("currentGraph", graph.toString()); + ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); + ctx.setDomDataBroker(domDataBroker); + + execute(graph, ctx); + + return(ctx.toProperties()); + } + + + + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java new file mode 100644 index 000000000..ac0c428b3 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SwitchNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(SwitchNodeExecutor.class); + + @Override + + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + + String testResult = evaluateNodeTest(node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.debug("Executing switch node"); + + + LOG.debug("test expression (" + node.getAttribute("test") + + ") evaluates to " + testResult); + } + + SvcLogicNode nextNode = node.getOutcomeValue(testResult); + + if (LOG.isDebugEnabled()) { + if (nextNode != null) { + LOG.debug("Next node to execute is node " + nextNode.getNodeId()); + } else { + LOG.debug("No next node found"); + } + } + return (nextNode); + + } +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java new file mode 100644 index 000000000..48510e60f --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UpdateNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(UpdateNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate( + node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey( + node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate( + node.getAttribute("pfx"), node, ctx); + + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate( + curExpr, node, ctx); + + LOG.debug("Parameter " + curName + " = " + + curExpr.asParsedExpr() + " resolves to " + + curExprValue); + + parmMap.put(curName, curExprValue); + } + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + + plugin); + } + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.update(resourceType, key, + parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + + plugin); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no "+outValue+" or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java new file mode 100644 index 000000000..bc3cc773b --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.BreakNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WhileNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + + String testResult = evaluateNodeTest(node, ctx); + SvcLogicExpression silentFailureExpr = node.getAttribute("do"); + String doWhile = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); + if ("true".equals(doWhile)) { + LOG.debug("While loop will execute once regardless of expression because do is set to true"); + } + + try { + while ("true".equals(testResult) || "true".equals(doWhile)) { + if (!"true".equals(doWhile)) { + LOG.debug("Test expression (" + node.getAttribute("test") + ") evaluates to true, executing loop."); + } + int numOutcomes = node.getNumOutcomes() + 1; + for (int i = 0; i < numOutcomes; i++) { + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + while (nextNode != null) { + nextNode = svc.executeNode(nextNode, ctx); + } + } else { + if ("true".equals(doWhile)) { + LOG.debug("Do executed, will only execute again if test expression is true."); + doWhile = "false"; + } + testResult = evaluateNodeTest(node, ctx); + LOG.debug("test expression (" + node.getAttribute("test") + ") evaluates to " + testResult); + } + } + } + LOG.debug("testResult was " + testResult + " which is not equal to true, exiting while loop."); + } catch (BreakNodeException e) { + LOG.debug("WhileNodeExecutor caught break"); + } + return (null); + } + +} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BlockNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BlockNodeExecutor.java deleted file mode 100644 index f83154d9e..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BlockNodeExecutor.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BlockNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(BlockNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - SvcLogicExpression atomicExpr = node.getAttribute("atomic"); - String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); - boolean isAtomic = "true".equalsIgnoreCase(atomicStr); - - // Initialize status to success so that at least one outcome will execute - ctx.setStatus("success"); - - int numOutcomes = node.getNumOutcomes(); - - for (int i = 0; i < numOutcomes; i++) { - if ("failure".equals(ctx.getStatus()) && isAtomic) { - LOG.info("Block - stopped executing nodes due to failure status"); - return(null); - } - - SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("Block - executing outcome " + (i + 1)); - } - while (nextNode != null) - { - nextNode = svc.executeNode(nextNode, ctx); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("Block - done: no outcome " + (i + 1)); - } - } - } - - return (null); - } - - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BreakNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BreakNodeExecutor.java deleted file mode 100644 index 0f8719c8a..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/BreakNodeExecutor.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.BreakNodeException; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BreakNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(BreakNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - String message = "BreakNodeExecutor encountered break with nodeId " + node.getNodeId(); - LOG.debug(message); - throw new BreakNodeException(message); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java deleted file mode 100644 index 7b79c19f6..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/CallNodeExecutor.java +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicGraph; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CallNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(CallNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String outValue = "not-found"; - - SvcLogicGraph myGraph = node.getGraph(); - - if (myGraph == null) - { - LOG.debug("execute: getGraph returned null"); - } - else - { - LOG.debug("execute: got SvcLogicGraph"); - } - - SvcLogicExpression moduleExpr = null; - - String module = null; - - moduleExpr = node.getAttribute("module"); - if (moduleExpr != null) - { - module = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); - } - - if ((module == null) || (module.length() == 0)) - { - if (myGraph != null) - { - module = myGraph.getModule(); - LOG.debug("myGraph.getModule() returned "+module); - } - } - - SvcLogicExpression rpcExpr = null; - String rpc = null; - rpcExpr = node.getAttribute("rpc"); - if (rpcExpr != null) - { - rpc = SvcLogicExpressionResolver.evaluate(rpcExpr, node, ctx); - } - - if ((rpc == null) || (rpc.length() == 0)) - { - if (myGraph != null) - { - rpc = myGraph.getRpc(); - LOG.debug("myGraph.getRpc() returned "+rpc); - } - } - - String mode = null; - - moduleExpr = node.getAttribute("mode"); - if (moduleExpr != null) - { - mode = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); - } - - if ((mode == null) || (mode.length() == 0)) - { - if (myGraph != null) - { - mode = myGraph.getMode(); - - LOG.debug("myGraph.getMode() returned "+mode); - } - } - - String version = null; - - moduleExpr = node.getAttribute("version"); - if (moduleExpr != null) - { - version = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); - } - - String parentGraph = ctx.getAttribute("currentGraph"); - ctx.setAttribute("parentGraph", parentGraph); - - SvcLogicStore store = getStore(); - - if (store != null) { - SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); - LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); - ctx.setAttribute("currentGraph", calledGraph.toString()); - if (calledGraph != null) { - svc.execute(calledGraph, ctx); - - outValue = ctx.getStatus(); - } else { - LOG.error("Could not find service logic for [" + module + "," + rpc + "," + version + "," + mode + "]"); - } - } - else - { - LOG.debug("Could not get SvcLogicStore reference"); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - ctx.setAttribute("currentGraph", parentGraph); - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no " + outValue + " or Other branch found"); - } - } - ctx.setAttribute("currentGraph", parentGraph); - ctx.setAttribute("parentGraph", null); - - return (nextNode); - - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java deleted file mode 100644 index a3f2874fb..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ConfigureNodeExecutor.java +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.openecomp.sdnc.sli.SvcLogicAdaptor; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ConfigureNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(ConfigureNodeExecutor.class); - - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String adaptorName = SvcLogicExpressionResolver.evaluate( - node.getAttribute("adaptor"), node, ctx); - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("configure node encountered - looking for adaptor " - + adaptorName); - } - - SvcLogicAdaptor adaptor = getAdaptor(adaptorName); - - if (adaptor != null) { - String activate = SvcLogicExpressionResolver.evaluate( - node.getAttribute("activate"), node, ctx); - String key = SvcLogicExpressionResolver.evaluate( - node.getAttribute("key"), node, ctx); - - Map parmMap = new HashMap(); - - Set> parmSet = node - .getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); - - parmMap.put(curName,curExprValue); - } - - if (hasParms) { - SvcLogicAdaptor.ConfigStatus confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - - try { - confStatus = adaptor.configure(key, parmMap, ctx); - } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".configure", e); - confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - - switch (confStatus) { - case SUCCESS: - outValue = "success"; - if ((activate != null) && (activate.length() > 0)) { - if ("true".equalsIgnoreCase(activate)) { - SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - - try { - activateStatus = adaptor.activate(key, ctx); - } catch (Exception e) { - - LOG.warn("Caught exception from "+adaptorName+".activate", e); - activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - switch (activateStatus) { - case SUCCESS: - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } else if ("false".equalsIgnoreCase(activate)) { - SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - - try { - deactivateStatus = adaptor.deactivate(key, ctx); - } catch (Exception e) { - - LOG.warn("Caught exception from "+adaptorName+".deactivate", e); - deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - switch (deactivateStatus) { - case SUCCESS: - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } - } - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } else { - if ((activate != null) && (activate.length() > 0)) { - if ("true".equalsIgnoreCase(activate)) { - SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - try { - activateStatus = adaptor.activate(key, ctx); - } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".activate", e); - activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - switch (activateStatus) { - case SUCCESS: - outValue = "success"; - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } else if ("false".equalsIgnoreCase(activate)) { - SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - - try { - deactivateStatus = adaptor.deactivate(key, ctx); - } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".deactivate", e); - deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - switch (deactivateStatus) { - case SUCCESS: - outValue = "success"; - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } - } else { - LOG.warn("Nothing to configure - no parameters passed, and activate attribute is not set"); - outValue = "success"; - } - } - } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Adaptor for " + adaptorName + " not found"); - } - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no " + outValue + " or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java deleted file mode 100644 index 081cbcfa1..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/DeleteNodeExecutor.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DeleteNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(DeleteNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("delete node encountered - looking for resource class " - + plugin); - } - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - - switch (resourcePlugin.delete(resourceType, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java deleted file mode 100644 index 7ae4d0db9..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutor.java +++ /dev/null @@ -1,161 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ExecuteNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(ExecuteNodeExecutor.class); - - private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure."; - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String pluginName = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("execute node encountered - looking for plugin " - + pluginName); - } - - SvcLogicJavaPlugin plugin = getSvcLogicJavaPlugin(pluginName); - - if (plugin == null) { - outValue = "not-found"; - } else { - - String methodName = evaluate(node.getAttribute("method"), node, ctx); - - Class pluginClass = plugin.getClass(); - - Method pluginMethod = null; - - try { - pluginMethod = pluginClass.getMethod(methodName, Map.class, SvcLogicContext.class); - } catch (NoSuchMethodException e) { - LOG.error(pluginErrorMessage, e); - } - - if (pluginMethod == null) { - outValue = "unsupported-method"; - } else { - try { - - Map parmMap = new HashMap(); - - Set> parmSet = node - .getParameterSet(); - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); - - parmMap.put(curName,curExprValue); - } - - Object o = pluginMethod.invoke(plugin, parmMap, ctx); - String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); - - outValue = mapOutcome(o, emitsOutcome); - - } catch (InvocationTargetException e) { - if(e.getCause() != null){ - LOG.error(pluginErrorMessage, e.getCause()); - }else{ - LOG.error(pluginErrorMessage, e); - } - outValue = "failure"; - ctx.setStatus("failure"); - } catch (IllegalAccessException e) { - LOG.error(pluginErrorMessage, e); - outValue = "failure"; - ctx.setStatus("failure"); - } catch (IllegalArgumentException e) { - LOG.error(pluginErrorMessage, e); - outValue = "failure"; - ctx.setStatus("failure"); - } - } - - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no " + outValue + " or Other branch found"); - } - } - return (nextNode); - } - - protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - return SvcLogicExpressionResolver.evaluate(node.getAttribute("method"), node, ctx); - } - - public String mapOutcome(Object o, String emitsOutcome) { - if (emitsOutcome != null) { - Boolean nodeEmitsOutcome = Boolean.valueOf(emitsOutcome); - if (nodeEmitsOutcome) { - return (String) o; - } else { - return "success"; - } - - } else { - return "success"; - } - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java deleted file mode 100644 index 688a86e53..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ExistsNodeExecutor.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ExistsNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(ExistsNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("exists node encountered - looking for resource class " - + plugin); - } - - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - - try { - - switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) { - case SUCCESS: - outValue = "true"; - break; - case NOT_FOUND: - outValue = "false"; - break; - case FAILURE: - default: - outValue = "false"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ForNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ForNodeExecutor.java deleted file mode 100644 index e9fdc55ef..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ForNodeExecutor.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.BreakNodeException; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ForNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(ForNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - SvcLogicExpression atomicExpr = node.getAttribute("atomic"); - String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); - boolean isAtomic = !("false".equalsIgnoreCase(atomicStr)); - - int numOutcomes = node.getNumOutcomes(); - String idxVar = SvcLogicExpressionResolver.evaluate( - node.getAttribute("index"), node, ctx); - String startVal = SvcLogicExpressionResolver.evaluate( - node.getAttribute("start"), node, ctx); - String endVal = SvcLogicExpressionResolver.evaluate( - node.getAttribute("end"), node, ctx); - - LOG.debug("Executing "+ (isAtomic ? "atomic" : "non-atomic") + " for loop - for (int " + idxVar + " = " + startVal - + "; " + idxVar + " < " + endVal + "; " + idxVar + "++)"); - - int startIdx = 0; - int endIdx = 0; - - try { - startIdx = Integer.parseInt(startVal); - endIdx = Integer.parseInt(endVal); - } catch (NumberFormatException e) { - SvcLogicExpression silentFailureExpr = node.getAttribute("silentFailure"); - String silentFailure = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); - boolean isSilentFailure = Boolean.parseBoolean(silentFailure); - String message = "Invalid index values [" + startVal + "," + endVal + "]"; - if(!isSilentFailure){ - throw new SvcLogicException(message); - }else{ - LOG.debug(message + ". Not exiting because silentFailure was set to true."); - return(null); - } - } - - try { - for (int ctr = startIdx; ctr < endIdx; ctr++) { - - ctx.setAttribute(idxVar, "" + ctr); - - for (int i = 0; i < numOutcomes; i++) { - - if ("failure".equals(ctx.getStatus()) && isAtomic) { - LOG.info("For - stopped executing nodes due to failure status"); - return(null); - } - - SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("For - executing outcome " + (i + 1)); - } - SvcLogicNode innerNextNode = nextNode; - while (innerNextNode != null) { - innerNextNode = svc.executeNode(innerNextNode, ctx); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("For - done: no outcome " + (i + 1)); - } - } - } - } - } catch (BreakNodeException br) { - LOG.debug("ForNodeExecutor caught break"); - } - return (null); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java deleted file mode 100644 index d431a18af..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/GetResourceNodeExecutor.java +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GetResourceNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(GetResourceNodeExecutor.class); - - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); - - String localOnlyStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("local-only"), node, ctx); - - // Note: for get-resource, only refresh from A&AI if the DG explicitly set - // local-only to false. Otherwise, just read from local database. - boolean localOnly = true; - - if ("false".equalsIgnoreCase(localOnlyStr)) { - localOnly = false; - } - - SvcLogicExpression selectExpr = node.getAttribute("select"); - String select = null; - - if (selectExpr != null) { - select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, - ctx); - } - - SvcLogicExpression orderByExpr = node.getAttribute("order-by"); - String orderBy = null; - - if (orderByExpr != null) { - orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, - ctx); - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug(node.getNodeType() - + " node encountered - looking for resource class " - + plugin); - } - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.query(resourceType, localOnly, select, key, - pfx, orderBy, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java deleted file mode 100644 index 0df73682c..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/IsAvailableNodeExecutor.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(IsAvailableNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("is-available node encountered - looking for resource class " - + plugin); - } - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - - if (resourcePlugin != null) { - try { - switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) { - case SUCCESS: - outValue = "true"; - break; - case NOT_FOUND: - outValue = "false"; - break; - case FAILURE: - default: - outValue = "false"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/MdsalHelper.java deleted file mode 100644 index 4c5ee0686..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/MdsalHelper.java +++ /dev/null @@ -1,1186 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yangtools.yang.binding.Identifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MdsalHelper { - - private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); - private static Properties yangMappingProperties = new Properties(); - - @Deprecated - public static void setProperties(Properties input) { - setYangMappingProperties(input); - } - - public static void setYangMappingProperties(Properties properties) { - for (Object propNameObj : properties.keySet()) { - String propName = (String) propNameObj; - MdsalHelper.yangMappingProperties.setProperty(propName, properties.getProperty(propName)); - } - } - - public static void loadProperties(String propertiesFile) { - File file = new File(propertiesFile); - Properties properties = new Properties(); - InputStream input = null; - if (file.isFile() && file.canRead()) { - try { - input = new FileInputStream(file); - properties.load(input); - MdsalHelper.setYangMappingProperties(properties); - LOG.info("Loaded properties from " + propertiesFile); - } catch (Exception e) { - LOG.error("Failed to load properties " + propertiesFile + "\n", e); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - LOG.error("Failed to close properties file " + propertiesFile + "\n", e); - } - } - } - }else{ - LOG.error("Failed to load the properties file " + propertiesFile + "\n"); - LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); - } - } - - public static Properties toProperties(Properties props, Object fromObj) { - Class fromClass = null; - - if (fromObj != null) { - fromClass = fromObj.getClass(); - } - return (toProperties(props, "", fromObj, fromClass)); - } - - public static Properties toProperties(Properties props, String pfx, Object fromObj) { - Class fromClass = null; - - if (fromObj != null) { - fromClass = fromObj.getClass(); - } - - return (toProperties(props, pfx, fromObj, fromClass)); - } - - public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { - - if (fromObj == null) { - return (props); - } - - String simpleName = fromClass.getSimpleName(); - - LOG.trace("Extracting properties from " + fromClass.getName() + " class"); - if (fromObj instanceof List) { - - // Class is a List. List should contain yang-generated classes. - LOG.trace(fromClass.getName() + " is a List"); - - List fromList = (List) fromObj; - - for (int i = 0; i < fromList.size(); i++) { - toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); - } - props.setProperty(pfx + "_length", "" + fromList.size()); - - } else if (isYangGenerated(fromClass)) { - // Class is yang generated. - LOG.trace(fromClass.getName() + " is a Yang-generated class"); - - String propNamePfx = null; - - // If called from a list (so prefix ends in ']'), don't - // add class name again - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx; - } else { - propNamePfx = toLowerHyphen(fromClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - // Iterate through getter methods to figure out values we need to - // save from - - int numGetters = 0; - String lastGetterName = null; - String propVal = null; - - for (Method m : fromClass.getMethods()) { - if (isGetter(m)) { - - numGetters++; - lastGetterName = m.getName(); - - Class returnType = m.getReturnType(); - String fieldName; - if (m.getName().startsWith("get")) { - fieldName = toLowerHyphen(m.getName().substring(3)); - } else { - - fieldName = toLowerHyphen(m.getName().substring(2)); - } - - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - // Is the return type a yang generated class? - if (isYangGenerated(returnType)) { - // Is it an enum? - if (returnType.isEnum()) { - // Return type is a typedef. Save its value. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - Object retValue = m.invoke(fromObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - String propName = propNamePfx + "." + fieldName; - propVal = retValue.toString(); - props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert Yang-generated enum returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpv4Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = retValue.getValue().toString(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpv6Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = retValue.getValue().toString(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpAddress(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - IpAddress retValue = (IpAddress) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = new String(retValue.getValue()); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpPrefix(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - IpPrefix retValue = (IpPrefix) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = new String(retValue.getValue()); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retValue = m.invoke(fromObj); - - if (retValue instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); - retValue = new String((byte[]) retValue, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + retValue); - } - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); - } - } catch (Exception e) { - - if (m.getName().equals("getKey")) { - LOG.trace("Caught " + e.getClass().getName() + " exception trying to convert results from getKey() - ignoring"); - } else { - LOG.error("Caught exception trying to convert Yang-generated class returned by" + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - } else if (returnType.equals(Class.class)) { - - LOG.trace(m.getName() + " returns a Class object - not interested"); - - } else if (List.class.isAssignableFrom(returnType)) { - - // This getter method returns a list. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retList = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - // Figure out what type of elements are stored in - // this array. - Type paramType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; - toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType); - } catch (Exception e) { - LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - - } else { - - // Method returns something that is not a List and not - // yang-generated. - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object propValObj = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (propValObj != null) { - if (propValObj instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); - propVal = new String((byte[]) propValObj, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + propVal); - - } else { - propVal = propValObj.toString(); - } - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - if (m.getName().equals("getKey")) { - LOG.trace("Caught " + e.getClass().getName() + " exception trying to convert results from getKey() - ignoring"); - } else { - LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - - } - } - - // End of method loop. If there was only one getter, named - // "getValue", then - // set value identified by "prefix" to that one value. - if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { - LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + " = " + propVal); - props.setProperty(propNamePfx, propVal); - } else { - LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " + lastGetterName); - - } - - } else { - // Class is not yang generated and not a list - // It must be an element of a leaf list - set "prefix" to value - String fromVal = null; - if (fromObj instanceof byte[]) { - try { - fromVal = new String((byte[]) fromObj, "UTF-8"); - LOG.trace("Converted byte array " + pfx + "to string " + fromVal); - } catch (Exception e) { - LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); - fromVal = fromObj.toString(); - } - - } else { - fromVal = fromObj.toString(); - } - LOG.debug("Setting property " + pfx + " to " + fromVal); - props.setProperty(pfx, fromVal); - } - - return (props); - } - - public static Object toBuilder(Properties props, Object toObj) { - - return (toBuilder(props, "", toObj)); - } - - public static List toList(Properties props, String pfx, List toObj, Class elemType) { - - int maxIdx = -1; - boolean foundValue = false; - - LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); - - if (props.contains(pfx + "_length")) { - try { - int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); - - if (listLength > 0) { - maxIdx = listLength - 1; - } - } catch (Exception e) { - // Ignore exception - } - } - - if (maxIdx == -1) { - // Figure out array size - for (Object pNameObj : props.keySet()) { - String key = (String) pNameObj; - - if (key.startsWith(pfx + "[")) { - String idxStr = key.substring(pfx.length() + 1); - int endloc = idxStr.indexOf("]"); - if (endloc != -1) { - idxStr = idxStr.substring(0, endloc); - } - - try { - int curIdx = Integer.parseInt(idxStr); - if (curIdx > maxIdx) { - maxIdx = curIdx; - } - } catch (Exception e) { - LOG.error("Illegal subscript in property " + key); - } - - } - } - } - - LOG.trace(pfx + " has max index of " + maxIdx); - for (int i = 0; i <= maxIdx; i++) { - - String curBase = pfx + "[" + i + "]"; - - if (isYangGenerated(elemType)) { - String builderName = elemType.getName() + "Builder"; - try { - Class builderClass = Class.forName(builderName); - Object builderObj = builderClass.newInstance(); - Method buildMethod = builderClass.getMethod("build"); - builderObj = toBuilder(props, curBase, builderObj, true); - if (builderObj != null) { - LOG.trace("Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(builderObj); - toObj.add(builtObj); - foundValue = true; - } - - } catch (ClassNotFoundException e) { - LOG.warn("Could not find builder class " + builderName, e); - } catch (Exception e) { - LOG.error("Caught exception trying to populate list from " + pfx); - } - } else { - // Must be a leaf list - String curValue = props.getProperty(curBase, ""); - - toObj.add(curValue); - - if ((curValue != null) && (curValue.length() > 0)) { - foundValue = true; - } - } - - } - - if (foundValue) { - return (toObj); - } else { - return (null); - } - - } - - public static Object toBuilder(Properties props, String pfx, Object toObj) { - return (toBuilder(props, pfx, toObj, false)); - } - - public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { - Class toClass = toObj.getClass(); - boolean foundValue = false; - - LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); - - Ipv4Address addr; - - if (isYangGenerated(toClass)) { - // Class is yang generated. - LOG.trace(toClass.getName() + " is a Yang-generated class"); - - String propNamePfx = null; - if (preservePfx) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - if (toObj instanceof Identifier) { - LOG.trace(toClass.getName() + " is a Key - skipping"); - return (toObj); - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - if (isSetter(m)) { - Class paramTypes[] = m.getParameterTypes(); - Class paramClass = paramTypes[0]; - - String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - - String paramValue = props.getProperty(propName); - if (paramValue == null) { - LOG.trace(propName + " is unset"); - } else { - LOG.trace(propName + " = " + paramValue); - } - - // Is the return type a yang generated class? - if (isYangGenerated(paramClass)) { - // Is it an enum? - if (paramClass.isEnum()) { - - LOG.trace(m.getName() + " expects an Enum"); - // Param type is a typedef. - if ((paramValue != null) && (paramValue.length() > 0)) { - Object paramObj = null; - - try { - paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); - } catch (Exception e) { - LOG.error("Caught exception trying to convert field " + propName + " to enum " + paramClass.getName(), e); - } - - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to create Yang-generated enum expected by" + toClass.getName() + "." + m.getName() + "() from Properties entry", e); - } - } - } else { - - String simpleName = paramClass.getSimpleName(); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName)) { - - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); - - if ("Ipv4Address".equals(simpleName)) { - m.invoke(toObj, ipAddr.getIpv4Address()); - } else if ("Ipv6Address".equals(simpleName)) { - m.invoke(toObj, ipAddr.getIpv6Address()); - - } else { - m.invoke(toObj, ipAddr); - } - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + paramValue + ")", e); - - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to call " + toClass.getName() + "." + m.getName() + "() with Properties entry", e); - } - } - } else if ("IpPrefix".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); - m.invoke(toObj, ipPrefix); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + paramValue + ")", e); - } - } - } else { - // setter expects a yang-generated class. Need - // to - // create a builder to set it. - - String builderName = paramClass.getName() + "Builder"; - Class builderClass = null; - Object builderObj = null; - Object paramObj = null; - - Object constObj = null; - - LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " + builderName); - try { - builderClass = Class.forName(builderName); - builderObj = builderClass.newInstance(); - paramObj = toBuilder(props, propNamePfx, builderObj); - } catch (ClassNotFoundException e) { - - if (paramValue == null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(null)"); - m.invoke(toObj, new Object[] { null }); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e1) { - LOG.error("Caught exception trying to cally" + toClass.getName() + "." + m.getName() + "() with Properties entry", e1); - } - } else { - try { - // See if I can find a constructor I - // can - // use - Constructor[] constructors = paramClass.getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (String.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (Long.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(Long.parseLong(paramValue)); - } - } - } - - } - - if (constObj == null) { - - // Last chance - see if - // parameter class has a static - // method - // getDefaultInstance(String) - try { - Method gm = paramClass.getMethod("getDefaultInstance", String.class); - - int gmodifier = gm.getModifiers(); - if (Modifier.isStatic(gmodifier)) { - // Invoke static - // getDefaultInstance(String) - paramObj = gm.invoke(null, paramValue); - } - - } catch (Exception gme) { - // Ignore exceptions - } - } - - } catch (Exception e1) { - LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); - } - - if (constObj == null) { - LOG.warn("Could not find builder class " + builderName + " and could not find a String or Long constructor or static getDefaultInstance(String) - trying just to set passing paramValue"); - - } - } - } catch (Exception e) { - LOG.error("Caught exception trying to create builder " + builderName, e); - } - - if (paramObj != null) { - - try { - - Method buildMethod = builderClass.getMethod("build"); - LOG.trace("Calling " + paramObj.getClass().getName() + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(paramObj); - - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); - m.invoke(toObj, builtObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to set Yang-generated class expected by" + toClass.getName() + "." + m.getName() + "() from Properties entry", e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - if (constObj != null) { - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + constObj.toString() + ")"); - m.invoke(toObj, constObj); - } else { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramValue); - - } - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(paramClass)) { - - LOG.trace("Parameter class " + paramClass.getName() + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type paramType = m.getGenericParameterTypes()[0]; - Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; - Object paramObj = new LinkedList(); - try { - paramObj = toList(props, propName, (List) paramObj, (Class) elementType); - } catch (Exception e) { - LOG.error("Caught exception trying to create list expected as argument to " + toClass.getName() + "." + m.getName()); - } - - if (paramObj != null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert List returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } else { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + paramClass.getName() + " is not a yang-generated class or a List"); - - if ((paramValue != null) && (paramValue.length() > 0)) { - - Object constObj = null; - - try { - // See if I can find a constructor I can use - Constructor[] constructors = paramClass.getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (String.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (Long.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(Long.parseLong(paramValue)); - } - } - } - - } - - if (constObj != null) { - try { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + constObj + ")"); - m.invoke(toObj, constObj); - foundValue = true; - } catch (Exception e2) { - LOG.error("Caught exception trying to call " + m.getName(), e2); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } catch (Exception e1) { - LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); - } - - } - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - if (foundValue) { - return (toObj); - } else { - return (null); - } - } - - public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { - boolean foundValue = false; - - LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); - - if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { - // Class is yang generated. - LOG.trace(toClass.getName() + " is a Yang-generated class"); - - if (toClass.getName().endsWith("Key")) { - if (Identifier.class.isAssignableFrom(toClass)) { - LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); - } else { - - LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); - } - } - - String propNamePfx = null; - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - LOG.trace("Is " + m.getName() + " method a getter?"); - if (isGetter(m)) { - LOG.trace(m.getName() + " is a getter"); - Class returnClass = m.getReturnType(); - - String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - - // Is the return type a yang generated class? - if (isYangGenerated(returnClass)) { - // Is it an enum? - if (returnClass.isEnum()) { - - LOG.trace(m.getName() + " is an Enum"); - pstr.print("\n\n * " + propName); - - } else { - - String simpleName = returnClass.getSimpleName(); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName)) { - LOG.trace(m.getName() + " is an " + simpleName); - pstr.print("\n\n * " + propName); - } else { - printPropertyList(pstr, propNamePfx, returnClass); - } - - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(returnClass)) { - - LOG.trace("Parameter class " + returnClass.getName() + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type returnType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; - Class elementClass = (Class) elementType; - LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); - printPropertyList(pstr, propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", elementClass); - - } else if (!returnClass.equals(Class.class)) { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + returnClass.getName() + " is not a yang-generated class or a List"); - - pstr.print("\n\n * " + propName); - - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - } - - public static boolean isYangGenerated(Class c) { - if (c == null) { - return (false); - } else { - return (c.getName().startsWith("org.opendaylight.yang.gen.")); - } - } - - public static boolean isIpPrefix(Class c) { - - if (c == null) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("IpPrefix".equals(simpleName)); - } - - public static boolean isIpv4Address(Class c) { - - if (c == null) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv4Address".equals(simpleName)); - } - - public static boolean isIpv6Address(Class c) { - - if (c == null) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv6Address".equals(simpleName)); - } - - public static boolean isIpAddress(Class c) { - - if (c == null) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("IpAddress".equals(simpleName)); - } - - public static String toLowerHyphen(String inStr) { - if (inStr == null) { - return (null); - } - - String str = inStr.substring(0, 1).toLowerCase(); - if (inStr.length() > 1) { - str = str + inStr.substring(1); - } - - String regex = "(([a-z0-9])([A-Z]))"; - String replacement = "$2-$3"; - - String retval = str.replaceAll(regex, replacement).toLowerCase(); - - LOG.trace("Converting " + inStr + " => " + str + " => " + retval); - return (retval); - } - - //This is called when mapping the yang value back to a valid java enumeration - public static String toJavaEnum(String inStr) { - if (inStr == null) { - return (null); - } else if (inStr.length() == 0) { - return (inStr); - } - - //This will strip out all periods, which cannot be in a java enum - inStr = inStr.replaceAll("\\.", ""); - - String[] terms = inStr.split("-"); - StringBuffer sbuff = new StringBuffer(); - - //appends an _ if the string starts with a digit to make it a valid java enum - if (Character.isDigit(inStr.charAt(0))) { - sbuff.append('_'); - } - //If the string contains hyphens it will convert the string to upperCamelCase without hyphens - for (String term : terms) { - sbuff.append(term.substring(0, 1).toUpperCase()); - if (term.length() > 1) { - sbuff.append(term.substring(1)); - } - } - return (sbuff.toString()); - - } - - public static boolean isGetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { - if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { - if (!"getClass".equals(m.getName())) { - return (true); - } - } - - if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { - return (true); - } - - if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { - return (true); - } - } - - return (false); - } - - public static boolean isSetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { - if (m.getName().matches("^set[A-Z].*")) { - Class[] paramTypes = m.getParameterTypes(); - if (paramTypes[0].isAssignableFrom(Identifier.class) || Identifier.class.isAssignableFrom(paramTypes[0])) { - return (false); - } else { - return (true); - } - } - - } - - return (false); - } - - public static String getFullPropertiesPath(String propertiesFileName) { - return "/opt/bvc/controller/configuration/" + propertiesFileName; - } - - //This is called when mapping a valid java enumeration back to the yang model value - public static String mapEnumeratedValue(String propertyName, String propertyValue) { - LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); - String mappingKey = "yang." + propertyName + "." + propertyValue; - if (yangMappingProperties.containsKey(mappingKey)) { - return (yangMappingProperties.getProperty(mappingKey)); - } else { - LOG.info("yangMappingProperties did not contain the key " + mappingKey + " returning the original value."); - return propertyValue; - } - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java deleted file mode 100644 index 706014a32..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/NotifyNodeExecutor.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NotifyNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(NotifyNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String action = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("action"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("release node encountered - looking for resource class " - + plugin); - } - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - - switch (resourcePlugin.notify(resourceType, action, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java deleted file mode 100644 index 8ba14d276..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/RecordNodeExecutor.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicRecorder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RecordNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(RecordNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String outValue = "failure"; - - if (LOG.isTraceEnabled()) { - LOG.trace(node.getNodeType() - + " node encountered - looking for recorder class " - + plugin); - } - - Map parmMap = new HashMap(); - - Set> parmSet = node - .getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, - node, ctx); - - if (LOG.isTraceEnabled()) { - LOG.trace("executeRecordNode : parameter " + curName + " = " - + curExpr + " => " + curExprValue); - } - parmMap.put(curName, curExprValue); - } - - - SvcLogicRecorder recorder = getSvcLogicRecorder(plugin); - - if (recorder != null) { - - try { - recorder.record(parmMap); - } catch (SvcLogicException e) { - LOG.error("Caught exception from recorder plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicRecorder object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isTraceEnabled()) { - LOG.trace("no failure or Other branch found"); - } - } - return (nextNode); - } - - - - - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java deleted file mode 100644 index 0d8416cdd..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReleaseNodeExecutor.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReleaseNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(ReleaseNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("release node encountered - looking for resource class " - + plugin); - } - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - - switch (resourcePlugin.release(resourceType, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java deleted file mode 100644 index f0bbda88f..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReserveNodeExecutor.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReserveNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(ReserveNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"),node,ctx); - - - SvcLogicExpression selectExpr = node.getAttribute("select"); - String select = null; - - if (selectExpr != null) - { - select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("reserve node encountered - looking for resource class " - + plugin); - } - - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReturnNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReturnNodeExecutor.java deleted file mode 100644 index 5cca47128..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/ReturnNodeExecutor.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReturnNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(ReturnNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String status = SvcLogicExpressionResolver.evaluate( - node.getAttribute("status"), node, ctx); - - if (status != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("Returning status " + status); - } - ctx.setStatus(status); - } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Return node has no status attribute set"); - } - } - - Set> parameterSet = node - .getParameterSet(); - - for (Iterator> iter = parameterSet - .iterator(); iter.hasNext();) { - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - String curValue = SvcLogicExpressionResolver.evaluate( - curEnt.getValue(), node, ctx); - - if (LOG.isDebugEnabled()) { - LOG.debug("Setting context attribute " + curName + " to " - + curValue); - } - ctx.setAttribute(curName, curValue); - } - return null; - } - - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java deleted file mode 100644 index 57eac7f7b..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SaveNodeExecutor.java +++ /dev/null @@ -1,142 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SaveNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(SaveNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String forceStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("force"), node, ctx); - String localOnlyStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("local-only"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); - - boolean force = "true".equalsIgnoreCase(forceStr); - boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); - - Map parmMap = new HashMap(); - - Set> parmSet = node - .getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate( - curExpr, node, ctx); - - LOG.debug("Parameter " + curName + " = " - + curExpr.asParsedExpr() + " resolves to " - + curExprValue); - - parmMap.put(curName, curExprValue); - } - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("save node encountered - looking for resource class " - + plugin); - } - - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.save(resourceType, force, localOnly, key, - parmMap, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java deleted file mode 100644 index 013997eda..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SetNodeExecutor.java +++ /dev/null @@ -1,189 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.Set; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicExpressionFactory; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SetNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(SetNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String ifunsetStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("only-if-unset"), node, ctx); - - boolean ifunset = "true".equalsIgnoreCase(ifunsetStr); - - Set> parameterSet = node - .getParameterSet(); - - for (Iterator> iter = parameterSet - .iterator(); iter.hasNext();) { - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - String lhsVarName = curName; - - // Resolve LHS of assignment (could contain index variables) - try { - SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); - lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); - } catch (Exception e) { - LOG.warn("Caught exception trying to resolve variable name ("+curName+")", e); - } - - - boolean setValue = true; - - if (curName.endsWith(".")) { - - // Copy subtree - value should be a variable name - SvcLogicExpression curValue = curEnt.getValue(); - - if (curValue != null) { - String rhsRoot = curValue.toString(); - - if ((rhsRoot != null) && (rhsRoot.length() > 0)) { - if (rhsRoot.endsWith(".")) { - rhsRoot = rhsRoot - .substring(0, rhsRoot.length() - 1); - } - - - // SDNGC-2321 : rhsRoot is variable name, possibly with subscript(s) to be resolved - try { - SvcLogicExpression rhsExpr = SvcLogicExpressionFactory.parse(rhsRoot); - rhsRoot = SvcLogicExpressionResolver.resolveVariableName(rhsExpr, node, ctx); - } catch (Exception e) { - LOG.warn("Caught exception trying to resolve variable name ("+rhsRoot+")", e); - } - - // See if the parameters are reversed (copying service-data to input) .. this - // was done as a workaround to earlier issue - if (curName.endsWith("-input.") && rhsRoot.startsWith("service-data")) { - LOG.warn("Arguments appear to be reversed .. will copy input to service-data instead"); - lhsVarName = rhsRoot + "."; - rhsRoot = curName.substring(0, curName.length()-1); - } - - rhsRoot = rhsRoot + "."; - String lhsPrefix = lhsVarName; - - if (lhsPrefix.endsWith(".")) { - lhsPrefix = lhsPrefix.substring(0, - lhsPrefix.length()-1); - } - int lhsPfxLength = lhsPrefix.length(); - HashMap parmsToAdd = new HashMap(); - - for (String sourceVarName : ctx.getAttributeKeySet()) { - - if (sourceVarName.startsWith(rhsRoot)) { - - String targetVar = lhsPrefix - + "." - + sourceVarName - .substring(rhsRoot.length()); - - LOG.debug("Copying " + sourceVarName - + " value to " + targetVar); - - parmsToAdd.put(targetVar, - ctx.getAttribute(sourceVarName)); - } - } - - for (String newParmName : parmsToAdd.keySet()) { - ctx.setAttribute(newParmName, parmsToAdd.get(newParmName)); - } - - } else { - // If RHS is empty, unset attributes in LHS - String lhsPrefix = lhsVarName.substring(0, - lhsVarName.length() - 1); - int lhsPfxLength = lhsPrefix.length(); - - LinkedList parmsToRemove = new LinkedList (); - - for (String curCtxVarname : ctx.getAttributeKeySet()) { - - if (curCtxVarname.startsWith(lhsPrefix)) { - LOG.debug("Unsetting " + curCtxVarname); - parmsToRemove.add(curCtxVarname); - } - } - - for (String parmName : parmsToRemove) { - ctx.setAttribute(parmName, null); - } - - } - } - - } else { - - if (ifunset) { - String ctxValue = ctx.getAttribute(lhsVarName); - - if ((ctxValue != null) && (ctxValue.length() > 0)) { - setValue = false; - LOG.debug("Attribute " - + lhsVarName - + " already set and only-if-unset is true, so not overriding"); - } - } - - if (setValue) { - String curValue = SvcLogicExpressionResolver.evaluate( - curEnt.getValue(), node, ctx); - - if (LOG.isDebugEnabled()) { - LOG.trace("Parameter value " - + curEnt.getValue().asParsedExpr() - + " resolves to " + curValue); - LOG.debug("Setting context attribute " + lhsVarName - + " to " + curValue); - } - ctx.setAttribute(lhsVarName, curValue); - } - } - } - - return null; - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java deleted file mode 100644 index ae42e2c7e..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicActivator.java +++ /dev/null @@ -1,225 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.io.File; -import java.io.FileInputStream; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.Map; -import java.util.Properties; - -import org.openecomp.sdnc.sli.ConfigurationException; -import org.openecomp.sdnc.sli.SvcLogicAdaptor; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicStore; -import org.openecomp.sdnc.sli.SvcLogicStoreFactory; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.mysql.jdbc.Driver; - -public class SvcLogicActivator implements BundleActivator { - - private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - - private static final Map BUILTIN_NODES = new HashMap() { - { - put("block", new BlockNodeExecutor()); - put("call", new CallNodeExecutor()); - put("configure", new ConfigureNodeExecutor()); - put("delete", new DeleteNodeExecutor()); - put("execute", new ExecuteNodeExecutor()); - put("exists", new ExistsNodeExecutor()); - put("for", new ForNodeExecutor()); - put("get-resource", new GetResourceNodeExecutor()); - put("is-available", new IsAvailableNodeExecutor()); - put("notify", new NotifyNodeExecutor()); - put("record", new RecordNodeExecutor()); - put("release", new ReleaseNodeExecutor()); - put("reserve", new ReserveNodeExecutor()); - put("return", new ReturnNodeExecutor()); - put("save", new SaveNodeExecutor()); - put("set", new SetNodeExecutor()); - put("switch", new SwitchNodeExecutor()); - put("update", new UpdateNodeExecutor()); - put("break", new BreakNodeExecutor()); - - } - }; - - private static LinkedList registrations = new LinkedList(); - - private static HashMap adaptorMap = null; - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicActivator.class); - - private static Properties props = null; - - private static BundleContext bundleCtx = null; - - private static SvcLogicService svcLogicServiceImpl = null; - - @Override - public void start(BundleContext ctx) throws Exception { - - LOG.info("Activating SLI"); - - bundleCtx = ctx; - - // Read properties - props = new Properties(); - String propPath = System.getenv(SVCLOGIC_PROP_VAR); - - if (propPath == null) { - String propDir = System.getenv(SDNC_CONFIG_DIR); - if (propDir == null) { - - propDir = "/opt/sdnc/data/properties"; - } - propPath = propDir + "/svclogic.properties"; - LOG.warn("Environment variable "+SVCLOGIC_PROP_VAR+" unset - defaulting to "+propPath); - } - - File propFile = new File(propPath); - - if (!propFile.exists()) { - - throw new ConfigurationException( - "Missing configuration properties file : " - + propFile); - } - try { - - props.load(new FileInputStream(propFile)); - } catch (Exception e) { - throw new ConfigurationException( - "Could not load properties file " + propPath, e); - - } - - - if (registrations == null) { - - registrations = new LinkedList(); - } - - // Advertise SvcLogicService - svcLogicServiceImpl = new SvcLogicServiceImpl(); - - LOG.info("SLI: Registering service " + SvcLogicService.NAME - + " in bundle " + ctx.getBundle().getSymbolicName()); - ServiceRegistration reg = ctx.registerService(SvcLogicService.NAME, - svcLogicServiceImpl, null); - registrations.add(reg); - - // Initialize SvcLogicStore - try { - SvcLogicStore store = getStore(); - registerNodeTypes(store); - } catch (ConfigurationException e) { - LOG.warn("Could not initialize SvcLogicScore", e); - } - - LOG.info("SLI - done registering services"); - } - - @Override - public void stop(BundleContext ctx) throws Exception { - - if (registrations != null) { - for (ServiceRegistration reg : registrations) { - ServiceReference regRef = reg.getReference(); - /* Don't bother to remove node types from table - String nodeType = (String) regRef.getProperty("nodeType"); - if (nodeType != null) { - LOG.info("SLI - unregistering node type " + nodeType); - store.unregisterNodeType(nodeType); - } - */ - reg.unregister(); - } - registrations = null; - } - } - - public static SvcLogicStore getStore() throws SvcLogicException { - // Create and initialize SvcLogicStore object - used to access - // saved service logic. - - SvcLogicStore store = null; - - try { - Driver dvr = new Driver(); - store = SvcLogicStoreFactory.getSvcLogicStore(props); - } catch (Exception e) { - throw new ConfigurationException( - "Could not get service logic store", e); - - } - - try { - store.init(props); - } catch (Exception e) { - throw new ConfigurationException( - "Could not get service logic store", e); - } - - return(store); - } - - private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException { - - if (store == null) { - return; - } - // Advertise built-in node executors - LOG.info("SLI : Registering built-in node executors"); - Hashtable propTable = new Hashtable(); - - for (String nodeType : BUILTIN_NODES.keySet()) { - LOG.info("SLI - registering node type " + nodeType); - propTable.clear(); - propTable.put("nodeType", nodeType); - - ServiceRegistration reg = bundleCtx.registerService(SvcLogicNodeExecutor.class.getName(), - BUILTIN_NODES.get(nodeType), propTable); - registrations.add(reg); - - store.registerNodeType(nodeType); - - LOG.info("SLI - registering node executor"); - - ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); - - } - - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicAdaptorFactory.java deleted file mode 100644 index aa8c005a6..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicAdaptorFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.HashMap; - -import org.openecomp.sdnc.sli.SvcLogicAdaptor; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SvcLogicAdaptorFactory { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicAdaptorFactory.class); - - private static HashMap adaptorMap = new HashMap(); - - public static void registerAdaptor(SvcLogicAdaptor adaptor) { - String name = adaptor.getClass().getName(); - LOG.info("Registering adaptor " + name); - adaptorMap.put(name, adaptor); - - } - - public static void unregisterAdaptor(String name) { - if (adaptorMap.containsKey(name)) { - LOG.info("Unregistering " + name); - adaptorMap.remove(name); - } - } - - public static SvcLogicAdaptor getInstance(String name) { - if (adaptorMap.containsKey(name)) { - return (adaptorMap.get(name)); - } else { - BundleContext bctx = null; - try - { - bctx = FrameworkUtil.getBundle(SvcLogicAdaptorFactory.class) - .getBundleContext(); - } - catch (Exception e) - { - LOG.debug("Caught exception trying to locate device adaptor "+name, e); - return(null); - } - - ServiceReference sref = bctx.getServiceReference(name); - - if (sref != null) { - SvcLogicAdaptor adaptor = (SvcLogicAdaptor) bctx - .getService(sref); - - if (adaptor != null) { - registerAdaptor(adaptor); - - return (adaptor); - } - return (null); - } - } - return(null); - } -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java deleted file mode 100644 index 5c17c7997..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolver.java +++ /dev/null @@ -1,605 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.openecomp.sdnc.sli.SvcLogicAtom; -import org.openecomp.sdnc.sli.SvcLogicAtom.AtomType; -import org.openecomp.sdnc.sli.SvcLogicBinaryExpression; -import org.openecomp.sdnc.sli.SvcLogicBinaryExpression.OperatorType; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicFunctionCall; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicVariableTerm; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SvcLogicExpressionResolver { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicExpressionResolver.class); - - public static String evaluate(SvcLogicExpression expr, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - if (expr == null) { - return (null); - } - - - - if (expr instanceof SvcLogicAtom) { - SvcLogicAtom atom = (SvcLogicAtom) expr; - - AtomType atomType = atom.getAtomType(); - switch (atomType) { - case NUMBER: - case STRING: - return (atom.toString()); - case CONTEXT_VAR: - case IDENTIFIER: - - String varName = resolveVariableName(atom, node, ctx); - - if (atomType == AtomType.CONTEXT_VAR) - { - LOG.trace("Evaluating context variable $"+varName); - - String varValue = ctx.getAttribute(varName); - - if (varValue == null) { - LOG.trace("Context variable $"+varName+" unset - treating as empty string"); - varValue = ""; - } - - return (varValue); - } - SvcLogicExpression parm = node.getParameter(varName); - if (parm != null) { - LOG.trace("Evaluating value of parameter "+varName+": "+parm.asParsedExpr()); - - return (evaluate(parm, node, ctx)); - } - else - { - return(varName); - } - default: - return(null); - } - - } else if (expr instanceof SvcLogicBinaryExpression) { - SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; - List operators = binExpr.getOperators(); - if (operators.isEmpty()) - { - List operands = binExpr.getOperands(); - if (operands.size() == 1) - { - LOG.trace("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); - return(evaluate(operands.get(0), node, ctx)); - } - else - { - if (operands.isEmpty()) - { - LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); - } - else - { - LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); - } - return(null); - } - } - switch (operators.get(0)) { - case addOp: - case subOp: - case multOp: - case divOp: - return(evalArithExpression(binExpr, node, ctx)); - case equalOp: - case neOp: - case ltOp: - case leOp: - case gtOp: - case geOp: - return (evalCompareExpression(binExpr, node, ctx)); - case andOp: - case orOp: - return(evalLogicExpression(binExpr, node, ctx)); - - default: - return(null); - } - } - else if (expr instanceof SvcLogicFunctionCall) - { - return(evalFunctionCall((SvcLogicFunctionCall)expr, node, ctx)); - } - else - { - throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); - } - } - - private static String evalArithExpression(SvcLogicBinaryExpression binExpr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - List operands = binExpr.getOperands(); - List operators = binExpr.getOperators(); - if (operands.size() != (operators.size()+1)) - { - throw new SvcLogicException("Invalid expression ("+binExpr+")"); - } - String retval = evaluate(operands.get(0), node, ctx); - String retsval = retval; - long retlval = 0; - boolean valueIsLong = false; - - int i = 1; - try - { - - if ((retval.length() > 0) && StringUtils.isNumeric(retval)) - { - retlval = Long.parseLong(retval); - valueIsLong = true; - } - for (OperatorType operator: operators) - { - String curOperandValue = evaluate(operands.get(i++), node, ctx); - switch(operator) { - case addOp: - retsval = retsval + curOperandValue; - if (valueIsLong) - { - if ((curOperandValue.length() > 0) && StringUtils.isNumeric(curOperandValue) ) - { - retlval = retlval + Long.parseLong(curOperandValue); - } - else - { - valueIsLong = false; - } - } - break; - case subOp: - retlval = retlval - Long.parseLong(curOperandValue); - break; - case multOp: - retlval = retlval * Long.parseLong(curOperandValue); - break; - case divOp: - retlval = retlval / Long.parseLong(curOperandValue); - break; - } - - } - } - catch (NumberFormatException e1) - { - throw new SvcLogicException("Illegal value in arithmetic expression", e1); - } - - if (valueIsLong) - { - return("" + retlval); - } - else - { - return(retsval); - } - - } - - - - private static String evalCompareExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException - { - - List operators = expr.getOperators(); - List operands = expr.getOperands(); - - if ((operators.size() != 1) || (operands.size() != 2)) - { - throw new SvcLogicException ("Invalid comparison expression : "+expr); - } - - OperatorType operator = operators.get(0); - String op1Value = evaluate(operands.get(0), node, ctx); - String op2Value = evaluate(operands.get(1), node, ctx); - - if ((StringUtils.isNotEmpty(op1Value) && StringUtils.isNumeric(op1Value) && StringUtils.isNotEmpty(op2Value) && StringUtils.isNumeric(op2Value))) - { - try - { - double op1dbl = Double.parseDouble(op1Value); - double op2dbl = Double.parseDouble(op2Value); - - switch(operator) - { - case equalOp: - return(Boolean.toString(op1dbl == op2dbl)); - case neOp: - return(Boolean.toString(op1dbl != op2dbl)); - case ltOp: - return(Boolean.toString(op1dbl < op2dbl)); - case leOp: - return(Boolean.toString(op1dbl <= op2dbl)); - case gtOp: - return(Boolean.toString(op1dbl > op2dbl)); - case geOp: - return(Boolean.toString(op1dbl >= op2dbl)); - default: - return(null); - } - } - catch (NumberFormatException e) - { - throw new SvcLogicException("Caught exception trying to compare numeric values", e); - } - } - else - { - - int compResult = 0; - - if (op1Value == null) { - compResult = -1; - } else if (op2Value == null ) { - compResult = 1; - } else { - compResult = op1Value.compareToIgnoreCase(op2Value); - } - - switch(operator) - { - case equalOp: - return(Boolean.toString(compResult == 0)); - case neOp: - return(Boolean.toString(compResult != 0)); - case ltOp: - return(Boolean.toString(compResult < 0)); - case leOp: - return(Boolean.toString(compResult <= 0)); - case gtOp: - return(Boolean.toString(compResult > 0)); - case geOp: - return(Boolean.toString(compResult >= 0)); - default: - return(null); - } - } - - } - - private static String evalLogicExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException - { - boolean retval; - - List operands = expr.getOperands(); - List operators = expr.getOperators(); - - if (operands.size() != (operators.size()+1)) - { - throw new SvcLogicException("Invalid expression ("+expr+")"); - } - - try - { - retval = Boolean.parseBoolean(evaluate(operands.get(0), node, ctx)); - int i = 1; - for (OperatorType operator : operators) - { - if (operator == OperatorType.andOp) - { - retval = retval && Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); - } - else - { - - retval = retval || Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); - } - - } - } - catch (Exception e) - { - throw new SvcLogicException("Invalid expression ("+expr+")"); - } - - - return(Boolean.toString(retval)); - } - - private static String evalFunctionCall(SvcLogicFunctionCall func, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException - { - String funcName = func.getFunctionName(); - List operands = func.getOperands(); - - if ("length".equalsIgnoreCase(funcName)) - { - - if (operands.size() == 1) - { - String opValue = evaluate(operands.get(0), node, ctx); - return(""+opValue.length()); - } - else - { - throw new SvcLogicException("Invalid call to length() function"); - } - } - else if ("substr".equalsIgnoreCase(funcName)) - { - if (operands.size() == 3) - { - String op1Value = evaluate(operands.get(0), node, ctx); - String op2Value = evaluate(operands.get(1), node, ctx); - String op3Value = evaluate(operands.get(2), node, ctx); - - if (!StringUtils.isNumeric(op2Value) || !StringUtils.isNumeric(op3Value)) - { - throw new SvcLogicException("Invalid arguments to substr() function"); - } - - try - { - return(op1Value.substring(Integer.parseInt(op2Value), Integer.parseInt(op3Value))); - } - catch (Exception e) - { - throw new SvcLogicException("Caught exception trying to take substring", e); - } - } - else - { - - throw new SvcLogicException("Invalid call to substr() function"); - } - - } - else if ("toUpperCase".equalsIgnoreCase(funcName)) - { - if (operands.size() == 1) - { - String opValue = evaluate(operands.get(0), node, ctx); - if (opValue != null) { - return(opValue.toUpperCase()); - } else { - return(""); - } - } - else - { - throw new SvcLogicException("Invalid call to toUpperCase() function"); - } - } - else if ("toLowerCase".equalsIgnoreCase(funcName)) - { - if (operands.size() == 1) - { - String opValue = evaluate(operands.get(0), node, ctx); - if (opValue != null) { - return(opValue.toLowerCase()); - } else { - return(""); - } - } - else - { - throw new SvcLogicException("Invalid call to toLowerCase() function"); - } - } - else if ("convertBase".equalsIgnoreCase(funcName)) { - int fromBase = 10; - int toBase = 10; - String srcString = ""; - - if (operands.size() == 2) - { - fromBase = 10; - srcString = evaluate(operands.get(0), node, ctx); - toBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); - } else if (operands.size() == 3) { - - srcString = evaluate(operands.get(0), node, ctx); - fromBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); - toBase = Integer.parseInt(evaluate(operands.get(2), node, ctx)); - } else { - throw new SvcLogicException("Invalid call to convertBase() function"); - } - - long srcValue = Long.parseLong(srcString, fromBase); - return(Long.toString(srcValue, toBase)); - } - else - { - throw new SvcLogicException("Unrecognized function ("+funcName+")"); - } - - } - - public static String evaluateAsKey(SvcLogicExpression expr, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - if (expr == null) { - return (null); - } - - - - if (expr instanceof SvcLogicAtom) { - SvcLogicAtom atom = (SvcLogicAtom) expr; - - AtomType atomType = atom.getAtomType(); - StringBuffer varNameBuff = new StringBuffer(); - switch (atomType) { - case NUMBER: - return (atom.toString()); - case STRING: - return("'"+atom.toString()+"'"); - case CONTEXT_VAR: - case IDENTIFIER: - boolean needDot = false; - for (SvcLogicExpression term : atom.getOperands()) - { - if (needDot) - { - varNameBuff.append("."); - } - if (term instanceof SvcLogicVariableTerm) - { - SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; - varNameBuff.append(vterm.getName()); - if (vterm.numOperands() > 0) - { - varNameBuff.append("["); - varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); - varNameBuff.append("]"); - - } - } - else - { - varNameBuff.append(term.toString()); - } - needDot = true; - } - - String varName = varNameBuff.toString(); - LOG.debug("Evaluating context variable $"+varName); - String ctxValue = ctx.getAttribute(varName); - if (ctxValue == null) - { - return(null); - } - if (StringUtils.isNumeric(ctxValue)) - { - return(ctxValue); - } - else - { - return("'"+ctxValue+"'"); - } - - default: - return(null); - } - - } else if (expr instanceof SvcLogicBinaryExpression) { - SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; - List operators = binExpr.getOperators(); - List operands = binExpr.getOperands(); - if (operators.isEmpty()) - { - if (operands.size() == 1) - { - LOG.debug("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); - return(evaluateAsKey(operands.get(0), node, ctx)); - } - else - { - if (operands.isEmpty()) - { - LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); - } - else - { - LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); - } - return(null); - } - } - StringBuffer sbuff = new StringBuffer(); - sbuff.append(evaluateAsKey(operands.get(0), node, ctx)); - int i = 1; - for (OperatorType operator : operators) - { - sbuff.append(" "); - sbuff.append(operator.toString()); - sbuff.append(" "); - sbuff.append(evaluateAsKey(operands.get(i++), node,ctx)); - } - return(sbuff.toString()); - } - else if (expr instanceof SvcLogicFunctionCall) - { - StringBuffer sbuff = new StringBuffer(); - SvcLogicFunctionCall funcCall = (SvcLogicFunctionCall) expr; - sbuff.append(funcCall.getFunctionName()); - sbuff.append("("); - boolean needComma = false; - for (SvcLogicExpression operand : funcCall.getOperands()) - { - if (needComma) - { - sbuff.append(","); - } - else - { - needComma = true; - } - sbuff.append(evaluateAsKey(operand, node, ctx)); - } - sbuff.append(")"); - return(sbuff.toString()); - } - else - { - throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); - } - } - - public static String resolveVariableName(SvcLogicExpression atom, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException - { - StringBuffer varNameBuff = new StringBuffer(); - - boolean needDot = false; - for (SvcLogicExpression term : atom.getOperands()) - { - if (needDot) - { - varNameBuff.append("."); - } - if (term instanceof SvcLogicVariableTerm) - { - SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; - varNameBuff.append(vterm.getName()); - if (vterm.numOperands() > 0) - { - varNameBuff.append("["); - varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); - varNameBuff.append("]"); - } - } - else - { - varNameBuff.append(term.toString()); - } - needDot = true; - } - return(varNameBuff.toString()); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java deleted file mode 100644 index 0c8166ae1..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicNodeExecutor.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicAdaptor; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicRecorder; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.openecomp.sdnc.sli.SvcLogicStore; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public abstract class SvcLogicNodeExecutor { - - public abstract SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; - - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class); - - protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - if (node == null) { - return null; - } - - return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"), - node, ctx)); - - } - - protected SvcLogicStore getStore() throws SvcLogicException { - return SvcLogicActivator.getStore(); - } - - protected SvcLogicAdaptor getAdaptor(String adaptorName) { - return SvcLogicAdaptorFactory.getInstance(adaptorName); - } - - protected SvcLogicResource getSvcLogicResource(String plugin) { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(plugin); - if (sref != null) { - SvcLogicResource resourcePlugin = (SvcLogicResource) bctx - .getService(sref); - return resourcePlugin; - } - else { - LOG.warn("Could not find service reference object for plugin " + plugin); - return null; - } - } - - protected SvcLogicRecorder getSvcLogicRecorder(String plugin) { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(plugin); - if (sref != null) { - SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx - .getService(sref); - return resourcePlugin; - } - else { - return null; - } - } - - protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){ - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(pluginName); - - if (sref == null) { - LOG.warn("Could not find service reference object for plugin " + pluginName); - return null; - } else { - SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx - .getService(sref); - return plugin; - } - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java deleted file mode 100644 index f30b3fc06..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicService.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.Properties; - -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.openecomp.sdnc.sli.SvcLogicException; - -public interface SvcLogicService { - - public static final String NAME = "org.openecomp.sdnc.sli.provider.SvcLogicService"; - - // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException; - /** - * Check for existence of a directed graph - * @param module - module name - * @param rpc - rpc name - * @param version - version. If null, looks for active version - * @param mode - mode (sync/async) - * @return true if directed graph found, false otherwise - * @throws SvcLogicException - */ - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; - - /** - * Execute a directed graph - * - * @param module - module name - * @param rpc - rpc name - * @param version - version. If null, use active version - * @param mode - mode (sync/async) - * @param parms - parameters, used to set SvcLogicContext attributes - * @return final values of attributes from SvcLogicContext, as Properties - * @throws SvcLogicException - * - * - * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead - */ - @Deprecated - public Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; - - /** - * Execute a directed graph - * - * @param module - module name - * @param rpc - rpc name - * @param version - version. If null, use active version - * @param mode - mode (sync/async) - * @param parms - parameters, used to set SvcLogicContext attributes - * @param domDataBroker - DOMDataBroker object - * @return final values of attributes from SvcLogicContext, as Properties - * @throws SvcLogicException - */ - public Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException; - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicServiceImpl.java deleted file mode 100644 index ba929bae7..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SvcLogicServiceImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.HashMap; -import java.util.Properties; - -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.openecomp.sdnc.sli.MetricLogger; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicGraph; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicStore; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceEvent; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -public class SvcLogicServiceImpl implements SvcLogicService { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicServiceImpl.class); - - private HashMap nodeExecutors = null; - - private BundleContext bctx = null; - - private void registerExecutors() { - - LOG.info("Entered register executors"); - if (bctx == null) { - bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - } - - if (nodeExecutors == null) { - nodeExecutors = new HashMap(); - } - - LOG.info("Opening service tracker"); - ServiceTracker tracker = new ServiceTracker(bctx, - SvcLogicNodeExecutor.class.getName(), null); - - tracker.open(); - - ServiceListener listener = new ServiceListener() { - - public void serviceChanged(ServiceEvent ev) { - ServiceReference sr = ev.getServiceReference(); - switch (ev.getType()) { - case ServiceEvent.REGISTERED: { - registerExecutor(sr); - } - break; - case ServiceEvent.UNREGISTERING: { - unregisterExecutor(sr); - } - break; - } - } - }; - - LOG.info("Adding service listener"); - String filter = "(objectclass=" + SvcLogicNodeExecutor.class.getName() - + ")"; - try { - bctx.addServiceListener(listener, filter); - ServiceReference[] srl = bctx.getServiceReferences( - SvcLogicNodeExecutor.class.getName(), null); - for (int i = 0; srl != null && i < srl.length; i++) { - listener.serviceChanged(new ServiceEvent( - ServiceEvent.REGISTERED, srl[i])); - } - } catch (InvalidSyntaxException e) { - e.printStackTrace(); - } - LOG.info("Done registerExecutors"); - } - - public void registerExecutor(ServiceReference sr) { - - String nodeName = (String) sr.getProperty("nodeType"); - if (nodeName != null) { - - SvcLogicNodeExecutor executor = null; - - try { - executor = (SvcLogicNodeExecutor) bctx.getService(sr); - } catch (Exception e) { - LOG.error("Cannot get service executor for " + nodeName); - return; - } - - registerExecutor(nodeName, executor); - - } - } - - public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) - { - if (nodeExecutors == null) { - nodeExecutors = new HashMap(); - } - LOG.info("SLI - registering executor for node type "+nodeName); - nodeExecutors.put(nodeName, executor); - } - - public void unregisterExecutor(ServiceReference sr) { - String nodeName = (String) sr.getProperty("nodeType"); - - if (nodeName != null) { - - unregisterExecutor(nodeName); - - } - - } - - public void unregisterExecutor(String nodeName) - { - - LOG.info("SLI - unregistering executor for node type "+nodeName); - nodeExecutors.remove(nodeName); - } - - - - - public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) - throws SvcLogicException { - - if (nodeExecutors == null) { - registerExecutors(); - } - - // Set service name in MDC to reference current working directed graph - MDC.put(MetricLogger.SERVICE_NAME, graph.getModule()+":"+graph.getRpc()+"/v"+graph.getVersion()); - - SvcLogicNode curNode = graph.getRootNode(); - LOG.info("About to execute graph " + graph.toString()); - - - - while (curNode != null) { - LOG.info("About to execute node # "+curNode.getNodeId()+" ("+curNode.getNodeType()+")"); - - SvcLogicNode nextNode = executeNode(curNode, ctx); - curNode = nextNode; - } - - return (ctx); - } - - - public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - if (node == null) { - return (null); - } - - if (LOG.isDebugEnabled()) { - LOG.debug("Executing node " + node.getNodeId()); - } - - SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); - - if (executor != null) { - LOG.debug("Executing node executor for node type "+node.getNodeType()+" - "+executor.getClass().getName()); - return (executor.execute(this, node, ctx)); - } else { - if (LOG.isDebugEnabled()) { - LOG.debug(node.getNodeType() + " node not implemented"); - } - SvcLogicNode nextNode = node.getOutcomeValue("failure"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute failure branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no failure or Other branch found"); - } - } - return (nextNode); - } - - } - - @Override - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException - { - SvcLogicStore store = SvcLogicActivator.getStore(); - - return (store.hasGraph(module, rpc, version, mode)); - } - - @Override - public Properties execute(String module, String rpc, String version, String mode, Properties props) - throws SvcLogicException { - return(execute(module, rpc, version, mode, props, null)); - } - - - @Override - public Properties execute(String module, String rpc, String version, String mode, - Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { - - - // See if there is a service logic defined - // - SvcLogicStore store = SvcLogicActivator.getStore(); - - LOG.info("Fetching service logic from data store"); - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - - - - if (graph == null) - { - Properties retProps = new Properties(); - retProps.setProperty("error-code", "401"); - retProps.setProperty("error-message", "No service logic found for ["+module+","+rpc+","+version+","+mode+"]"); - return(retProps); - - } - - SvcLogicContext ctx = new SvcLogicContext(props); - ctx.setAttribute("currentGraph", graph.toString()); - ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); - ctx.setDomDataBroker(domDataBroker); - - execute(graph, ctx); - - return(ctx.toProperties()); - } - - - - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java deleted file mode 100644 index e8ae7c89d..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/SwitchNodeExecutor.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SwitchNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(SwitchNodeExecutor.class); - - @Override - - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - - String testResult = evaluateNodeTest(node, ctx); - - if (LOG.isDebugEnabled()) { - LOG.debug("Executing switch node"); - - - LOG.debug("test expression (" + node.getAttribute("test") - + ") evaluates to " + testResult); - } - - SvcLogicNode nextNode = node.getOutcomeValue(testResult); - - if (LOG.isDebugEnabled()) { - if (nextNode != null) { - LOG.debug("Next node to execute is node " + nextNode.getNodeId()); - } else { - LOG.debug("No next node found"); - } - } - return (nextNode); - - } -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java deleted file mode 100644 index 9eeab65a3..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/UpdateNodeExecutor.java +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class UpdateNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(UpdateNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); - - - Map parmMap = new HashMap(); - - Set> parmSet = node - .getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate( - curExpr, node, ctx); - - LOG.debug("Parameter " + curName + " = " - + curExpr.asParsedExpr() + " resolves to " - + curExprValue); - - parmMap.put(curName, curExprValue); - } - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("save node encountered - looking for resource class " - + plugin); - } - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.update(resourceType, key, - parmMap, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java b/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java deleted file mode 100644 index 5bbab323b..000000000 --- a/sli/provider/src/main/java/org/openecomp/sdnc/sli/provider/WhileNodeExecutor.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.BreakNodeException; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WhileNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - - String testResult = evaluateNodeTest(node, ctx); - SvcLogicExpression silentFailureExpr = node.getAttribute("do"); - String doWhile = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); - if ("true".equals(doWhile)) { - LOG.debug("While loop will execute once regardless of expression because do is set to true"); - } - - try { - while ("true".equals(testResult) || "true".equals(doWhile)) { - if (!"true".equals(doWhile)) { - LOG.debug("Test expression (" + node.getAttribute("test") + ") evaluates to true, executing loop."); - } - int numOutcomes = node.getNumOutcomes() + 1; - for (int i = 0; i < numOutcomes; i++) { - SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); - if (nextNode != null) { - while (nextNode != null) { - nextNode = svc.executeNode(nextNode, ctx); - } - } else { - if ("true".equals(doWhile)) { - LOG.debug("Do executed, will only execute again if test expression is true."); - doWhile = "false"; - } - testResult = evaluateNodeTest(node, ctx); - LOG.debug("test expression (" + node.getAttribute("test") + ") evaluates to " + testResult); - } - } - } - LOG.debug("testResult was " + testResult + " which is not equal to true, exiting while loop."); - } catch (BreakNodeException e) { - LOG.debug("WhileNodeExecutor caught break"); - } - return (null); - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java new file mode 100644 index 000000000..87273d0b1 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + + +public class BadPlugin implements SvcLogicJavaPlugin { + public String selectLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + String day = parameters.get("day"); + if (day == null || day.length() < 1) { + throw new SvcLogicException("What day is it?"); + } + switch (day) { + case ("monday"): { + return "pizza"; + } + case ("tuesday"): { + return "soup"; + } + case ("wednesday"): { + return "salad"; + } + case ("thursday"): { + return "sushi"; + } + case ("friday"): { + return "bbq"; + } + } + throw new SvcLogicException("Lunch cannot be served"); + } +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java new file mode 100644 index 000000000..4c16222b2 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.Map.Entry; + +import org.onap.ccsdk.sli.core.sli.DuplicateValueException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; + +import junit.framework.TestCase; + +public class ExecuteNodeExecutorTest extends TestCase { + public class MockExecuteNodeExecutor extends ExecuteNodeExecutor { + + protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { + return (SvcLogicJavaPlugin) new LunchSelectorPlugin(); + } + + protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + return "selectLunch"; + } + } + + public void testBadPlugin() throws DuplicateValueException, SvcLogicException { + LunchSelectorPlugin p = new LunchSelectorPlugin(); + MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor(); + SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph()); + node.setAttribute("method", "selectLunch"); + execute.execute(new SvcLogicServiceImpl(), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java new file mode 100644 index 000000000..4d6b0b4dd --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + + + +public class LunchSelectorPlugin implements SvcLogicJavaPlugin { + public class UnknownLunchDayException extends Exception{ + + public UnknownLunchDayException(String string) { + super(string); + } + + } + class Sandwhich { + String meat; + String cheese; + + public Sandwhich(String meat, String cheese) { + this.meat = meat; + this.cheese = cheese; + } + } + + public String selectLunch(Map parameters, SvcLogicContext ctx) throws Exception { + String day = parameters.get("day"); + if (day == null || day.length() < 1) { + throw new UnknownLunchDayException("What day is it?"); + } + switch (day) { + case ("monday"): { + return "pizza"; + } + case ("tuesday"): { + return "soup"; + } + case ("wednesday"): { + return "salad"; + } + case ("thursday"): { + return "sushi"; + } + case ("friday"): { + return "bbq"; + } + } + throw new SvcLogicException("Lunch cannot be served"); + } + + public Sandwhich makeLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + return new Sandwhich("ham", "american"); + } +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java new file mode 100644 index 000000000..8057dbd12 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import junit.framework.TestCase; + +public class MdsalHelperTest extends TestCase { + + public static final String pathToSdnPropertiesFile = "./src/test/resources/l3sdn.properties"; + + public void testSdnProperties() { + MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile); + assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); + assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); + assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete")); + assertEquals("service-configuration-operation", MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", + "ServiceConfigurationOperation")); + } + + public void testNegativeSdnProperties() { + assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTesterUtil.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTesterUtil.java new file mode 100644 index 000000000..75517a1e6 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTesterUtil.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MdsalHelperTesterUtil extends MdsalHelper { + + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTesterUtil.class); + + //Normally static init of classes goes here for some weird classloader thing + static { + String str = "Hello World!"; + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java new file mode 100644 index 000000000..08ab5eebf --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver; + +import junit.framework.TestCase; + +public class PluginTest extends TestCase { + + // The existing plugins work just like a VoidDummyPlugin + // They will return null simply because they are all void + // The attribute emitsOutcome will not be present, the expected outcome is success when no exception is thrown by the plugin + public void testOldPlugin() throws Exception { + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new VoidDummyPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("dummy", Map.class, SvcLogicContext.class); + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("success",outValue); + } + + //Newer plugins can set the attribute emitsOutcome to true, if so they should return a string + //The string represents the outcome value + public void testNewPlugin() throws Exception { + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("selectLunch", Map.class, SvcLogicContext.class); + + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + + parmMap.put("day", "monday"); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + node.setAttribute("emitsOutcome", "true"); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("pizza", outValue); + + parmMap.put("day", "tuesday"); + outValue = (String) pluginMethod.invoke(plugin, parmMap, ctx); + o = pluginMethod.invoke(plugin, parmMap, ctx); + outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("soup",outValue); + + } + + //APPC had some legacy plugins returning objects which should not be treated as outcomes + //The attribute emitsOutcome will not be set + //The outcome should be success as it has always been + public void testObjPlugin() throws Exception{ + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("makeLunch", Map.class, SvcLogicContext.class); + + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("success",outValue); + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java new file mode 100644 index 000000000..1705e7902 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicExprListener; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.Assert; +import junit.framework.TestCase; + +public class SvcLogicExpressionResolverTest extends TestCase { + + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExpressionResolver.class); + + public void testEvaluate() + { + InputStream testStr = getClass().getResourceAsStream("/expression.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + try + { + SvcLogicContext ctx = new SvcLogicContext(); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + graph.setRootNode(node); + + String line = null; + int lineNo = 0; + while ((line = testsReader.readLine()) != null) { + ++lineNo; + if (line.startsWith("#")) + { + String testExpr = line.trim().substring(1).trim(); + String[] nameValue = testExpr.split("="); + String name = nameValue[0].trim(); + String value = nameValue[1].trim(); + + if (name.startsWith("$")) + { + LOG.info("Setting context attribute "+name+" = "+value); + ctx.setAttribute(name.substring(1), value); + } + else + { + + LOG.info("Setting node attribute "+name+" = "+value); + node.setAttribute(name, value); + + } + } + else + { + // if the line contains #, what comes before is the expression to evaluate, and what comes after + // is the expected value + String[] substrings = line.split("#"); + String expectedValue = substrings.length > 1 ? substrings[1].trim() : null; + String testExpr = substrings[0].trim(); + + LOG.info("Parsing expression "+testExpr); + SvcLogicExpression expr = SvcLogicExpressionFactory.parse(testExpr); + if (expr == null) + { + fail("Unable to parse expression "+testExpr); + } + else + { + LOG.info("Evaluating parsed expression "+expr.asParsedExpr()); + String exprValue = SvcLogicExpressionResolver.evaluate(expr, node, ctx); + if (exprValue == null) + { + fail("Unable to evaluate expression "+testExpr); + } + else + { + LOG.info("Expression " + testExpr + " evaluates to " + exprValue); + if (expectedValue != null) { + Assert.assertEquals("Line " + lineNo + ": " + testExpr, expectedValue, exprValue); + } + } + } + } + } + } + catch (Exception e) + { + LOG.error("Caught exception", e); + fail("Caught exception"); + } + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java new file mode 100644 index 000000000..b54f28460 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java @@ -0,0 +1,211 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.MetricLogger; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.provider.BlockNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.CallNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ConfigureNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.DeleteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ExistsNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ForNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.GetResourceNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.IsAvailableNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.NotifyNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.RecordNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReleaseNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReserveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReturnNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SaveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SetNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; +import org.onap.ccsdk.sli.core.sli.provider.SwitchNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.UpdateNodeExecutor; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.TestCase; + +public class SvcLogicGraphExecutorTest extends TestCase { + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicGraph.class); + + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + + } + }; + + public void testExecute() { + + try { + InputStream testStr = getClass().getResourceAsStream("/executor.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + + assertNotNull(store); + + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + SvcLogicParser parser = new SvcLogicParser(store); + + // Loop through executor tests + + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); + + for (String nodeType : BUILTIN_NODES.keySet()) { + + LOG.info("SLI - registering node executor for node type "+nodeType); + + svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + + } + String testCaseLine = null; + while ((testCaseLine = testsReader.readLine()) != null) { + + String[] testCaseFields = testCaseLine.split(":"); + String testCaseFile = testCaseFields[0]; + String testCaseMethod = testCaseFields[1]; + String testCaseParameters = null; + + if (testCaseFields.length > 2) { + testCaseParameters = testCaseFields[2]; + } + + SvcLogicContext ctx = new SvcLogicContext(); + if (testCaseParameters != null) { + String[] testCaseParameterSettings = testCaseParameters.split(","); + + for (int i = 0 ; i < testCaseParameterSettings.length ; i++) { + String[] nameValue = testCaseParameterSettings[i].split("="); + if (nameValue != null) { + String name = nameValue[0]; + String value = ""; + if (nameValue.length > 1) { + value = nameValue[1]; + } + + ctx.setAttribute(name, value); + } + } + } + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) { + if (!testCaseFile.startsWith("/")) { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) { + fail("Could not resolve test case file "+testCaseFile); + } + + LinkedList graphs = parser.parse(testCaseUrl.getPath()); + + + assertNotNull(graphs); + + for (SvcLogicGraph graph: graphs) { + if (graph.getRpc().equals(testCaseMethod)) { + Properties props = ctx.toProperties(); + LOG.info("SvcLogicContext before executing "+testCaseMethod+":"); + for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements() ; ) { + String propName = (String) e1.nextElement(); + LOG.info(propName+" = "+props.getProperty(propName)); + } + + svc.execute(graph, ctx); + + props = ctx.toProperties(); + LOG.info("SvcLogicContext after executing "+testCaseMethod+":"); + for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements() ; ) { + String propName = (String) e2.nextElement(); + LOG.info(propName+" = "+props.getProperty(propName)); + } + } + } + + } + + + } + + + } catch (Exception e) { + LOG.error("Caught exception executing directed graphs", e); + fail("Exception executing graphs"); + } + } + + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java new file mode 100644 index 000000000..7c6eee9ab --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + + + +public class VoidDummyPlugin implements SvcLogicJavaPlugin { + + public void dummy(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + return; + } + +} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java deleted file mode 100644 index d1ab4cfdd..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.Map; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; - - -public class BadPlugin implements SvcLogicJavaPlugin { - public String selectLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - String day = parameters.get("day"); - if (day == null || day.length() < 1) { - throw new SvcLogicException("What day is it?"); - } - switch (day) { - case ("monday"): { - return "pizza"; - } - case ("tuesday"): { - return "soup"; - } - case ("wednesday"): { - return "salad"; - } - case ("thursday"): { - return "sushi"; - } - case ("friday"): { - return "bbq"; - } - } - throw new SvcLogicException("Lunch cannot be served"); - } -} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java deleted file mode 100644 index 3d43ee11d..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.Map.Entry; - -import org.openecomp.sdnc.sli.DuplicateValueException; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicGraph; -import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; -import org.openecomp.sdnc.sli.SvcLogicNode; - -import junit.framework.TestCase; - -public class ExecuteNodeExecutorTest extends TestCase { - public class MockExecuteNodeExecutor extends ExecuteNodeExecutor { - - protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { - return (SvcLogicJavaPlugin) new LunchSelectorPlugin(); - } - - protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - return "selectLunch"; - } - } - - public void testBadPlugin() throws DuplicateValueException, SvcLogicException { - LunchSelectorPlugin p = new LunchSelectorPlugin(); - MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor(); - SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph()); - node.setAttribute("method", "selectLunch"); - execute.execute(new SvcLogicServiceImpl(), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); - } - -} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java deleted file mode 100644 index b9156bcdc..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.Map; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; - - - -public class LunchSelectorPlugin implements SvcLogicJavaPlugin { - public class UnknownLunchDayException extends Exception{ - - public UnknownLunchDayException(String string) { - super(string); - } - - } - class Sandwhich { - String meat; - String cheese; - - public Sandwhich(String meat, String cheese) { - this.meat = meat; - this.cheese = cheese; - } - } - - public String selectLunch(Map parameters, SvcLogicContext ctx) throws Exception { - String day = parameters.get("day"); - if (day == null || day.length() < 1) { - throw new UnknownLunchDayException("What day is it?"); - } - switch (day) { - case ("monday"): { - return "pizza"; - } - case ("tuesday"): { - return "soup"; - } - case ("wednesday"): { - return "salad"; - } - case ("thursday"): { - return "sushi"; - } - case ("friday"): { - return "bbq"; - } - } - throw new SvcLogicException("Lunch cannot be served"); - } - - public Sandwhich makeLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - return new Sandwhich("ham", "american"); - } -} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java deleted file mode 100644 index a4e41bbad..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import junit.framework.TestCase; - -public class MdsalHelperTest extends TestCase { - - public static final String pathToSdnPropertiesFile = "./src/test/resources/l3sdn.properties"; - - public void testSdnProperties() { - MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile); - assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); - assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); - assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete")); - assertEquals("service-configuration-operation", MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", - "ServiceConfigurationOperation")); - } - - public void testNegativeSdnProperties() { - assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); - } - -} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java deleted file mode 100644 index 01e333f6e..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import org.openecomp.sdnc.sli.provider.MdsalHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MdsalHelperTesterUtil extends MdsalHelper { - - private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTesterUtil.class); - - //Normally static init of classes goes here for some weird classloader thing - static { - String str = "Hello World!"; - } - -} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java deleted file mode 100644 index 035cd3e79..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicGraph; -import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; -import org.openecomp.sdnc.sli.SvcLogicNode; - -import junit.framework.TestCase; - -public class PluginTest extends TestCase { - - // The existing plugins work just like a VoidDummyPlugin - // They will return null simply because they are all void - // The attribute emitsOutcome will not be present, the expected outcome is success when no exception is thrown by the plugin - public void testOldPlugin() throws Exception { - ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); - SvcLogicJavaPlugin plugin = new VoidDummyPlugin(); - - Class pluginClass = plugin.getClass(); - Method pluginMethod = pluginClass.getMethod("dummy", Map.class, SvcLogicContext.class); - Map parmMap = new HashMap(); - SvcLogicContext ctx = new SvcLogicContext(); - Object o = pluginMethod.invoke(plugin, parmMap, ctx); - - SvcLogicGraph graph = new SvcLogicGraph(); - SvcLogicNode node = new SvcLogicNode(1, "return", graph); - String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); - String outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("success",outValue); - } - - //Newer plugins can set the attribute emitsOutcome to true, if so they should return a string - //The string represents the outcome value - public void testNewPlugin() throws Exception { - ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); - SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); - - Class pluginClass = plugin.getClass(); - Method pluginMethod = pluginClass.getMethod("selectLunch", Map.class, SvcLogicContext.class); - - Map parmMap = new HashMap(); - SvcLogicContext ctx = new SvcLogicContext(); - - parmMap.put("day", "monday"); - Object o = pluginMethod.invoke(plugin, parmMap, ctx); - SvcLogicGraph graph = new SvcLogicGraph(); - SvcLogicNode node = new SvcLogicNode(1, "return", graph); - node.setAttribute("emitsOutcome", "true"); - String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); - String outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("pizza", outValue); - - parmMap.put("day", "tuesday"); - outValue = (String) pluginMethod.invoke(plugin, parmMap, ctx); - o = pluginMethod.invoke(plugin, parmMap, ctx); - outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("soup",outValue); - - } - - //APPC had some legacy plugins returning objects which should not be treated as outcomes - //The attribute emitsOutcome will not be set - //The outcome should be success as it has always been - public void testObjPlugin() throws Exception{ - ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); - SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); - - Class pluginClass = plugin.getClass(); - Method pluginMethod = pluginClass.getMethod("makeLunch", Map.class, SvcLogicContext.class); - - Map parmMap = new HashMap(); - SvcLogicContext ctx = new SvcLogicContext(); - Object o = pluginMethod.invoke(plugin, parmMap, ctx); - SvcLogicGraph graph = new SvcLogicGraph(); - SvcLogicNode node = new SvcLogicNode(1, "return", graph); - String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); - String outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("success",outValue); - } - -} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java deleted file mode 100644 index 618154883..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicExprListener; -import org.openecomp.sdnc.sli.SvcLogicExpression; -import org.openecomp.sdnc.sli.SvcLogicExpressionFactory; -import org.openecomp.sdnc.sli.SvcLogicGraph; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.provider.SvcLogicExpressionResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import junit.framework.Assert; -import junit.framework.TestCase; - -public class SvcLogicExpressionResolverTest extends TestCase { - - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicExpressionResolver.class); - - public void testEvaluate() - { - InputStream testStr = getClass().getResourceAsStream("/expression.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - - try - { - SvcLogicContext ctx = new SvcLogicContext(); - SvcLogicGraph graph = new SvcLogicGraph(); - SvcLogicNode node = new SvcLogicNode(1, "return", graph); - graph.setRootNode(node); - - String line = null; - int lineNo = 0; - while ((line = testsReader.readLine()) != null) { - ++lineNo; - if (line.startsWith("#")) - { - String testExpr = line.trim().substring(1).trim(); - String[] nameValue = testExpr.split("="); - String name = nameValue[0].trim(); - String value = nameValue[1].trim(); - - if (name.startsWith("$")) - { - LOG.info("Setting context attribute "+name+" = "+value); - ctx.setAttribute(name.substring(1), value); - } - else - { - - LOG.info("Setting node attribute "+name+" = "+value); - node.setAttribute(name, value); - - } - } - else - { - // if the line contains #, what comes before is the expression to evaluate, and what comes after - // is the expected value - String[] substrings = line.split("#"); - String expectedValue = substrings.length > 1 ? substrings[1].trim() : null; - String testExpr = substrings[0].trim(); - - LOG.info("Parsing expression "+testExpr); - SvcLogicExpression expr = SvcLogicExpressionFactory.parse(testExpr); - if (expr == null) - { - fail("Unable to parse expression "+testExpr); - } - else - { - LOG.info("Evaluating parsed expression "+expr.asParsedExpr()); - String exprValue = SvcLogicExpressionResolver.evaluate(expr, node, ctx); - if (exprValue == null) - { - fail("Unable to evaluate expression "+testExpr); - } - else - { - LOG.info("Expression " + testExpr + " evaluates to " + exprValue); - if (expectedValue != null) { - Assert.assertEquals("Line " + lineNo + ": " + testExpr, expectedValue, exprValue); - } - } - } - } - } - } - catch (Exception e) - { - LOG.error("Caught exception", e); - fail("Caught exception"); - } - } - -} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java deleted file mode 100644 index 2e8b35e12..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java +++ /dev/null @@ -1,212 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Properties; - -import org.openecomp.sdnc.sli.MetricLogger; -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicGraph; -import org.openecomp.sdnc.sli.SvcLogicNode; -import org.openecomp.sdnc.sli.SvcLogicParser; -import org.openecomp.sdnc.sli.SvcLogicStore; -import org.openecomp.sdnc.sli.SvcLogicStoreFactory; -import org.openecomp.sdnc.sli.provider.BlockNodeExecutor; -import org.openecomp.sdnc.sli.provider.CallNodeExecutor; -import org.openecomp.sdnc.sli.provider.ConfigureNodeExecutor; -import org.openecomp.sdnc.sli.provider.DeleteNodeExecutor; -import org.openecomp.sdnc.sli.provider.ExecuteNodeExecutor; -import org.openecomp.sdnc.sli.provider.ExistsNodeExecutor; -import org.openecomp.sdnc.sli.provider.ForNodeExecutor; -import org.openecomp.sdnc.sli.provider.GetResourceNodeExecutor; -import org.openecomp.sdnc.sli.provider.IsAvailableNodeExecutor; -import org.openecomp.sdnc.sli.provider.NotifyNodeExecutor; -import org.openecomp.sdnc.sli.provider.RecordNodeExecutor; -import org.openecomp.sdnc.sli.provider.ReleaseNodeExecutor; -import org.openecomp.sdnc.sli.provider.ReserveNodeExecutor; -import org.openecomp.sdnc.sli.provider.ReturnNodeExecutor; -import org.openecomp.sdnc.sli.provider.SaveNodeExecutor; -import org.openecomp.sdnc.sli.provider.SetNodeExecutor; -import org.openecomp.sdnc.sli.provider.SvcLogicNodeExecutor; -import org.openecomp.sdnc.sli.provider.SvcLogicServiceImpl; -import org.openecomp.sdnc.sli.provider.SwitchNodeExecutor; -import org.openecomp.sdnc.sli.provider.UpdateNodeExecutor; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import junit.framework.TestCase; - -public class SvcLogicGraphExecutorTest extends TestCase { - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicGraph.class); - - private static final Map BUILTIN_NODES = new HashMap() { - { - put("block", new BlockNodeExecutor()); - put("call", new CallNodeExecutor()); - put("configure", new ConfigureNodeExecutor()); - put("delete", new DeleteNodeExecutor()); - put("execute", new ExecuteNodeExecutor()); - put("exists", new ExistsNodeExecutor()); - put("for", new ForNodeExecutor()); - put("get-resource", new GetResourceNodeExecutor()); - put("is-available", new IsAvailableNodeExecutor()); - put("notify", new NotifyNodeExecutor()); - put("record", new RecordNodeExecutor()); - put("release", new ReleaseNodeExecutor()); - put("reserve", new ReserveNodeExecutor()); - put("return", new ReturnNodeExecutor()); - put("save", new SaveNodeExecutor()); - put("set", new SetNodeExecutor()); - put("switch", new SwitchNodeExecutor()); - put("update", new UpdateNodeExecutor()); - - } - }; - - public void testExecute() { - - try { - InputStream testStr = getClass().getResourceAsStream("/executor.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - - InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - - assertNotNull(store); - - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); - SvcLogicParser parser = new SvcLogicParser(store); - - // Loop through executor tests - - SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); - - for (String nodeType : BUILTIN_NODES.keySet()) { - - LOG.info("SLI - registering node executor for node type "+nodeType); - - svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); - - } - String testCaseLine = null; - while ((testCaseLine = testsReader.readLine()) != null) { - - String[] testCaseFields = testCaseLine.split(":"); - String testCaseFile = testCaseFields[0]; - String testCaseMethod = testCaseFields[1]; - String testCaseParameters = null; - - if (testCaseFields.length > 2) { - testCaseParameters = testCaseFields[2]; - } - - SvcLogicContext ctx = new SvcLogicContext(); - if (testCaseParameters != null) { - String[] testCaseParameterSettings = testCaseParameters.split(","); - - for (int i = 0 ; i < testCaseParameterSettings.length ; i++) { - String[] nameValue = testCaseParameterSettings[i].split("="); - if (nameValue != null) { - String name = nameValue[0]; - String value = ""; - if (nameValue.length > 1) { - value = nameValue[1]; - } - - ctx.setAttribute(name, value); - } - } - } - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) { - if (!testCaseFile.startsWith("/")) { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) { - fail("Could not resolve test case file "+testCaseFile); - } - - LinkedList graphs = parser.parse(testCaseUrl.getPath()); - - - assertNotNull(graphs); - - for (SvcLogicGraph graph: graphs) { - if (graph.getRpc().equals(testCaseMethod)) { - Properties props = ctx.toProperties(); - LOG.info("SvcLogicContext before executing "+testCaseMethod+":"); - for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements() ; ) { - String propName = (String) e1.nextElement(); - LOG.info(propName+" = "+props.getProperty(propName)); - } - - svc.execute(graph, ctx); - - props = ctx.toProperties(); - LOG.info("SvcLogicContext after executing "+testCaseMethod+":"); - for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements() ; ) { - String propName = (String) e2.nextElement(); - LOG.info(propName+" = "+props.getProperty(propName)); - } - } - } - - } - - - } - - - } catch (Exception e) { - LOG.error("Caught exception executing directed graphs", e); - fail("Exception executing graphs"); - } - } - - -} diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java deleted file mode 100644 index 6c8214ab7..000000000 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.openecomp.sdnc.sli.provider; - -import java.util.Map; - -import org.openecomp.sdnc.sli.SvcLogicContext; -import org.openecomp.sdnc.sli.SvcLogicException; -import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; - - - -public class VoidDummyPlugin implements SvcLogicJavaPlugin { - - public void dummy(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - return; - } - -} diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml index d81b8b789..56e1a81ef 100644 --- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml +++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml @@ -1,10 +1,9 @@ - org:openecomp:sdnc:sliapi:provider:impl?module=sliapi-provider-impl&revision=2014-05-23 + org:onap:ccsdk:sli:core:sliapi:provider:impl?module=sliapi-provider-impl&revision=2014-05-23 diff --git a/sliapi/provider/src/main/yang/sliapi-provider-impl.yang b/sliapi/provider/src/main/yang/sliapi-provider-impl.yang index b32ff6c3d..0421ad0c4 100755 --- a/sliapi/provider/src/main/yang/sliapi-provider-impl.yang +++ b/sliapi/provider/src/main/yang/sliapi-provider-impl.yang @@ -1,7 +1,7 @@ module sliapi-provider-impl { yang-version 1; - namespace "org:openecomp:sdnc:sliapi:provider:impl"; + namespace "org:onap:ccsdk:sli:core:sliapi:provider:impl"; prefix "sliapi-provider-impl"; import config { prefix config; revision-date 2013-04-05; } -- cgit 1.2.3-korg From 7e4cb0e2ee64777b1069a8371529be42efc437f8 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 7 Aug 2017 15:02:16 -0400 Subject: Refactor sliPluginUtils package names Update Java package names from org.openecomp to org.onap Issue: CCSDK-11 Change-Id: I7e318565197b5806f6a7d7131bd3118fbe9cf8e0 Signed-off-by: Dan Timoney --- sliPluginUtils/provider/pom.xml | 8 +- .../onap/ccsdk/sli/core/slipluginutils/DME2.java | 110 +++ .../sli/core/slipluginutils/SliPluginUtils.java | 753 +++++++++++++++++++++ .../slipluginutils/SliPluginUtilsActivator.java | 94 +++ .../sli/core/slipluginutils/SliStringUtils.java | 395 +++++++++++ .../core/slipluginutils/SvcLogicContextList.java | 209 ++++++ .../core/slipluginutils/SvcLogicContextObject.java | 27 + .../slipluginutils/commondatastructures/YesNo.java | 50 ++ .../commondatastructures/package-info.java | 27 + .../openecomp/sdnc/sli/SliPluginUtils/DME2.java | 110 --- .../sdnc/sli/SliPluginUtils/SliPluginUtils.java | 753 --------------------- .../SliPluginUtils/SliPluginUtilsActivator.java | 94 --- .../sdnc/sli/SliPluginUtils/SliStringUtils.java | 395 ----------- .../sli/SliPluginUtils/SvcLogicContextList.java | 209 ------ .../sli/SliPluginUtils/SvcLogicContextObject.java | 27 - .../SliPluginUtils/commondatastructures/YesNo.java | 50 -- .../commondatastructures/package-info.java | 27 - .../core/slipluginutils/CheckParametersTest.java | 116 ++++ .../ccsdk/sli/core/slipluginutils/Dme2Test.java | 106 +++ .../SliPluginUtils_StaticFunctionsTest.java | 250 +++++++ .../slipluginutils/SliPluginUtils_ctxSortList.java | 96 +++ .../SliPluginUtils_ctxSortListTest.java | 97 +++ .../core/slipluginutils/SliStringUtilsTest.java | 244 +++++++ .../slipluginutils/SvcLogicContextListTest.java | 307 +++++++++ .../sli/SliPluginUtils/CheckParametersTest.java | 115 ---- .../sdnc/sli/SliPluginUtils/Dme2Test.java | 108 --- .../SliPluginUtils_StaticFunctionsTest.java | 249 ------- .../SliPluginUtils/SliPluginUtils_ctxSortList.java | 95 --- .../SliPluginUtils_ctxSortListTest.java | 96 --- .../sli/SliPluginUtils/SliStringUtilsTest.java | 243 ------- .../SliPluginUtils/SvcLogicContextListTest.java | 306 --------- 31 files changed, 2885 insertions(+), 2881 deletions(-) create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/commondatastructures/YesNo.java create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/commondatastructures/package-info.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/DME2.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtilsActivator.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtils.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextList.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextObject.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/YesNo.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/package-info.java create mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java create mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java create mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java delete mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/CheckParametersTest.java delete mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/Dme2Test.java delete mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_StaticFunctionsTest.java delete mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortList.java delete mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortListTest.java delete mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtilsTest.java delete mode 100644 sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextListTest.java diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index cd240d162..1db16779b 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -69,10 +69,10 @@ true - org.openecomp.sdnc.sli.SliPluginUtils - org.openecomp.sdnc.sli.SliPluginUtils.SliPluginUtilsActivator - org.openecomp.sdnc.sli.SliPluginUtils - org.openecomp.sdnc.*,org.osgi.framework.*,org.slf4j.*,java.net.* + org.onap.ccsdk.sli.core.slipluginutils + org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtilsActivator + org.onap.ccsdk.sli.core.slipluginutils + org.onap.ccsdk.sli.core.*,org.osgi.framework.*,org.slf4j.*,java.net.* *;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mysql-connector-java|slf4j-api|jcl-over-slf4j true diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java new file mode 100644 index 000000000..e7c34de20 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + + +/** + * A SvcLogicJavaPlugin that generates DME2 proxy urls using parameters from context memory. + */ +public class DME2 implements SvcLogicJavaPlugin { + String aafUserName; + String aafPassword; + String envContext; + String routeOffer; + String[] proxyUrls; + Integer index; + String commonServiceVersion; + String partner; + + private static final Logger LOG = LoggerFactory.getLogger(DME2.class); + + public void setPartner(String partner) { + if (partner != null && partner.length() > 0) { + this.partner = partner; + } + } + + public DME2(String aafUserName, String aafPassword, String envContext, String routeOffer, String[] proxyUrls, String commonServiceVersion) { + this.aafUserName = aafUserName; + this.aafPassword = aafPassword; + this.envContext = envContext; + this.routeOffer = routeOffer; + this.proxyUrls = proxyUrls; + this.index = 0; + this.commonServiceVersion = commonServiceVersion; + } + + // constructs a URL to contact the proxy which contacts a DME2 service + public String constructUrl(String service, String version, String subContext) { + StringBuilder sb = new StringBuilder(); + + // The hostname is assigned in a round robin fashion + sb.append(acquireHostName()); + sb.append("/service=" + service); + + //If the directedGraph passes an explicit version use that, if not use the commonServiceVersion found in the properties file + if (version == null) { + version = this.commonServiceVersion; + } + sb.append("/version=" + version); + + sb.append("/envContext=" + this.envContext); + if (this.routeOffer != null && this.routeOffer.length() > 0) { + sb.append("/routeOffer=" + this.routeOffer); + } + if (subContext != null && subContext.length() > 0) { + sb.append("/subContext=" + subContext); + } + sb.append("?dme2.password=" + this.aafPassword); + sb.append("&dme2.username=" + this.aafUserName); + if (this.partner != null) { + sb.append("&dme2.partner=" + this.partner); + } + sb.append("&dme2.allowhttpcode=true"); + return (sb.toString()); + } + + public synchronized String acquireHostName() { + String retVal = proxyUrls[index]; + index++; + if (index == this.proxyUrls.length) { + index = 0; + } + return retVal; + } + + // Node entry point + public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] { "service", "outputPath" }, LOG); + String completeProxyUrl = constructUrl(parameters.get("service"), parameters.get("version"), parameters.get("subContext")); + ctx.setAttribute(parameters.get("outputPath"), completeProxyUrl); + } + +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java new file mode 100644 index 000000000..0522b25d5 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -0,0 +1,753 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; +import java.util.Set; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A utility class used to streamline the interface between Java plugins, + * the Service Logic Context, and Directed Graphs. + * @version 7.0.1 + * @see org.onap.ccsdk.sli.core.sli.SvcLogicContext + */ +public class SliPluginUtils implements SvcLogicJavaPlugin { + public enum LogLevel { + TRACE, DEBUG, INFO, WARN, ERROR; + } + + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils.class); + + + // ========== CONSTRUCTORS ========== + + public SliPluginUtils() {} + + public SliPluginUtils( Properties props ) {} + + + + // ========== CONTEXT MEMORY FUNCTIONS ========== + + /** + * Removes 1 or more elements from a list in context memory. + *

+ * Values are removed based on either the index in the list, a key-value + * pair, or a list of key-value pairs that all must match in the element. + * @param parameters + * @param ctx Reference to context memory + * @throws SvcLogicException All exceptions are wrapped in + * SvcLogicException for compatibility with SLI. + * @since 7.0.1 + */ + public void ctxListRemove( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + try{ + LOG.debug( "ENTERING Execute Node \"ctxListRemove\"" ); + + // Validate, Log, & read parameters + checkParameters(parameters, new String[]{"list_pfx"}, LOG); + logExecuteNodeParameters(parameters, LOG, LogLevel.DEBUG); + String list_pfx = parameters.get("list_pfx"); + String param_index = parameters.get("index"); + String param_key = parameters.get("key"); + String param_value = parameters.get("value"); + String param_keys_length = parameters.get("keys_length"); + + // Initialize context memory list mimic + SvcLogicContextList list; + + // Process based on input parameters: + // index: remove object at specific index + // key & value: remove all objects with key-value pair + // keys_length: remove all objects that match all key-value pairs + // in list + if( param_index != null ) { + // Parse index + LOG.trace("executing remove by index logic"); + int index; + try { + index = Integer.parseInt(param_index); + } + catch( NumberFormatException e ) { + throw new IllegalArgumentException("\"index\" parameter is not a number. index = " + param_index, e); + } + + // Extract list from context memory & remove object @ index + LOG.trace("extracting list from context memory"); + list = SvcLogicContextList.extract(ctx, list_pfx); + LOG.trace("removing elements from list"); + list.remove(index); + } + else if( param_value != null ) { + if( param_key == null ) { param_key = ""; } + + // Extract list from context memory & remove objects with + // key-value pair + LOG.trace("executing remove by key-value pair logic"); + LOG.trace("extracting list from context memory"); + list = SvcLogicContextList.extract(ctx, list_pfx); + LOG.trace("removing elements from list"); + list.remove( param_key, param_value ); + } + else if( param_keys_length != null ) { + // Parse keys_length + LOG.trace("executing remove by key-value pair list logic"); + int keys_length; + try { + keys_length = Integer.parseInt(param_keys_length); + } + catch( NumberFormatException e ) { + throw new IllegalArgumentException("\"keys_length\" parameters is not a number. keys_length = " + param_keys_length, e); + } + + // Obtain key-value pairs to check from parameters + LOG.trace("reading keys parameter list"); + HashMap keys_values = new HashMap(); + for( int i = 0; i < keys_length; i++ ) { + keys_values.put(parameters.get("keys[" + i + "].key"), parameters.get("keys[" + i + "].value")); + } + + // Extract list from context memory & remove objects with all + // key-value pairs matching + LOG.trace("extracting list from context memory"); + list = SvcLogicContextList.extract(ctx, list_pfx); + LOG.trace("removing elements from list"); + list.remove(keys_values); + } + else { + throw new IllegalArgumentException("Required parameters missing. Requires one of: index, key & value, or keys_length array"); + } + + // Remove index from list + LOG.trace("writing list back into context memory"); + list.writeToContext(ctx); + } + catch( Exception e ) { + throw new SvcLogicException( "An error occurred in the ctxListRemove Execute node", e ); + } + finally { + LOG.debug( "EXITING Execute Node \"ctxListRemove\"" ); + } + } + + /** + * ctxSortList + * @param parameters - the set of required parameters must contain list and delimiter. + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public void ctxSortList( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + checkParameters(parameters, new String[]{"list","delimiter"}, LOG); + ArrayList list = new ArrayList(); + + String[] sort_fields = null; + if( parameters.containsKey("sort-fields") ) { + sort_fields = parameters.get("sort-fields").split(parameters.get("delimiter"), 0); + } + + String ctx_list_str = parameters.get("list"); + int listSz = getArrayLength(ctx, ctx_list_str); + + + + for( int i = 0; i < listSz; i++ ) { + list.add( new SortableCtxListElement(ctx, ctx_list_str + '[' + i + ']', sort_fields) ); + } + Collections.sort(list); + + ctxBulkErase(ctx, ctx_list_str); + int i = 0; + for( SortableCtxListElement list_element : list ) { + for( Map.Entry entry : list_element.child_elements.entrySet() ) { + if( sort_fields == null ) { + ctx.setAttribute(ctx_list_str + '[' + i + ']', entry.getValue()); + } + else { + ctx.setAttribute(ctx_list_str + '[' + i + "]." + entry.getKey(), entry.getValue()); + } + } + i++; + } + // Reset list length (removed by ctxBulkErase above) + ctx.setAttribute(ctx_list_str+"_length", ""+listSz); + } + + /** + * generates a UUID and writes it to context memory + * @param parameters - ctx-destination is a required parameter + * @param ctx Reference to context memory + * @throws SvcLogicException thrown if a UUID cannot be generated or if ctx-destination is missing or null + */ + public void generateUUID( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + checkParameters(parameters, new String[]{"ctx-destination"}, LOG); + ctx.setAttribute(parameters.get("ctx-destination"), UUID.randomUUID().toString() ); + } + + /** + * Provides substring functionality to Directed Graphs. + *

+ * Calls either String.substring(String beginIndex) or + * String.substring(String beginInded, String endIndex) if the end-index + * is present or not. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
stringMandatoryString to perform substring on
resultMandatoryKey in context memory to populate the resulting string in
begin-indexMandatoryBeginning index to pass to Java substring function
end-indexOptionalEnding index to pass to Java substring function. If not included, String.substring(begin) will be called.
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 8.0.1 + * @see SliPluginUtils#substring(Map, SvcLogicContext) + */ + @Deprecated + public void substring( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + try { + checkParameters( parameters, new String[]{"string","begin-index","result"}, LOG ); + final String string = parameters.get("string"); + final String result = parameters.get("result"); + final String begin = parameters.get("begin-index"); + final String end = parameters.get("end-index"); + + if( StringUtils.isEmpty(end) ) { + ctx.setAttribute( result, string.substring(Integer.parseInt(begin)) ); + } + else { + ctx.setAttribute( result, string.substring(Integer.parseInt(begin), Integer.parseInt(end)) ); + } + } + catch( Exception e ) { + throw new SvcLogicException( "An error occurred while the Directed Graph was performing a substring", e ); + } + } + + + + // ========== PUBLIC STATIC UTILITY FUNCTIONS ========== + + /** + * Throws an exception and writes an error to the log file if a required + * parameters is not found in the parametersMap. + *

+ * Use at the beginning of functions that can be called by Directed Graphs + * and can take parameters to verify that all parameters have been provided + * by the Directed Graph. + * @param parametersMap parameters Map passed to this node + * @param requiredParams Array of parameters required by the calling function + * @param log Reference to Logger to log to + * @throws SvcLogicException if a String in the requiredParams array is + * not a key in parametersMap. + * @since 1.0 + */ + public static final void checkParameters(Map parametersMap, String[] requiredParams, Logger log) throws SvcLogicException { + if( requiredParams == null || requiredParams.length < 1){ + log.debug("required parameters was empty, exiting early."); + return; + } + if (parametersMap == null || parametersMap.keySet().size() < 1){ + String errorMessage = "This method requires the parameters [" + StringUtils.join(requiredParams,",") + "], but no parameters were passed in."; + log.error(errorMessage); + throw new SvcLogicException(errorMessage); + } + + for (String param : requiredParams) { + if (!parametersMap.containsKey(param)) { + String errorMessage = "Required parameter \"" + param + "\" was not found in parameter list."; + log.error(errorMessage); + log.error("Total list of required parameters is [" + StringUtils.join(requiredParams, ",") + "]."); + throw new SvcLogicException(errorMessage); + } + } + } + + /** + * Removes all key-value pairs with keys that begin with pfx + * @param ctx Reference to context memory + * @param pfx Prefix of key-value pairs to remove + * @since 1.0 + */ + public static final void ctxBulkErase( SvcLogicContext ctx, String pfx ) { + ArrayList Keys = new ArrayList( ctx.getAttributeKeySet() ); + for( String key : Keys ) { + if( key.startsWith( pfx ) ) { + ctx.setAttribute( pfx + key.substring(pfx.length()) , null); + } + } + } + + /** + * Copies all context memory key-value pairs that start with src_pfx to + * the keys that start with dest_pfx + suffix, where suffix is the result + * of {@code key.substring(src_pfx.length())}. + *

+ * Does NOT guarantee removal of all keys at the destination before + * copying, but will overwrite any destination keys that have a + * corresponding source key. Use {@link #ctxBulkErase(SvcLogicContext, String) ctxBulkErase} + * before copy to erase destination root before copying from source. + * @param ctx Reference to context memory. + * @param src_pfx Prefix of the keys to copy values from. + * @param dest_pfx Prefix of the keys to copy values to. + * @since 1.0 + */ + public static final void ctxBulkCopy( SvcLogicContext ctx, String src_pfx, String dest_pfx ) { + // Remove trailing period from dest_pfx + if( dest_pfx.charAt(dest_pfx.length()-1) == '.' ) { + dest_pfx = dest_pfx.substring(0,dest_pfx.length()-1); + } + + // For each context key that begins with src_pfx, set the value of the + // key dest_pfx + the suffix of the key to the key's value + ArrayList Keys = new ArrayList(ctx.getAttributeKeySet()); + for( String key : Keys ) { + if( key.startsWith(src_pfx) ) { + // Get suffix (no leading period) + String suffix = key.substring(src_pfx.length()); + if( suffix.charAt(0) == '.') { + suffix = suffix.substring(1); + } + + // Set destination's value to key's value + ctx.setAttribute(dest_pfx + '.' + suffix, ctx.getAttribute(key)); + } + } + } + + /** + * Creates and returns a {@code Map} that is a subset of + * context memory where all keys begin with the prefix. + * @param ctx Reference to context memory. + * @param prefix Returned map's keys should all begin with this value. + * @return A {@code Map} containing all the key-value pairs + * in ctx whose key begins with prefix. + */ + public static final Map ctxGetBeginsWith( SvcLogicContext ctx, String prefix ) { + Map prefixMap = new HashMap(); + + for( String key : ctx.getAttributeKeySet() ) { + if( key.startsWith(prefix) ) { + prefixMap.put( key, ctx.getAttribute(key) ); + } + } + + return prefixMap; + } + + /** + * Returns true if key's value in context memory is "" or if it doesn't + * exist in context memory. + * @param ctx Reference to context memory. + * @param key Key to search for. + * @return true if key's value in context memory is "" or if it doesn't + * exist in context memory. + * @since 1.0 + */ + public static final boolean ctxKeyEmpty( SvcLogicContext ctx, String key ) { + String value = ctx.getAttribute(key); + return value == null || value.isEmpty(); + } + + /** + * Adds all key-value pairs in the entries Map to context memory. + * @param ctx Reference to context memory. Value's {@code toString()} + * function is used to add it. + * @param entries {@code Map} of key-value pairs to add to + * context memory. Value's {@code toString()} function is used to add it. + * @return Reference to context memory to be used for function chaining. + */ + public static final SvcLogicContext ctxPutAll( SvcLogicContext ctx, Map entries ) { + for( Map.Entry entry : entries.entrySet() ) { + ctxSetAttribute( ctx, entry.getKey(), entry.getValue() ); + //ctx.setAttribute(entry.getKey(), entry.getValue().toString()); + } + + return ctx; + } + + /** + * Sets a key in context memory to the output of object's toString(). The + * key is deleted from context memory if object is null. + * @param ctx Reference to context memory. + * @param key Key to set. + * @param object Object whose toString() will be the value set + */ + public static final void ctxSetAttribute( SvcLogicContext ctx, String key, Object object ) { + if( object == null ) { + ctx.setAttribute(key, null); + } + else { + ctx.setAttribute(key, object.toString()); + } + } + + /** + * Sets a key in context memory to the output of object's toString(). + *

+ * The key is deleted from context memory if object is null. The key and + * value set in context memory are logged to the Logger at the provided + * logLevel level. + * @param Any Java object + * @param ctx Reference to context memory. + * @param key Key to set. + * @param obj Object whose toString() will be the value set + * @param LOG Logger to log to + * @param logLevel level to log at in Logger + */ + public static final void ctxSetAttribute( SvcLogicContext ctx, String key, O obj, Logger LOG, LogLevel logLevel ) { + String value = Objects.toString( obj, null ); + ctx.setAttribute( key, value ); + if( logLevelIsEnabled(LOG, logLevel ) ) { + if( value == null ) { + logMessageAtLevel( LOG, logLevel, "Deleting " + key ); + } + else { + logMessageAtLevel( LOG, logLevel, "Setting " + key + " = " + value ); + } + } + } + + /** + * Utility function used to get an array's length from context memory. + * Will return 0 if key doesn't exist in context memory or isn't numeric. + *

+ * Use to obtain a context memory array length without having to worry + * about throwing a NumberFormatException. + * @param ctx Reference to context memory + * @param key Key in context memory whose value is the array's length. If + * the key doesn't end in "_length", then "_length is appended. + * @param log Reference to Logger to log to + * @return The array length or 0 if the key is not found in context memory. + * @since 1.0 + */ + public static final int getArrayLength( SvcLogicContext ctx, String key ) { + return getArrayLength(ctx, key, null, null, null); + } + + /** + * Utility function used to get an array's length from context memory. + * Will return 0 if key doesn't exist in context memory or isn't numeric + * and print the provided log message to the configured log file. + *

+ * Use to obtain a context memory array length without having to worry + * about throwing a NumberFormatException. + * @param ctx Reference to context memory. + * @param key Key in context memory whose value is the array's length. If + * the key doesn't end in "_length", then "_length is appended. + * @param log Reference to Logger to log to. Doesn't log if null. + * @param logLevel Logging level to log the message at if the context + * memory key isn't found. Doesn't log if null. + * @param log_message Message to log if the context memory key isn't found. + * Doesn't log if null. + * @return The array length or 0 if the key is not found in context memory. + * @since 1.0 + */ + public static final int getArrayLength( SvcLogicContext ctx, String key, Logger log, LogLevel logLevel, String log_message ) { + String ctxKey = ( key.endsWith("_length") ) ? key : key + "_length"; + try { + return Integer.parseInt(ctx.getAttribute(ctxKey)); + } + catch( NumberFormatException e ) { + if( log != null && logLevel != null && log_message != null ) { + switch( logLevel ) { + case TRACE: + log.trace(log_message); + case DEBUG: + log.debug(log_message); + break; + case INFO: + log.info(log_message); + break; + case WARN: + log.warn(log_message); + break; + case ERROR: + log.error(log_message); + break; + } + } + } + + return 0; + } + + /** + * Prints sorted context memory key-value pairs to the log file at the log + * level. Returns immediately if the log level isn't enabled. + *

+ * O(n log(n)) time where n = size of context memory + * @param ctx Reference to context memory + * @param log Reference to Logger to log to + * @param logLevel Logging level to log the context memory key-value pairs + * at. + * @since 1.0 + */ + public static final void logContextMemory( SvcLogicContext ctx, Logger log, LogLevel logLevel ) { + logLevelIsEnabled( log, logLevel ); + + // Print sorted context memory key-value pairs to the log + ArrayList keys = new ArrayList(ctx.getAttributeKeySet()); + Collections.sort(keys); + for( String key : keys ) { + logMessageAtLevel( log, logLevel, key + " = " + ctx.getAttribute(key) ); + } + } + + + + // ========== PRIVATE FUNCTIONS ========== + + // TODO: javadoc + /** + * + * @param parameters + * @param log + * @param loglevel + * @since 7.0.1 + */ + public static final void logExecuteNodeParameters( Map parameters, Logger log, LogLevel loglevel ) { + logLevelIsEnabled( log, loglevel ); + + for( Map.Entry param : parameters.entrySet() ) { + logMessageAtLevel( log, loglevel, "PARAM: " + param.getKey() + " = " + param.getValue() ); + } + } + + // TODO: javadoc + /** + * Returns true if the loglevel is enabled. Otherwise, returns false. + * @param log Reference to logger + * @param loglevel Log level to check if enabled + * @return True if the loglevel is enabled. Otherwise, false + * @since 7.0.1 + */ + private static final boolean logLevelIsEnabled( Logger log, LogLevel loglevel ) { + // Return immediately if logging level isn't enabled + switch( loglevel ) { + case TRACE: + if( log.isTraceEnabled() ) { return true; } + return false; + case DEBUG: + if( log.isDebugEnabled() ) { return true; } + return false; + case INFO: + if( log.isInfoEnabled() ) { return true; } + return false; + case WARN: + if( log.isWarnEnabled() ) { return true; } + return false; + case ERROR: + if( log.isErrorEnabled() ) { return true; } + return false; + default: + throw new IllegalArgumentException("Unknown LogLevel: " + loglevel.toString()); + } + } + + // TODO: javadoc + /** + * + * @param log + * @param loglevel + * @param msg + * @since 7.0.1 + */ + private static final void logMessageAtLevel( Logger log, LogLevel loglevel, String msg ) { + switch( loglevel ) { + case TRACE: + log.trace(msg); + return; + case DEBUG: + log.debug(msg); + return; + case INFO: + log.info(msg); + return; + case WARN: + log.warn(msg); + return; + case ERROR: + log.error(msg); + return; + } + } + + + + // ========== LOCAL CLASSES ========== + + private class SortableCtxListElement implements Comparable { + HashMap child_elements = new HashMap(); + String[] sort_fields; + + public SortableCtxListElement( SvcLogicContext ctx, String root, String[] sort_fields ) { + this.sort_fields = sort_fields; + + for( String key : ctx.getAttributeKeySet() ) { + if( key.startsWith(root) ) { + if( key.length() == root.length() ) { + child_elements.put("", ctx.getAttribute(key)); + break; + } + else { + child_elements.put(key.substring(root.length()+1), ctx.getAttribute(key)); + } + } + } + } + + @Override + public int compareTo(SortableCtxListElement arg0) { + if( sort_fields == null ) { + return this.child_elements.get("").compareTo(arg0.child_elements.get("")); + } + + for( String field : this.sort_fields ) { + int result = this.child_elements.get(field).compareTo(arg0.child_elements.get(field)); + if( result != 0 ) { + return result; + } + } + + return 0; + } + } + + /** + * Creates a file that contains the content of context memory. + * @param parameters - must contain the parameter filename + * @param ctx Reference to context memory + * @throws SvcLogicException thrown if file cannot be created or if parameters are missing + */ + public static void printContext(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + if (parameters == null || parameters.isEmpty()) { + throw new SvcLogicException("no parameters passed"); + } + + checkParameters(parameters, new String[]{"filename"}, LOG); + + String fileName = parameters.get("filename"); + + + try (FileOutputStream fstr = new FileOutputStream(new File(fileName)); + PrintStream pstr = new PrintStream(fstr, true);) + { + pstr.println("#######################################"); + for (String attr : ctx.getAttributeKeySet()) { + pstr.println(attr + " = " + ctx.getAttribute(attr)); + } + } catch (Exception e) { + throw new SvcLogicException("Cannot write context to file " + fileName, e); + } + + + } + + /** + * Checks context memory for a set of required parameters + * Every parameter aside from prefix will be treated as mandatory + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + *
parameterMandatory/Optionaldescription
prefixOptionalthe prefix will be added to each parameter
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void requiredParameters(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + if (parameters == null || parameters.keySet().size() < 1) { + String errorMessage = "requiredParameters should not be called if the parameters hashmap is null or empty!"; + LOG.error(errorMessage); + throw new SvcLogicException(errorMessage); + } + String prefixValue = null; + String prefix = "prefix"; + if(parameters.containsKey(prefix)){ + prefixValue = parameters.get(prefix); + parameters.remove(prefix); + } + checkParameters(prefixValue, ctx.getAttributeKeySet(), parameters.keySet(), LOG); + } + + private static void checkParameters(String prefixValue, Set ctx, Set parameters, Logger log) throws SvcLogicException { + for (String param : parameters) { + if (prefixValue != null) { + param = prefixValue + param; + } + if (!ctx.contains(param)) { + String errorMessage = "This method requires the parameters [" + StringUtils.join(parameters, ",") + + "], but " + param + " was not passed in."; + log.error(errorMessage); + throw new SvcLogicException(errorMessage); + } + } + } + + /** + * is in a different DG invocation just before/after we call NCS and set the state to InProgress + */ + /** + * setTime write the current date time to a string located at outputPath + * @param parameters - requires outputPath to not be null + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public static void setTime(Map parameters, SvcLogicContext ctx) throws SvcLogicException + { + checkParameters(parameters, new String[] { "outputPath" }, LOG); + + // Set the DateFormat + // "2015-03-16T12:18:35.138Z" + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + + // Parse the date + String ctxVariable = parameters.get("outputPath"); + try { + String dateTime = format.format(new Date()); + ctx.setAttribute(ctxVariable, dateTime); + } catch (Exception ex) { + throw new SvcLogicException("problem with setTime", ex); + } + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java new file mode 100644 index 000000000..0e4a0be25 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SliPluginUtilsActivator implements BundleActivator { + @SuppressWarnings("rawtypes") private List registrations = new LinkedList(); + + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtilsActivator.class); + private static final String SDNC_ROOT_DIR = "SDNC_CONFIG_DIR"; + private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; + + @Override + public void start(BundleContext ctx) throws Exception { + SliPluginUtils plugin = new SliPluginUtils(new Properties()); + LOG.info("Registering service " + plugin.getClass().getName()); + registrations.add(ctx.registerService(plugin.getClass().getName(), plugin, null)); + + SliStringUtils sliStringUtils_Plugin = new SliStringUtils(); + LOG.info("Registering service " + sliStringUtils_Plugin.getClass().getName()); + registrations.add(ctx.registerService(sliStringUtils_Plugin.getClass().getName(), sliStringUtils_Plugin, null)); + + try { + String path = System.getenv(SDNC_ROOT_DIR) + File.separator + DME2_PROPERTIES_FILE_NAME; + DME2 dmePlugin = initDme2(path); + if (dmePlugin != null) { + LOG.info("Registering service " + dmePlugin.getClass().getName()); + registrations.add(ctx.registerService(dmePlugin.getClass().getName(), dmePlugin, null)); + } + } catch (Exception e) { + LOG.error("DME2 plugin could not be started", e); + } + } + + public DME2 initDme2(String pathToDmeProperties) { + Properties dme2properties = new Properties(); + String loadPropertiesErrorMessage = "Couldn't load DME2 properties at path " + pathToDmeProperties; + File dme2propertiesFile = new File(pathToDmeProperties); + + try { + dme2properties.load(new FileReader(dme2propertiesFile)); + String proxyUrlProperty = dme2properties.getProperty("proxyUrl"); + String[] proxyUrls = proxyUrlProperty.split(","); + DME2 dmePlugin = new DME2(dme2properties.getProperty("aafUserName"), dme2properties.getProperty("aafPassword"), dme2properties.getProperty("envContext"), dme2properties.getProperty("routeOffer"), proxyUrls, dme2properties.getProperty("commonServiceVersion")); + dmePlugin.setPartner(dme2properties.getProperty("partner")); + return dmePlugin; + } catch (FileNotFoundException e) { + LOG.error(loadPropertiesErrorMessage); + } catch (IOException e) { + LOG.error(loadPropertiesErrorMessage); + } + LOG.error("Couldn't create DME2 plugin"); + return null; + } + + @Override + public void stop(BundleContext ctx) throws Exception { + for (@SuppressWarnings("rawtypes") ServiceRegistration registration : registrations) { + registration.unregister(); + registration = null; + } + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java new file mode 100644 index 000000000..2664da2ca --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -0,0 +1,395 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A SvcLogicJavaPlugin that exposes java.lang.String functions to DirectedGraph + */ +public class SliStringUtils implements SvcLogicJavaPlugin { + private static final Logger LOG = LoggerFactory.getLogger(SliStringUtils.class); + + public SliStringUtils() {} + + /** + * Provides split functionality to Directed Graphs. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
original_stringMandatoryString to perform split on
regexMandatorythe delimiting regular expression
limitOptionalresult threshold. See String.split method for further description. Defaults to 0
ctx_memory_result_keyMandatoryKey in context memory to populate the resulting array of strings under
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + * @see String#split(String, int) + */ + public void split( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + final String original_string = parameters.get("original_string"); + LOG.trace("original_string = " + original_string); + final String regex = parameters.get("regex"); + LOG.trace("regex = " + regex); + final String limit_str = parameters.get("limit"); + LOG.trace("limit_str = " + limit_str); + final String ctx_memory_result_key = parameters.get("ctx_memory_result_key"); + LOG.trace("ctx_memory_result_key = " + ctx_memory_result_key); + + try { + // Validation that parameters are not null + SliPluginUtils.checkParameters( parameters, new String[]{"original_string","regex","ctx_memory_result_key"}, LOG ); + + // Read limit from context memory. Default to 0 if null/empty + int limit = 0; + if( StringUtils.isNotEmpty(limit_str) ) { + try { + limit = Integer.parseInt(limit_str); + } + catch( NumberFormatException e ) { + throw new IllegalArgumentException( "The limit parameter of the SliStringUtils.split() function must be a number, empty string, or null", e ); + } + } + + // Call String.split(regex,limit) on string passed in + String[] split_string = original_string.split(regex, limit); + + // Populate context memory with results + for( int i = 0; i < split_string.length; i++ ) { + SliPluginUtils.ctxSetAttribute(ctx, ctx_memory_result_key + '[' + i + ']', split_string[i], LOG, SliPluginUtils.LogLevel.DEBUG); + } + SliPluginUtils.ctxSetAttribute(ctx, ctx_memory_result_key + "_length", new Integer(split_string.length), LOG, SliPluginUtils.LogLevel.DEBUG); + } + catch( Exception e ) { + // Have error message print parameters + throw new SvcLogicException( "An error occurred during SliStringUtils.split() where original_string = " + quotedOrNULL(regex) + + " regex = " + quotedOrNULL(regex) + + " limit = " + quotedOrNULL(regex) + + " ctx_memory_result_key = " + quotedOrNULL(regex), e ); + } + } + + private static String quotedOrNULL( String str ) { + return (str == null) ? "NULL" : '"' + str + '"'; + } + + /** + * exposes equalsIgnoreCase to directed graph + * @param parameters HashMap of parameters passed by the DG to this function + * emits a true or false outcome + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static String equalsIgnoreCase(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); + if(parameters.get("source").equalsIgnoreCase(parameters.get("target"))){ + return "true"; + } + return "false"; + } + + /** + * exposes toUpperCase to directed graph + * writes an upperCase version of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void toUpper(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").toUpperCase()); + } + + /** + * exposes toLowerCase to directed graph + * writes a lowerCase version of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void toLower(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").toLowerCase()); + } + + /** + * exposes contains to directed graph to test if one string contains another + * tests if the source contains the target + * @param parameters HashMap of parameters passed by the DG to this function + * emits a true or false outcome + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static String contains(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); + if(parameters.get("source").contains(parameters.get("target"))){ + return "true"; + } + return "false"; + } + + /** + * exposes endsWith to directed graph to test if one string endsWith another string + * tests if the source ends with the target + * @param parameters HashMap of parameters passed by the DG to this function + * emits a true or false outcome + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static String endsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); + if(parameters.get("source").endsWith(parameters.get("target"))){ + return "true"; + } + return "false"; + } + + /** + * exposes startsWith to directed graph to test if one string endsWith another string + * tests if the source ends with the target + * @param parameters HashMap of parameters passed by the DG to this function + * emits a true or false outcome + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static String startsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); + if(parameters.get("source").startsWith(parameters.get("target"))){ + return "true"; + } + return "false"; + } + + /** + * exposes trim to directed graph + * writes a trimmed version of the string to the outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void trim(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").trim()); + } + + /** + * exposes String.length() to directed graph + * writes the length of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void getLength(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), String.valueOf(parameters.get("source").length())); + } + + /** + * exposes replace to directed graph + * writes the length of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatoryThe sequence of char values to be replaced
replacementMandatoryThe replacement sequence of char values
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void replace(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath","target","replacement"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), (parameters.get("source").replace(parameters.get("target"), parameters.get("replacement")))); + } + + /** + * Provides substring functionality to Directed Graphs. + *

+ * Calls either String.substring(String beginIndex) or + * String.substring(String beginInded, String endIndex) if the end-index + * is present or not. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
stringMandatoryString to perform substring on
resultMandatoryKey in context memory to populate the resulting string in
begin-indexMandatoryBeginning index to pass to Java substring function
end-indexOptionalEnding index to pass to Java substring function. If not included, String.substring(begin) will be called.
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public void substring( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + try { + SliPluginUtils.checkParameters( parameters, new String[]{"string","begin-index","result"}, LOG ); + final String string = parameters.get("string"); + final String result = parameters.get("result"); + final String begin = parameters.get("begin-index"); + final String end = parameters.get("end-index"); + if( StringUtils.isEmpty(end) ) { + ctx.setAttribute( result, string.substring(Integer.parseInt(begin)) ); + } + else { + ctx.setAttribute( result, string.substring(Integer.parseInt(begin), Integer.parseInt(end)) ); + } + } + catch( Exception e ) { + throw new SvcLogicException( "An error occurred while the Directed Graph was performing a substring", e ); + } + } + + /** + * Provides concat functionality to Directed Graphs. + *

+ * Will concat target to source and write the result to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatoryThe sequence of char values to be replaced
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void concat( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { + SliPluginUtils.checkParameters( parameters, new String[]{"source","target","outputPath"}, LOG ); + String result = parameters.get("source").concat(parameters.get("target")); + ctx.setAttribute(parameters.get("outputPath"), result); + } + + /** + * Provides url encoding functionality to Directed Graphs. + *

+ * Will url encode the source and write the result to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
sourceMandatorysource string
encodingOptionalthe name of a supported character encoding, defaulted to UTF-8 if not supplied
outputPathMandatorythe location in context memory the result is written to
+ * @param ctx Reference to context memory + * @throws SvcLogicException + */ + public static void urlEncode(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] { "source", "outputPath" }, LOG); + String encoding = parameters.get("encoding"); + if (encoding == null) { + encoding = "UTF-8"; + } + try { + String result = URLEncoder.encode(parameters.get("source"), encoding); + ctx.setAttribute(parameters.get("outputPath"), result); + } catch (UnsupportedEncodingException e) { + throw new SvcLogicException("Url encode failed.", e); + } + } + +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java new file mode 100644 index 000000000..fb7f5efe3 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java @@ -0,0 +1,209 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.ListIterator; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +/** + * A utility class used to manage list manipulation in the context memory. + * @see org.onap.ccsdk.sli.core.sli.SvcLogicContext + */ +public class SvcLogicContextList { + /** + * Internal flag indicating if list should be deleted from context memory + * when it is copied into the SvcLogicContextList object. + */ + private enum OperType { + COPY, EXTRACT + } + + // TODO: javadoc + protected final String prefix; + // TODO: javadoc + protected final ArrayList> list; + + + // TODO: javadoc + public SvcLogicContextList( SvcLogicContext ctx, String list_prefix ) { + this(ctx, list_prefix, OperType.COPY); + } + + // TODO: javadoc + private SvcLogicContextList( SvcLogicContext ctx, String list_prefix, OperType operation ) { + this.prefix = list_prefix; + + // Initialize list + int capacity = getCtxListLength(ctx, prefix); + this.list = new ArrayList>(capacity); + for( int i = 0; i < capacity; i++ ) { + this.list.add(i, new HashMap()); + } + + // Populate "elements" in list + String prefix_bracket = this.prefix + '['; + for (String key : new HashSet(ctx.getAttributeKeySet())) { + if( key.startsWith(prefix_bracket) ) { + // Extract the index of the list + int index = getCtxListIndex(key, this.prefix, capacity); + + // Store the + String suffix = key.substring((prefix_bracket + index + ']').length()); + suffix = suffix.isEmpty() ? suffix : suffix.substring(1); + this.list.get(index).put( suffix, ctx.getAttribute(key)); + + // If flag to extract set, remove data from context memory as + // it is read into this list + if( operation == OperType.EXTRACT ) { + ctx.setAttribute(key, null); + } + } + } + + // If flag to extract set, remove list _length value from cxt mem + if( operation == OperType.EXTRACT ) { + ctx.setAttribute(this.prefix + "_length", null); + } + } + + // TODO: javadoc + public static SvcLogicContextList extract( SvcLogicContext ctx, String list_prefix ) { + return new SvcLogicContextList(ctx, list_prefix, OperType.EXTRACT); + } + + + // ========== PUBLIC FUNCTIONS ========== + + // TODO: javadoc + public HashMap get( int index ) { + return this.list.get(index); + } + + // TODO: javadoc + public HashMap remove( int index ) { + return this.list.remove(index); + } + + // TODO: javadoc + public void remove( String value ) { + remove( "", value ); + } + + // TODO: javadoc + public void remove( String key, String value ) { + if( value == null ) { + throw new IllegalArgumentException("value cannot be null"); + } + + ListIterator> itr = this.list.listIterator(); + while( itr.hasNext() ) { + if( value.equals(itr.next().get(key)) ) { + itr.remove(); + } + } + } + + // TODO javadoc + public void remove( Map primary_key ) { + ListIterator> itr = this.list.listIterator(); + while( itr.hasNext() ) { + boolean found = true; + HashMap list_element = itr.next(); + for( Map.Entry key : primary_key.entrySet() ) { + if( !key.getValue().equals(list_element.get(key.getKey())) ) { + found = false; + break; + } + } + + if( found ) { + itr.remove(); + } + } + } + + // TODO: javadoc + public int size() { + return list.size(); + } + + // TODO: javadoc + public void writeToContext( SvcLogicContext ctx ) { + ctx.setAttribute( prefix + "_length", Integer.toString(this.list.size()) ); + + for( int i = 0; i < this.list.size(); i++ ) { + for( Map.Entry entry : this.list.get(i).entrySet() ) { + if( entry.getKey().equals("") ) { + ctx.setAttribute(prefix + '[' + i + ']', entry.getValue()); + } else { + ctx.setAttribute(prefix + '[' + i + "]." + entry.getKey(), entry.getValue()); + } + } + } + } + + + + // ========== PRIVATE STATIC FUNCTIONS ========== + + // TODO: javadoc + private static int getCtxListIndex( String key, String prefix, int list_size ) { + int index = getCtxListIndex( key, prefix ); + if( index >= list_size ) { + throw new IllegalArgumentException("Context memory list \"" + prefix + "[]\" contains an index >= the size of the list", new ArrayIndexOutOfBoundsException("index \"" + index + "\" is outside the bounds of the context memory list \"" + prefix + "[]. List Length = " + list_size)); + } else if (index < 0) { + throw new IllegalArgumentException("Context memory list \"" + prefix + "[]\" contains a negative index", new NegativeArraySizeException("index \"" + index + "\" of context memory list is negative")); + } + + return index; + } + + // TODO: javadoc + private static int getCtxListIndex( String key, String prefix ) { + String ctx_index_str = StringUtils.substringBetween(key.substring(prefix.length()), "[", "]"); + try { + return Integer.parseInt( ctx_index_str ); + } catch (NumberFormatException e) { + throw new IllegalStateException("Could not parse index value \"" + ctx_index_str + "\" in context memory key \"" + key + "\"", e); + } + } + + // TODO: javadoc + private static int getCtxListLength( SvcLogicContext ctx, String prefix ) { + String _length_key = prefix + "_length"; + String _length_val_str = ctx.getAttribute(_length_key); + try { + return Integer.parseInt(_length_val_str); + } catch (NumberFormatException e) { + if( _length_val_str == null ) { + throw new IllegalStateException( "Could not find list length \"" + _length_key + "\" in context memory." ); + } else { + throw new IllegalStateException( "Could not parse index value \"" + _length_val_str + "\" of context memory list length \"" + _length_key + "\"" , e ); + } + } + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java new file mode 100644 index 000000000..871d9459c --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +public interface SvcLogicContextObject { + public void writeToContext( SvcLogicContext ctx, String root ); +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/commondatastructures/YesNo.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/commondatastructures/YesNo.java new file mode 100644 index 000000000..2cba40ebb --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/commondatastructures/YesNo.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils.commondatastructures; + +/** + * An enum found in many Yang models. It is commonly used as a + * substitute for boolean. + */ +public enum YesNo { + N, Y; + + /** + * Method overload for {@link #valueOf(String)} for the char primative + */ + public static YesNo valueOf( final char name ) { + return YesNo.valueOf( Character.toString(name) ); + } + + /** + * Method overload for {@link #valueOf(String)} for the Character object + */ + public static YesNo valueOf( final Character name ) { + if( name == null ) { + return null; + } + + return YesNo.valueOf( name.toString() ); + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/commondatastructures/package-info.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/commondatastructures/package-info.java new file mode 100644 index 000000000..f01116f4d --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/commondatastructures/package-info.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils.commondatastructures; diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/DME2.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/DME2.java deleted file mode 100644 index 29ce8c5ac..000000000 --- a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/DME2.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import java.util.Map; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -/** - * A SvcLogicJavaPlugin that generates DME2 proxy urls using parameters from context memory. - */ -public class DME2 implements SvcLogicJavaPlugin { - String aafUserName; - String aafPassword; - String envContext; - String routeOffer; - String[] proxyUrls; - Integer index; - String commonServiceVersion; - String partner; - - private static final Logger LOG = LoggerFactory.getLogger(DME2.class); - - public void setPartner(String partner) { - if (partner != null && partner.length() > 0) { - this.partner = partner; - } - } - - public DME2(String aafUserName, String aafPassword, String envContext, String routeOffer, String[] proxyUrls, String commonServiceVersion) { - this.aafUserName = aafUserName; - this.aafPassword = aafPassword; - this.envContext = envContext; - this.routeOffer = routeOffer; - this.proxyUrls = proxyUrls; - this.index = 0; - this.commonServiceVersion = commonServiceVersion; - } - - // constructs a URL to contact the proxy which contacts a DME2 service - public String constructUrl(String service, String version, String subContext) { - StringBuilder sb = new StringBuilder(); - - // The hostname is assigned in a round robin fashion - sb.append(acquireHostName()); - sb.append("/service=" + service); - - //If the directedGraph passes an explicit version use that, if not use the commonServiceVersion found in the properties file - if (version == null) { - version = this.commonServiceVersion; - } - sb.append("/version=" + version); - - sb.append("/envContext=" + this.envContext); - if (this.routeOffer != null && this.routeOffer.length() > 0) { - sb.append("/routeOffer=" + this.routeOffer); - } - if (subContext != null && subContext.length() > 0) { - sb.append("/subContext=" + subContext); - } - sb.append("?dme2.password=" + this.aafPassword); - sb.append("&dme2.username=" + this.aafUserName); - if (this.partner != null) { - sb.append("&dme2.partner=" + this.partner); - } - sb.append("&dme2.allowhttpcode=true"); - return (sb.toString()); - } - - public synchronized String acquireHostName() { - String retVal = proxyUrls[index]; - index++; - if (index == this.proxyUrls.length) { - index = 0; - } - return retVal; - } - - // Node entry point - public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[] { "service", "outputPath" }, LOG); - String completeProxyUrl = constructUrl(parameters.get("service"), parameters.get("version"), parameters.get("subContext")); - ctx.setAttribute(parameters.get("outputPath"), completeProxyUrl); - } - -} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils.java deleted file mode 100644 index 9da1a4776..000000000 --- a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils.java +++ /dev/null @@ -1,753 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.PrintStream; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Properties; -import java.util.Set; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A utility class used to streamline the interface between Java plugins, - * the Service Logic Context, and Directed Graphs. - * @version 7.0.1 - * @see org.onap.ccsdk.sli.core.sli.SvcLogicContext - */ -public class SliPluginUtils implements SvcLogicJavaPlugin { - public enum LogLevel { - TRACE, DEBUG, INFO, WARN, ERROR; - } - - private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils.class); - - - // ========== CONSTRUCTORS ========== - - public SliPluginUtils() {} - - public SliPluginUtils( Properties props ) {} - - - - // ========== CONTEXT MEMORY FUNCTIONS ========== - - /** - * Removes 1 or more elements from a list in context memory. - *

- * Values are removed based on either the index in the list, a key-value - * pair, or a list of key-value pairs that all must match in the element. - * @param parameters - * @param ctx Reference to context memory - * @throws SvcLogicException All exceptions are wrapped in - * SvcLogicException for compatibility with SLI. - * @since 7.0.1 - */ - public void ctxListRemove( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - try{ - LOG.debug( "ENTERING Execute Node \"ctxListRemove\"" ); - - // Validate, Log, & read parameters - checkParameters(parameters, new String[]{"list_pfx"}, LOG); - logExecuteNodeParameters(parameters, LOG, LogLevel.DEBUG); - String list_pfx = parameters.get("list_pfx"); - String param_index = parameters.get("index"); - String param_key = parameters.get("key"); - String param_value = parameters.get("value"); - String param_keys_length = parameters.get("keys_length"); - - // Initialize context memory list mimic - SvcLogicContextList list; - - // Process based on input parameters: - // index: remove object at specific index - // key & value: remove all objects with key-value pair - // keys_length: remove all objects that match all key-value pairs - // in list - if( param_index != null ) { - // Parse index - LOG.trace("executing remove by index logic"); - int index; - try { - index = Integer.parseInt(param_index); - } - catch( NumberFormatException e ) { - throw new IllegalArgumentException("\"index\" parameter is not a number. index = " + param_index, e); - } - - // Extract list from context memory & remove object @ index - LOG.trace("extracting list from context memory"); - list = SvcLogicContextList.extract(ctx, list_pfx); - LOG.trace("removing elements from list"); - list.remove(index); - } - else if( param_value != null ) { - if( param_key == null ) { param_key = ""; } - - // Extract list from context memory & remove objects with - // key-value pair - LOG.trace("executing remove by key-value pair logic"); - LOG.trace("extracting list from context memory"); - list = SvcLogicContextList.extract(ctx, list_pfx); - LOG.trace("removing elements from list"); - list.remove( param_key, param_value ); - } - else if( param_keys_length != null ) { - // Parse keys_length - LOG.trace("executing remove by key-value pair list logic"); - int keys_length; - try { - keys_length = Integer.parseInt(param_keys_length); - } - catch( NumberFormatException e ) { - throw new IllegalArgumentException("\"keys_length\" parameters is not a number. keys_length = " + param_keys_length, e); - } - - // Obtain key-value pairs to check from parameters - LOG.trace("reading keys parameter list"); - HashMap keys_values = new HashMap(); - for( int i = 0; i < keys_length; i++ ) { - keys_values.put(parameters.get("keys[" + i + "].key"), parameters.get("keys[" + i + "].value")); - } - - // Extract list from context memory & remove objects with all - // key-value pairs matching - LOG.trace("extracting list from context memory"); - list = SvcLogicContextList.extract(ctx, list_pfx); - LOG.trace("removing elements from list"); - list.remove(keys_values); - } - else { - throw new IllegalArgumentException("Required parameters missing. Requires one of: index, key & value, or keys_length array"); - } - - // Remove index from list - LOG.trace("writing list back into context memory"); - list.writeToContext(ctx); - } - catch( Exception e ) { - throw new SvcLogicException( "An error occurred in the ctxListRemove Execute node", e ); - } - finally { - LOG.debug( "EXITING Execute Node \"ctxListRemove\"" ); - } - } - - /** - * ctxSortList - * @param parameters - the set of required parameters must contain list and delimiter. - * @param ctx Reference to context memory - * @throws SvcLogicException if a required parameter is missing an exception is thrown - */ - public void ctxSortList( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - checkParameters(parameters, new String[]{"list","delimiter"}, LOG); - ArrayList list = new ArrayList(); - - String[] sort_fields = null; - if( parameters.containsKey("sort-fields") ) { - sort_fields = parameters.get("sort-fields").split(parameters.get("delimiter"), 0); - } - - String ctx_list_str = parameters.get("list"); - int listSz = getArrayLength(ctx, ctx_list_str); - - - - for( int i = 0; i < listSz; i++ ) { - list.add( new SortableCtxListElement(ctx, ctx_list_str + '[' + i + ']', sort_fields) ); - } - Collections.sort(list); - - ctxBulkErase(ctx, ctx_list_str); - int i = 0; - for( SortableCtxListElement list_element : list ) { - for( Map.Entry entry : list_element.child_elements.entrySet() ) { - if( sort_fields == null ) { - ctx.setAttribute(ctx_list_str + '[' + i + ']', entry.getValue()); - } - else { - ctx.setAttribute(ctx_list_str + '[' + i + "]." + entry.getKey(), entry.getValue()); - } - } - i++; - } - // Reset list length (removed by ctxBulkErase above) - ctx.setAttribute(ctx_list_str+"_length", ""+listSz); - } - - /** - * generates a UUID and writes it to context memory - * @param parameters - ctx-destination is a required parameter - * @param ctx Reference to context memory - * @throws SvcLogicException thrown if a UUID cannot be generated or if ctx-destination is missing or null - */ - public void generateUUID( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - checkParameters(parameters, new String[]{"ctx-destination"}, LOG); - ctx.setAttribute(parameters.get("ctx-destination"), UUID.randomUUID().toString() ); - } - - /** - * Provides substring functionality to Directed Graphs. - *

- * Calls either String.substring(String beginIndex) or - * String.substring(String beginInded, String endIndex) if the end-index - * is present or not. - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
stringMandatoryString to perform substring on
resultMandatoryKey in context memory to populate the resulting string in
begin-indexMandatoryBeginning index to pass to Java substring function
end-indexOptionalEnding index to pass to Java substring function. If not included, String.substring(begin) will be called.
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 8.0.1 - * @see SliPluginUtils#substring(Map, SvcLogicContext) - */ - @Deprecated - public void substring( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - try { - checkParameters( parameters, new String[]{"string","begin-index","result"}, LOG ); - final String string = parameters.get("string"); - final String result = parameters.get("result"); - final String begin = parameters.get("begin-index"); - final String end = parameters.get("end-index"); - - if( StringUtils.isEmpty(end) ) { - ctx.setAttribute( result, string.substring(Integer.parseInt(begin)) ); - } - else { - ctx.setAttribute( result, string.substring(Integer.parseInt(begin), Integer.parseInt(end)) ); - } - } - catch( Exception e ) { - throw new SvcLogicException( "An error occurred while the Directed Graph was performing a substring", e ); - } - } - - - - // ========== PUBLIC STATIC UTILITY FUNCTIONS ========== - - /** - * Throws an exception and writes an error to the log file if a required - * parameters is not found in the parametersMap. - *

- * Use at the beginning of functions that can be called by Directed Graphs - * and can take parameters to verify that all parameters have been provided - * by the Directed Graph. - * @param parametersMap parameters Map passed to this node - * @param requiredParams Array of parameters required by the calling function - * @param log Reference to Logger to log to - * @throws SvcLogicException if a String in the requiredParams array is - * not a key in parametersMap. - * @since 1.0 - */ - public static final void checkParameters(Map parametersMap, String[] requiredParams, Logger log) throws SvcLogicException { - if( requiredParams == null || requiredParams.length < 1){ - log.debug("required parameters was empty, exiting early."); - return; - } - if (parametersMap == null || parametersMap.keySet().size() < 1){ - String errorMessage = "This method requires the parameters [" + StringUtils.join(requiredParams,",") + "], but no parameters were passed in."; - log.error(errorMessage); - throw new SvcLogicException(errorMessage); - } - - for (String param : requiredParams) { - if (!parametersMap.containsKey(param)) { - String errorMessage = "Required parameter \"" + param + "\" was not found in parameter list."; - log.error(errorMessage); - log.error("Total list of required parameters is [" + StringUtils.join(requiredParams, ",") + "]."); - throw new SvcLogicException(errorMessage); - } - } - } - - /** - * Removes all key-value pairs with keys that begin with pfx - * @param ctx Reference to context memory - * @param pfx Prefix of key-value pairs to remove - * @since 1.0 - */ - public static final void ctxBulkErase( SvcLogicContext ctx, String pfx ) { - ArrayList Keys = new ArrayList( ctx.getAttributeKeySet() ); - for( String key : Keys ) { - if( key.startsWith( pfx ) ) { - ctx.setAttribute( pfx + key.substring(pfx.length()) , null); - } - } - } - - /** - * Copies all context memory key-value pairs that start with src_pfx to - * the keys that start with dest_pfx + suffix, where suffix is the result - * of {@code key.substring(src_pfx.length())}. - *

- * Does NOT guarantee removal of all keys at the destination before - * copying, but will overwrite any destination keys that have a - * corresponding source key. Use {@link #ctxBulkErase(SvcLogicContext, String) ctxBulkErase} - * before copy to erase destination root before copying from source. - * @param ctx Reference to context memory. - * @param src_pfx Prefix of the keys to copy values from. - * @param dest_pfx Prefix of the keys to copy values to. - * @since 1.0 - */ - public static final void ctxBulkCopy( SvcLogicContext ctx, String src_pfx, String dest_pfx ) { - // Remove trailing period from dest_pfx - if( dest_pfx.charAt(dest_pfx.length()-1) == '.' ) { - dest_pfx = dest_pfx.substring(0,dest_pfx.length()-1); - } - - // For each context key that begins with src_pfx, set the value of the - // key dest_pfx + the suffix of the key to the key's value - ArrayList Keys = new ArrayList(ctx.getAttributeKeySet()); - for( String key : Keys ) { - if( key.startsWith(src_pfx) ) { - // Get suffix (no leading period) - String suffix = key.substring(src_pfx.length()); - if( suffix.charAt(0) == '.') { - suffix = suffix.substring(1); - } - - // Set destination's value to key's value - ctx.setAttribute(dest_pfx + '.' + suffix, ctx.getAttribute(key)); - } - } - } - - /** - * Creates and returns a {@code Map} that is a subset of - * context memory where all keys begin with the prefix. - * @param ctx Reference to context memory. - * @param prefix Returned map's keys should all begin with this value. - * @return A {@code Map} containing all the key-value pairs - * in ctx whose key begins with prefix. - */ - public static final Map ctxGetBeginsWith( SvcLogicContext ctx, String prefix ) { - Map prefixMap = new HashMap(); - - for( String key : ctx.getAttributeKeySet() ) { - if( key.startsWith(prefix) ) { - prefixMap.put( key, ctx.getAttribute(key) ); - } - } - - return prefixMap; - } - - /** - * Returns true if key's value in context memory is "" or if it doesn't - * exist in context memory. - * @param ctx Reference to context memory. - * @param key Key to search for. - * @return true if key's value in context memory is "" or if it doesn't - * exist in context memory. - * @since 1.0 - */ - public static final boolean ctxKeyEmpty( SvcLogicContext ctx, String key ) { - String value = ctx.getAttribute(key); - return value == null || value.isEmpty(); - } - - /** - * Adds all key-value pairs in the entries Map to context memory. - * @param ctx Reference to context memory. Value's {@code toString()} - * function is used to add it. - * @param entries {@code Map} of key-value pairs to add to - * context memory. Value's {@code toString()} function is used to add it. - * @return Reference to context memory to be used for function chaining. - */ - public static final SvcLogicContext ctxPutAll( SvcLogicContext ctx, Map entries ) { - for( Map.Entry entry : entries.entrySet() ) { - ctxSetAttribute( ctx, entry.getKey(), entry.getValue() ); - //ctx.setAttribute(entry.getKey(), entry.getValue().toString()); - } - - return ctx; - } - - /** - * Sets a key in context memory to the output of object's toString(). The - * key is deleted from context memory if object is null. - * @param ctx Reference to context memory. - * @param key Key to set. - * @param object Object whose toString() will be the value set - */ - public static final void ctxSetAttribute( SvcLogicContext ctx, String key, Object object ) { - if( object == null ) { - ctx.setAttribute(key, null); - } - else { - ctx.setAttribute(key, object.toString()); - } - } - - /** - * Sets a key in context memory to the output of object's toString(). - *

- * The key is deleted from context memory if object is null. The key and - * value set in context memory are logged to the Logger at the provided - * logLevel level. - * @param Any Java object - * @param ctx Reference to context memory. - * @param key Key to set. - * @param obj Object whose toString() will be the value set - * @param LOG Logger to log to - * @param logLevel level to log at in Logger - */ - public static final void ctxSetAttribute( SvcLogicContext ctx, String key, O obj, Logger LOG, LogLevel logLevel ) { - String value = Objects.toString( obj, null ); - ctx.setAttribute( key, value ); - if( logLevelIsEnabled(LOG, logLevel ) ) { - if( value == null ) { - logMessageAtLevel( LOG, logLevel, "Deleting " + key ); - } - else { - logMessageAtLevel( LOG, logLevel, "Setting " + key + " = " + value ); - } - } - } - - /** - * Utility function used to get an array's length from context memory. - * Will return 0 if key doesn't exist in context memory or isn't numeric. - *

- * Use to obtain a context memory array length without having to worry - * about throwing a NumberFormatException. - * @param ctx Reference to context memory - * @param key Key in context memory whose value is the array's length. If - * the key doesn't end in "_length", then "_length is appended. - * @param log Reference to Logger to log to - * @return The array length or 0 if the key is not found in context memory. - * @since 1.0 - */ - public static final int getArrayLength( SvcLogicContext ctx, String key ) { - return getArrayLength(ctx, key, null, null, null); - } - - /** - * Utility function used to get an array's length from context memory. - * Will return 0 if key doesn't exist in context memory or isn't numeric - * and print the provided log message to the configured log file. - *

- * Use to obtain a context memory array length without having to worry - * about throwing a NumberFormatException. - * @param ctx Reference to context memory. - * @param key Key in context memory whose value is the array's length. If - * the key doesn't end in "_length", then "_length is appended. - * @param log Reference to Logger to log to. Doesn't log if null. - * @param logLevel Logging level to log the message at if the context - * memory key isn't found. Doesn't log if null. - * @param log_message Message to log if the context memory key isn't found. - * Doesn't log if null. - * @return The array length or 0 if the key is not found in context memory. - * @since 1.0 - */ - public static final int getArrayLength( SvcLogicContext ctx, String key, Logger log, LogLevel logLevel, String log_message ) { - String ctxKey = ( key.endsWith("_length") ) ? key : key + "_length"; - try { - return Integer.parseInt(ctx.getAttribute(ctxKey)); - } - catch( NumberFormatException e ) { - if( log != null && logLevel != null && log_message != null ) { - switch( logLevel ) { - case TRACE: - log.trace(log_message); - case DEBUG: - log.debug(log_message); - break; - case INFO: - log.info(log_message); - break; - case WARN: - log.warn(log_message); - break; - case ERROR: - log.error(log_message); - break; - } - } - } - - return 0; - } - - /** - * Prints sorted context memory key-value pairs to the log file at the log - * level. Returns immediately if the log level isn't enabled. - *

- * O(n log(n)) time where n = size of context memory - * @param ctx Reference to context memory - * @param log Reference to Logger to log to - * @param logLevel Logging level to log the context memory key-value pairs - * at. - * @since 1.0 - */ - public static final void logContextMemory( SvcLogicContext ctx, Logger log, LogLevel logLevel ) { - logLevelIsEnabled( log, logLevel ); - - // Print sorted context memory key-value pairs to the log - ArrayList keys = new ArrayList(ctx.getAttributeKeySet()); - Collections.sort(keys); - for( String key : keys ) { - logMessageAtLevel( log, logLevel, key + " = " + ctx.getAttribute(key) ); - } - } - - - - // ========== PRIVATE FUNCTIONS ========== - - // TODO: javadoc - /** - * - * @param parameters - * @param log - * @param loglevel - * @since 7.0.1 - */ - public static final void logExecuteNodeParameters( Map parameters, Logger log, LogLevel loglevel ) { - logLevelIsEnabled( log, loglevel ); - - for( Map.Entry param : parameters.entrySet() ) { - logMessageAtLevel( log, loglevel, "PARAM: " + param.getKey() + " = " + param.getValue() ); - } - } - - // TODO: javadoc - /** - * Returns true if the loglevel is enabled. Otherwise, returns false. - * @param log Reference to logger - * @param loglevel Log level to check if enabled - * @return True if the loglevel is enabled. Otherwise, false - * @since 7.0.1 - */ - private static final boolean logLevelIsEnabled( Logger log, LogLevel loglevel ) { - // Return immediately if logging level isn't enabled - switch( loglevel ) { - case TRACE: - if( log.isTraceEnabled() ) { return true; } - return false; - case DEBUG: - if( log.isDebugEnabled() ) { return true; } - return false; - case INFO: - if( log.isInfoEnabled() ) { return true; } - return false; - case WARN: - if( log.isWarnEnabled() ) { return true; } - return false; - case ERROR: - if( log.isErrorEnabled() ) { return true; } - return false; - default: - throw new IllegalArgumentException("Unknown LogLevel: " + loglevel.toString()); - } - } - - // TODO: javadoc - /** - * - * @param log - * @param loglevel - * @param msg - * @since 7.0.1 - */ - private static final void logMessageAtLevel( Logger log, LogLevel loglevel, String msg ) { - switch( loglevel ) { - case TRACE: - log.trace(msg); - return; - case DEBUG: - log.debug(msg); - return; - case INFO: - log.info(msg); - return; - case WARN: - log.warn(msg); - return; - case ERROR: - log.error(msg); - return; - } - } - - - - // ========== LOCAL CLASSES ========== - - private class SortableCtxListElement implements Comparable { - HashMap child_elements = new HashMap(); - String[] sort_fields; - - public SortableCtxListElement( SvcLogicContext ctx, String root, String[] sort_fields ) { - this.sort_fields = sort_fields; - - for( String key : ctx.getAttributeKeySet() ) { - if( key.startsWith(root) ) { - if( key.length() == root.length() ) { - child_elements.put("", ctx.getAttribute(key)); - break; - } - else { - child_elements.put(key.substring(root.length()+1), ctx.getAttribute(key)); - } - } - } - } - - @Override - public int compareTo(SortableCtxListElement arg0) { - if( sort_fields == null ) { - return this.child_elements.get("").compareTo(arg0.child_elements.get("")); - } - - for( String field : this.sort_fields ) { - int result = this.child_elements.get(field).compareTo(arg0.child_elements.get(field)); - if( result != 0 ) { - return result; - } - } - - return 0; - } - } - - /** - * Creates a file that contains the content of context memory. - * @param parameters - must contain the parameter filename - * @param ctx Reference to context memory - * @throws SvcLogicException thrown if file cannot be created or if parameters are missing - */ - public static void printContext(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - if (parameters == null || parameters.isEmpty()) { - throw new SvcLogicException("no parameters passed"); - } - - checkParameters(parameters, new String[]{"filename"}, LOG); - - String fileName = parameters.get("filename"); - - - try (FileOutputStream fstr = new FileOutputStream(new File(fileName)); - PrintStream pstr = new PrintStream(fstr, true);) - { - pstr.println("#######################################"); - for (String attr : ctx.getAttributeKeySet()) { - pstr.println(attr + " = " + ctx.getAttribute(attr)); - } - } catch (Exception e) { - throw new SvcLogicException("Cannot write context to file " + fileName, e); - } - - - } - - /** - * Checks context memory for a set of required parameters - * Every parameter aside from prefix will be treated as mandatory - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - *
parameterMandatory/Optionaldescription
prefixOptionalthe prefix will be added to each parameter
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static void requiredParameters(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - if (parameters == null || parameters.keySet().size() < 1) { - String errorMessage = "requiredParameters should not be called if the parameters hashmap is null or empty!"; - LOG.error(errorMessage); - throw new SvcLogicException(errorMessage); - } - String prefixValue = null; - String prefix = "prefix"; - if(parameters.containsKey(prefix)){ - prefixValue = parameters.get(prefix); - parameters.remove(prefix); - } - checkParameters(prefixValue, ctx.getAttributeKeySet(), parameters.keySet(), LOG); - } - - private static void checkParameters(String prefixValue, Set ctx, Set parameters, Logger log) throws SvcLogicException { - for (String param : parameters) { - if (prefixValue != null) { - param = prefixValue + param; - } - if (!ctx.contains(param)) { - String errorMessage = "This method requires the parameters [" + StringUtils.join(parameters, ",") - + "], but " + param + " was not passed in."; - log.error(errorMessage); - throw new SvcLogicException(errorMessage); - } - } - } - - /** - * is in a different DG invocation just before/after we call NCS and set the state to InProgress - */ - /** - * setTime write the current date time to a string located at outputPath - * @param parameters - requires outputPath to not be null - * @param ctx Reference to context memory - * @throws SvcLogicException if a required parameter is missing an exception is thrown - */ - public static void setTime(Map parameters, SvcLogicContext ctx) throws SvcLogicException - { - checkParameters(parameters, new String[] { "outputPath" }, LOG); - - // Set the DateFormat - // "2015-03-16T12:18:35.138Z" - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - - // Parse the date - String ctxVariable = parameters.get("outputPath"); - try { - String dateTime = format.format(new Date()); - ctx.setAttribute(ctxVariable, dateTime); - } catch (Exception ex) { - throw new SvcLogicException("problem with setTime", ex); - } - } -} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtilsActivator.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtilsActivator.java deleted file mode 100644 index 923cde841..000000000 --- a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtilsActivator.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SliPluginUtilsActivator implements BundleActivator { - @SuppressWarnings("rawtypes") private List registrations = new LinkedList(); - - private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtilsActivator.class); - private static final String SDNC_ROOT_DIR = "SDNC_CONFIG_DIR"; - private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; - - @Override - public void start(BundleContext ctx) throws Exception { - SliPluginUtils plugin = new SliPluginUtils(new Properties()); - LOG.info("Registering service " + plugin.getClass().getName()); - registrations.add(ctx.registerService(plugin.getClass().getName(), plugin, null)); - - SliStringUtils sliStringUtils_Plugin = new SliStringUtils(); - LOG.info("Registering service " + sliStringUtils_Plugin.getClass().getName()); - registrations.add(ctx.registerService(sliStringUtils_Plugin.getClass().getName(), sliStringUtils_Plugin, null)); - - try { - String path = System.getenv(SDNC_ROOT_DIR) + File.separator + DME2_PROPERTIES_FILE_NAME; - DME2 dmePlugin = initDme2(path); - if (dmePlugin != null) { - LOG.info("Registering service " + dmePlugin.getClass().getName()); - registrations.add(ctx.registerService(dmePlugin.getClass().getName(), dmePlugin, null)); - } - } catch (Exception e) { - LOG.error("DME2 plugin could not be started", e); - } - } - - public DME2 initDme2(String pathToDmeProperties) { - Properties dme2properties = new Properties(); - String loadPropertiesErrorMessage = "Couldn't load DME2 properties at path " + pathToDmeProperties; - File dme2propertiesFile = new File(pathToDmeProperties); - - try { - dme2properties.load(new FileReader(dme2propertiesFile)); - String proxyUrlProperty = dme2properties.getProperty("proxyUrl"); - String[] proxyUrls = proxyUrlProperty.split(","); - DME2 dmePlugin = new DME2(dme2properties.getProperty("aafUserName"), dme2properties.getProperty("aafPassword"), dme2properties.getProperty("envContext"), dme2properties.getProperty("routeOffer"), proxyUrls, dme2properties.getProperty("commonServiceVersion")); - dmePlugin.setPartner(dme2properties.getProperty("partner")); - return dmePlugin; - } catch (FileNotFoundException e) { - LOG.error(loadPropertiesErrorMessage); - } catch (IOException e) { - LOG.error(loadPropertiesErrorMessage); - } - LOG.error("Couldn't create DME2 plugin"); - return null; - } - - @Override - public void stop(BundleContext ctx) throws Exception { - for (@SuppressWarnings("rawtypes") ServiceRegistration registration : registrations) { - registration.unregister(); - registration = null; - } - } -} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtils.java deleted file mode 100644 index 609de8188..000000000 --- a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtils.java +++ /dev/null @@ -1,395 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A SvcLogicJavaPlugin that exposes java.lang.String functions to DirectedGraph - */ -public class SliStringUtils implements SvcLogicJavaPlugin { - private static final Logger LOG = LoggerFactory.getLogger(SliStringUtils.class); - - public SliStringUtils() {} - - /** - * Provides split functionality to Directed Graphs. - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
original_stringMandatoryString to perform split on
regexMandatorythe delimiting regular expression
limitOptionalresult threshold. See String.split method for further description. Defaults to 0
ctx_memory_result_keyMandatoryKey in context memory to populate the resulting array of strings under
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - * @see String#split(String, int) - */ - public void split( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - final String original_string = parameters.get("original_string"); - LOG.trace("original_string = " + original_string); - final String regex = parameters.get("regex"); - LOG.trace("regex = " + regex); - final String limit_str = parameters.get("limit"); - LOG.trace("limit_str = " + limit_str); - final String ctx_memory_result_key = parameters.get("ctx_memory_result_key"); - LOG.trace("ctx_memory_result_key = " + ctx_memory_result_key); - - try { - // Validation that parameters are not null - SliPluginUtils.checkParameters( parameters, new String[]{"original_string","regex","ctx_memory_result_key"}, LOG ); - - // Read limit from context memory. Default to 0 if null/empty - int limit = 0; - if( StringUtils.isNotEmpty(limit_str) ) { - try { - limit = Integer.parseInt(limit_str); - } - catch( NumberFormatException e ) { - throw new IllegalArgumentException( "The limit parameter of the SliStringUtils.split() function must be a number, empty string, or null", e ); - } - } - - // Call String.split(regex,limit) on string passed in - String[] split_string = original_string.split(regex, limit); - - // Populate context memory with results - for( int i = 0; i < split_string.length; i++ ) { - SliPluginUtils.ctxSetAttribute(ctx, ctx_memory_result_key + '[' + i + ']', split_string[i], LOG, SliPluginUtils.LogLevel.DEBUG); - } - SliPluginUtils.ctxSetAttribute(ctx, ctx_memory_result_key + "_length", new Integer(split_string.length), LOG, SliPluginUtils.LogLevel.DEBUG); - } - catch( Exception e ) { - // Have error message print parameters - throw new SvcLogicException( "An error occurred during SliStringUtils.split() where original_string = " + quotedOrNULL(regex) + - " regex = " + quotedOrNULL(regex) + - " limit = " + quotedOrNULL(regex) + - " ctx_memory_result_key = " + quotedOrNULL(regex), e ); - } - } - - private static String quotedOrNULL( String str ) { - return (str == null) ? "NULL" : '"' + str + '"'; - } - - /** - * exposes equalsIgnoreCase to directed graph - * @param parameters HashMap of parameters passed by the DG to this function - * emits a true or false outcome - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static String equalsIgnoreCase(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); - if(parameters.get("source").equalsIgnoreCase(parameters.get("target"))){ - return "true"; - } - return "false"; - } - - /** - * exposes toUpperCase to directed graph - * writes an upperCase version of source to outputPath - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static void toUpper(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").toUpperCase()); - } - - /** - * exposes toLowerCase to directed graph - * writes a lowerCase version of source to outputPath - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static void toLower(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").toLowerCase()); - } - - /** - * exposes contains to directed graph to test if one string contains another - * tests if the source contains the target - * @param parameters HashMap of parameters passed by the DG to this function - * emits a true or false outcome - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static String contains(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); - if(parameters.get("source").contains(parameters.get("target"))){ - return "true"; - } - return "false"; - } - - /** - * exposes endsWith to directed graph to test if one string endsWith another string - * tests if the source ends with the target - * @param parameters HashMap of parameters passed by the DG to this function - * emits a true or false outcome - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static String endsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); - if(parameters.get("source").endsWith(parameters.get("target"))){ - return "true"; - } - return "false"; - } - - /** - * exposes startsWith to directed graph to test if one string endsWith another string - * tests if the source ends with the target - * @param parameters HashMap of parameters passed by the DG to this function - * emits a true or false outcome - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatorytarget string
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static String startsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); - if(parameters.get("source").startsWith(parameters.get("target"))){ - return "true"; - } - return "false"; - } - - /** - * exposes trim to directed graph - * writes a trimmed version of the string to the outputPath - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static void trim(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").trim()); - } - - /** - * exposes String.length() to directed graph - * writes the length of source to outputPath - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
outputPathMandatorythe location in context memory the result is written to
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static void getLength(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), String.valueOf(parameters.get("source").length())); - } - - /** - * exposes replace to directed graph - * writes the length of source to outputPath - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatoryThe sequence of char values to be replaced
replacementMandatoryThe replacement sequence of char values
outputPathMandatorythe location in context memory the result is written to
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static void replace(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath","target","replacement"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), (parameters.get("source").replace(parameters.get("target"), parameters.get("replacement")))); - } - - /** - * Provides substring functionality to Directed Graphs. - *

- * Calls either String.substring(String beginIndex) or - * String.substring(String beginInded, String endIndex) if the end-index - * is present or not. - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
stringMandatoryString to perform substring on
resultMandatoryKey in context memory to populate the resulting string in
begin-indexMandatoryBeginning index to pass to Java substring function
end-indexOptionalEnding index to pass to Java substring function. If not included, String.substring(begin) will be called.
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public void substring( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - try { - SliPluginUtils.checkParameters( parameters, new String[]{"string","begin-index","result"}, LOG ); - final String string = parameters.get("string"); - final String result = parameters.get("result"); - final String begin = parameters.get("begin-index"); - final String end = parameters.get("end-index"); - if( StringUtils.isEmpty(end) ) { - ctx.setAttribute( result, string.substring(Integer.parseInt(begin)) ); - } - else { - ctx.setAttribute( result, string.substring(Integer.parseInt(begin), Integer.parseInt(end)) ); - } - } - catch( Exception e ) { - throw new SvcLogicException( "An error occurred while the Directed Graph was performing a substring", e ); - } - } - - /** - * Provides concat functionality to Directed Graphs. - *

- * Will concat target to source and write the result to outputPath - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
targetMandatoryThe sequence of char values to be replaced
outputPathMandatorythe location in context memory the result is written to
- * @param ctx Reference to context memory - * @throws SvcLogicException - * @since 11.0.2 - */ - public static void concat( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - SliPluginUtils.checkParameters( parameters, new String[]{"source","target","outputPath"}, LOG ); - String result = parameters.get("source").concat(parameters.get("target")); - ctx.setAttribute(parameters.get("outputPath"), result); - } - - /** - * Provides url encoding functionality to Directed Graphs. - *

- * Will url encode the source and write the result to outputPath - * @param parameters HashMap of parameters passed by the DG to this function - * - * - * - * - * - * - * - *
parameterMandatory/Optionaldescription
sourceMandatorysource string
encodingOptionalthe name of a supported character encoding, defaulted to UTF-8 if not supplied
outputPathMandatorythe location in context memory the result is written to
- * @param ctx Reference to context memory - * @throws SvcLogicException - */ - public static void urlEncode(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[] { "source", "outputPath" }, LOG); - String encoding = parameters.get("encoding"); - if (encoding == null) { - encoding = "UTF-8"; - } - try { - String result = URLEncoder.encode(parameters.get("source"), encoding); - ctx.setAttribute(parameters.get("outputPath"), result); - } catch (UnsupportedEncodingException e) { - throw new SvcLogicException("Url encode failed.", e); - } - } - -} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextList.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextList.java deleted file mode 100644 index ba1c20440..000000000 --- a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextList.java +++ /dev/null @@ -1,209 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.ListIterator; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -/** - * A utility class used to manage list manipulation in the context memory. - * @see org.onap.ccsdk.sli.core.sli.SvcLogicContext - */ -public class SvcLogicContextList { - /** - * Internal flag indicating if list should be deleted from context memory - * when it is copied into the SvcLogicContextList object. - */ - private enum OperType { - COPY, EXTRACT - } - - // TODO: javadoc - protected final String prefix; - // TODO: javadoc - protected final ArrayList> list; - - - // TODO: javadoc - public SvcLogicContextList( SvcLogicContext ctx, String list_prefix ) { - this(ctx, list_prefix, OperType.COPY); - } - - // TODO: javadoc - private SvcLogicContextList( SvcLogicContext ctx, String list_prefix, OperType operation ) { - this.prefix = list_prefix; - - // Initialize list - int capacity = getCtxListLength(ctx, prefix); - this.list = new ArrayList>(capacity); - for( int i = 0; i < capacity; i++ ) { - this.list.add(i, new HashMap()); - } - - // Populate "elements" in list - String prefix_bracket = this.prefix + '['; - for (String key : new HashSet(ctx.getAttributeKeySet())) { - if( key.startsWith(prefix_bracket) ) { - // Extract the index of the list - int index = getCtxListIndex(key, this.prefix, capacity); - - // Store the - String suffix = key.substring((prefix_bracket + index + ']').length()); - suffix = suffix.isEmpty() ? suffix : suffix.substring(1); - this.list.get(index).put( suffix, ctx.getAttribute(key)); - - // If flag to extract set, remove data from context memory as - // it is read into this list - if( operation == OperType.EXTRACT ) { - ctx.setAttribute(key, null); - } - } - } - - // If flag to extract set, remove list _length value from cxt mem - if( operation == OperType.EXTRACT ) { - ctx.setAttribute(this.prefix + "_length", null); - } - } - - // TODO: javadoc - public static SvcLogicContextList extract( SvcLogicContext ctx, String list_prefix ) { - return new SvcLogicContextList(ctx, list_prefix, OperType.EXTRACT); - } - - - // ========== PUBLIC FUNCTIONS ========== - - // TODO: javadoc - public HashMap get( int index ) { - return this.list.get(index); - } - - // TODO: javadoc - public HashMap remove( int index ) { - return this.list.remove(index); - } - - // TODO: javadoc - public void remove( String value ) { - remove( "", value ); - } - - // TODO: javadoc - public void remove( String key, String value ) { - if( value == null ) { - throw new IllegalArgumentException("value cannot be null"); - } - - ListIterator> itr = this.list.listIterator(); - while( itr.hasNext() ) { - if( value.equals(itr.next().get(key)) ) { - itr.remove(); - } - } - } - - // TODO javadoc - public void remove( Map primary_key ) { - ListIterator> itr = this.list.listIterator(); - while( itr.hasNext() ) { - boolean found = true; - HashMap list_element = itr.next(); - for( Map.Entry key : primary_key.entrySet() ) { - if( !key.getValue().equals(list_element.get(key.getKey())) ) { - found = false; - break; - } - } - - if( found ) { - itr.remove(); - } - } - } - - // TODO: javadoc - public int size() { - return list.size(); - } - - // TODO: javadoc - public void writeToContext( SvcLogicContext ctx ) { - ctx.setAttribute( prefix + "_length", Integer.toString(this.list.size()) ); - - for( int i = 0; i < this.list.size(); i++ ) { - for( Map.Entry entry : this.list.get(i).entrySet() ) { - if( entry.getKey().equals("") ) { - ctx.setAttribute(prefix + '[' + i + ']', entry.getValue()); - } else { - ctx.setAttribute(prefix + '[' + i + "]." + entry.getKey(), entry.getValue()); - } - } - } - } - - - - // ========== PRIVATE STATIC FUNCTIONS ========== - - // TODO: javadoc - private static int getCtxListIndex( String key, String prefix, int list_size ) { - int index = getCtxListIndex( key, prefix ); - if( index >= list_size ) { - throw new IllegalArgumentException("Context memory list \"" + prefix + "[]\" contains an index >= the size of the list", new ArrayIndexOutOfBoundsException("index \"" + index + "\" is outside the bounds of the context memory list \"" + prefix + "[]. List Length = " + list_size)); - } else if (index < 0) { - throw new IllegalArgumentException("Context memory list \"" + prefix + "[]\" contains a negative index", new NegativeArraySizeException("index \"" + index + "\" of context memory list is negative")); - } - - return index; - } - - // TODO: javadoc - private static int getCtxListIndex( String key, String prefix ) { - String ctx_index_str = StringUtils.substringBetween(key.substring(prefix.length()), "[", "]"); - try { - return Integer.parseInt( ctx_index_str ); - } catch (NumberFormatException e) { - throw new IllegalStateException("Could not parse index value \"" + ctx_index_str + "\" in context memory key \"" + key + "\"", e); - } - } - - // TODO: javadoc - private static int getCtxListLength( SvcLogicContext ctx, String prefix ) { - String _length_key = prefix + "_length"; - String _length_val_str = ctx.getAttribute(_length_key); - try { - return Integer.parseInt(_length_val_str); - } catch (NumberFormatException e) { - if( _length_val_str == null ) { - throw new IllegalStateException( "Could not find list length \"" + _length_key + "\" in context memory." ); - } else { - throw new IllegalStateException( "Could not parse index value \"" + _length_val_str + "\" of context memory list length \"" + _length_key + "\"" , e ); - } - } - } -} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextObject.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextObject.java deleted file mode 100644 index 049bdb20e..000000000 --- a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextObject.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -public interface SvcLogicContextObject { - public void writeToContext( SvcLogicContext ctx, String root ); -} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/YesNo.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/YesNo.java deleted file mode 100644 index 059761326..000000000 --- a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/YesNo.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils.commondatastructures; - -/** - * An enum found in many Yang models. It is commonly used as a - * substitute for boolean. - */ -public enum YesNo { - N, Y; - - /** - * Method overload for {@link #valueOf(String)} for the char primative - */ - public static YesNo valueOf( final char name ) { - return YesNo.valueOf( Character.toString(name) ); - } - - /** - * Method overload for {@link #valueOf(String)} for the Character object - */ - public static YesNo valueOf( final Character name ) { - if( name == null ) { - return null; - } - - return YesNo.valueOf( name.toString() ); - } -} diff --git a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/package-info.java b/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/package-info.java deleted file mode 100644 index a7850ee51..000000000 --- a/sliPluginUtils/provider/src/main/java/org/openecomp/sdnc/sli/SliPluginUtils/commondatastructures/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils.commondatastructures; diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java new file mode 100644 index 000000000..59f6bea33 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CheckParametersTest { + + @Test + public void nullRequiredParameters() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = null; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void emptyParametersMap() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = new String[] { "param1", "param2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void paramNotFound() throws Exception { + Map parametersMap = new HashMap(); + parametersMap.put("tst", "me"); + String[] requiredParams = new String[] { "param1", "parm2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test + public void testSunnyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param2", "world"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test + public void testSunnyRequiredParametersWithPrefix() throws Exception { + String prefixValue = "my.unique.path."; + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(prefixValue + "param1", "hello"); + ctx.setAttribute(prefixValue + "param2", "world"); + ctx.setAttribute(prefixValue + "param3", "!"); + + Map parameters = new HashMap(); + parameters.put("prefix", prefixValue); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testRainyMissingRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", null); + parameters.put("param2", null); + parameters.put("param3", null); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testEmptyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + + SliPluginUtils.requiredParameters(parameters, ctx); + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java new file mode 100644 index 000000000..4aef5e391 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; + +public class Dme2Test { + + @Test + public void createInstarUrl() { + String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com"; + DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(instarUrl, constructedUrl); + } + + @Test + public void createInstarUrlNoSubContext() { + String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com"; + DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); + Map parameters = new HashMap(); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", parameters.get(null)); + assertEquals(instarUrl, constructedUrl); + } + + @Test + public void testRoundRobin() { + String[] proxyHostNames = new String[] { "http://one:25055", "http://two:25055", "http://three:25055" }; + String urlSuffix = "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com"; + DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNames, "common"); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + } + + @Test + public void createDme2EndtoEnd() { + SliPluginUtilsActivator activator = new SliPluginUtilsActivator(); + DME2 dme2 = activator.initDme2("src/test/resources/dme2.e2e.properties"); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("UAT", dme2.envContext); + assertEquals("UAT", dme2.routeOffer); + Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); + assertEquals("1702.0", dme2.commonServiceVersion); + assertEquals(null, dme2.partner); + + String constructedUrl = dme2.constructUrl("sample.com/restservices/instar/v1/assetSearch", null, "/mySubContext"); + assertNotNull(constructedUrl); + System.out.println(constructedUrl); + } + + @Test + public void createDme2Prod() { + SliPluginUtilsActivator activator = new SliPluginUtilsActivator(); + DME2 dme2 = activator.initDme2("src/test/resources/dme2.prod.properties"); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("PROD", dme2.envContext); + assertEquals("", dme2.routeOffer); + Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); + assertEquals("1.0", dme2.commonServiceVersion); + assertEquals("LPP_PROD", dme2.partner); + + String constructedUrl = dme2.constructUrl("sample.com/restservices/instar/v1/assetSearch", null, "/mySubContext"); + assertNotNull(constructedUrl); + System.out.println(constructedUrl); + } + +} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java new file mode 100644 index 000000000..3f8ad1ec4 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java @@ -0,0 +1,250 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SliPluginUtils_StaticFunctionsTest { + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_StaticFunctionsTest.class); + SliPluginUtils utils = new SliPluginUtils(); + private SvcLogicContext ctx; + private HashMap parameters; + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + parameters = new HashMap(); + } + + // TODO: javadoc + @Test + public final void testCtxGetBeginsWith() { + ctx.setAttribute("service-data.oper-status.order-status", "InProgress"); + ctx.setAttribute("service-data.service-information.service-instance-id", "my-instance"); + ctx.setAttribute("service-data.service-information.service-type", "my-service"); + + Map entries = SliPluginUtils.ctxGetBeginsWith(ctx, "service-data.service-information"); + + assertEquals("my-instance", entries.get("service-data.service-information.service-instance-id")); + assertEquals("my-service", entries.get("service-data.service-information.service-type")); + assertFalse(entries.containsKey("service-data.oper-status.order-status")); + } + + // TODO: javadoc + @Test + public final void testCtxListRemove_index() throws SvcLogicException { + LOG.trace("=== testCtxListRemove_index ==="); + ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); + ctx.setAttribute("service-data.vnf-l3_length", "3"); + + parameters.put("index", "1"); + parameters.put("list_pfx", "service-data.vnf-l3"); + + utils.ctxListRemove(parameters, ctx); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); + assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); + assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); + assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); + assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); + } + + // TODO: javadoc + @Test + public final void textCtxListRemove_keyValue() throws SvcLogicException { + LOG.trace("=== textCtxListRemove_keyValue ==="); + ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); + // 2nd entry + ctx.setAttribute("service-data.vnf-l3[3].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[3].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3_length", "4"); + + parameters.put("list_pfx", "service-data.vnf-l3"); + parameters.put("key", "vnf-host-name"); + parameters.put("value", "vnf-host-name_1"); + + utils.ctxListRemove(parameters, ctx); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); + assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); + assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); + assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); + assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); + } + + // TODO: javadoc + @Test + public final void textCtxListRemove_keyValue_nullkey() throws SvcLogicException { + LOG.trace("=== textCtxListRemove_keyValue_nullkey ==="); + ctx.setAttribute("service-data.vnf-l3[0]", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1]", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2]", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3_length", "3"); + + parameters.put("list_pfx", "service-data.vnf-l3"); + parameters.put("value", "vnf-host-name_1"); + + utils.ctxListRemove(parameters, ctx); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); + assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0]")); + assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1]")); + } + + // TODO: javadoc + @Test + public final void textCtxListRemove_keyValueList() throws SvcLogicException { + LOG.trace("=== textCtxListRemove_keyValueList ==="); + ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); + // 2nd entry + ctx.setAttribute("service-data.vnf-l3[3].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[3].device-host-name", "device-host-name_1"); + // entries with only 1 of 2 key-value pairs matching + ctx.setAttribute("service-data.vnf-l3[4].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[4].device-host-name", "device-host-name_4"); + ctx.setAttribute("service-data.vnf-l3[5].vnf-host-name", "vnf-host-name_5"); + ctx.setAttribute("service-data.vnf-l3[5].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3_length", "6"); + + parameters.put("list_pfx", "service-data.vnf-l3"); + parameters.put("keys_length", "2"); + parameters.put("keys[0].key", "vnf-host-name"); + parameters.put("keys[0].value", "vnf-host-name_1"); + parameters.put("keys[1].key", "device-host-name"); + parameters.put("keys[1].value", "device-host-name_1"); + + utils.ctxListRemove(parameters, ctx); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + assertEquals("4", ctx.getAttribute("service-data.vnf-l3_length")); + assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); + assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); + assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); + assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); + assertEquals("vnf-host-name_1", ctx.getAttribute("service-data.vnf-l3[2].vnf-host-name")); + assertEquals("device-host-name_4", ctx.getAttribute("service-data.vnf-l3[2].device-host-name")); + assertEquals("vnf-host-name_5", ctx.getAttribute("service-data.vnf-l3[3].vnf-host-name")); + assertEquals("device-host-name_1", ctx.getAttribute("service-data.vnf-l3[3].device-host-name")); + } + + // TODO: javadoc + @Test(expected = SvcLogicException.class) + public final void testCtxListRemove_nullListLength() throws SvcLogicException { + LOG.trace("=== testCtxListRemove_nullListLength ==="); + ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); + ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); + ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); + ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); + + parameters.put("index", "1"); + parameters.put("list_pfx", "service-data.vnf-l3"); + + utils.ctxListRemove(parameters, ctx); + } + + // TODO: javadoc + @Test + public final void testCtxPutAll() { + HashMap entries = new HashMap(); + entries.put("service-data.oper-status.order-status", "InProgress"); + entries.put("service-data.service-information.service-instance-id", "my-instance"); + entries.put("service-data.request-information.order-number", 1234); + entries.put("service-data.request-information.request-id", null); + + SliPluginUtils.ctxPutAll(ctx, entries); + + assertEquals("InProgress", ctx.getAttribute("service-data.oper-status.order-status")); + assertEquals("my-instance", ctx.getAttribute("service-data.service-information.service-instance-id")); + assertEquals("1234", ctx.getAttribute("service-data.request-information.order-number")); + assertFalse(ctx.getAttributeKeySet().contains("service-data.request-information.request-id")); + } + + // TODO: javadoc + @Test + public final void testCtxSetAttribute_LOG() { + LOG.debug("=== testCtxSetAttribute_LOG ==="); + Integer i = new Integer(3); + SliPluginUtils.ctxSetAttribute(ctx, "test", i, LOG, SliPluginUtils.LogLevel.TRACE); + } + + /*@Test + public void printContext() throws SvcLogicException, IOException { + String filePath = "/src/test/resources/printContext.txt"; + parameters.put("filename", filePath); + File f = new File(filePath); + assert (f.exists()); + assert (!f.isDirectory()); + ctx.setAttribute("hello", "world"); + ctx.setAttribute("name", "value"); + + SliPluginUtils.printContext(parameters, ctx); + BufferedReader br = new BufferedReader(new FileReader(f)); + String line = br.readLine(); + assertEquals("#######################################", line); + line = br.readLine(); + assertEquals("hello = world", line); + line = br.readLine(); + assertEquals("name = value", line); + br.close(); + Files.delete(Paths.get(filePath)); + }*/ + + @Test + public void setTime() throws SvcLogicException { + String outputPath = "output"; + parameters.put("outputPath", outputPath); + SliPluginUtils.setTime(parameters, ctx); + assertNotNull(ctx.getAttribute(outputPath)); + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java new file mode 100644 index 000000000..1188e8b65 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Random; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings("unused") +public class SliPluginUtils_ctxSortList { + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class); + SliPluginUtils utils = new SliPluginUtils(); + SvcLogicContext ctx; + HashMap parameters; + Random rand = new Random(); + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + this.parameters = new HashMap(); + } + + @Test + public final void list_of_containers() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("sort-fields", "sort-key"); + this.parameters.put("delimiter",","); + + ctx.setAttribute("input.list_length", "10"); + for( int i = 0; i < 10; i++ ) { + this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString( rand.nextInt(10) )); + this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString( rand.nextInt(10) )); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for( int i = 0; i < 9; i++ ) { + assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i+1) + "].sort-key")) < 1 ); + } + } + + @Test public final void list_of_elements() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("delimiter",","); + + this.ctx.setAttribute("input.list_length", "10"); + for( int i = 0; i < 10; i++ ) { + this.ctx.setAttribute("input.list[" + i + ']', Integer.toString( rand.nextInt(10) )); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for( int i = 0; i < 9; i++ ) { + assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i+1) + ']')) < 1 ); + } + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java new file mode 100644 index 000000000..6b7fe6b19 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Random; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings("unused") +public class SliPluginUtils_ctxSortListTest { + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortListTest.class); + SliPluginUtils utils = new SliPluginUtils(); + SvcLogicContext ctx; + HashMap parameters; + Random rand = new Random(); + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + this.parameters = new HashMap(); + } + + @Test + public final void list_of_containers() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("sort-fields", "sort-key"); + this.parameters.put("delimiter", ","); + + ctx.setAttribute("input.list_length", "10"); + for (int i = 0; i < 10; i++) { + this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString(rand.nextInt(10))); + this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString(rand.nextInt(10))); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for (int i = 0; i < 9; i++) { + assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i + 1) + "].sort-key")) < 1); + } + } + + @Test + public final void list_of_elements() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("delimiter", ","); + + this.ctx.setAttribute("input.list_length", "10"); + for (int i = 0; i < 10; i++) { + this.ctx.setAttribute("input.list[" + i + ']', Integer.toString(rand.nextInt(10))); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for (int i = 0; i < 9; i++) { + assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i + 1) + ']')) < 1); + } + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java new file mode 100644 index 000000000..b62738497 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -0,0 +1,244 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils; + +/** + * @author km991u + * + */ +public class SliStringUtilsTest { + private SvcLogicContext ctx; + private HashMap param; + private SliStringUtils stringUtils = new SliStringUtils(); + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + param = new HashMap(); + } + + /** + * @throws SvcLogicException + * @see SliStringUtils#split(Map, SvcLogicContext) + */ + @Test + public final void testSplit() throws SvcLogicException { + param.put("original_string", "one ## two ## three"); + param.put("regex", " ## "); + param.put("ctx_memory_result_key", "result"); + + stringUtils.split(param, ctx); + + assertThat(ctx.getAttribute("result[0]"), equalTo("one")); + assertThat(ctx.getAttribute("result[1]"), equalTo("two")); + assertThat(ctx.getAttribute("result[2]"), equalTo("three")); + assertThat(ctx.getAttribute("result_length"), equalTo("3")); + } + + /** + * @throws SvcLogicException + * @see SliStringUtils#split(Map, SvcLogicContext) + */ + @Test + public final void testSplit_limit() throws SvcLogicException { + param.put("original_string", "one ## two ## three"); + param.put("regex", " ## "); + param.put("limit", "2"); + param.put("ctx_memory_result_key", "result"); + + stringUtils.split(param, ctx); + + assertThat(ctx.getAttribute("result[0]"), equalTo("one")); + assertThat(ctx.getAttribute("result[1]"), equalTo("two ## three")); + assertThat(ctx.getAttribute("result_length"), equalTo("2")); + } + + @Test + public void equalsIgnoreCaseTrue() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + String targetSTring = "HELLOWORLD"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.equalsIgnoreCase(param, ctx)); + } + + @Test + public void equalsIgnoreCaseFalse() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + String targetSTring = "goodbyeWORLD"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.equalsIgnoreCase(param, ctx)); + } + + @Test + public void toUpper() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + param.put("source", sourceString); + String path = "my.unique.path."; + param.put("outputPath", path); + SliStringUtils.toUpper(param, ctx); + assertEquals(sourceString.toUpperCase(), ctx.getAttribute(path)); + } + + @Test + public void toLower() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + param.put("source", sourceString); + String path = "my.unique.path."; + param.put("outputPath", path); + SliStringUtils.toLower(param, ctx); + assertEquals(sourceString.toLowerCase(), ctx.getAttribute(path)); + } + + @Test + public void containsTrue() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "izza"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.contains(param, ctx)); + } + + @Test + public void containsFalse() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "muffin"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.contains(param, ctx)); + } + + @Test + public void endsWithTrue() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "za"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.endsWith(param, ctx)); + } + + @Test + public void endsWithFalse() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "muffin"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.endsWith(param, ctx)); + } + + @Test + public void trim() throws SvcLogicException { + String sourceString = " H E L L O W O R L D"; + String outputPath = "muffin"; + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.trim(param, ctx); + assertEquals(sourceString.trim(), ctx.getAttribute(outputPath)); + } + + @Test + public void getLength() throws SvcLogicException { + String sourceString = "SomeRandomString"; + String outputPath = "muffin"; + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.getLength(param, ctx); + assertEquals(String.valueOf(sourceString.length()), ctx.getAttribute(outputPath)); + } + + @Test + public void startsWithFalse() throws SvcLogicException { + String sourceString = "Java"; + String targetSTring = "DG"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.startsWith(param, ctx)); + } + + @Test + public void startsWithTrue() throws SvcLogicException { + String sourceString = "Java"; + String targetSTring = "Ja"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.startsWith(param, ctx)); + } + + @Test + public void replace() throws SvcLogicException { + String sourceString = "cat Hello World cat"; + String old = "cat"; + String neww = "dog"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("target", old); + param.put("replacement", neww); + param.put("outputPath", outputPath); + SliStringUtils.replace(param, ctx); + assertEquals(sourceString.replace(old, neww), ctx.getAttribute(outputPath)); + } + + @Test + public void concat() throws SvcLogicException { + String sourceString = "cat"; + String targetString = "dog"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("target", targetString); + param.put("outputPath", outputPath); + SliStringUtils.concat(param, ctx); + assertEquals(sourceString + targetString, ctx.getAttribute(outputPath)); + } + + @Test + public void urlEncode() throws SvcLogicException { + String sourceString = "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.urlEncode(param, ctx); + assertEquals("102%2FGE100%2FSNJSCAMCJP8%2FSNJSCAMCJT4", ctx.getAttribute(outputPath)); + } + +} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java new file mode 100644 index 000000000..d3725a227 --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java @@ -0,0 +1,307 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 ONAP + * ================================================================================ + * 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.slipluginutils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.HashMap; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.slipluginutils.SvcLogicContextList; + +public class SvcLogicContextListTest { + //private static final Logger LOG = LoggerFactory.getLogger(SvcLogicContextTest.class); + private SvcLogicContext ctx; + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + } + + // TODO: javadoc + @Test + public final void testSvcLogicContextList_SingleValueList() { + ctx.setAttribute("list[0]", "0"); + ctx.setAttribute("list[1]", "1"); + ctx.setAttribute("list[2]", "2"); + ctx.setAttribute("list[3]", "3"); + ctx.setAttribute("list[4]", "4"); + ctx.setAttribute("list_length", "5"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + + // Check that size of list is 5 + assertEquals(5, list.size()); + + // Check that each HashMap has it's list value in the empty string key + // and has no other values + assertEquals(1, list.get(0).size()); + assertEquals("0", list.get(0).get("")); + assertEquals(1, list.get(1).size()); + assertEquals("1", list.get(1).get("")); + assertEquals(1, list.get(2).size()); + assertEquals("2", list.get(2).get("")); + assertEquals(1, list.get(3).size()); + assertEquals("3", list.get(3).get("")); + assertEquals(1, list.get(4).size()); + assertEquals("4", list.get(4).get("")); + } + + // TODO: javadoc + @Test + public final void testSvcLogicContextList_ObjectList() { + ctx.setAttribute("list[0].ipv4", "1.1.1.0"); + ctx.setAttribute("list[0].ipv6", "2001::0"); + ctx.setAttribute("list[1].ipv4", "1.1.1.1"); + ctx.setAttribute("list[1].ipv6", "2001::1"); + ctx.setAttribute("list[2].ipv4", "1.1.1.2"); + ctx.setAttribute("list[2].ipv6", "2001::2"); + ctx.setAttribute("list[3].ipv4", "1.1.1.3"); + ctx.setAttribute("list[3].ipv6", "2001::3"); + ctx.setAttribute("list[4].ipv4", "1.1.1.4"); + ctx.setAttribute("list[4].ipv6", "2001::4"); + ctx.setAttribute("list_length", "5"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + + // Check that size of list is 5 + assertEquals(5, list.size()); + + assertEquals(2, list.get(0).size()); + assertEquals("1.1.1.0", list.get(0).get("ipv4")); + assertEquals("2001::0", list.get(0).get("ipv6")); + assertEquals(2, list.get(1).size()); + assertEquals("1.1.1.1", list.get(1).get("ipv4")); + assertEquals("2001::1", list.get(1).get("ipv6")); + assertEquals(2, list.get(2).size()); + assertEquals("1.1.1.2", list.get(2).get("ipv4")); + assertEquals("2001::2", list.get(2).get("ipv6")); + assertEquals(2, list.get(3).size()); + assertEquals("1.1.1.3", list.get(3).get("ipv4")); + assertEquals("2001::3", list.get(3).get("ipv6")); + assertEquals(2, list.get(4).size()); + assertEquals("1.1.1.4", list.get(4).get("ipv4")); + assertEquals("2001::4", list.get(4).get("ipv6")); + } + + // TODO: javadoc + @Test + public final void testExtract() { + ctx.setAttribute("list[0]", "0"); + ctx.setAttribute("list[1]", "1"); + ctx.setAttribute("list[2]", "2"); + ctx.setAttribute("list[3]", "3"); + ctx.setAttribute("list[4]", "4"); + ctx.setAttribute("list_length", "5"); + ctx.setAttribute("Other", "other"); + + SvcLogicContextList list = SvcLogicContextList.extract(ctx, "list"); + + // Check that size of list is 5 + assertEquals(5, list.size()); + + // Check that all list values exist in list object + assertEquals(1, list.get(0).size()); + assertEquals("0", list.get(0).get("")); + assertEquals(1, list.get(1).size()); + assertEquals("1", list.get(1).get("")); + assertEquals(1, list.get(2).size()); + assertEquals("2", list.get(2).get("")); + assertEquals(1, list.get(3).size()); + assertEquals("3", list.get(3).get("")); + assertEquals(1, list.get(4).size()); + assertEquals("4", list.get(4).get("")); + + // Check that all list values no longer exist in ctx + assertNull(ctx.getAttribute("list[0]")); + assertNull(ctx.getAttribute("list[1]")); + assertNull(ctx.getAttribute("list[2]")); + assertNull(ctx.getAttribute("list[3]")); + assertNull(ctx.getAttribute("list[4]")); + assertNull(ctx.getAttribute("list_length")); + + // Check that non-list values still exist in ctx + assertEquals("other", ctx.getAttribute("Other")); + } + + // TODO: javadoc + @Test + public final void testRemove_int() { + ctx.setAttribute("list[0]", "0"); + ctx.setAttribute("list[1]", "1"); + ctx.setAttribute("list[2]", "2"); + ctx.setAttribute("list[3]", "3"); + ctx.setAttribute("list[4]", "4"); + ctx.setAttribute("list_length", "5"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + list.remove(2); + + // Check that size of list is 4 (1 less than original) + assertEquals(4, list.size()); + + // Check that value was remove from list + assertEquals(1, list.get(0).size()); + assertEquals("0", list.get(0).get("")); + assertEquals(1, list.get(1).size()); + assertEquals("1", list.get(1).get("")); + assertEquals(1, list.get(2).size()); + assertEquals("3", list.get(2).get("")); + assertEquals(1, list.get(3).size()); + assertEquals("4", list.get(3).get("")); + } + + // TODO: javadoc + @Test + public final void testRemove_StringString() { + ctx.setAttribute("list[0].ipv4", "1.1.1.0"); + ctx.setAttribute("list[0].ipv6", "2001::0"); + ctx.setAttribute("list[1].ipv4", "1.1.1.1"); + ctx.setAttribute("list[1].ipv6", "2001::1"); + ctx.setAttribute("list[2].ipv4", "1.1.1.2"); + ctx.setAttribute("list[2].ipv6", "2001::2"); + ctx.setAttribute("list[3].ipv4", "1.1.1.3"); + ctx.setAttribute("list[3].ipv6", "2001::3"); + ctx.setAttribute("list[4].ipv4", "1.1.1.4"); + ctx.setAttribute("list[4].ipv6", "2001::4"); + ctx.setAttribute("list[5].ipv4", "1.1.1.2"); + ctx.setAttribute("list[5].ipv6", "2001::2"); + ctx.setAttribute("list_length", "6"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + list.remove("ipv4", "1.1.1.2"); + + // Check that size of list is 4 (2 less than original) + assertEquals(4, list.size()); + + // Check that all elements with values ending in 2 were removed + assertEquals("1.1.1.0", list.get(0).get("ipv4")); + assertEquals("2001::0", list.get(0).get("ipv6")); + assertEquals("1.1.1.1", list.get(1).get("ipv4")); + assertEquals("2001::1", list.get(1).get("ipv6")); + assertEquals("1.1.1.3", list.get(2).get("ipv4")); + assertEquals("2001::3", list.get(2).get("ipv6")); + assertEquals("1.1.1.4", list.get(3).get("ipv4")); + assertEquals("2001::4", list.get(3).get("ipv6")); + } + + // TODO: javadoc + @Test + public final void testRemove_StringString_ValueList() { + ctx.setAttribute("list[0]", "5"); + ctx.setAttribute("list[1]", "6"); + ctx.setAttribute("list[2]", "7"); + ctx.setAttribute("list[3]", "8"); + ctx.setAttribute("list[4]", "9"); + ctx.setAttribute("list_length", "5"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + list.remove("", "6"); + + // Check that size of list is 4 (1 less than original) + assertEquals(4, list.size()); + + // Check that value was remove from list + assertEquals(1, list.get(0).size()); + assertEquals("5", list.get(0).get("")); + assertEquals(1, list.get(1).size()); + assertEquals("7", list.get(1).get("")); + assertEquals(1, list.get(2).size()); + assertEquals("8", list.get(2).get("")); + assertEquals(1, list.get(3).size()); + assertEquals("9", list.get(3).get("")); + } + + // TODO: javadoc + @Test + public final void testRemove_Map() { + ctx.setAttribute("list[0].ipv4", "1.1.1.0"); + ctx.setAttribute("list[0].ipv6", "2001::0"); + ctx.setAttribute("list[1].ipv4", "1.1.1.1"); + ctx.setAttribute("list[1].ipv6", "2001::1"); + ctx.setAttribute("list[2].ipv4", "1.1.1.2"); + ctx.setAttribute("list[2].ipv6", "2001::2"); + ctx.setAttribute("list[3].ipv4", "1.1.1.3"); + ctx.setAttribute("list[3].ipv6", "2001::3"); + ctx.setAttribute("list[4].ipv4", "1.1.1.4"); + ctx.setAttribute("list[4].ipv6", "2001::4"); + ctx.setAttribute("list[5].ipv4", "1.1.1.2"); + ctx.setAttribute("list[5].ipv6", "2001::2"); + ctx.setAttribute("list_length", "6"); + + HashMap remove_key = new HashMap(); + remove_key.put("ipv4", "1.1.1.2"); + remove_key.put("ipv6", "2001::2"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + list.remove(remove_key); + + // Check that size of list is 4 (2 less than original) + assertEquals(4, list.size()); + + // Check that all elements with values ending in 2 were removed + assertEquals("1.1.1.0", list.get(0).get("ipv4")); + assertEquals("2001::0", list.get(0).get("ipv6")); + assertEquals("1.1.1.1", list.get(1).get("ipv4")); + assertEquals("2001::1", list.get(1).get("ipv6")); + assertEquals("1.1.1.3", list.get(2).get("ipv4")); + assertEquals("2001::3", list.get(2).get("ipv6")); + assertEquals("1.1.1.4", list.get(3).get("ipv4")); + assertEquals("2001::4", list.get(3).get("ipv6")); + } + + // TODO: javadoc + @Test + public final void testWriteToContext() { + ctx.setAttribute("list[0]", "0"); + ctx.setAttribute("list[1]", "1"); + ctx.setAttribute("list[2]", "2"); + ctx.setAttribute("list[3]", "3"); + ctx.setAttribute("list[4]", "4"); + ctx.setAttribute("list_length", "5"); + ctx.setAttribute("Other", "other"); + + SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); + + // Erase context memory + ctx = new SvcLogicContext(); + + // Write list back into context memory + list.writeToContext(ctx); + + // Check that size of list is 5 + assertEquals(5, list.size()); + + // Check that all list values exist in list object + assertEquals("0", ctx.getAttribute("list[0]")); + assertEquals("1", ctx.getAttribute("list[1]")); + assertEquals("2", ctx.getAttribute("list[2]")); + assertEquals("3", ctx.getAttribute("list[3]")); + assertEquals("4", ctx.getAttribute("list[4]")); + assertEquals("5", ctx.getAttribute("list_length")); + + // Check that old list values aren't in new list + assertNull(ctx.getAttribute("Other")); + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/CheckParametersTest.java deleted file mode 100644 index 796b29f27..000000000 --- a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/CheckParametersTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CheckParametersTest { - - @Test - public void nullRequiredParameters() throws Exception { - Map parametersMap = new HashMap(); - String[] requiredParams = null; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test(expected = SvcLogicException.class) - public void emptyParametersMap() throws Exception { - Map parametersMap = new HashMap(); - String[] requiredParams = new String[] { "param1", "param2", "param3" }; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test(expected = SvcLogicException.class) - public void paramNotFound() throws Exception { - Map parametersMap = new HashMap(); - parametersMap.put("tst", "me"); - String[] requiredParams = new String[] { "param1", "parm2", "param3" }; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test - public void testSunnyRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param2", "world"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - parameters.put("param1", "dog"); - parameters.put("param2", "cat"); - parameters.put("param3", "fish"); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test - public void testSunnyRequiredParametersWithPrefix() throws Exception { - String prefixValue = "my.unique.path."; - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute(prefixValue + "param1", "hello"); - ctx.setAttribute(prefixValue + "param2", "world"); - ctx.setAttribute(prefixValue + "param3", "!"); - - Map parameters = new HashMap(); - parameters.put("prefix", prefixValue); - parameters.put("param1", "dog"); - parameters.put("param2", "cat"); - parameters.put("param3", "fish"); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testRainyMissingRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - parameters.put("param1", null); - parameters.put("param2", null); - parameters.put("param3", null); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testEmptyRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - - SliPluginUtils.requiredParameters(parameters, ctx); - } -} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/Dme2Test.java deleted file mode 100644 index cb22fbc5c..000000000 --- a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/Dme2Test.java +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; -import org.openecomp.sdnc.sli.SliPluginUtils.DME2; -import org.openecomp.sdnc.sli.SliPluginUtils.SliPluginUtilsActivator; - -public class Dme2Test { - - @Test - public void createInstarUrl() { - String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com"; - DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(instarUrl, constructedUrl); - } - - @Test - public void createInstarUrlNoSubContext() { - String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com"; - DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); - Map parameters = new HashMap(); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", parameters.get(null)); - assertEquals(instarUrl, constructedUrl); - } - - @Test - public void testRoundRobin() { - String[] proxyHostNames = new String[] { "http://one:25055", "http://two:25055", "http://three:25055" }; - String urlSuffix = "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com"; - DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNames, "common"); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - } - - @Test - public void createDme2EndtoEnd() { - SliPluginUtilsActivator activator = new SliPluginUtilsActivator(); - DME2 dme2 = activator.initDme2("src/test/resources/dme2.e2e.properties"); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("UAT", dme2.envContext); - assertEquals("UAT", dme2.routeOffer); - Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); - assertEquals("1702.0", dme2.commonServiceVersion); - assertEquals(null, dme2.partner); - - String constructedUrl = dme2.constructUrl("sample.com/restservices/instar/v1/assetSearch", null, "/mySubContext"); - assertNotNull(constructedUrl); - System.out.println(constructedUrl); - } - - @Test - public void createDme2Prod() { - SliPluginUtilsActivator activator = new SliPluginUtilsActivator(); - DME2 dme2 = activator.initDme2("src/test/resources/dme2.prod.properties"); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("PROD", dme2.envContext); - assertEquals("", dme2.routeOffer); - Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); - assertEquals("1.0", dme2.commonServiceVersion); - assertEquals("LPP_PROD", dme2.partner); - - String constructedUrl = dme2.constructUrl("sample.com/restservices/instar/v1/assetSearch", null, "/mySubContext"); - assertNotNull(constructedUrl); - System.out.println(constructedUrl); - } - -} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_StaticFunctionsTest.java deleted file mode 100644 index c1e4bface..000000000 --- a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_StaticFunctionsTest.java +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SliPluginUtils_StaticFunctionsTest { - private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_StaticFunctionsTest.class); - SliPluginUtils utils = new SliPluginUtils(); - private SvcLogicContext ctx; - private HashMap parameters; - - @Before - public void setUp() throws Exception { - this.ctx = new SvcLogicContext(); - parameters = new HashMap(); - } - - // TODO: javadoc - @Test - public final void testCtxGetBeginsWith() { - ctx.setAttribute("service-data.oper-status.order-status", "InProgress"); - ctx.setAttribute("service-data.service-information.service-instance-id", "my-instance"); - ctx.setAttribute("service-data.service-information.service-type", "my-service"); - - Map entries = SliPluginUtils.ctxGetBeginsWith(ctx, "service-data.service-information"); - - assertEquals("my-instance", entries.get("service-data.service-information.service-instance-id")); - assertEquals("my-service", entries.get("service-data.service-information.service-type")); - assertFalse(entries.containsKey("service-data.oper-status.order-status")); - } - - // TODO: javadoc - @Test - public final void testCtxListRemove_index() throws SvcLogicException { - LOG.trace("=== testCtxListRemove_index ==="); - ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); - ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); - ctx.setAttribute("service-data.vnf-l3_length", "3"); - - parameters.put("index", "1"); - parameters.put("list_pfx", "service-data.vnf-l3"); - - utils.ctxListRemove(parameters, ctx); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); - assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); - assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); - assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); - assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); - } - - // TODO: javadoc - @Test - public final void textCtxListRemove_keyValue() throws SvcLogicException { - LOG.trace("=== textCtxListRemove_keyValue ==="); - ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); - ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); - // 2nd entry - ctx.setAttribute("service-data.vnf-l3[3].vnf-host-name", "vnf-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[3].device-host-name", "device-host-name_1"); - ctx.setAttribute("service-data.vnf-l3_length", "4"); - - parameters.put("list_pfx", "service-data.vnf-l3"); - parameters.put("key", "vnf-host-name"); - parameters.put("value", "vnf-host-name_1"); - - utils.ctxListRemove(parameters, ctx); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); - assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); - assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); - assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); - assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); - } - - // TODO: javadoc - @Test - public final void textCtxListRemove_keyValue_nullkey() throws SvcLogicException { - LOG.trace("=== textCtxListRemove_keyValue_nullkey ==="); - ctx.setAttribute("service-data.vnf-l3[0]", "vnf-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[1]", "vnf-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[2]", "vnf-host-name_2"); - ctx.setAttribute("service-data.vnf-l3_length", "3"); - - parameters.put("list_pfx", "service-data.vnf-l3"); - parameters.put("value", "vnf-host-name_1"); - - utils.ctxListRemove(parameters, ctx); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - assertEquals("2", ctx.getAttribute("service-data.vnf-l3_length")); - assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0]")); - assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1]")); - } - - // TODO: javadoc - @Test - public final void textCtxListRemove_keyValueList() throws SvcLogicException { - LOG.trace("=== textCtxListRemove_keyValueList ==="); - ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); - ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); - // 2nd entry - ctx.setAttribute("service-data.vnf-l3[3].vnf-host-name", "vnf-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[3].device-host-name", "device-host-name_1"); - // entries with only 1 of 2 key-value pairs matching - ctx.setAttribute("service-data.vnf-l3[4].vnf-host-name", "vnf-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[4].device-host-name", "device-host-name_4"); - ctx.setAttribute("service-data.vnf-l3[5].vnf-host-name", "vnf-host-name_5"); - ctx.setAttribute("service-data.vnf-l3[5].device-host-name", "device-host-name_1"); - ctx.setAttribute("service-data.vnf-l3_length", "6"); - - parameters.put("list_pfx", "service-data.vnf-l3"); - parameters.put("keys_length", "2"); - parameters.put("keys[0].key", "vnf-host-name"); - parameters.put("keys[0].value", "vnf-host-name_1"); - parameters.put("keys[1].key", "device-host-name"); - parameters.put("keys[1].value", "device-host-name_1"); - - utils.ctxListRemove(parameters, ctx); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - assertEquals("4", ctx.getAttribute("service-data.vnf-l3_length")); - assertEquals("vnf-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].vnf-host-name")); - assertEquals("device-host-name_0", ctx.getAttribute("service-data.vnf-l3[0].device-host-name")); - assertEquals("vnf-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].vnf-host-name")); - assertEquals("device-host-name_2", ctx.getAttribute("service-data.vnf-l3[1].device-host-name")); - assertEquals("vnf-host-name_1", ctx.getAttribute("service-data.vnf-l3[2].vnf-host-name")); - assertEquals("device-host-name_4", ctx.getAttribute("service-data.vnf-l3[2].device-host-name")); - assertEquals("vnf-host-name_5", ctx.getAttribute("service-data.vnf-l3[3].vnf-host-name")); - assertEquals("device-host-name_1", ctx.getAttribute("service-data.vnf-l3[3].device-host-name")); - } - - // TODO: javadoc - @Test(expected = SvcLogicException.class) - public final void testCtxListRemove_nullListLength() throws SvcLogicException { - LOG.trace("=== testCtxListRemove_nullListLength ==="); - ctx.setAttribute("service-data.vnf-l3[0].vnf-host-name", "vnf-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[0].device-host-name", "device-host-name_0"); - ctx.setAttribute("service-data.vnf-l3[1].vnf-host-name", "vnf-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[1].device-host-name", "device-host-name_1"); - ctx.setAttribute("service-data.vnf-l3[2].vnf-host-name", "vnf-host-name_2"); - ctx.setAttribute("service-data.vnf-l3[2].device-host-name", "device-host-name_2"); - - parameters.put("index", "1"); - parameters.put("list_pfx", "service-data.vnf-l3"); - - utils.ctxListRemove(parameters, ctx); - } - - // TODO: javadoc - @Test - public final void testCtxPutAll() { - HashMap entries = new HashMap(); - entries.put("service-data.oper-status.order-status", "InProgress"); - entries.put("service-data.service-information.service-instance-id", "my-instance"); - entries.put("service-data.request-information.order-number", 1234); - entries.put("service-data.request-information.request-id", null); - - SliPluginUtils.ctxPutAll(ctx, entries); - - assertEquals("InProgress", ctx.getAttribute("service-data.oper-status.order-status")); - assertEquals("my-instance", ctx.getAttribute("service-data.service-information.service-instance-id")); - assertEquals("1234", ctx.getAttribute("service-data.request-information.order-number")); - assertFalse(ctx.getAttributeKeySet().contains("service-data.request-information.request-id")); - } - - // TODO: javadoc - @Test - public final void testCtxSetAttribute_LOG() { - LOG.debug("=== testCtxSetAttribute_LOG ==="); - Integer i = new Integer(3); - SliPluginUtils.ctxSetAttribute(ctx, "test", i, LOG, SliPluginUtils.LogLevel.TRACE); - } - - /*@Test - public void printContext() throws SvcLogicException, IOException { - String filePath = "/src/test/resources/printContext.txt"; - parameters.put("filename", filePath); - File f = new File(filePath); - assert (f.exists()); - assert (!f.isDirectory()); - ctx.setAttribute("hello", "world"); - ctx.setAttribute("name", "value"); - - SliPluginUtils.printContext(parameters, ctx); - BufferedReader br = new BufferedReader(new FileReader(f)); - String line = br.readLine(); - assertEquals("#######################################", line); - line = br.readLine(); - assertEquals("hello = world", line); - line = br.readLine(); - assertEquals("name = value", line); - br.close(); - Files.delete(Paths.get(filePath)); - }*/ - - @Test - public void setTime() throws SvcLogicException { - String outputPath = "output"; - parameters.put("outputPath", outputPath); - SliPluginUtils.setTime(parameters, ctx); - assertNotNull(ctx.getAttribute(outputPath)); - } -} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortList.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortList.java deleted file mode 100644 index 6569bd3fb..000000000 --- a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortList.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Random; - -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings("unused") -public class SliPluginUtils_ctxSortList { - private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class); - SliPluginUtils utils = new SliPluginUtils(); - SvcLogicContext ctx; - HashMap parameters; - Random rand = new Random(); - - @Before - public void setUp() throws Exception { - this.ctx = new SvcLogicContext(); - this.parameters = new HashMap(); - } - - @Test - public final void list_of_containers() throws SvcLogicException { - this.parameters.put("list", "input.list"); - this.parameters.put("sort-fields", "sort-key"); - this.parameters.put("delimiter",","); - - ctx.setAttribute("input.list_length", "10"); - for( int i = 0; i < 10; i++ ) { - this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString( rand.nextInt(10) )); - this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString( rand.nextInt(10) )); - } - - LOG.trace("BEFORE SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - utils.ctxSortList(this.parameters, this.ctx); - - LOG.trace("AFTER SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - for( int i = 0; i < 9; i++ ) { - assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i+1) + "].sort-key")) < 1 ); - } - } - - @Test public final void list_of_elements() throws SvcLogicException { - this.parameters.put("list", "input.list"); - this.parameters.put("delimiter",","); - - this.ctx.setAttribute("input.list_length", "10"); - for( int i = 0; i < 10; i++ ) { - this.ctx.setAttribute("input.list[" + i + ']', Integer.toString( rand.nextInt(10) )); - } - - LOG.trace("BEFORE SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - utils.ctxSortList(this.parameters, this.ctx); - - LOG.trace("AFTER SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - for( int i = 0; i < 9; i++ ) { - assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i+1) + ']')) < 1 ); - } - } -} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortListTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortListTest.java deleted file mode 100644 index b527f1fde..000000000 --- a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliPluginUtils_ctxSortListTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Random; - -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings("unused") -public class SliPluginUtils_ctxSortListTest { - private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortListTest.class); - SliPluginUtils utils = new SliPluginUtils(); - SvcLogicContext ctx; - HashMap parameters; - Random rand = new Random(); - - @Before - public void setUp() throws Exception { - this.ctx = new SvcLogicContext(); - this.parameters = new HashMap(); - } - - @Test - public final void list_of_containers() throws SvcLogicException { - this.parameters.put("list", "input.list"); - this.parameters.put("sort-fields", "sort-key"); - this.parameters.put("delimiter", ","); - - ctx.setAttribute("input.list_length", "10"); - for (int i = 0; i < 10; i++) { - this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString(rand.nextInt(10))); - this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString(rand.nextInt(10))); - } - - LOG.trace("BEFORE SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - utils.ctxSortList(this.parameters, this.ctx); - - LOG.trace("AFTER SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - for (int i = 0; i < 9; i++) { - assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i + 1) + "].sort-key")) < 1); - } - } - - @Test - public final void list_of_elements() throws SvcLogicException { - this.parameters.put("list", "input.list"); - this.parameters.put("delimiter", ","); - - this.ctx.setAttribute("input.list_length", "10"); - for (int i = 0; i < 10; i++) { - this.ctx.setAttribute("input.list[" + i + ']', Integer.toString(rand.nextInt(10))); - } - - LOG.trace("BEFORE SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - utils.ctxSortList(this.parameters, this.ctx); - - LOG.trace("AFTER SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - for (int i = 0; i < 9; i++) { - assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i + 1) + ']')) < 1); - } - } -} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtilsTest.java deleted file mode 100644 index cf819599f..000000000 --- a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SliStringUtilsTest.java +++ /dev/null @@ -1,243 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -/** - * @author km991u - * - */ -public class SliStringUtilsTest { - private SvcLogicContext ctx; - private HashMap param; - private SliStringUtils stringUtils = new SliStringUtils(); - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - this.ctx = new SvcLogicContext(); - param = new HashMap(); - } - - /** - * @throws SvcLogicException - * @see SliStringUtils#split(Map, SvcLogicContext) - */ - @Test - public final void testSplit() throws SvcLogicException { - param.put("original_string", "one ## two ## three"); - param.put("regex", " ## "); - param.put("ctx_memory_result_key", "result"); - - stringUtils.split(param, ctx); - - assertThat(ctx.getAttribute("result[0]"), equalTo("one")); - assertThat(ctx.getAttribute("result[1]"), equalTo("two")); - assertThat(ctx.getAttribute("result[2]"), equalTo("three")); - assertThat(ctx.getAttribute("result_length"), equalTo("3")); - } - - /** - * @throws SvcLogicException - * @see SliStringUtils#split(Map, SvcLogicContext) - */ - @Test - public final void testSplit_limit() throws SvcLogicException { - param.put("original_string", "one ## two ## three"); - param.put("regex", " ## "); - param.put("limit", "2"); - param.put("ctx_memory_result_key", "result"); - - stringUtils.split(param, ctx); - - assertThat(ctx.getAttribute("result[0]"), equalTo("one")); - assertThat(ctx.getAttribute("result[1]"), equalTo("two ## three")); - assertThat(ctx.getAttribute("result_length"), equalTo("2")); - } - - @Test - public void equalsIgnoreCaseTrue() throws SvcLogicException { - String sourceString = "HeLlOwORLD"; - String targetSTring = "HELLOWORLD"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("true", SliStringUtils.equalsIgnoreCase(param, ctx)); - } - - @Test - public void equalsIgnoreCaseFalse() throws SvcLogicException { - String sourceString = "HeLlOwORLD"; - String targetSTring = "goodbyeWORLD"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("false", SliStringUtils.equalsIgnoreCase(param, ctx)); - } - - @Test - public void toUpper() throws SvcLogicException { - String sourceString = "HeLlOwORLD"; - param.put("source", sourceString); - String path = "my.unique.path."; - param.put("outputPath", path); - SliStringUtils.toUpper(param, ctx); - assertEquals(sourceString.toUpperCase(), ctx.getAttribute(path)); - } - - @Test - public void toLower() throws SvcLogicException { - String sourceString = "HeLlOwORLD"; - param.put("source", sourceString); - String path = "my.unique.path."; - param.put("outputPath", path); - SliStringUtils.toLower(param, ctx); - assertEquals(sourceString.toLowerCase(), ctx.getAttribute(path)); - } - - @Test - public void containsTrue() throws SvcLogicException { - String sourceString = "Pizza"; - String targetSTring = "izza"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("true", SliStringUtils.contains(param, ctx)); - } - - @Test - public void containsFalse() throws SvcLogicException { - String sourceString = "Pizza"; - String targetSTring = "muffin"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("false", SliStringUtils.contains(param, ctx)); - } - - @Test - public void endsWithTrue() throws SvcLogicException { - String sourceString = "Pizza"; - String targetSTring = "za"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("true", SliStringUtils.endsWith(param, ctx)); - } - - @Test - public void endsWithFalse() throws SvcLogicException { - String sourceString = "Pizza"; - String targetSTring = "muffin"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("false", SliStringUtils.endsWith(param, ctx)); - } - - @Test - public void trim() throws SvcLogicException { - String sourceString = " H E L L O W O R L D"; - String outputPath = "muffin"; - param.put("source", sourceString); - param.put("outputPath", outputPath); - SliStringUtils.trim(param, ctx); - assertEquals(sourceString.trim(), ctx.getAttribute(outputPath)); - } - - @Test - public void getLength() throws SvcLogicException { - String sourceString = "SomeRandomString"; - String outputPath = "muffin"; - param.put("source", sourceString); - param.put("outputPath", outputPath); - SliStringUtils.getLength(param, ctx); - assertEquals(String.valueOf(sourceString.length()), ctx.getAttribute(outputPath)); - } - - @Test - public void startsWithFalse() throws SvcLogicException { - String sourceString = "Java"; - String targetSTring = "DG"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("false", SliStringUtils.startsWith(param, ctx)); - } - - @Test - public void startsWithTrue() throws SvcLogicException { - String sourceString = "Java"; - String targetSTring = "Ja"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("true", SliStringUtils.startsWith(param, ctx)); - } - - @Test - public void replace() throws SvcLogicException { - String sourceString = "cat Hello World cat"; - String old = "cat"; - String neww = "dog"; - String outputPath = "out"; - - param.put("source", sourceString); - param.put("target", old); - param.put("replacement", neww); - param.put("outputPath", outputPath); - SliStringUtils.replace(param, ctx); - assertEquals(sourceString.replace(old, neww), ctx.getAttribute(outputPath)); - } - - @Test - public void concat() throws SvcLogicException { - String sourceString = "cat"; - String targetString = "dog"; - String outputPath = "out"; - - param.put("source", sourceString); - param.put("target", targetString); - param.put("outputPath", outputPath); - SliStringUtils.concat(param, ctx); - assertEquals(sourceString + targetString, ctx.getAttribute(outputPath)); - } - - @Test - public void urlEncode() throws SvcLogicException { - String sourceString = "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"; - String outputPath = "out"; - - param.put("source", sourceString); - param.put("outputPath", outputPath); - SliStringUtils.urlEncode(param, ctx); - assertEquals("102%2FGE100%2FSNJSCAMCJP8%2FSNJSCAMCJT4", ctx.getAttribute(outputPath)); - } - -} diff --git a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextListTest.java b/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextListTest.java deleted file mode 100644 index 2ef2bed2a..000000000 --- a/sliPluginUtils/provider/src/test/java/org/openecomp/sdnc/sli/SliPluginUtils/SvcLogicContextListTest.java +++ /dev/null @@ -1,306 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 ONAP - * ================================================================================ - * 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.openecomp.sdnc.sli.SliPluginUtils; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.util.HashMap; - -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -public class SvcLogicContextListTest { - //private static final Logger LOG = LoggerFactory.getLogger(SvcLogicContextTest.class); - private SvcLogicContext ctx; - - @Before - public void setUp() throws Exception { - this.ctx = new SvcLogicContext(); - } - - // TODO: javadoc - @Test - public final void testSvcLogicContextList_SingleValueList() { - ctx.setAttribute("list[0]", "0"); - ctx.setAttribute("list[1]", "1"); - ctx.setAttribute("list[2]", "2"); - ctx.setAttribute("list[3]", "3"); - ctx.setAttribute("list[4]", "4"); - ctx.setAttribute("list_length", "5"); - - SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); - - // Check that size of list is 5 - assertEquals(5, list.size()); - - // Check that each HashMap has it's list value in the empty string key - // and has no other values - assertEquals(1, list.get(0).size()); - assertEquals("0", list.get(0).get("")); - assertEquals(1, list.get(1).size()); - assertEquals("1", list.get(1).get("")); - assertEquals(1, list.get(2).size()); - assertEquals("2", list.get(2).get("")); - assertEquals(1, list.get(3).size()); - assertEquals("3", list.get(3).get("")); - assertEquals(1, list.get(4).size()); - assertEquals("4", list.get(4).get("")); - } - - // TODO: javadoc - @Test - public final void testSvcLogicContextList_ObjectList() { - ctx.setAttribute("list[0].ipv4", "1.1.1.0"); - ctx.setAttribute("list[0].ipv6", "2001::0"); - ctx.setAttribute("list[1].ipv4", "1.1.1.1"); - ctx.setAttribute("list[1].ipv6", "2001::1"); - ctx.setAttribute("list[2].ipv4", "1.1.1.2"); - ctx.setAttribute("list[2].ipv6", "2001::2"); - ctx.setAttribute("list[3].ipv4", "1.1.1.3"); - ctx.setAttribute("list[3].ipv6", "2001::3"); - ctx.setAttribute("list[4].ipv4", "1.1.1.4"); - ctx.setAttribute("list[4].ipv6", "2001::4"); - ctx.setAttribute("list_length", "5"); - - SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); - - // Check that size of list is 5 - assertEquals(5, list.size()); - - assertEquals(2, list.get(0).size()); - assertEquals("1.1.1.0", list.get(0).get("ipv4")); - assertEquals("2001::0", list.get(0).get("ipv6")); - assertEquals(2, list.get(1).size()); - assertEquals("1.1.1.1", list.get(1).get("ipv4")); - assertEquals("2001::1", list.get(1).get("ipv6")); - assertEquals(2, list.get(2).size()); - assertEquals("1.1.1.2", list.get(2).get("ipv4")); - assertEquals("2001::2", list.get(2).get("ipv6")); - assertEquals(2, list.get(3).size()); - assertEquals("1.1.1.3", list.get(3).get("ipv4")); - assertEquals("2001::3", list.get(3).get("ipv6")); - assertEquals(2, list.get(4).size()); - assertEquals("1.1.1.4", list.get(4).get("ipv4")); - assertEquals("2001::4", list.get(4).get("ipv6")); - } - - // TODO: javadoc - @Test - public final void testExtract() { - ctx.setAttribute("list[0]", "0"); - ctx.setAttribute("list[1]", "1"); - ctx.setAttribute("list[2]", "2"); - ctx.setAttribute("list[3]", "3"); - ctx.setAttribute("list[4]", "4"); - ctx.setAttribute("list_length", "5"); - ctx.setAttribute("Other", "other"); - - SvcLogicContextList list = SvcLogicContextList.extract(ctx, "list"); - - // Check that size of list is 5 - assertEquals(5, list.size()); - - // Check that all list values exist in list object - assertEquals(1, list.get(0).size()); - assertEquals("0", list.get(0).get("")); - assertEquals(1, list.get(1).size()); - assertEquals("1", list.get(1).get("")); - assertEquals(1, list.get(2).size()); - assertEquals("2", list.get(2).get("")); - assertEquals(1, list.get(3).size()); - assertEquals("3", list.get(3).get("")); - assertEquals(1, list.get(4).size()); - assertEquals("4", list.get(4).get("")); - - // Check that all list values no longer exist in ctx - assertNull(ctx.getAttribute("list[0]")); - assertNull(ctx.getAttribute("list[1]")); - assertNull(ctx.getAttribute("list[2]")); - assertNull(ctx.getAttribute("list[3]")); - assertNull(ctx.getAttribute("list[4]")); - assertNull(ctx.getAttribute("list_length")); - - // Check that non-list values still exist in ctx - assertEquals("other", ctx.getAttribute("Other")); - } - - // TODO: javadoc - @Test - public final void testRemove_int() { - ctx.setAttribute("list[0]", "0"); - ctx.setAttribute("list[1]", "1"); - ctx.setAttribute("list[2]", "2"); - ctx.setAttribute("list[3]", "3"); - ctx.setAttribute("list[4]", "4"); - ctx.setAttribute("list_length", "5"); - - SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); - list.remove(2); - - // Check that size of list is 4 (1 less than original) - assertEquals(4, list.size()); - - // Check that value was remove from list - assertEquals(1, list.get(0).size()); - assertEquals("0", list.get(0).get("")); - assertEquals(1, list.get(1).size()); - assertEquals("1", list.get(1).get("")); - assertEquals(1, list.get(2).size()); - assertEquals("3", list.get(2).get("")); - assertEquals(1, list.get(3).size()); - assertEquals("4", list.get(3).get("")); - } - - // TODO: javadoc - @Test - public final void testRemove_StringString() { - ctx.setAttribute("list[0].ipv4", "1.1.1.0"); - ctx.setAttribute("list[0].ipv6", "2001::0"); - ctx.setAttribute("list[1].ipv4", "1.1.1.1"); - ctx.setAttribute("list[1].ipv6", "2001::1"); - ctx.setAttribute("list[2].ipv4", "1.1.1.2"); - ctx.setAttribute("list[2].ipv6", "2001::2"); - ctx.setAttribute("list[3].ipv4", "1.1.1.3"); - ctx.setAttribute("list[3].ipv6", "2001::3"); - ctx.setAttribute("list[4].ipv4", "1.1.1.4"); - ctx.setAttribute("list[4].ipv6", "2001::4"); - ctx.setAttribute("list[5].ipv4", "1.1.1.2"); - ctx.setAttribute("list[5].ipv6", "2001::2"); - ctx.setAttribute("list_length", "6"); - - SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); - list.remove("ipv4", "1.1.1.2"); - - // Check that size of list is 4 (2 less than original) - assertEquals(4, list.size()); - - // Check that all elements with values ending in 2 were removed - assertEquals("1.1.1.0", list.get(0).get("ipv4")); - assertEquals("2001::0", list.get(0).get("ipv6")); - assertEquals("1.1.1.1", list.get(1).get("ipv4")); - assertEquals("2001::1", list.get(1).get("ipv6")); - assertEquals("1.1.1.3", list.get(2).get("ipv4")); - assertEquals("2001::3", list.get(2).get("ipv6")); - assertEquals("1.1.1.4", list.get(3).get("ipv4")); - assertEquals("2001::4", list.get(3).get("ipv6")); - } - - // TODO: javadoc - @Test - public final void testRemove_StringString_ValueList() { - ctx.setAttribute("list[0]", "5"); - ctx.setAttribute("list[1]", "6"); - ctx.setAttribute("list[2]", "7"); - ctx.setAttribute("list[3]", "8"); - ctx.setAttribute("list[4]", "9"); - ctx.setAttribute("list_length", "5"); - - SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); - list.remove("", "6"); - - // Check that size of list is 4 (1 less than original) - assertEquals(4, list.size()); - - // Check that value was remove from list - assertEquals(1, list.get(0).size()); - assertEquals("5", list.get(0).get("")); - assertEquals(1, list.get(1).size()); - assertEquals("7", list.get(1).get("")); - assertEquals(1, list.get(2).size()); - assertEquals("8", list.get(2).get("")); - assertEquals(1, list.get(3).size()); - assertEquals("9", list.get(3).get("")); - } - - // TODO: javadoc - @Test - public final void testRemove_Map() { - ctx.setAttribute("list[0].ipv4", "1.1.1.0"); - ctx.setAttribute("list[0].ipv6", "2001::0"); - ctx.setAttribute("list[1].ipv4", "1.1.1.1"); - ctx.setAttribute("list[1].ipv6", "2001::1"); - ctx.setAttribute("list[2].ipv4", "1.1.1.2"); - ctx.setAttribute("list[2].ipv6", "2001::2"); - ctx.setAttribute("list[3].ipv4", "1.1.1.3"); - ctx.setAttribute("list[3].ipv6", "2001::3"); - ctx.setAttribute("list[4].ipv4", "1.1.1.4"); - ctx.setAttribute("list[4].ipv6", "2001::4"); - ctx.setAttribute("list[5].ipv4", "1.1.1.2"); - ctx.setAttribute("list[5].ipv6", "2001::2"); - ctx.setAttribute("list_length", "6"); - - HashMap remove_key = new HashMap(); - remove_key.put("ipv4", "1.1.1.2"); - remove_key.put("ipv6", "2001::2"); - - SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); - list.remove(remove_key); - - // Check that size of list is 4 (2 less than original) - assertEquals(4, list.size()); - - // Check that all elements with values ending in 2 were removed - assertEquals("1.1.1.0", list.get(0).get("ipv4")); - assertEquals("2001::0", list.get(0).get("ipv6")); - assertEquals("1.1.1.1", list.get(1).get("ipv4")); - assertEquals("2001::1", list.get(1).get("ipv6")); - assertEquals("1.1.1.3", list.get(2).get("ipv4")); - assertEquals("2001::3", list.get(2).get("ipv6")); - assertEquals("1.1.1.4", list.get(3).get("ipv4")); - assertEquals("2001::4", list.get(3).get("ipv6")); - } - - // TODO: javadoc - @Test - public final void testWriteToContext() { - ctx.setAttribute("list[0]", "0"); - ctx.setAttribute("list[1]", "1"); - ctx.setAttribute("list[2]", "2"); - ctx.setAttribute("list[3]", "3"); - ctx.setAttribute("list[4]", "4"); - ctx.setAttribute("list_length", "5"); - ctx.setAttribute("Other", "other"); - - SvcLogicContextList list = new SvcLogicContextList( ctx, "list" ); - - // Erase context memory - ctx = new SvcLogicContext(); - - // Write list back into context memory - list.writeToContext(ctx); - - // Check that size of list is 5 - assertEquals(5, list.size()); - - // Check that all list values exist in list object - assertEquals("0", ctx.getAttribute("list[0]")); - assertEquals("1", ctx.getAttribute("list[1]")); - assertEquals("2", ctx.getAttribute("list[2]")); - assertEquals("3", ctx.getAttribute("list[3]")); - assertEquals("4", ctx.getAttribute("list[4]")); - assertEquals("5", ctx.getAttribute("list_length")); - - // Check that old list values aren't in new list - assertNull(ctx.getAttribute("Other")); - } -} -- cgit 1.2.3-korg From 41cdaaa91806e520905d6238cb5479b2bb219e44 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 11 Aug 2017 11:26:18 -0400 Subject: Remove openecomp documentation references Removed openecomp references from site documentation. Also, removed sample settings.xml files. Latest direction from Linux Foundation is that the settings.xml configs they provided on their Jenkins will have no parameter settings - only server credentials. So, our sample settings.xml files are only misleading and hence should be removed. Change-Id: I4f663973ac07b6d78dffb93aef478a81d2a4450c Issue-ID: CCSDK-11 Signed-off-by: Dan Timoney --- example-settings.xml | 163 ----------------------------------------------- jenkins-settings.xml | 168 ------------------------------------------------- src/site/apt/nodes.apt | 34 +++++----- 3 files changed, 17 insertions(+), 348 deletions(-) delete mode 100644 example-settings.xml delete mode 100644 jenkins-settings.xml diff --git a/example-settings.xml b/example-settings.xml deleted file mode 100644 index bfd6b9f4a..000000000 --- a/example-settings.xml +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - - openecomp-release - - - openecomp-release - openecomp-release - https://nexus.onap.org/content/repositories/releases/ - - true - never - - - false - - - - - - openecomp-release - openecomp-release - https://nexus.onap.org/content/repositories/releases/ - - true - never - - - false - - - - - - - openecomp-snapshots - - - openecomp-snapshot - openecomp-snapshot - https://nexus.onap.org/content/repositories/snapshots/ - - false - - - true - - - - - - openecomp-snapshot - openecomp-snapshot - https://nexus.onap.org/content/repositories/snapshots/ - - false - - - true - - - - - - opendaylight-release - - - opendaylight-mirror - opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - never - - - false - - - - - - opendaylight-mirror - opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - never - - - false - - - - - - - opendaylight-snapshots - - - opendaylight-snapshot - opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - opendaylight-snapshot - opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - - - openecomp-release - openecomp-snapshots - opendaylight-release - opendaylight-snapshots - - - - - nexus - USERNAME - PASSWORD - - - openecomp-release - USERNAME - PASSWORD - - - openecomp-snapshot - USERNAME - PASSWORD - - - diff --git a/jenkins-settings.xml b/jenkins-settings.xml deleted file mode 100644 index 344994f85..000000000 --- a/jenkins-settings.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - - - openecomp-release - - - openecomp-release - openecomp-release - https://ecomp-nexus:8443/repository/maven-releases/ - - true - never - - - false - - - - - - openecomp-release - openecomp-release - https://ecomp-nexus:8443/repository/maven-releases/ - - true - never - - - false - - - - - - - openecomp-snapshots - - - openecomp-snapshot - openecomp-snapshot - https://ecomp-nexus:8443/repository/maven-snapshots/ - - false - - - true - - - - - - openecomp-snapshot - openecomp-snapshot - https://ecomp-nexus:8443/repository/maven-snapshots/ - - false - - - true - - - - - - opendaylight-release - - - opendaylight-mirror - opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - never - - - false - - - - - - opendaylight-mirror - opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - never - - - false - - - - - - - opendaylight-snapshots - - - opendaylight-snapshot - opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - opendaylight-snapshot - opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - - - openecomp-release - openecomp-snapshots - opendaylight-release - opendaylight-snapshots - - - - - nexus - ${ecomp.nexus.user} - ${ecomp.nexus.password} - - - openecomp-release - ${ecomp.nexus.user} - ${ecomp.nexus.password} - - - openecomp-snapshot - ${ecomp.nexus.user} - ${ecomp.nexus.password} - - - sdnc-javadoc - ${ecomp.nexus.user} - ${ecomp.nexus.password} - - - diff --git a/src/site/apt/nodes.apt b/src/site/apt/nodes.apt index 099af248a..8ddb711d1 100644 --- a/src/site/apt/nodes.apt +++ b/src/site/apt/nodes.apt @@ -7,9 +7,9 @@ ~~ 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. @@ -103,7 +103,7 @@ Supported node types +-----------------+ - + @@ -187,7 +187,7 @@ Supported node types +-------------------+ - + @@ -287,7 +287,7 @@ Supported node types +-------------------+ - @@ -306,7 +306,7 @@ Supported node types - @@ -366,7 +366,7 @@ Supported node types *** Example +-------------------+ - @@ -381,7 +381,7 @@ Supported node types - + @@ -442,7 +442,7 @@ Supported node types *** Example +-------------------+ - @@ -502,7 +502,7 @@ Supported node types *** Example +-------------------+ - + @@ -543,7 +543,7 @@ Supported node types *** Example +-------------------+ - @@ -589,7 +589,7 @@ Supported node types *** Example +-------------------+ - @@ -644,7 +644,7 @@ Supported node types *** Example +-------------------+ - @@ -695,7 +695,7 @@ Supported node types *** Example +-------------------+ - @@ -739,7 +739,7 @@ Supported node types *** Example +-------------------+ - @@ -785,7 +785,7 @@ Supported node types *** Example +-------------------+ - @@ -836,7 +836,7 @@ Supported node types *** Example +-------------------+ - -- cgit 1.2.3-korg From 68eeb041f3bec6548e94978dce2e6795c8a399e7 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 11 Aug 2017 15:57:21 -0400 Subject: Remove remaining references to openecomp Remove remaining references to openecomp from properties and sample files Change-Id: I985bae5e80ae130ffb512c9574f13172252bf6f8 Issue-ID: CCSDK-11 Signed-off-by: Dan Timoney --- README.md | 2 +- filters/README | 8 +- filters/pom.xml | 2 +- .../org/onap/ccsdk/sli/core/filters/LogFilter.java | 6 +- .../core/filters/RequestResponseLoggingFilter.java | 6 +- pom.xml | 2 +- .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 7 +- .../onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 312 ++++++++++----------- .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 6 +- .../ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 18 +- sli/common/src/main/resources/svclogic.xsd | 2 +- .../test/resources/EvcActivateSvcLogic_v100.xml | 8 +- .../src/test/resources/EvcPortSvcLogic_v100.xml | 26 +- .../test/resources/ReleasePortSvcLogic_v101.xml | 12 +- .../src/test/resources/bad_neutron_logic_v11.xml | 4 +- sli/common/src/test/resources/mergetest.xml | 2 +- .../src/test/resources/neutron_logic_v10.xml | 4 +- .../src/test/resources/simplelogger.properties | 6 +- sli/common/src/test/resources/svclogic.properties | 14 +- sli/common/src/test/resources/svclogic.sh | 6 +- sli/common/src/test/resources/svclogic.xsd | 2 +- sli/provider/pom.xml | 8 +- .../sli/core/sli/provider/SvcLogicService.java | 24 +- .../src/test/resources/l3sdn_logic_v10.xml | 4 +- .../src/test/resources/svclogic.properties | 14 +- .../src/main/resources/svclogic.properties | 14 +- sliapi/model/src/main/yang/sliapi.yang | 2 +- .../onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 6 +- .../src/main/resources/initial/sliapi-provider.xml | 2 +- 29 files changed, 262 insertions(+), 267 deletions(-) diff --git a/README.md b/README.md index 50134aea4..262339dde 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ This source repository contains the code for the core SDN Controller components. To compile this code: -1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the OpenECOMP repositories and OpenDaylight repositories. See example-settings.xml for an example. +1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the ONAP repositories and OpenDaylight repositories. 2. To compile, run "mvn clean install". diff --git a/filters/README b/filters/README index 9d69d638d..5c1b3d627 100755 --- a/filters/README +++ b/filters/README @@ -2,12 +2,12 @@ /restconf filters are enabled by specifying filter chain in /opt/opendaylight/current/etc/org.opendaylight.aaa.filterchain.cfg and enabling bundle class loading - >bundle:dynamic-import org.openecomp.sdnc.filters-provider + >bundle:dynamic-import org.onap.ccsdk.sli.core.filters-provider loggers: - org.openecomp.sdnc.filters.audit - org.openecomp.sdnc.filters.metric - org.openecomp.sdnc.filters.request.response + org.onap.ccsdk.sli.core.filters.audit + org.onap.ccsdk.sli.core.filters.metric + org.onap.ccsdk.sli.core.filters.request.response diff --git a/filters/pom.xml b/filters/pom.xml index cbc8f5873..4c5c6826e 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -71,7 +71,7 @@ - OpenECOMP + ONAP provider diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java index 9df74c35a..553a7cdd7 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java @@ -7,9 +7,9 @@ * 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. @@ -80,7 +80,7 @@ public class LogFilter implements Filter { private static final Logger log = LoggerFactory.getLogger(LogFilter.class); - private static final Logger AUDIT = LoggerFactory.getLogger("org.openecomp.sdnc.filters.audit"); + private static final Logger AUDIT = LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.audit"); @Override public void destroy() { } diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java index e4b0b7d1f..eb7937086 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -7,9 +7,9 @@ * 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. @@ -45,7 +45,7 @@ import javax.servlet.http.HttpServletResponseWrapper; public class RequestResponseLoggingFilter implements Filter { - private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("org.openecomp.sdnc.filters.request.response"); + private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.request.response"); private static class ByteArrayServletStream extends ServletOutputStream { diff --git a/pom.xml b/pom.xml index 4a1a25010..0674b6dac 100755 --- a/pom.xml +++ b/pom.xml @@ -184,7 +184,7 @@ sliapi - OpenECOMP + ONAP 0.0.1-SNAPSHOT diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index ac656ffa8..4673f9689 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -7,9 +7,9 @@ * 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. @@ -54,8 +54,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { .getLogger(SvcLogicDblibStore.class); private static final String DBLIB_SERVICE = - // "org.openecomp.sdnc.sli.resource.dblib.DBLibService"; - "org.openecomp.sdnc.sli.resource.dblib.DBResourceManager"; + "org.onap.ccsdk.sli.core.dblib.DBResourceManager"; Properties props = null; diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index 9aa0ddfb5..1b9c62748 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -7,9 +7,9 @@ * 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. @@ -49,7 +49,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { private String dbUser = null; private String dbPasswd = null; private String dbDriver = null; - + private Connection dbConn; private PreparedStatement hasActiveGraphStmt = null; private PreparedStatement hasVersionGraphStmt = null; @@ -57,22 +57,22 @@ public class SvcLogicJdbcStore implements SvcLogicStore { private PreparedStatement fetchVersionGraphStmt = null; private PreparedStatement storeGraphStmt = null; private PreparedStatement deleteGraphStmt = null; - + private PreparedStatement deactivateStmt = null; private PreparedStatement activateStmt = null; - + private PreparedStatement registerNodeStmt = null; private PreparedStatement unregisterNodeStmt = null; private PreparedStatement validateNodeStmt = null; - + private void getConnection() throws ConfigurationException { Properties jdbcProps = new Properties(); - + jdbcProps.setProperty("user", dbUser); jdbcProps.setProperty("password", dbPasswd); - + try { Driver dvr = new com.mysql.jdbc.Driver(); if (dvr.acceptsURL(dbUrl)) @@ -88,8 +88,8 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } - - + + try { this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps); @@ -97,17 +97,17 @@ public class SvcLogicJdbcStore implements SvcLogicStore { catch (Exception e) { throw new ConfigurationException("failed to get database connection ["+dbUrl+"]", e); - } - + } + } - + private void createTable() throws ConfigurationException { DatabaseMetaData dbm = null; - - + + try { dbm = dbConn.getMetaData(); } catch (SQLException e) { @@ -164,9 +164,9 @@ public class SvcLogicJdbcStore implements SvcLogicStore { { throw new ConfigurationException("could not create SVC_LOGIC table", e); } - + // See if NODE_TYPES table exists and, if not, create it - + try { @@ -211,14 +211,14 @@ public class SvcLogicJdbcStore implements SvcLogicStore { throw new ConfigurationException("could not create SVC_LOGIC table", e); } } - + private void prepStatements() throws ConfigurationException { // Prepare statements String hasVersionGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - + try { hasVersionGraphStmt = dbConn.prepareStatement(hasVersionGraphSql); @@ -226,12 +226,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { catch (Exception e) { throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); - + } - + String hasActiveGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; - + try { hasActiveGraphStmt = dbConn.prepareStatement(hasActiveGraphSql); @@ -239,12 +239,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { catch (Exception e) { throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); - + } - + String fetchVersionGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - + try { fetchVersionGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); @@ -252,12 +252,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { catch (Exception e) { throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); - + } - + String fetchActiveGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; - + try { fetchActiveGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); @@ -265,12 +265,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { catch (Exception e) { throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); - + } - + String storeGraphSql = "INSERT INTO "+dbName+".SVC_LOGIC (module, rpc, version, mode, active, graph)" + " VALUES(?, ?, ?, ?, ?, ?)"; - + try { storeGraphStmt = dbConn.prepareStatement(storeGraphSql); @@ -279,9 +279,9 @@ public class SvcLogicJdbcStore implements SvcLogicStore { { throw new ConfigurationException("could not prepare statement "+storeGraphSql, e); } - + String deleteGraphSql = "DELETE FROM "+dbName+".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - + try { deleteGraphStmt = dbConn.prepareStatement(deleteGraphSql); @@ -290,9 +290,9 @@ public class SvcLogicJdbcStore implements SvcLogicStore { { throw new ConfigurationException("could not prepare statement "+deleteGraphSql, e); } - + String deactivateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; - + try { deactivateStmt = dbConn.prepareStatement(deactivateSql); @@ -301,9 +301,9 @@ public class SvcLogicJdbcStore implements SvcLogicStore { { throw new ConfigurationException("could not prepare statement "+deactivateSql, e); } - + String activateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - + try { activateStmt = dbConn.prepareStatement(activateSql); @@ -312,7 +312,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { { throw new ConfigurationException("could not prepare statement "+activateSql, e); } - + String registerNodeSql = "INSERT INTO "+dbName+".NODE_TYPES (nodetype) VALUES(?)"; try { @@ -322,7 +322,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { { throw new ConfigurationException("could not prepare statement "+registerNodeSql, e); } - + String unregisterNodeSql = "DELETE FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; try { @@ -332,7 +332,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { { throw new ConfigurationException("could not prepare statement "+unregisterNodeSql, e); } - + String validateNodeSql = "SELECT count(*) FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; try { @@ -343,12 +343,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { throw new ConfigurationException("could not prepare statement "+validateNodeSql, e); } } - + private void initDbResources() throws ConfigurationException { if ((dbDriver != null) && (dbDriver.length() > 0)) { - + try { Class.forName(dbDriver); @@ -362,48 +362,48 @@ public class SvcLogicJdbcStore implements SvcLogicStore { createTable(); prepStatements(); } - + public void init(Properties props) throws ConfigurationException { - - - dbUrl = props.getProperty("org.openecomp.sdnc.sli.jdbc.url"); + + + dbUrl = props.getProperty("org.onap.ccsdk.sli.jdbc.url"); if ((dbUrl == null) || (dbUrl.length() == 0)) { - throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.url unset"); + throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.url unset"); } - - dbName = props.getProperty("org.openecomp.sdnc.sli.jdbc.database"); + + dbName = props.getProperty("org.onap.ccsdk.sli.jdbc.database"); if ((dbName == null) || (dbName.length() == 0)) { - throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.database unset"); + throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.database unset"); } - - dbUser = props.getProperty("org.openecomp.sdnc.sli.jdbc.user"); + + dbUser = props.getProperty("org.onap.ccsdk.sli.jdbc.user"); if ((dbUser == null) || (dbUser.length() == 0)) { - throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.user unset"); + throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.user unset"); } - - dbPasswd = props.getProperty("org.openecomp.sdnc.sli.jdbc.password"); + + dbPasswd = props.getProperty("org.onap.ccsdk.sli.jdbc.password"); if ((dbPasswd == null) || (dbPasswd.length() == 0)) { - throw new ConfigurationException("property org.openecomp.sdnc.sli.jdbc.password unset"); + throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.password unset"); } - - dbDriver = props.getProperty("org.openecomp.sdnc.sli.jdbc.driver"); - + dbDriver = props.getProperty("org.onap.ccsdk.sli.jdbc.driver"); + + initDbResources(); - + } - + private boolean isDbConnValid() { boolean isValid = false; - + try { if (dbConn != null) @@ -413,31 +413,31 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (SQLException e) {} - + return(isValid); } public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - - + + if (!isDbConnValid()) { - + // Try reinitializing initDbResources(); - + if (!isDbConnValid()) { throw new ConfigurationException("no jdbc connection"); } } - - + + boolean retval = false; ResultSet results = null; - + PreparedStatement hasGraphStmt = null; if (version == null) { @@ -447,16 +447,16 @@ public boolean hasGraph(String module, String rpc, String version, String mode) { hasGraphStmt = hasVersionGraphStmt; } - - + + try { hasGraphStmt.setString(1, module); hasGraphStmt.setString(2, rpc); hasGraphStmt.setString(3, mode); - + if (version != null) { hasGraphStmt.setString(4, version); @@ -466,11 +466,11 @@ public boolean hasGraph(String module, String rpc, String version, String mode) results = hasGraphStmt.executeQuery(); dbConn.commit(); dbConn.setAutoCommit(oldAutoCommit); - + if (results.next()) { int cnt = results.getInt(1); - + if (cnt > 0) { retval = true; @@ -488,43 +488,43 @@ public boolean hasGraph(String module, String rpc, String version, String mode) { try { - + results.close(); } catch (SQLException x) {} } - + } - - + + return(retval); - - + + } public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { - - + + if (!isDbConnValid()) { - + // Try reinitializing initDbResources(); - + if (!isDbConnValid()) { throw new ConfigurationException("no jdbc connection"); } } - - + + SvcLogicGraph retval = null; ResultSet results = null; - + PreparedStatement fetchGraphStmt = null; if (version == null) { @@ -540,7 +540,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) fetchGraphStmt.setString(2, rpc); fetchGraphStmt.setString(3, mode); - + if (version != null) { fetchGraphStmt.setString(4, version); @@ -550,16 +550,16 @@ public boolean hasGraph(String module, String rpc, String version, String mode) results = fetchGraphStmt.executeQuery(); dbConn.commit(); dbConn.setAutoCommit(oldAutoCommit); - + if (results.next()) { Blob graphBlob = results.getBlob("graph"); - + ObjectInputStream gStream = new ObjectInputStream(graphBlob.getBinaryStream()); - + Object graphObj = gStream.readObject(); gStream.close(); - + if (graphObj instanceof SvcLogicGraph) { retval = (SvcLogicGraph) graphObj; @@ -567,9 +567,9 @@ public boolean hasGraph(String module, String rpc, String version, String mode) else { throw new ConfigurationException("invalid type for graph ("+graphObj.getClass().getName()); - + } - + } else { @@ -591,24 +591,24 @@ public boolean hasGraph(String module, String rpc, String version, String mode) catch (SQLException x) {} } - + } - - + + return(retval); - - + + } public void store(SvcLogicGraph graph) throws SvcLogicException { - - + + if (!isDbConnValid()) { - + // Try reinitializing initDbResources(); - + if (!isDbConnValid()) { throw new ConfigurationException("no jdbc connection"); @@ -619,20 +619,20 @@ public boolean hasGraph(String module, String rpc, String version, String mode) { throw new SvcLogicException("graph cannot be null"); } - + byte[] graphBytes = null; - + ByteArrayOutputStream byteStr = null; ObjectOutputStream goutStr = null; - + try { byteStr = new ByteArrayOutputStream(); goutStr = new ObjectOutputStream(byteStr); goutStr.writeObject(graph); - + graphBytes = byteStr.toByteArray(); - + } catch (Exception e) { @@ -640,33 +640,33 @@ public boolean hasGraph(String module, String rpc, String version, String mode) } finally { - + if (goutStr != null) { try { goutStr.close(); } catch (IOException e) { - + } } - + if (byteStr != null) { try { byteStr.close(); } catch (IOException e) { - + } } } - - + + // If object already stored in database, delete it if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode())) { delete(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode()); } - + try { boolean oldAutoCommit = dbConn.getAutoCommit(); @@ -677,26 +677,26 @@ public boolean hasGraph(String module, String rpc, String version, String mode) storeGraphStmt.setString(4, graph.getMode()); storeGraphStmt.setString(5, "N"); storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); - + storeGraphStmt.executeUpdate(); dbConn.commit(); - + dbConn.setAutoCommit(oldAutoCommit); } catch (Exception e) { throw new SvcLogicException("Could not write object to database", e); - } + } } - + public void delete(String module, String rpc, String version, String mode) throws SvcLogicException - { + { if (!isDbConnValid()) { - + // Try reinitializing initDbResources(); - + if (!isDbConnValid()) { throw new ConfigurationException("no jdbc connection"); @@ -712,7 +712,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) deleteGraphStmt.setString(3, version); deleteGraphStmt.setString(4, mode); - + deleteGraphStmt.executeUpdate(); dbConn.commit(); dbConn.setAutoCommit(oldAutoCommit); @@ -720,7 +720,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) catch (Exception e) { throw new SvcLogicException("Could not delete object from database", e); - } + } } public void activate(SvcLogicGraph graph) throws SvcLogicException @@ -728,26 +728,26 @@ public boolean hasGraph(String module, String rpc, String version, String mode) try { boolean oldAutoCommit = dbConn.getAutoCommit(); - + dbConn.setAutoCommit(false); - + // Deactivate any current active version deactivateStmt.setString(1, graph.getModule()); deactivateStmt.setString(2, graph.getRpc()); deactivateStmt.setString(3, graph.getMode()); deactivateStmt.executeUpdate(); - + // Activate this version activateStmt.setString(1, graph.getModule()); activateStmt.setString(2, graph.getRpc()); activateStmt.setString(3, graph.getVersion()); activateStmt.setString(4, graph.getMode()); activateStmt.executeUpdate(); - + dbConn.commit(); - + dbConn.setAutoCommit(oldAutoCommit); - + } catch (Exception e) { @@ -757,24 +757,24 @@ public boolean hasGraph(String module, String rpc, String version, String mode) @Override public void registerNodeType(String nodeType) throws SvcLogicException { - + if (isValidNodeType(nodeType)) { return; } - + if (!isDbConnValid()) { - + // Try reinitializing initDbResources(); - + if (!isDbConnValid()) { throw new ConfigurationException("no jdbc connection"); } } - + try { boolean oldAutoCommit = dbConn.getAutoCommit(); @@ -788,29 +788,29 @@ public boolean hasGraph(String module, String rpc, String version, String mode) { throw new SvcLogicException("Could not add node type to database", e); } - + } @Override public void unregisterNodeType(String nodeType) throws SvcLogicException { - + if (!isValidNodeType(nodeType)) { return; } - + if (!isDbConnValid()) { - + // Try reinitializing initDbResources(); - + if (!isDbConnValid()) { throw new ConfigurationException("no jdbc connection"); } } - + try { boolean oldAutoCommit = dbConn.getAutoCommit(); @@ -824,50 +824,50 @@ public boolean hasGraph(String module, String rpc, String version, String mode) { throw new SvcLogicException("Could not delete node type from database", e); } - + } @Override public boolean isValidNodeType(String nodeType) throws SvcLogicException { - + boolean isValid = false; - + if (!isDbConnValid()) { - + // Try reinitializing initDbResources(); - + if (!isDbConnValid()) { throw new ConfigurationException("no jdbc connection"); } } - + ResultSet results = null; try { validateNodeStmt.setString(1, nodeType); - + boolean oldAutoCommit = dbConn.getAutoCommit(); dbConn.setAutoCommit(false); results = validateNodeStmt.executeQuery(); dbConn.commit(); dbConn.setAutoCommit(oldAutoCommit); - + if (results != null) { if (results.next()) { int cnt = results.getInt(1); - + if (cnt > 0) { isValid = true; } } } - + } catch (Exception e) { @@ -884,11 +884,11 @@ public boolean hasGraph(String module, String rpc, String version, String mode) catch (SQLException x) {} } - + } - + return(isValid); } - - + + } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 9ba502666..3a60001fa 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -7,9 +7,9 @@ * 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. @@ -60,7 +60,7 @@ public class SvcLogicParser { private static final String SVC_LOGIC_STORE_ERROR = "Could not get service logic store"; private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicParser.class); - private static final String SLI_VALIDATING_PARSER = "org.openecomp.sdnc.sli.parser.validate"; + private static final String SLI_VALIDATING_PARSER = "org.onap.ccsdk.sli.parser.validate"; private static final String SVCLOGIC_XSD = "/svclogic.xsd"; private class SvcLogicHandler extends DefaultHandler { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index 38b5b69d6..22e27735f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -7,9 +7,9 @@ * 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. @@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory; public class SvcLogicStoreFactory { private static final Logger LOG = LoggerFactory.getLogger(SvcLogicStoreFactory.class); - + public static SvcLogicStore getSvcLogicStore(String propfile) throws SvcLogicException { File propFile = new File(propfile); @@ -54,27 +54,27 @@ public class SvcLogicStoreFactory { public static SvcLogicStore getSvcLogicStore(InputStream inStr) throws SvcLogicException { Properties props = new Properties(); - + try { props.load(inStr); } catch (Exception e) { throw new ConfigurationException("Could not get load properties from input stream", e); } - + return(getSvcLogicStore(props)); } public static SvcLogicStore getSvcLogicStore(Properties props) throws SvcLogicException { - String storeType = props.getProperty("org.openecomp.sdnc.sli.dbtype"); + String storeType = props.getProperty("org.onap.ccsdk.sli.dbtype"); if ((storeType == null) || (storeType.length() == 0)) { throw new ConfigurationException( - "property org.openecomp.sdnc.sli.dbtype unset"); + "property org.onap.ccsdk.sli.dbtype unset"); } SvcLogicStore retval = null; - LOG.debug(String.format("Using org.openecomp.sdnc.sli.dbtype=%s", storeType)); + LOG.debug(String.format("Using org.onap.ccsdk.sli.dbtype=%s", storeType)); if ("jdbc".equalsIgnoreCase(storeType)) { retval = new SvcLogicJdbcStore(); @@ -87,7 +87,7 @@ public class SvcLogicStoreFactory { } - + retval.init(props); return (retval); } diff --git a/sli/common/src/main/resources/svclogic.xsd b/sli/common/src/main/resources/svclogic.xsd index f74bd5dcd..2704de88e 100755 --- a/sli/common/src/main/resources/svclogic.xsd +++ b/sli/common/src/main/resources/svclogic.xsd @@ -1,5 +1,5 @@ - + diff --git a/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml index 308bda1e9..de1f316e9 100644 --- a/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml +++ b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml @@ -18,14 +18,14 @@ --> - - @@ -50,7 +50,7 @@ - diff --git a/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml b/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml index 8a9578bbe..268fc3126 100644 --- a/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml +++ b/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml @@ -18,16 +18,16 @@ --> - - @@ -35,7 +35,7 @@ - + @@ -66,7 +66,7 @@ - @@ -74,7 +74,7 @@ - + @@ -115,11 +115,11 @@ then configures it on device --> - - @@ -134,7 +134,7 @@ - + @@ -183,7 +183,7 @@ - @@ -214,7 +214,7 @@ - @@ -225,11 +225,11 @@ - - + diff --git a/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml b/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml index 1cc6274de..863b7f8d3 100644 --- a/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml +++ b/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml @@ -18,14 +18,14 @@ --> - - @@ -36,15 +36,15 @@ - - - + diff --git a/sli/common/src/test/resources/bad_neutron_logic_v11.xml b/sli/common/src/test/resources/bad_neutron_logic_v11.xml index f3455388e..3219310bb 100644 --- a/sli/common/src/test/resources/bad_neutron_logic_v11.xml +++ b/sli/common/src/test/resources/bad_neutron_logic_v11.xml @@ -18,9 +18,9 @@ --> - diff --git a/sli/common/src/test/resources/mergetest.xml b/sli/common/src/test/resources/mergetest.xml index 378744135..91164beee 100644 --- a/sli/common/src/test/resources/mergetest.xml +++ b/sli/common/src/test/resources/mergetest.xml @@ -16,7 +16,7 @@ ============LICENSE_END========================================================= --> - + Y Y diff --git a/sli/common/src/test/resources/neutron_logic_v10.xml b/sli/common/src/test/resources/neutron_logic_v10.xml index 730ebc21d..73d142019 100644 --- a/sli/common/src/test/resources/neutron_logic_v10.xml +++ b/sli/common/src/test/resources/neutron_logic_v10.xml @@ -18,9 +18,9 @@ --> - diff --git a/sli/common/src/test/resources/simplelogger.properties b/sli/common/src/test/resources/simplelogger.properties index d88e59ebe..05f72cd72 100644 --- a/sli/common/src/test/resources/simplelogger.properties +++ b/sli/common/src/test/resources/simplelogger.properties @@ -7,9 +7,9 @@ # 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. @@ -19,5 +19,5 @@ ### org.slf4j.simpleLogger.defaultLogLevel=info -org.slf4j.simplelogger.log.org.openecomp.sdnc.sli.SvcLogicContext=debug +org.slf4j.simplelogger.log.org.onap.ccsdk.sli.core.sli.SvcLogicContext=debug org.slf4j.simplelogger.log.SvcLogicContext=debug diff --git a/sli/common/src/test/resources/svclogic.properties b/sli/common/src/test/resources/svclogic.properties index fa7a20417..df814e01b 100644 --- a/sli/common/src/test/resources/svclogic.properties +++ b/sli/common/src/test/resources/svclogic.properties @@ -7,9 +7,9 @@ # 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. @@ -18,8 +18,8 @@ # ============LICENSE_END========================================================= ### -org.openecomp.sdnc.sli.dbtype = jdbc -org.openecomp.sdnc.sli.jdbc.url = jdbc:mysql://localhost:3306/sdnctl -org.openecomp.sdnc.sli.jdbc.database = sdnctl -org.openecomp.sdnc.sli.jdbc.user = sdnctl -org.openecomp.sdnc.sli.jdbc.password = gamma +org.onap.ccsdk.sli.dbtype = jdbc +org.onap.ccsdk.sli.jdbc.url = jdbc:mysql://localhost: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/common/src/test/resources/svclogic.sh b/sli/common/src/test/resources/svclogic.sh index f6c6f4b67..601e94f69 100644 --- a/sli/common/src/test/resources/svclogic.sh +++ b/sli/common/src/test/resources/svclogic.sh @@ -9,9 +9,9 @@ # 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. @@ -28,4 +28,4 @@ SLI_COMMON_JAR=${SLI_COMMON_JAR:=${SLI_COMMON_TARGETDIR}/sli-common-${SLI_VERSIO echo SLI_COMMON_JAR is $SLI_COMMON_JAR -java -cp ${CLASSPATH}:${MYSQL_JDBC_DRIVER}:${SLI_COMMON_JAR} org.openecomp.sdnc.sli.SvcLogicParser $* +java -cp ${CLASSPATH}:${MYSQL_JDBC_DRIVER}:${SLI_COMMON_JAR} org.onap.ccsdk.sli.core.sli.SvcLogicParser $* diff --git a/sli/common/src/test/resources/svclogic.xsd b/sli/common/src/test/resources/svclogic.xsd index 074308915..a63758f7c 100755 --- a/sli/common/src/test/resources/svclogic.xsd +++ b/sli/common/src/test/resources/svclogic.xsd @@ -1,5 +1,5 @@ - + diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index df6c7bcdf..25632f154 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -73,14 +73,10 @@ org.onap.ccsdk.sli.core.sli.provider;version=${project.version} * - + org.onap.ccsdk.sli.core.sli;version="${project.version}",* - + *;scope=compile;artifactId=commons-lang|commons-lang3 true diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java index cfba5866e..22c475d88 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java @@ -7,9 +7,9 @@ * 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. @@ -26,9 +26,9 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; public interface SvcLogicService { - - public static final String NAME = "org.openecomp.sdnc.sli.provider.SvcLogicService"; - + + public static final String NAME = "org.onap.ccsdk.sli.core.sli.provider.SvcLogicService"; + // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException; /** * Check for existence of a directed graph @@ -40,10 +40,10 @@ public interface SvcLogicService { * @throws SvcLogicException */ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; - + /** * Execute a directed graph - * + * * @param module - module name * @param rpc - rpc name * @param version - version. If null, use active version @@ -51,16 +51,16 @@ public interface SvcLogicService { * @param parms - parameters, used to set SvcLogicContext attributes * @return final values of attributes from SvcLogicContext, as Properties * @throws SvcLogicException - * - * + * + * * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead */ @Deprecated public Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; - + /** * Execute a directed graph - * + * * @param module - module name * @param rpc - rpc name * @param version - version. If null, use active version @@ -71,5 +71,5 @@ public interface SvcLogicService { * @throws SvcLogicException */ public Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException; - + } diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml index 56e1a81ef..3bf8ef682 100644 --- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml +++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml @@ -18,9 +18,9 @@ --> - diff --git a/sli/provider/src/test/resources/svclogic.properties b/sli/provider/src/test/resources/svclogic.properties index fa7a20417..df814e01b 100644 --- a/sli/provider/src/test/resources/svclogic.properties +++ b/sli/provider/src/test/resources/svclogic.properties @@ -7,9 +7,9 @@ # 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. @@ -18,8 +18,8 @@ # ============LICENSE_END========================================================= ### -org.openecomp.sdnc.sli.dbtype = jdbc -org.openecomp.sdnc.sli.jdbc.url = jdbc:mysql://localhost:3306/sdnctl -org.openecomp.sdnc.sli.jdbc.database = sdnctl -org.openecomp.sdnc.sli.jdbc.user = sdnctl -org.openecomp.sdnc.sli.jdbc.password = gamma +org.onap.ccsdk.sli.dbtype = jdbc +org.onap.ccsdk.sli.jdbc.url = jdbc:mysql://localhost: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/main/resources/svclogic.properties b/sli/recording/src/main/resources/svclogic.properties index 723aed8c3..8c301d47c 100644 --- a/sli/recording/src/main/resources/svclogic.properties +++ b/sli/recording/src/main/resources/svclogic.properties @@ -7,9 +7,9 @@ # 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. @@ -18,8 +18,8 @@ # ============LICENSE_END========================================================= ### -org.openecomp.sdnc.sli.dbtype = jdbc -org.openecomp.sdnc.sli.jdbc.url = jdbc:mysql://dbhost:3306/sdnctl -org.openecomp.sdnc.sli.jdbc.database = sdnctl -org.openecomp.sdnc.sli.jdbc.user = sdnctl -org.openecomp.sdnc.sli.jdbc.password = gamma +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/sliapi/model/src/main/yang/sliapi.yang b/sliapi/model/src/main/yang/sliapi.yang index a8fe33b7d..8deb8a10f 100755 --- a/sliapi/model/src/main/yang/sliapi.yang +++ b/sliapi/model/src/main/yang/sliapi.yang @@ -8,7 +8,7 @@ module SLI-API { import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; } - organization "openECOMP"; + organization "ONAP"; contact "Dan Timoney"; diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index 9ec5b6614..36e401144 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -7,9 +7,9 @@ * 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. @@ -117,7 +117,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ protected BindingAwareBroker.RpcRegistration rpcRegistration; - private static String SLIAPI_NAMESPACE = "org:openecomp:sdnc:sliapi"; + private static String SLIAPI_NAMESPACE = "org:onap:ccsdk:sli:core:sliapi"; private static String SLIAPI_REVISION = "2016-11-10"; private static QName TEST_RESULTS_QNAME = null; diff --git a/sliapi/provider/src/main/resources/initial/sliapi-provider.xml b/sliapi/provider/src/main/resources/initial/sliapi-provider.xml index 038d209d8..780be2785 100644 --- a/sliapi/provider/src/main/resources/initial/sliapi-provider.xml +++ b/sliapi/provider/src/main/resources/initial/sliapi-provider.xml @@ -26,7 +26,7 @@ - + prefix:sliapi-provider-impl sliapi-provider-impl -- cgit 1.2.3-korg From f84d3ea7e6a08a62ddd4960fcf8592b8b5c07f52 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 11 Aug 2017 20:12:41 -0400 Subject: Compile against Carbon Update sli/core to compile against OpenDaylight Carbon SR1 Change-Id: Ibb4a3a4cfa64f0539b520f56f11d7bf1fce62357 Issue-ID: CCSDK-23 Signed-off-by: Dan Timoney --- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 2 +- .../src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java | 4 ++-- .../onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 2 +- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java | 4 ++-- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 4 ++-- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java | 4 ++-- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 4 ++-- sli/common/src/test/resources/simplelogger.properties | 4 ++-- sli/common/src/test/resources/svclogic.properties | 4 ++-- sli/common/src/test/resources/svclogic.sh | 4 ++-- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 2 +- .../java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java | 4 ++-- .../java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java | 4 ++-- sli/provider/src/test/resources/svclogic.properties | 4 ++-- sli/recording/pom.xml | 2 +- sli/recording/src/main/resources/svclogic.properties | 4 ++-- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 5 ++++- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 5 ++++- .../src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 4 ++-- src/site/apt/nodes.apt | 4 ++-- 39 files changed, 67 insertions(+), 61 deletions(-) diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index b8b211c6e..3af56c129 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT dblib-features DBLIB Adaptor - Features diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index a06a3969a..aa68d5a6d 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT dblib-installer DBLIB Adaptor - Karaf Installer diff --git a/dblib/pom.xml b/dblib/pom.xml index 775ff0591..81e1b8011 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core sdnc-core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT @@ -16,7 +16,7 @@ DBLIB Adaptor The DBLIB adaptor allows service logic to access persistent data in a local sql database - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 41d383ef0..579ab40ea 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -4,10 +4,10 @@ org.onap.ccsdk.sli.core dblib - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT dblib-provider - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT bundle DBLIB Adaptor - Provider http://maven.apache.org diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 456b6a475..baf497d49 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -4,7 +4,7 @@ filters org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT filters-features Filters - Features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index ff09b43d0..ca35e3c33 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT filters-installer Filters - Karaf Installer diff --git a/filters/pom.xml b/filters/pom.xml index 4c5c6826e..d5ff51764 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sdnc-core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT 4.0.0 @@ -16,7 +16,7 @@ Filters Servlet filter to implement ECOMP logging spec - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index cfbb7b594..0c73949ea 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT filters-provider bundle diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java index 553a7cdd7..719d9e08e 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java @@ -7,9 +7,9 @@ * 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. diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java index eb7937086..f07e07e42 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -7,9 +7,9 @@ * 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. diff --git a/pom.xml b/pom.xml index 0674b6dac..e3a845481 100755 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.onap.ccsdk.parent - odlparent-boron-sr3 + odlparent-carbon-sr1 0.0.1-SNAPSHOT @@ -186,7 +186,7 @@ ONAP - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 8b19891f0..dfec19333 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -3,7 +3,7 @@ sli org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sli-common bundle diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 4673f9689..803c55150 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -7,9 +7,9 @@ * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index 1b9c62748..47cbac8ef 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -7,9 +7,9 @@ * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 3a60001fa..040d8876d 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -7,9 +7,9 @@ * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index 22e27735f..53410dbb4 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -7,9 +7,9 @@ * 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. diff --git a/sli/common/src/test/resources/simplelogger.properties b/sli/common/src/test/resources/simplelogger.properties index 05f72cd72..fa22a18f2 100644 --- a/sli/common/src/test/resources/simplelogger.properties +++ b/sli/common/src/test/resources/simplelogger.properties @@ -7,9 +7,9 @@ # 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. diff --git a/sli/common/src/test/resources/svclogic.properties b/sli/common/src/test/resources/svclogic.properties index df814e01b..bf7469064 100644 --- a/sli/common/src/test/resources/svclogic.properties +++ b/sli/common/src/test/resources/svclogic.properties @@ -7,9 +7,9 @@ # 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. diff --git a/sli/common/src/test/resources/svclogic.sh b/sli/common/src/test/resources/svclogic.sh index 601e94f69..3d231a2fb 100644 --- a/sli/common/src/test/resources/svclogic.sh +++ b/sli/common/src/test/resources/svclogic.sh @@ -9,9 +9,9 @@ # 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. diff --git a/sli/features/pom.xml b/sli/features/pom.xml index f5acafa4b..5dd0d550a 100755 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sli-features SLI - Features diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 905a77dd7..616c3c467 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sli-installer SLI - Karaf Installer diff --git a/sli/pom.xml b/sli/pom.xml index 27e603625..08d684d74 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core sdnc-core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT 4.0.0 pom @@ -59,7 +59,7 @@ ONAP - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 25632f154..7d02869fb 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sli-provider bundle diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java index 22c475d88..89391bf41 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java @@ -7,9 +7,9 @@ * 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. diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index ae5548862..433270faf 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -7,9 +7,9 @@ * 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. diff --git a/sli/provider/src/test/resources/svclogic.properties b/sli/provider/src/test/resources/svclogic.properties index df814e01b..bf7469064 100644 --- a/sli/provider/src/test/resources/svclogic.properties +++ b/sli/provider/src/test/resources/svclogic.properties @@ -7,9 +7,9 @@ # 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. diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index afd0adc16..499181e7a 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sli-recording bundle diff --git a/sli/recording/src/main/resources/svclogic.properties b/sli/recording/src/main/resources/svclogic.properties index 8c301d47c..51a581d42 100644 --- a/sli/recording/src/main/resources/svclogic.properties +++ b/sli/recording/src/main/resources/svclogic.properties @@ -7,9 +7,9 @@ # 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. diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index c90cfc260..b512f9ee6 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -8,7 +8,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT SliPluginUtils Plugin - Features diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 2744f7dae..330891316 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -4,7 +4,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sliPluginUtils-installer SLI Plugin Utilities - Karaf Installer diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index bb6cad3f6..ca40d6de0 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT pom 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sdnc-core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT Service Logic Interface Plugin Utilities A package of static utility functions to be used when developing SLI plugins diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 1db16779b..aeb86d040 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -8,7 +8,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT SliPluginUtils Plugin - Provider diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 1fc0f61be..63fd51a4e 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sliapi-features diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 36570cded..b3939a6bc 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sliapi-installer pom diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 17bee5a99..b6dcfe8bd 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sliapi-model bundle @@ -43,7 +43,10 @@ ${yang.file.directory} + + org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl ${salGeneratorPath} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 1ca872e1f..6837cc04e 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.sli.core sdnc-core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT pom org.onap.ccsdk.sli.core sliapi - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index d5f491771..9afbdc5fe 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT sliapi-provider bundle @@ -42,7 +42,10 @@ + + org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl ${salGeneratorPath} diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index 36e401144..2894ba75a 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -7,9 +7,9 @@ * 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. diff --git a/src/site/apt/nodes.apt b/src/site/apt/nodes.apt index 8ddb711d1..b89b511f1 100644 --- a/src/site/apt/nodes.apt +++ b/src/site/apt/nodes.apt @@ -7,9 +7,9 @@ ~~ 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. -- cgit 1.2.3-korg From 28fa1c931b1cb9ce1ca50589b2a02c48d6e66fe9 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 15 Aug 2017 09:55:50 -0400 Subject: Fix license headers Licence headers were accidentally updated incorrectly by previous update. This commit restores the license headers for seed code to the wording from the original seed code Change-Id: Ie73bc836079be7eb1b310c472ee39b58ffeaa01c Issue-ID: CCSDK-31 Signed-off-by: Dan Timoney --- filters/features/src/main/resources/features.xml | 3 ++- filters/installer/src/assembly/assemble_installer_zip.xml | 3 ++- filters/installer/src/assembly/assemble_mvnrepo_zip.xml | 3 ++- filters/installer/src/main/resources/scripts/install-feature.sh | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java | 3 ++- .../onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java | 3 ++- .../org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java | 3 ++- pom.xml | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java | 3 ++- sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java | 3 ++- sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java | 3 ++- .../org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 3 ++- sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java | 3 ++- sli/common/src/main/resources/crAseNetwork.sql | 3 ++- .../src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java | 3 ++- .../src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java | 3 ++- sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml | 3 ++- sli/common/src/test/resources/EvcPortSvcLogic_v100.xml | 3 ++- sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml | 3 ++- sli/common/src/test/resources/bad_neutron_logic_v11.xml | 3 ++- sli/common/src/test/resources/mergetest.xml | 3 ++- sli/common/src/test/resources/neutron_logic_v10.xml | 3 ++- sli/common/src/test/resources/nonsense.xml | 3 ++- sli/common/src/test/resources/simplelogger.properties | 3 ++- sli/common/src/test/resources/svclogic.properties | 3 ++- sli/common/src/test/resources/svclogic.sh | 3 ++- sli/features/src/main/resources/features.xml | 3 ++- sli/installer/src/assembly/assemble_installer_zip.xml | 3 ++- sli/installer/src/assembly/assemble_mvnrepo_zip.xml | 3 ++- sli/installer/src/main/resources/scripts/install-feature.sh | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java | 3 ++- .../org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java | 3 ++- .../org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java | 3 ++- .../org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java | 3 ++- .../org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java | 3 ++- .../onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java | 3 ++- .../org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java | 3 ++- .../src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java | 3 ++- .../org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java | 3 ++- .../org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTesterUtil.java | 3 ++- .../src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java | 3 ++- .../ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java | 3 ++- .../onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java | 3 ++- sli/provider/src/test/resources/l3sdn_logic_v10.xml | 3 ++- sli/provider/src/test/resources/simplelogger.properties | 3 ++- sli/provider/src/test/resources/svclogic.properties | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java | 3 ++- .../java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java | 3 ++- .../main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java | 3 ++- sli/recording/src/main/resources/svclogic.properties | 3 ++- sliPluginUtils/features/src/main/resources/features.xml | 3 ++- sliPluginUtils/installer/src/assembly/assemble_installer_zip.xml | 3 ++- sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml | 3 ++- sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java | 3 ++- .../java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java | 3 ++- .../onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java | 3 ++- .../java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java | 3 ++- .../org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java | 3 ++- .../org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java | 3 ++- .../onap/ccsdk/sli/core/slipluginutils/commondatastructures/YesNo.java | 3 ++- .../sli/core/slipluginutils/commondatastructures/package-info.java | 3 ++- .../org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java | 3 ++- .../src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java | 3 ++- .../sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java | 3 ++- .../onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java | 3 ++- .../ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java | 3 ++- .../org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java | 3 ++- .../onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java | 3 ++- sliapi/features/src/main/resources/features.xml | 3 ++- sliapi/installer/src/assembly/assemble_installer_zip.xml | 3 ++- sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml | 3 ++- sliapi/installer/src/main/resources/scripts/install-feature.sh | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelper.java | 3 ++- .../src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 3 ++- sliapi/provider/src/main/resources/initial/sliapi-provider.xml | 3 ++- src/site/apt/nodes.apt | 3 ++- src/site/site.xml | 3 ++- 125 files changed, 250 insertions(+), 125 deletions(-) diff --git a/filters/features/src/main/resources/features.xml b/filters/features/src/main/resources/features.xml index 6837553d5..7ede2083a 100644 --- a/filters/features/src/main/resources/features.xml +++ b/filters/features/src/main/resources/features.xml @@ -3,7 +3,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/filters/installer/src/assembly/assemble_installer_zip.xml b/filters/installer/src/assembly/assemble_installer_zip.xml index 4fa3a8ae5..2ff550d2c 100644 --- a/filters/installer/src/assembly/assemble_installer_zip.xml +++ b/filters/installer/src/assembly/assemble_installer_zip.xml @@ -2,7 +2,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/filters/installer/src/assembly/assemble_mvnrepo_zip.xml b/filters/installer/src/assembly/assemble_mvnrepo_zip.xml index 0e669ca5f..f000fd074 100644 --- a/filters/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/filters/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -2,7 +2,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/filters/installer/src/main/resources/scripts/install-feature.sh b/filters/installer/src/main/resources/scripts/install-feature.sh index c58b57985..70cd85162 100644 --- a/filters/installer/src/main/resources/scripts/install-feature.sh +++ b/filters/installer/src/main/resources/scripts/install-feature.sh @@ -4,7 +4,8 @@ # ============LICENSE_START======================================================= # ONAP : CCSDK # ================================================================================ -# Copyright (C) 2017 ONAP +# 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. diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java index c97142f1b..6cac336a1 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java index 719d9e08e..4b14b21df 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java index b187d9573..8b67276b0 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java index f07e07e42..440aa41bd 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/pom.xml b/pom.xml index e3a845481..a4b3f27ca 100755 --- a/pom.xml +++ b/pom.xml @@ -118,7 +118,8 @@ 2017 - ONAP + AT&T Intellectual Property. All rights + reserved. ONAP : CCSDK diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java index d85514cbc..e1c0e3db5 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/BreakNodeException.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java index 7a8531008..144b99a8a 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ConfigurationException.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java index 24d06a211..43f4fe53e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/DuplicateValueException.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java index b9f9e5347..c75873eb6 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 7d1250c03..0d0faee8a 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java index 3a3dd75d3..a76b123ca 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAdaptor.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java index 47912397c..699ace2e8 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java index ee2a24358..45458e8d6 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index b5892eff5..eaf57428f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 803c55150..2aed6511d 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java index 198f8d577..c03ef9787 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicException.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java index 0dda84697..2a40e7a1d 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java index 79979e75f..03f2a8b0b 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprParserErrorListener.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java index 72a438454..b8a47c45e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java index 18a433f64..c229cf59f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java index fc899704f..8289f16da 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicFunctionCall.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java index 158d815b0..35486eba8 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java index eaf4c7196..451277576 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index 47cbac8ef..b4b77660d 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java index 3aab21f2f..56ed53054 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 040d8876d..5270143a6 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java index a2d2ac4c4..61f80f7e2 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserException.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java index 1c85394b2..ca13536bb 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicRecorder.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java index 10d31f56e..40295bd75 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java index 6d2b99c57..3a3f9288a 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index 53410dbb4..11b5fdea4 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java index ac642a2d9..b089d60e3 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/main/resources/crAseNetwork.sql b/sli/common/src/main/resources/crAseNetwork.sql index d95891ae1..83f1dfc82 100644 --- a/sli/common/src/main/resources/crAseNetwork.sql +++ b/sli/common/src/main/resources/crAseNetwork.sql @@ -2,7 +2,8 @@ -- ============LICENSE_START======================================================= -- ONAP : CCSDK -- ================================================================================ --- Copyright (C) 2017 ONAP +-- 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. diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java index 123083a74..60d70460d 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java index 543bb1be3..125ac5618 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java index 2da8dd4f8..687f06e76 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ - * Copyright (C) 2017 ONAP + * 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. diff --git a/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml index de1f316e9..708823efc 100644 --- a/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml +++ b/sli/common/src/test/resources/EvcActivateSvcLogic_v100.xml @@ -3,7 +3,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml b/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml index 268fc3126..9a1a14708 100644 --- a/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml +++ b/sli/common/src/test/resources/EvcPortSvcLogic_v100.xml @@ -3,7 +3,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml b/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml index 863b7f8d3..cee027f75 100644 --- a/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml +++ b/sli/common/src/test/resources/ReleasePortSvcLogic_v101.xml @@ -3,7 +3,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/common/src/test/resources/bad_neutron_logic_v11.xml b/sli/common/src/test/resources/bad_neutron_logic_v11.xml index 3219310bb..e6ec8614b 100644 --- a/sli/common/src/test/resources/bad_neutron_logic_v11.xml +++ b/sli/common/src/test/resources/bad_neutron_logic_v11.xml @@ -3,7 +3,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/common/src/test/resources/mergetest.xml b/sli/common/src/test/resources/mergetest.xml index 91164beee..95c26da27 100644 --- a/sli/common/src/test/resources/mergetest.xml +++ b/sli/common/src/test/resources/mergetest.xml @@ -2,7 +2,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/common/src/test/resources/neutron_logic_v10.xml b/sli/common/src/test/resources/neutron_logic_v10.xml index 73d142019..74088036b 100644 --- a/sli/common/src/test/resources/neutron_logic_v10.xml +++ b/sli/common/src/test/resources/neutron_logic_v10.xml @@ -3,7 +3,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/common/src/test/resources/nonsense.xml b/sli/common/src/test/resources/nonsense.xml index fdcfa3467..c30c6bfc6 100644 --- a/sli/common/src/test/resources/nonsense.xml +++ b/sli/common/src/test/resources/nonsense.xml @@ -2,7 +2,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/common/src/test/resources/simplelogger.properties b/sli/common/src/test/resources/simplelogger.properties index fa22a18f2..73e4d3a99 100644 --- a/sli/common/src/test/resources/simplelogger.properties +++ b/sli/common/src/test/resources/simplelogger.properties @@ -2,7 +2,8 @@ # ============LICENSE_START======================================================= # ONAP : CCSDK # ================================================================================ -# Copyright (C) 2017 ONAP +# 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. diff --git a/sli/common/src/test/resources/svclogic.properties b/sli/common/src/test/resources/svclogic.properties index bf7469064..25eb3bd47 100644 --- a/sli/common/src/test/resources/svclogic.properties +++ b/sli/common/src/test/resources/svclogic.properties @@ -2,7 +2,8 @@ # ============LICENSE_START======================================================= # ONAP : CCSDK # ================================================================================ -# Copyright (C) 2017 ONAP +# 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. diff --git a/sli/common/src/test/resources/svclogic.sh b/sli/common/src/test/resources/svclogic.sh index 3d231a2fb..67977c3d9 100644 --- a/sli/common/src/test/resources/svclogic.sh +++ b/sli/common/src/test/resources/svclogic.sh @@ -4,7 +4,8 @@ # ============LICENSE_START======================================================= # ONAP : CCSDK # ================================================================================ -# Copyright (C) 2017 ONAP +# 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. diff --git a/sli/features/src/main/resources/features.xml b/sli/features/src/main/resources/features.xml index 6e47aee8a..fef113317 100644 --- a/sli/features/src/main/resources/features.xml +++ b/sli/features/src/main/resources/features.xml @@ -3,7 +3,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/installer/src/assembly/assemble_installer_zip.xml b/sli/installer/src/assembly/assemble_installer_zip.xml index 761142eaf..2d3c0606d 100644 --- a/sli/installer/src/assembly/assemble_installer_zip.xml +++ b/sli/installer/src/assembly/assemble_installer_zip.xml @@ -2,7 +2,8 @@ ============LICENSE_START======================================================= ONAP : CCSDK ================================================================================ - Copyright (C) 2017 ONAP + 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. diff --git a/sli/installer/src/assembly/assemble_mvnrepo_zip.xml b/sli/installer/src/assembly/assemble_mvnrepo_zip.xml index ae84fff43..a1be36792 100644 --- a/sli/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/sli/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -1,7 +1,8 @@ - - - - org.codehaus.mojo - - license-maven-plugin - - 1.10 - - - - false - - ============LICENSE_START======================================================= - - ============LICENSE_END========================================================= - - ================================================================================ - - apache_v2 - - 2017 - - AT&T Intellectual Property. All rights - reserved. - - ONAP : CCSDK - - true - - true - - true - - true - - - - - - - - first - - - - update-file-header - - - - process-sources - - - - - - - org.apache.maven.plugins -- cgit 1.2.3-korg From 6f3bb14fde75d785164c6ef3501b029c9bd145e9 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Mon, 28 Aug 2017 13:48:06 -0700 Subject: Change 2 sli/core unit tests to int. tests Change SvcLogicGraphExecutorTest and SvcLogicParserTest to IT Tests because they require outside dependencies (sql database). This change enables running jobs without skipping tests and futher enables SONAR scans of unit tests. Issue-Id: CCSDK-67 Change-Id: I74184b2f2d8cb5fcc7b065c3e2e859b85dd1630b Signed-off-by: Marcus G K Williams --- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 163 ++++++++++++++++ .../ccsdk/sli/core/sli/SvcLogicParserTest.java | 163 ---------------- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 212 +++++++++++++++++++++ .../sli/provider/SvcLogicGraphExecutorTest.java | 212 --------------------- 4 files changed, 375 insertions(+), 375 deletions(-) create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java delete mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java new file mode 100644 index 000000000..ec18b8765 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -0,0 +1,163 @@ +/*- + * ============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; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.LinkedList; + +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.SvcLogicParserException; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; + +import junit.framework.TestCase; + +/** + * @author dt5972 + * + */ +public class ITCaseSvcLogicParser extends TestCase { + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}. + */ + + + public void testParse() { + + + try + { + + URL propUrl = getClass().getResource("/svclogic.properties"); + + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + + assertNotNull(store); + + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + + + InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + String testCaseFile = null; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) + { + if (!testCaseFile.startsWith("/")) + { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) + { + fail("Could not resolve test case file "+testCaseFile); + } + + try { + SvcLogicParser.validate(testCaseUrl.getPath(), store); + } catch (Exception e) { + fail("Validation failure ["+e.getMessage()+"]"); + + } + + + + + + } + } + + testStr = getClass().getResourceAsStream("/parser-bad.tests"); + testsReader = new BufferedReader(new InputStreamReader(testStr)); + testCaseFile = null; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) + { + if (!testCaseFile.startsWith("/")) + { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) + { + fail("Could not resolve test case file "+testCaseFile); + } + + boolean valid = true; + try { + SvcLogicParser.load(testCaseUrl.getPath(), store); + } catch (Exception e) { + System.out.println(e.getMessage()); + valid = false; + } + + if (valid) { + fail("Expected compiler error on "+testCaseFile+", but got success"); + } + + + } + } + } + catch (SvcLogicParserException e) + { + fail("Parser error : "+e.getMessage()); + } + catch (Exception e) + { + e.printStackTrace(); + fail("Caught exception processing test cases"); + } + + + } + + + +} diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java deleted file mode 100644 index 687f06e76..000000000 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserTest.java +++ /dev/null @@ -1,163 +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; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.LinkedList; - -import org.onap.ccsdk.sli.core.sli.SvcLogicParser; -import org.onap.ccsdk.sli.core.sli.SvcLogicParserException; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; - -import junit.framework.TestCase; - -/** - * @author dt5972 - * - */ -public class SvcLogicParserTest extends TestCase { - - /** - * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}. - */ - - - public void testParse() { - - - try - { - - URL propUrl = getClass().getResource("/svclogic.properties"); - - InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - - assertNotNull(store); - - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); - - - InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - String testCaseFile = null; - while ((testCaseFile = testsReader.readLine()) != null) { - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) - { - if (!testCaseFile.startsWith("/")) - { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) - { - fail("Could not resolve test case file "+testCaseFile); - } - - try { - SvcLogicParser.validate(testCaseUrl.getPath(), store); - } catch (Exception e) { - fail("Validation failure ["+e.getMessage()+"]"); - - } - - - - - - } - } - - testStr = getClass().getResourceAsStream("/parser-bad.tests"); - testsReader = new BufferedReader(new InputStreamReader(testStr)); - testCaseFile = null; - while ((testCaseFile = testsReader.readLine()) != null) { - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) - { - if (!testCaseFile.startsWith("/")) - { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) - { - fail("Could not resolve test case file "+testCaseFile); - } - - boolean valid = true; - try { - SvcLogicParser.load(testCaseUrl.getPath(), store); - } catch (Exception e) { - System.out.println(e.getMessage()); - valid = false; - } - - if (valid) { - fail("Expected compiler error on "+testCaseFile+", but got success"); - } - - - } - } - } - catch (SvcLogicParserException e) - { - fail("Parser error : "+e.getMessage()); - } - catch (Exception e) - { - e.printStackTrace(); - fail("Caught exception processing test cases"); - } - - - } - - - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java new file mode 100644 index 000000000..5e895aa3e --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -0,0 +1,212 @@ +/*- + * ============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.provider; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.MetricLogger; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.provider.BlockNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.CallNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ConfigureNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.DeleteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ExistsNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ForNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.GetResourceNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.IsAvailableNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.NotifyNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.RecordNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReleaseNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReserveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReturnNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SaveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SetNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; +import org.onap.ccsdk.sli.core.sli.provider.SwitchNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.UpdateNodeExecutor; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.TestCase; + +public class ITCaseSvcLogicGraphExecutor extends TestCase { + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicGraph.class); + + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + + } + }; + + public void testExecute() { + + try { + InputStream testStr = getClass().getResourceAsStream("/executor.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + + assertNotNull(store); + + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + SvcLogicParser parser = new SvcLogicParser(store); + + // Loop through executor tests + + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); + + for (String nodeType : BUILTIN_NODES.keySet()) { + + LOG.info("SLI - registering node executor for node type "+nodeType); + + svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + + } + String testCaseLine = null; + while ((testCaseLine = testsReader.readLine()) != null) { + + String[] testCaseFields = testCaseLine.split(":"); + String testCaseFile = testCaseFields[0]; + String testCaseMethod = testCaseFields[1]; + String testCaseParameters = null; + + if (testCaseFields.length > 2) { + testCaseParameters = testCaseFields[2]; + } + + SvcLogicContext ctx = new SvcLogicContext(); + if (testCaseParameters != null) { + String[] testCaseParameterSettings = testCaseParameters.split(","); + + for (int i = 0 ; i < testCaseParameterSettings.length ; i++) { + String[] nameValue = testCaseParameterSettings[i].split("="); + if (nameValue != null) { + String name = nameValue[0]; + String value = ""; + if (nameValue.length > 1) { + value = nameValue[1]; + } + + ctx.setAttribute(name, value); + } + } + } + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) { + if (!testCaseFile.startsWith("/")) { + testCaseFile = "/"+testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) { + fail("Could not resolve test case file "+testCaseFile); + } + + LinkedList graphs = parser.parse(testCaseUrl.getPath()); + + + assertNotNull(graphs); + + for (SvcLogicGraph graph: graphs) { + if (graph.getRpc().equals(testCaseMethod)) { + Properties props = ctx.toProperties(); + LOG.info("SvcLogicContext before executing "+testCaseMethod+":"); + for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements() ; ) { + String propName = (String) e1.nextElement(); + LOG.info(propName+" = "+props.getProperty(propName)); + } + + svc.execute(graph, ctx); + + props = ctx.toProperties(); + LOG.info("SvcLogicContext after executing "+testCaseMethod+":"); + for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements() ; ) { + String propName = (String) e2.nextElement(); + LOG.info(propName+" = "+props.getProperty(propName)); + } + } + } + + } + + + } + + + } catch (Exception e) { + LOG.error("Caught exception executing directed graphs", e); + fail("Exception executing graphs"); + } + } + + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java deleted file mode 100644 index 062ba9a09..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicGraphExecutorTest.java +++ /dev/null @@ -1,212 +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.provider; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Properties; - -import org.onap.ccsdk.sli.core.sli.MetricLogger; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicParser; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.onap.ccsdk.sli.core.sli.provider.BlockNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.CallNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ConfigureNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.DeleteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ExistsNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ForNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.GetResourceNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.IsAvailableNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.NotifyNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.RecordNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReleaseNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReserveNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReturnNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SaveNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SetNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; -import org.onap.ccsdk.sli.core.sli.provider.SwitchNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.UpdateNodeExecutor; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import junit.framework.TestCase; - -public class SvcLogicGraphExecutorTest extends TestCase { - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicGraph.class); - - private static final Map BUILTIN_NODES = new HashMap() { - { - put("block", new BlockNodeExecutor()); - put("call", new CallNodeExecutor()); - put("configure", new ConfigureNodeExecutor()); - put("delete", new DeleteNodeExecutor()); - put("execute", new ExecuteNodeExecutor()); - put("exists", new ExistsNodeExecutor()); - put("for", new ForNodeExecutor()); - put("get-resource", new GetResourceNodeExecutor()); - put("is-available", new IsAvailableNodeExecutor()); - put("notify", new NotifyNodeExecutor()); - put("record", new RecordNodeExecutor()); - put("release", new ReleaseNodeExecutor()); - put("reserve", new ReserveNodeExecutor()); - put("return", new ReturnNodeExecutor()); - put("save", new SaveNodeExecutor()); - put("set", new SetNodeExecutor()); - put("switch", new SwitchNodeExecutor()); - put("update", new UpdateNodeExecutor()); - - } - }; - - public void testExecute() { - - try { - InputStream testStr = getClass().getResourceAsStream("/executor.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - - InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - - assertNotNull(store); - - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); - SvcLogicParser parser = new SvcLogicParser(store); - - // Loop through executor tests - - SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); - - for (String nodeType : BUILTIN_NODES.keySet()) { - - LOG.info("SLI - registering node executor for node type "+nodeType); - - svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); - - } - String testCaseLine = null; - while ((testCaseLine = testsReader.readLine()) != null) { - - String[] testCaseFields = testCaseLine.split(":"); - String testCaseFile = testCaseFields[0]; - String testCaseMethod = testCaseFields[1]; - String testCaseParameters = null; - - if (testCaseFields.length > 2) { - testCaseParameters = testCaseFields[2]; - } - - SvcLogicContext ctx = new SvcLogicContext(); - if (testCaseParameters != null) { - String[] testCaseParameterSettings = testCaseParameters.split(","); - - for (int i = 0 ; i < testCaseParameterSettings.length ; i++) { - String[] nameValue = testCaseParameterSettings[i].split("="); - if (nameValue != null) { - String name = nameValue[0]; - String value = ""; - if (nameValue.length > 1) { - value = nameValue[1]; - } - - ctx.setAttribute(name, value); - } - } - } - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) { - if (!testCaseFile.startsWith("/")) { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) { - fail("Could not resolve test case file "+testCaseFile); - } - - LinkedList graphs = parser.parse(testCaseUrl.getPath()); - - - assertNotNull(graphs); - - for (SvcLogicGraph graph: graphs) { - if (graph.getRpc().equals(testCaseMethod)) { - Properties props = ctx.toProperties(); - LOG.info("SvcLogicContext before executing "+testCaseMethod+":"); - for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements() ; ) { - String propName = (String) e1.nextElement(); - LOG.info(propName+" = "+props.getProperty(propName)); - } - - svc.execute(graph, ctx); - - props = ctx.toProperties(); - LOG.info("SvcLogicContext after executing "+testCaseMethod+":"); - for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements() ; ) { - String propName = (String) e2.nextElement(); - LOG.info(propName+" = "+props.getProperty(propName)); - } - } - } - - } - - - } - - - } catch (Exception e) { - LOG.error("Caught exception executing directed graphs", e); - fail("Exception executing graphs"); - } - } - - -} -- cgit 1.2.3-korg From c4d6e3619f2ec4d2b25f0ac6316892ae4b49006e Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 29 Aug 2017 08:41:38 -0400 Subject: Cleanup artifactId for ccsdk/sli/core ArtifactId for ccsdk/sli/core pom.xml should not be identical to that for sdnc/core, otherwise import to Eclipse of both will be confusing. Update parent tag in each module pom under ccsdk/sli/core to new artifactId Change-Id: Ia78a11dc4f82dfda8fd863167daa8e8f4951b6f5 Issue-ID: CCSDK-70 Signed-off-by: Dan Timoney --- dblib/pom.xml | 2 +- filters/pom.xml | 2 +- pom.xml | 2 +- sli/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliapi/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dblib/pom.xml b/dblib/pom.xml index 3138f43e2..4f26be3f4 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -2,7 +2,7 @@ org.onap.ccsdk.sli.core - sdnc-core + ccsdk-sli-core 0.1.0-SNAPSHOT diff --git a/filters/pom.xml b/filters/pom.xml index d5ff51764..f0593adb0 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core - sdnc-core + ccsdk-sli-core 0.1.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index bee5e926d..9552b685f 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 pom org.onap.ccsdk.sli.core - sdnc-core + ccsdk-sli-core SDN-C Core Components https://wiki.onap.org diff --git a/sli/pom.xml b/sli/pom.xml index 08d684d74..d74112371 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core - sdnc-core + ccsdk-sli-core 0.1.0-SNAPSHOT 4.0.0 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index ca40d6de0..561359a27 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.core - sdnc-core + ccsdk-sli-core 0.1.0-SNAPSHOT Service Logic Interface Plugin Utilities diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 6837cc04e..31f6608af 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core - sdnc-core + ccsdk-sli-core 0.1.0-SNAPSHOT -- cgit 1.2.3-korg From ba02fc8ee8afa868dda1ca6f11d3dfa293ad4cf3 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 30 Aug 2017 16:22:00 -0400 Subject: Roll version to rule out staging issue Behavior observed in the odlsli docker container suggests that it might be picking up an old build of 0.1.0-SNAPSHOT version of sli/core. We have observed this problem before due to issues with the Nexus staging plugin. This change bumps the version of sli/core to 0.1.1-SNAPSHOT and comments out the staging plugin from the sli/core pom.xml to make sure that the current build is picked up. There will be a corresponding change in ccsdk/distribution to change which version of sli/core is used in the odlsli container Change-Id: Ie3c2b4ff66191748df14240a69a7d461fc0d4639 Issue-ID: CCSDK-69 Signed-off-by: Dan Timoney --- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 2 +- version.properties | 4 ++-- 25 files changed, 32 insertions(+), 32 deletions(-) diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 3af56c129..2be6c8dbe 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT dblib-features DBLIB Adaptor - Features diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index aa68d5a6d..10845db17 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT dblib-installer DBLIB Adaptor - Karaf Installer diff --git a/dblib/pom.xml b/dblib/pom.xml index 4f26be3f4..9e1516374 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT @@ -16,7 +16,7 @@ DBLIB Adaptor The DBLIB adaptor allows service logic to access persistent data in a local sql database - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 579ab40ea..1f9a5d475 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -4,10 +4,10 @@ org.onap.ccsdk.sli.core dblib - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT dblib-provider - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT bundle DBLIB Adaptor - Provider http://maven.apache.org diff --git a/filters/features/pom.xml b/filters/features/pom.xml index baf497d49..0d71e9167 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -4,7 +4,7 @@ filters org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT filters-features Filters - Features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index ca35e3c33..1e839d93e 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT filters-installer Filters - Karaf Installer diff --git a/filters/pom.xml b/filters/pom.xml index f0593adb0..2e159c410 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT 4.0.0 @@ -16,7 +16,7 @@ Filters Servlet filter to implement ECOMP logging spec - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 0c73949ea..9f59d3463 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT filters-provider bundle diff --git a/pom.xml b/pom.xml index 9552b685f..3c01ec987 100755 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ ONAP - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT diff --git a/sli/common/pom.xml b/sli/common/pom.xml index dfec19333..52bfd53f4 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -3,7 +3,7 @@ sli org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sli-common bundle diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 5dd0d550a..975839fc0 100755 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sli-features SLI - Features diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 616c3c467..0319f5bcf 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sli-installer SLI - Karaf Installer diff --git a/sli/pom.xml b/sli/pom.xml index d74112371..b8ce1e3a0 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT 4.0.0 pom @@ -59,7 +59,7 @@ ONAP - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 7d02869fb..5ef47ef19 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sli-provider bundle diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 499181e7a..932e3ccab 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sli-recording bundle diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index b512f9ee6..ce87536df 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -8,7 +8,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT SliPluginUtils Plugin - Features diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 330891316..a92c9cd9a 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -4,7 +4,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sliPluginUtils-installer SLI Plugin Utilities - Karaf Installer diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 561359a27..5e084af8d 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT pom 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT Service Logic Interface Plugin Utilities A package of static utility functions to be used when developing SLI plugins diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index aeb86d040..1af88e829 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -8,7 +8,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT SliPluginUtils Plugin - Provider diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 63fd51a4e..531315e8d 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sliapi-features diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index b3939a6bc..249520569 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sliapi-installer pom diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index b6dcfe8bd..8fed20036 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sliapi-model bundle diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 31f6608af..64f84b9ac 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT pom org.onap.ccsdk.sli.core sliapi - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 9afbdc5fe..e679f3687 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.0-SNAPSHOT + 0.1.1-SNAPSHOT sliapi-provider bundle diff --git a/version.properties b/version.properties index f78b4bdf5..45771401d 100644 --- a/version.properties +++ b/version.properties @@ -4,9 +4,9 @@ # because they are used in Jenkins, whose plug-in doesn't support -release_name=1 +release_name=0 sprint_number=1 -feature_revision=2 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From bc1d45117a4b7bf4a224ffe2dd16e532e4f123ee Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 31 Aug 2017 15:28:01 -0400 Subject: Add missing implementation code Due to an error in .gitignore, code that is initially generated from provider yang, but then customized was not submitted to gerrit. This in turn is causing the UnsupportedOperationException seen when sliapi installs in odlsli container. Change-Id: Iceec13b59e5e2bd6f0b868b548d300b76c7f7a38 Issue-ID: CCSDK-69 Signed-off-by: Dan Timoney --- .gitignore | 2 - .../impl/rev140523/SliapiProviderModule.java | 64 ++++++++++++++++++++++ .../rev140523/SliapiProviderModuleFactory.java | 34 ++++++++++++ 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModule.java create mode 100644 sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java diff --git a/.gitignore b/.gitignore index 418ae91ba..319e695b1 100755 --- a/.gitignore +++ b/.gitignore @@ -43,5 +43,3 @@ sdnc-core_bdio.jsonld blackDuckHubProjectName.txt blackDuckHubProjectVersionName.txt -# Yang-generated Java -**/src/main/java/org/opendaylight/ diff --git a/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModule.java b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModule.java new file mode 100644 index 000000000..e7444e318 --- /dev/null +++ b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModule.java @@ -0,0 +1,64 @@ +/*- + * ============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.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523; + +import org.onap.ccsdk.sli.core.sliapi.sliapiProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SliapiProviderModule extends org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523.AbstractSliapiProviderModule { + private final Logger LOG = LoggerFactory.getLogger( SliapiProviderModule.class ); + + public SliapiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public SliapiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523.SliapiProviderModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + + LOG.info("Calling SliapiProviderModule.createInstance"); + final sliapiProvider provider = new sliapiProvider(); + provider.setDataBroker( getDataBrokerDependency() ); + provider.setNotificationService( getNotificationServiceDependency() ); + provider.setRpcRegistry( getRpcRegistryDependency() ); + provider.initialize(); + return new AutoCloseable() { + + @Override + public void close() throws Exception { + //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION + //SERVIE/RPC REGISTRY + provider.close(); + } + }; + } + +} diff --git a/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java new file mode 100644 index 000000000..6454d17c4 --- /dev/null +++ b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java @@ -0,0 +1,34 @@ +/*- + * ============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========================================================= + */ + +/* +* Generated file +* +* Generated from: yang module name: sliapi-provider-impl yang module local name: sliapi-provider-impl +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Thu Aug 03 16:10:18 EDT 2017 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523; +public class SliapiProviderModuleFactory extends org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523.AbstractSliapiProviderModuleFactory { + +} -- cgit 1.2.3-korg From 18ba1ed88d0d88a8d72c47702e00477eabb94a4b Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Fri, 1 Sep 2017 14:56:46 -0700 Subject: Update mvn name in POM to CCSDK Issue-Id: CCSDK-67 Change-Id: Ie0413cd3099cdebac81b0586789354a1c98d0a31 Signed-off-by: Marcus G K Williams --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9552b685f..94a2810e6 100755 --- a/pom.xml +++ b/pom.xml @@ -6,9 +6,9 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - SDN-C Core Components + CCSDK Core Components https://wiki.onap.org - The SDN-C core components contains the SLI, dblib and root pom + CCSDK core components contains the SLI, dblib org.onap.ccsdk.parent -- cgit 1.2.3-korg From af22e3dbddd5b372e815970ff43cc73e29135218 Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Thu, 17 Aug 2017 16:15:39 -0400 Subject: Fix service registration for SDNC Addresses the inherit race conditions associated with the BundleActivator abstraction. From lessons learned in OpenDaylight project, dependency injection and service injection via Aries Blueprint is faster, more deterministic, and has better error messaging than using BundleActivator(s). This change addresses several aspects: 1) DBLIBResourceActivator is changed to DBLIBResourceProvider. This was done in order to imply that this is no longer an Activator or subclass of an Activator. The class is a POJO. 2) DBLIBResourceProvider is split from a single monolithic method into several more manageable and better documented methods. 3) Documentation surrounding the resolution of the DB properties is added so that a developer can more easily identify the strategy (priority) used for resolving properties. 4) dblib-blueprint.xml is added. This is used to register the configuration bean (DBLIBResourceProvider), and pass it as an argument to the actual Service (DBLIBResourceManager). 5) Tests are added to test the functionality and resolution of the properties file loading. Issue-Id: SDNC-54 Change-Id: Ie9d5fb423ae7a67e9aec026c78321537399cc308 Signed-off-by: Ryan Goulding --- dblib/provider/pom.xml | 13 +- .../sli/core/dblib/DBLIBResourceActivator.java | 130 ---------------- .../sli/core/dblib/DBLIBResourceProvider.java | 164 +++++++++++++++++++++ .../ccsdk/sli/core/dblib/DBResourceManager.java | 83 ++++++----- .../DblibDefaultFileResolver.java | 63 ++++++++ .../DblibEnvVarFileResolver.java | 68 +++++++++ .../DblibJREFileResolver.java | 73 +++++++++ .../DblibKarafRootFileResolver.java | 64 ++++++++ .../DblibPropertiesFileResolver.java | 45 ++++++ .../org/opendaylight/blueprint/dblib-blueprint.xml | 13 ++ .../DblibDefaultFileResolverTest.java | 24 +++ .../DblibEnvVarFileResolverTest.java | 23 +++ .../DblibJREFileResolverTest.java | 17 +++ .../DblibKarafRootFileResolverTest.java | 14 ++ .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 2 +- 15 files changed, 621 insertions(+), 175 deletions(-) delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceActivator.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolver.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolver.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolver.java create mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibPropertiesFileResolver.java create mode 100644 dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml create mode 100644 dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java create mode 100644 dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java create mode 100644 dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java create mode 100644 dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 1f9a5d475..11e0ff748 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -52,6 +52,17 @@ tomcat-jdbc ${tomcat-jdbc.version} + + com.google.guava + guava + + + + + org.mockito + mockito-core + test + @@ -64,9 +75,7 @@ org.onap.ccsdk.sli.core.dblib - org.onap.ccsdk.sli.core.dblib.DBLIBResourceActivator org.onap.ccsdk.sli.core.dblib;version=${project.version} - * true diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceActivator.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceActivator.java deleted file mode 100644 index 8ae9a2665..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceActivator.java +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib; - -import java.io.File; -import java.net.URL; -import java.util.Properties; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DBLIBResourceActivator implements BundleActivator { - - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - - private static final String DBLIB_PROP_PATH = "/dblib.properties"; - - private ServiceRegistration registration = null; - - private static final Logger LOG = LoggerFactory.getLogger(DBLIBResourceActivator.class); - - @Override - public void start(BundleContext ctx) throws Exception { - LOG.info("entering DBLIBResourceActivator.start"); - - DbLibService jdbcDataSource = null; - // Read properties - Properties props = new Properties(); - - File file = null; - URL propURL = null; - String propDir = System.getenv(SDNC_CONFIG_DIR); - if ((propDir == null) || (propDir.length() == 0)) { - propDir = "/opt/sdnc/data/properties"; - } - file = new File(propDir + DBLIB_PROP_PATH); - if(file.exists()) { - propURL = file.toURI().toURL(); - LOG.info("Using property file (1): " + file.toString()); - } else { - propURL = ctx.getBundle().getResource("dblib.properties"); - URL tmp = null; - if (propURL == null) { - file = new File(DBLIB_PROP_PATH); - tmp = this.getClass().getResource(DBLIB_PROP_PATH); -// if(!file.exists()) { - if(tmp == null) { - throw new DblibConfigurationException("Missing configuration properties resource(3) : " + DBLIB_PROP_PATH); - } else { - propURL = tmp; //file.toURI().toURL(); - LOG.info("Using property file (4): " + file.toString()); - } - } else { - LOG.info("Using property file (2): " + propURL.toString()); - } - } - - - try { - props.load(propURL.openStream()); - } catch (Exception e) { - throw new DblibConfigurationException("Could not load properties at URL " + propURL.toString(), e); - - } - - - - try { - jdbcDataSource = DBResourceManager.create(props); - } catch (Exception exc) { - throw new DblibConfigurationException("Could not get initialize database", exc); - } - - String regName = jdbcDataSource.getClass().getName(); - - LOG.info("Registering DBResourceManager service "+regName); - registration = ctx.registerService(new String[] { regName, DbLibService.class.getName(), "javax.sql.DataSource" }, jdbcDataSource, null); - } - - @Override - public void stop(BundleContext ctx) throws Exception { - LOG.info("entering DBLIBResourceActivator.stop"); - if (registration != null) - { - try { - ServiceReference sref = ctx.getServiceReference(DbLibService.class.getName()); - - if (sref == null) { - LOG.warn("Could not find service reference for DBLIB service (" + DbLibService.class.getName() + ")"); - } else { - DBResourceManager dblibSvc = (DBResourceManager) ctx.getService(sref); - if (dblibSvc == null) { - LOG.warn("Could not find service reference for DBLIB service (" + DbLibService.class.getName() + ")"); - } else { - dblibSvc.cleanUp(); - } - } - } catch(Throwable exc) { - LOG.warn("Cleanup", exc); - } - - registration.unregister(); - registration = null; - LOG.debug("Deregistering DBResourceManager service"); - } - } - -} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java new file mode 100644 index 000000000..201cc4019 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java @@ -0,0 +1,164 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import com.google.common.annotations.VisibleForTesting; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Optional; +import java.util.Properties; +import java.util.Vector; + +import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibDefaultFileResolver; +import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibEnvVarFileResolver; +import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibJREFileResolver; +import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibKarafRootFileResolver; +import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibPropertiesFileResolver; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Responsible for determining the properties file to use and instantiating the DBResourceManager + * Service. The priority for properties file resolution is as follows: + * + *

    + *
  1. A directory identified by the system environment variable SDNC_CONFIG_DIR
  2. + *
  3. The default directory DEFAULT_DBLIB_PROP_DIR
  4. + *
  5. A directory identified by the JRE argument dblib.properties
  6. + *
  7. A dblib.properties file located in the karaf root directory
  8. + *
+ */ +public class DBLIBResourceProvider { + + private static final Logger LOG = LoggerFactory.getLogger(DBLIBResourceProvider.class); + + /** + * The name of the properties file for database configuration + */ + private static final String DBLIB_PROP_FILE_NAME = "dblib.properties"; + + /** + * A prioritized list of strategies for resolving dblib properties files. + */ + private Vector dblibPropertiesFileResolvers = new Vector(); + + /** + * The configuration properties for the db connection. + */ + private Properties properties; + + /** + * Set up the prioritized list of strategies for resolving dblib properties files. + */ + public DBLIBResourceProvider() { + dblibPropertiesFileResolvers.add(new DblibEnvVarFileResolver( + "Using property file (1) from environment variable" + )); + dblibPropertiesFileResolvers.add(new DblibDefaultFileResolver( + "Using property file (1) from default directory" + )); + dblibPropertiesFileResolvers.add(new DblibJREFileResolver( + "Using property file (2) from JRE argument" + )); + dblibPropertiesFileResolvers.add(new DblibKarafRootFileResolver( + "Using property file (4) from karaf root", this)); + + // determines properties file as according to the priority described in the class header comment + final File propertiesFile = determinePropertiesFile(this); + if (propertiesFile != null) { + try { + final FileInputStream fileInputStream = new FileInputStream(propertiesFile); + properties = new Properties(); + properties.load(fileInputStream); + } catch (final IOException e) { + LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), + new DblibConfigurationException("Failed to load properties for file: " + + propertiesFile.toString(), e)); + } + } + } + + /** + * Extract db config properties. + * + * @return the db config properties + */ + public Properties getProperties() { + return properties; + } + + /** + * Reports the method chosen for properties resolution to the Logger. + * + * @param message Some user friendly message + * @param fileOptional The file location of the chosen properties file + * @return the file location of the chosen properties file + */ + private static File reportSuccess(final String message, final Optional fileOptional) { + final File file = fileOptional.get(); + LOG.info("{} {}", message, file.getPath()); + return file; + } + + /** + * Reports fatal errors. This is the case in which no properties file could be found. + * + * @param message An appropriate fatal error message + * @param dblibConfigurationException An exception describing what went wrong during resolution + */ + private static void reportFailure(final String message, + final DblibConfigurationException dblibConfigurationException) { + + LOG.error("{}", message, dblibConfigurationException); + } + + /** + * Determines the dblib properties file to use based on the following priority: + *
    + *
  1. A directory identified by the system environment variable SDNC_CONFIG_DIR
  2. + *
  3. The default directory DEFAULT_DBLIB_PROP_DIR
  4. + *
  5. A directory identified by the JRE argument dblib.properties
  6. + *
  7. A dblib.properties file located in the karaf root directory
  8. + *
+ */ + @VisibleForTesting + File determinePropertiesFile(final DBLIBResourceProvider dblibResourceProvider) { + + for (final DblibPropertiesFileResolver dblibPropertiesFileResolver : dblibPropertiesFileResolvers) { + final Optional fileOptional = dblibPropertiesFileResolver.resolveFile(DBLIB_PROP_FILE_NAME); + if (fileOptional.isPresent()) { + return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); + } + } + + reportFailure("Missing configuration properties resource(3)", + new DblibConfigurationException("Missing configuration properties resource(3): " + + DBLIB_PROP_FILE_NAME)); + return null; + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 78b970bf5..46c003a5a 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -105,67 +105,72 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb protected final long expectedCompletionTime; protected final long unprocessedFailoverThreshold; - public DBResourceManager(Properties props){ - this.configProps = props; + public DBResourceManager(final DBLIBResourceProvider configuration) { + this(configuration.getProperties()); + } + + public DBResourceManager(final Properties properties) { + this.configProps = properties; // get retry interval value - retryInterval = getLongFromProperties(props, "org.onap.dblib.connection.retry", 10000L); + retryInterval = getLongFromProperties(properties, "org.onap.dblib.connection.retry", 10000L); // get recovery mode flag - recoveryMode = getBooleanFromProperties(props, "org.onap.dblib.connection.recovery", true); + recoveryMode = getBooleanFromProperties(properties, "org.onap.dblib.connection.recovery", true); if(!recoveryMode) { recoveryMode = false; LOGGER.info("Recovery Mode disabled"); } // get time out value for thread cleanup - terminationTimeOut = getLongFromProperties(props, "org.onap.dblib.termination.timeout", 300000L); + terminationTimeOut = getLongFromProperties(properties, "org.onap.dblib.termination.timeout", 300000L); // get properties for monitoring - monitorDbResponse = getBooleanFromProperties(props, "org.onap.dblib.connection.monitor", false); - monitoringInterval = getLongFromProperties(props, "org.onap.dblib.connection.monitor.interval", 1000L); - monitoringInitialDelay = getLongFromProperties(props, "org.onap.dblib.connection.monitor.startdelay", 5000L); - expectedCompletionTime = getLongFromProperties(props, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); - unprocessedFailoverThreshold = getLongFromProperties(props, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); + monitorDbResponse = getBooleanFromProperties(properties, "org.onap.dblib.connection.monitor", false); + monitoringInterval = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.interval", 1000L); + monitoringInitialDelay = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.startdelay", 5000L); + expectedCompletionTime = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); + unprocessedFailoverThreshold = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); // initialize performance monitor - PollingWorker.createInistance(props); + PollingWorker.createInistance(properties); // initialize recovery thread worker = new RecoveryMgr(); worker.setName("DBResourcemanagerWatchThread"); worker.setDaemon(true); worker.start(); + + try { + this.config(properties); + } catch (final Exception e) { + // TODO: config throws Exception which is poor practice. Eliminate this in a separate patch. + LOGGER.error("Fatal Exception encountered while configuring DBResourceManager", e); + } } - private void config(Properties ctx) throws Exception { + private void config(Properties configProps) throws Exception { - DbConfigPool dbConfig = DBConfigFactory.createConfig(this.configProps); + final DbConfigPool dbConfig = DBConfigFactory.createConfig(configProps); + final AbstractResourceManagerFactory factory = + AbstractDBResourceManagerFactory.getFactory(dbConfig.getType()); + LOGGER.info("Default DB config is : {}", dbConfig.getType()); + LOGGER.info("Using factory : {}", factory.getClass().getName()); - try { - AbstractResourceManagerFactory factory = AbstractDBResourceManagerFactory.getFactory(dbConfig.getType()); - if(LOGGER.isInfoEnabled()){ - LOGGER.info("Default DB config is : " + dbConfig.getType()); - LOGGER.info("Using factory : " + factory.getClass().getName()); - } - CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, this); - if(cachedDS == null || cachedDS.length == 0) { - LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); - throw new Exception("Failed to initialize DB Library. No data source was created."); - } + final CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, this); + if (cachedDS == null || cachedDS.length == 0) { + LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); + throw new Exception("Failed to initialize DB Library. No data source was created."); + } - for(int i=0; i/opt/sdnc/data/properties + */ +public class DblibDefaultFileResolver implements DblibPropertiesFileResolver { + + /** + * Default path to look for the configuration directory + */ + private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("opt", "sdnc", "data", "properties"); + + private final String successMessage; + + public DblibDefaultFileResolver(final String successMessage) { + this.successMessage = successMessage; + } + + /** + * Parse a properties file location based on the default properties location + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String dblibFileName) { + final File fileFromDefaultDblibDir = DEFAULT_DBLIB_PROP_DIR.resolve(dblibFileName).toFile(); + if (fileFromDefaultDblibDir.exists()) { + Optional.of(fileFromDefaultDblibDir); + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java new file mode 100644 index 000000000..17c42ec83 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.propertiesfileresolver; + +import com.google.common.base.Strings; +import java.io.File; +import java.nio.file.Paths; +import java.util.Optional; + +/** + * Resolves dblib properties files relative to the directory identified by the SDNC_CONFIG_DIR + * environment variable. + */ +public class DblibEnvVarFileResolver implements DblibPropertiesFileResolver { + + /** + * Key for environment variable representing the configuration directory + */ + private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; + + private final String successMessage; + + public DblibEnvVarFileResolver(final String successMessage) { + this.successMessage = successMessage; + } + + /** + * Parse a properties file location based on System environment variable + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String dblibFileName) { + // attempt to resolve the property directory from the corresponding environment variable + final String propDirectoryFromEnvVariable = System.getenv(SDNC_CONFIG_DIR_PROP_KEY); + final File fileFromEnvVariable; + if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { + fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(dblibFileName).toFile(); + if(fileFromEnvVariable.exists()) { + return Optional.of(fileFromEnvVariable); + } + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolver.java new file mode 100644 index 000000000..673ccbf03 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolver.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.propertiesfileresolver; + +import java.io.File; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; +import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProvider; +import org.osgi.framework.FrameworkUtil; + +/** + * Resolves dblib properties files relative to the directory identified by the JRE property + * dblib.properties. + */ +public class DblibJREFileResolver implements DblibPropertiesFileResolver { + + /** + * Key for JRE argument representing the configuration directory + */ + private static final String DBLIB_JRE_PROPERTY_KEY = "dblib.properties"; + + private final String successMessage; + + public DblibJREFileResolver(final String successMessage) { + this.successMessage = successMessage; + } + + /** + * Parse a properties file location based on JRE argument + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String dblibFileName) { + final URL jreArgumentUrl = FrameworkUtil.getBundle(DBLIBResourceProvider.class) + .getResource(DBLIB_JRE_PROPERTY_KEY); + try { + if (jreArgumentUrl == null) { + return Optional.empty(); + } + final Path dblibPath = Paths.get(jreArgumentUrl.toURI()); + return Optional.of(dblibPath.resolve(dblibFileName).toFile()); + } catch(final URISyntaxException e) { + return Optional.empty(); + } + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolver.java new file mode 100644 index 000000000..d2b164e3b --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolver.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.propertiesfileresolver; + +import java.io.File; +import java.net.URL; +import java.util.Optional; +import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProvider; + +/** + * Resolves dblib properties files relative to the karaf root directory. + */ +public class DblibKarafRootFileResolver implements DblibPropertiesFileResolver { + + final DBLIBResourceProvider dblibResourceProvider; + + private final String successMessage; + + public DblibKarafRootFileResolver(final String successMessage, final DBLIBResourceProvider dblibResourceProvider) { + this.successMessage = successMessage; + this.dblibResourceProvider = dblibResourceProvider; + } + + /** + * Parse a properties file location relative to the karaf root + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String dblibFileName) { + final URL fromKarafRoot = dblibResourceProvider.getClass().getResource(dblibFileName); + if (fromKarafRoot != null) { + final File propertiesFile = new File(fromKarafRoot.getFile()); + if (propertiesFile.exists()) { + return Optional.of(propertiesFile); + } + return Optional.empty(); + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibPropertiesFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibPropertiesFileResolver.java new file mode 100644 index 000000000..97ab08acf --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibPropertiesFileResolver.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.propertiesfileresolver; + +import java.io.File; +import java.util.Optional; + +/** + * Strategy for resolving dblib properties. + */ +public interface DblibPropertiesFileResolver { + + /** + * Resolve dblib properties file. + * + * @param dblibFileName the name of the file to look for at the specific location. + * @return An optional File or empty. + */ + Optional resolveFile(final String dblibFileName); + + /** + * A success message, used only for logging now. + * + * @return a success message, used only for logging now. + */ + String getSuccessfulResolutionMessage(); +} diff --git a/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml b/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml new file mode 100644 index 000000000..ee3e0f033 --- /dev/null +++ b/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java new file mode 100644 index 000000000..41011e55b --- /dev/null +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; + +public class DblibDefaultFileResolverTest { + + @Test + public void resolveFile() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java new file mode 100644 index 000000000..775898930 --- /dev/null +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java @@ -0,0 +1,23 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; + +public class DblibEnvVarFileResolverTest { + @Test + public void resolveFile() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java new file mode 100644 index 000000000..117492d0b --- /dev/null +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java @@ -0,0 +1,17 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; + +public class DblibJREFileResolverTest { + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibJREFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java new file mode 100644 index 000000000..0a032e8b7 --- /dev/null +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class DblibKarafRootFileResolverTest { + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibKarafRootFileResolver("success", null); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 2aed6511d..de3682d8a 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -498,7 +498,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { } try { - dblibSvc = DBResourceManager.create(dblibProps); + dblibSvc = new DBResourceManager(dblibProps); JavaSingleton.setInstance(dblibSvc); } catch (Exception e) { LOG.warn("Caught exception trying to create DBResourceManager", e); -- cgit 1.2.3-korg From 21788cc75a85a6e7b2097c5549957a38178a9197 Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Wed, 6 Sep 2017 11:47:00 -0400 Subject: Fix service registration for SDNC sliPluginUtils was using a BundleActivator for Service Instantiation, which is prone to heisenbugs due to indeterminate service instantiation logic. This removes the BundleActivator and instantiates services using blueprint. Since dme2.properties are parsed using Properties instead of using a ManagedService, the decision was to just keep them immutable. Future work may involve making instance variables private in DME2, since currently Dme2Test performs direct member access on DME2 instance variables which is considered bad practices (violates encapsulation). Issue-Id: SDNC-54 Change-Id: Ib1155565e04e9a95d222bc4028a0845d9d81bd82 Signed-off-by: Ryan Goulding --- sliPluginUtils/provider/pom.xml | 1 - .../onap/ccsdk/sli/core/slipluginutils/DME2.java | 49 ++++- .../slipluginutils/Dme2PropertiesProvider.java | 223 +++++++++++++++++++++ .../sli/core/slipluginutils/SliPluginUtils.java | 2 - .../slipluginutils/SliPluginUtilsActivator.java | 95 --------- .../blueprint/slipluginutils-blueprint.xml | 19 ++ .../ccsdk/sli/core/slipluginutils/Dme2Test.java | 10 +- 7 files changed, 290 insertions(+), 109 deletions(-) create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java create mode 100644 sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 1af88e829..430221fcb 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -70,7 +70,6 @@ org.onap.ccsdk.sli.core.slipluginutils - org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtilsActivator org.onap.ccsdk.sli.core.slipluginutils org.onap.ccsdk.sli.core.*,org.osgi.framework.*,org.slf4j.*,java.net.* *;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mysql-connector-java|slf4j-api|jcl-over-slf4j diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java index 105ae9545..326490d9d 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java @@ -23,6 +23,7 @@ package org.onap.ccsdk.sli.core.slipluginutils; import java.util.Map; +import java.util.Optional; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -35,16 +36,19 @@ import org.slf4j.LoggerFactory; * A SvcLogicJavaPlugin that generates DME2 proxy urls using parameters from context memory. */ public class DME2 implements SvcLogicJavaPlugin { - String aafUserName; - String aafPassword; - String envContext; - String routeOffer; - String[] proxyUrls; + + private static final Logger LOG = LoggerFactory.getLogger(DME2.class); + + final String aafUserName; + final String aafPassword; + final String envContext; + final String routeOffer; + final String[] proxyUrls; + final String commonServiceVersion; + Integer index; - String commonServiceVersion; String partner; - private static final Logger LOG = LoggerFactory.getLogger(DME2.class); public void setPartner(String partner) { if (partner != null && partner.length() > 0) { @@ -62,6 +66,37 @@ public class DME2 implements SvcLogicJavaPlugin { this.commonServiceVersion = commonServiceVersion; } + public DME2(final Dme2PropertiesProvider provider) { + this.aafUserName = useProperty(provider.getAafUsername(), Dme2PropertiesProvider.AAF_USERNAME_KEY); + this.aafPassword = useProperty(provider.getAafPassword(), Dme2PropertiesProvider.AAF_PASSWORD_KEY); + this.envContext = useProperty(provider.getEnvContext(), Dme2PropertiesProvider.ENV_CONTEXT_KEY); + this.routeOffer = useProperty(provider.getRouteOffer(), Dme2PropertiesProvider.ROUTE_OFFER_KEY); + this.index = 0; + this.commonServiceVersion = useProperty(provider.getCommonServiceVersion(), + Dme2PropertiesProvider.COMMON_SERVICE_VERSION_KEY); + + final Optional maybeProxyUrls = provider.getProxyUrls(); + if (maybeProxyUrls.isPresent()) { + this.proxyUrls = maybeProxyUrls.get(); + } else { + warnOfMissingProperty(Dme2PropertiesProvider.PROXY_URL_KEY); + this.proxyUrls = null; + } + this.setPartner(useProperty(provider.getPartner(), Dme2PropertiesProvider.PARTNER_KEY)); + } + + private String useProperty(final Optional propertyOptional, final String propertyKey) { + if (propertyOptional.isPresent()) { + return propertyOptional.get(); + } + warnOfMissingProperty(propertyKey); + return null; + } + + private void warnOfMissingProperty(final String propertyName) { + LOG.warn("Utilizing null for {} since it was left unassigned in the properties file"); + } + // constructs a URL to contact the proxy which contacts a DME2 service public String constructUrl(String service, String version, String subContext) { StringBuilder sb = new StringBuilder(); diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java new file mode 100644 index 000000000..519614916 --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java @@ -0,0 +1,223 @@ +/*- + * ============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.slipluginutils; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Strings; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Immutable properties container for dme2 properties. Since the initial design decision was made to + * utilize Properties instead of an OSGi ManagedService, it was decided + * to make these properties immutable. + */ +public final class Dme2PropertiesProvider { + + private static final Logger LOG = LoggerFactory.getLogger(Dme2PropertiesProvider.class); + + /** + * The name of the environment variable to specify the configuration directory. + */ + private static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR"; + + /** + * the dme2 properties file name. + */ + private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; + + /** + * the key for proxyUrl, which represents a CSV list of urls + */ + static final String PROXY_URL_KEY = "proxyUrl"; + + /** + * indicates that proxy urls are separated by commas + */ + private static final String PROXY_URLS_VALUE_SEPARATOR = ","; + + /** + * the key for aafUsername + */ + static final String AAF_USERNAME_KEY = "aafUsername"; + + /** + * the key for aafPassword + */ + static final String AAF_PASSWORD_KEY = "aafPassword"; + + /** + * the key for envContext + */ + static final String ENV_CONTEXT_KEY = "envContext"; + + /** + * the key for routeOffer + */ + static final String ROUTE_OFFER_KEY = "routeOffer"; + + /** + * the key for commonServiceVersion + */ + static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; + + /** + * the key for partner + */ + static final String PARTNER_KEY = "partner"; + + private Optional proxyUrls = Optional.empty(); + + private Optional aafUsername = Optional.empty(); + + private Optional aafPassword = Optional.empty(); + + private Optional envContext = Optional.empty(); + + private Optional routeOffer = Optional.empty(); + + private Optional commonServiceVersion = Optional.empty(); + + private Optional partner = Optional.empty(); + + + /** + * Instantiates the properties provider, which involves loading the appropriate properties for dme2. + */ + public Dme2PropertiesProvider() { + this(getDme2Path(SDNC_ROOT_DIR_ENV_VAR_KEY, DME2_PROPERTIES_FILE_NAME).toString()); + } + + /** + * Instantiates the properties provider, which involves loading the appropriate properties for dme2. + * + * @param dme2Path location of the dme2.properties file + */ + @VisibleForTesting + Dme2PropertiesProvider(final String dme2Path) { + final Properties properties; + try { + properties = getProperties(dme2Path); + this.proxyUrls = getProxyUrls(properties); + this.aafUsername = getAafUsername(properties); + this.aafPassword = getAafPassword(properties); + this.envContext = getEnvContext(properties); + this.routeOffer = getRouteOffer(properties); + this.commonServiceVersion = getCommonServiceVersion(properties); + this.partner = getPartner(properties); + } catch (final FileNotFoundException e) { + LOG.error("dme2.properties file could not be found at path: {}", dme2Path, e); + } catch (final IOException e) { + LOG.error("fatal error reading dme2.properties at path: {}", dme2Path, e); + } + } + + private static Path getDme2Path(final String sdncRootDirectory, final String dme2Filename) { + return Paths.get(sdncRootDirectory, dme2Filename); + } + + private static Properties getProperties(final String dme2Path) throws IOException { + final File dme2File = new File(dme2Path); + final Properties properties = new Properties(); + properties.load(new FileReader(dme2File)); + return properties; + } + + private String getProxyUrl(final Properties properties) { + return properties.getProperty(PROXY_URL_KEY); + } + + private Optional getProxyUrls(final Properties properties) { + final String proxyUrlsValue = getProxyUrl(properties); + if (!Strings.isNullOrEmpty(proxyUrlsValue)) { + return Optional.ofNullable(proxyUrlsValue.split(PROXY_URLS_VALUE_SEPARATOR)); + } + return Optional.empty(); + } + + public Optional getProxyUrls() { + return this.proxyUrls; + } + + private Optional getAafUsername(final Properties properties) { + final String aafUsernameValue = properties.getProperty(AAF_USERNAME_KEY); + return Optional.ofNullable(aafUsernameValue); + } + + Optional getAafUsername() { + return this.aafUsername; + } + + private Optional getAafPassword(final Properties properties) { + final String aafPassword = properties.getProperty(AAF_PASSWORD_KEY); + return Optional.ofNullable(aafPassword); + } + + Optional getAafPassword() { + return this.aafPassword; + } + + private Optional getEnvContext(final Properties properties) { + final String envContext = properties.getProperty(ENV_CONTEXT_KEY); + return Optional.ofNullable(envContext); + } + + Optional getEnvContext() { + return this.envContext; + } + + private Optional getRouteOffer(final Properties properties) { + final String routeOffer = properties.getProperty(ROUTE_OFFER_KEY); + return Optional.ofNullable(routeOffer); + } + + Optional getRouteOffer() { + return this.routeOffer; + } + + private Optional getCommonServiceVersion(final Properties properties) { + final String commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY); + return Optional.ofNullable(commonServiceVersion); + } + + Optional getCommonServiceVersion() { + return this.commonServiceVersion; + } + + private Optional getPartner(final Properties properties) { + final String partner = properties.getProperty(PARTNER_KEY); + return Optional.ofNullable(partner); + } + + Optional getPartner() { + return this.partner; + } +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 8a2aa6d69..e6811e789 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -60,8 +60,6 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { public SliPluginUtils() {} - public SliPluginUtils( Properties props ) {} - // ========== CONTEXT MEMORY FUNCTIONS ========== diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java deleted file mode 100644 index 89eb4f23b..000000000 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtilsActivator.java +++ /dev/null @@ -1,95 +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.slipluginutils; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SliPluginUtilsActivator implements BundleActivator { - @SuppressWarnings("rawtypes") private List registrations = new LinkedList(); - - private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtilsActivator.class); - private static final String SDNC_ROOT_DIR = "SDNC_CONFIG_DIR"; - private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; - - @Override - public void start(BundleContext ctx) throws Exception { - SliPluginUtils plugin = new SliPluginUtils(new Properties()); - LOG.info("Registering service " + plugin.getClass().getName()); - registrations.add(ctx.registerService(plugin.getClass().getName(), plugin, null)); - - SliStringUtils sliStringUtils_Plugin = new SliStringUtils(); - LOG.info("Registering service " + sliStringUtils_Plugin.getClass().getName()); - registrations.add(ctx.registerService(sliStringUtils_Plugin.getClass().getName(), sliStringUtils_Plugin, null)); - - try { - String path = System.getenv(SDNC_ROOT_DIR) + File.separator + DME2_PROPERTIES_FILE_NAME; - DME2 dmePlugin = initDme2(path); - if (dmePlugin != null) { - LOG.info("Registering service " + dmePlugin.getClass().getName()); - registrations.add(ctx.registerService(dmePlugin.getClass().getName(), dmePlugin, null)); - } - } catch (Exception e) { - LOG.error("DME2 plugin could not be started", e); - } - } - - public DME2 initDme2(String pathToDmeProperties) { - Properties dme2properties = new Properties(); - String loadPropertiesErrorMessage = "Couldn't load DME2 properties at path " + pathToDmeProperties; - File dme2propertiesFile = new File(pathToDmeProperties); - - try { - dme2properties.load(new FileReader(dme2propertiesFile)); - String proxyUrlProperty = dme2properties.getProperty("proxyUrl"); - String[] proxyUrls = proxyUrlProperty.split(","); - DME2 dmePlugin = new DME2(dme2properties.getProperty("aafUserName"), dme2properties.getProperty("aafPassword"), dme2properties.getProperty("envContext"), dme2properties.getProperty("routeOffer"), proxyUrls, dme2properties.getProperty("commonServiceVersion")); - dmePlugin.setPartner(dme2properties.getProperty("partner")); - return dmePlugin; - } catch (FileNotFoundException e) { - LOG.error(loadPropertiesErrorMessage); - } catch (IOException e) { - LOG.error(loadPropertiesErrorMessage); - } - LOG.error("Couldn't create DME2 plugin"); - return null; - } - - @Override - public void stop(BundleContext ctx) throws Exception { - for (@SuppressWarnings("rawtypes") ServiceRegistration registration : registrations) { - registration.unregister(); - registration = null; - } - } -} diff --git a/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml b/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml new file mode 100644 index 000000000..c0952d2a2 --- /dev/null +++ b/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java index 48c32f452..ab681ad25 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java @@ -72,8 +72,9 @@ public class Dme2Test { @Test public void createDme2EndtoEnd() { - SliPluginUtilsActivator activator = new SliPluginUtilsActivator(); - DME2 dme2 = activator.initDme2("src/test/resources/dme2.e2e.properties"); + Dme2PropertiesProvider provider = + new Dme2PropertiesProvider("src/test/resources/dme2.e2e.properties"); + DME2 dme2 = new DME2(provider); assertEquals("user@sample.com", dme2.aafUserName); assertEquals("fake", dme2.aafPassword); assertEquals("UAT", dme2.envContext); @@ -89,8 +90,9 @@ public class Dme2Test { @Test public void createDme2Prod() { - SliPluginUtilsActivator activator = new SliPluginUtilsActivator(); - DME2 dme2 = activator.initDme2("src/test/resources/dme2.prod.properties"); + Dme2PropertiesProvider provider = + new Dme2PropertiesProvider("src/test/resources/dme2.prod.properties"); + DME2 dme2 = new DME2(provider); assertEquals("user@sample.com", dme2.aafUserName); assertEquals("fake", dme2.aafPassword); assertEquals("PROD", dme2.envContext); -- cgit 1.2.3-korg From 4ca4e0d5b321d3f4f321b49df02498d66b547d11 Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Wed, 6 Sep 2017 12:03:51 -0400 Subject: Fix SDNC service registration Convert the BundleActivator to a POJO provider, and do the service registration through blueprint instead. Issue-Id: SDNC-54 Change-Id: Ia5618ef443967803b31da1ac9e020d1092c3ab8d Signed-off-by: Ryan Goulding --- filters/provider/pom.xml | 1 - .../org/onap/ccsdk/sli/core/filters/Activator.java | 63 ---------------------- .../ccsdk/sli/core/filters/FiltersService.java | 4 ++ .../ccsdk/sli/core/filters/FiltersServiceImpl.java | 33 ++++++++++++ .../opendaylight/blueprint/filters-blueprint.xml | 9 ++++ 5 files changed, 46 insertions(+), 64 deletions(-) delete mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java create mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersService.java create mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersServiceImpl.java create mode 100644 filters/provider/src/main/resources/org/opendaylight/blueprint/filters-blueprint.xml diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 9f59d3463..240966e8b 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -73,7 +73,6 @@ org.onap.ccsdk.sli.core.filters - org.onap.ccsdk.sli.core.filters.Activator org.onap.ccsdk.sli.core.filters org.onap.ccsdk.sli.core.filters javax.servlet.*,java.io.*,org.osgi.framework.*,org.slf4j.*,org.apache.commons.codec.binary.* diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java deleted file mode 100644 index 6cac336a1..000000000 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/Activator.java +++ /dev/null @@ -1,63 +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.filters; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class Activator implements BundleActivator { - - private ServiceRegistration registration = null; - - private static final Logger LOG = LoggerFactory.getLogger(Activator.class); - - @Override - public void start(BundleContext ctx) throws Exception { - - - - Object impl = new String(); - String regName = impl.getClass().getName(); - - if (registration == null) - { - LOG.debug("Registering Filters service "+regName); - registration = ctx.registerService(regName, impl, null); - } - - } - - @Override - public void stop(BundleContext ctx) throws Exception { - - if (registration != null) - { - registration.unregister(); - registration = null; - } - } - -} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersService.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersService.java new file mode 100644 index 000000000..9587e8d96 --- /dev/null +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersService.java @@ -0,0 +1,4 @@ +package org.onap.ccsdk.sli.core.filters; + +public interface FiltersService { +} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersServiceImpl.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersServiceImpl.java new file mode 100644 index 000000000..12370ca9a --- /dev/null +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersServiceImpl.java @@ -0,0 +1,33 @@ +/*- + * ============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.filters; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class FiltersServiceImpl implements FiltersService { + private static final Logger LOG = LoggerFactory.getLogger(FiltersServiceImpl.class); + + public FiltersServiceImpl() { + LOG.debug("Registering {}", FiltersServiceImpl.class.getName()); + } +} diff --git a/filters/provider/src/main/resources/org/opendaylight/blueprint/filters-blueprint.xml b/filters/provider/src/main/resources/org/opendaylight/blueprint/filters-blueprint.xml new file mode 100644 index 000000000..3bf8423e9 --- /dev/null +++ b/filters/provider/src/main/resources/org/opendaylight/blueprint/filters-blueprint.xml @@ -0,0 +1,9 @@ + + + + + + + -- cgit 1.2.3-korg From 0d63d99ea283749d2b5c24b073b585faf8a62e7b Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Fri, 1 Sep 2017 15:44:56 -0700 Subject: Enable surefire unit testing Issue-Id: CCSDK-67 Change-Id: I3d03ff1a3e312edd4af7ab69508760d2fe49be78 Signed-off-by: Marcus G K Williams --- pom.xml | 2 +- .../test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java | 6 +++--- sliPluginUtils/provider/src/test/resources/dme2.e2e.properties | 7 +++++++ sliPluginUtils/provider/src/test/resources/dme2.prod.properties | 7 +++++++ 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 sliPluginUtils/provider/src/test/resources/dme2.e2e.properties create mode 100644 sliPluginUtils/provider/src/test/resources/dme2.prod.properties diff --git a/pom.xml b/pom.xml index 3c01ec987..c0c63412a 100755 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,7 @@ maven-surefire-plugin 2.17 - true + false diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java index 48c32f452..97346549e 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java @@ -34,7 +34,7 @@ public class Dme2Test { @Test public void createInstarUrl() { - String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com"; + String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); assertEquals(instarUrl, constructedUrl); @@ -42,7 +42,7 @@ public class Dme2Test { @Test public void createInstarUrlNoSubContext() { - String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com"; + String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); Map parameters = new HashMap(); String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", parameters.get(null)); @@ -52,7 +52,7 @@ public class Dme2Test { @Test public void testRoundRobin() { String[] proxyHostNames = new String[] { "http://one:25055", "http://two:25055", "http://three:25055" }; - String urlSuffix = "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com"; + String urlSuffix = "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNames, "common"); String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); diff --git a/sliPluginUtils/provider/src/test/resources/dme2.e2e.properties b/sliPluginUtils/provider/src/test/resources/dme2.e2e.properties new file mode 100644 index 000000000..373448447 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/dme2.e2e.properties @@ -0,0 +1,7 @@ +aafUserName=user@sample.com +aafPassword=fake +envContext=UAT +routeOffer=UAT +proxyUrl=http://sample.com:25055,http://sample.com:25055 +commonServiceVersion=1702.0 +partner= \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/resources/dme2.prod.properties b/sliPluginUtils/provider/src/test/resources/dme2.prod.properties new file mode 100644 index 000000000..4326b0048 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/dme2.prod.properties @@ -0,0 +1,7 @@ +aafUserName=user@sample.com +aafPassword=fake +envContext=PROD +routeOffer= +proxyUrl=http://sample.com:25055,http://sample.com:25055 +commonServiceVersion=1.0 +partner=LPP_PROD \ No newline at end of file -- cgit 1.2.3-korg From de9f4a0a63e7eef6663a132b6ec565b49bbd01b6 Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Thu, 7 Sep 2017 10:38:44 -0400 Subject: Fix SDNC service registration Fix the aaaUserName constant. Change-Id: I4d9272e476874f6a7747970bc67f8f88ff803f21 Issue-Id: SDNC-54 Signed-off-by: Ryan Goulding --- .../onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java index 519614916..07c84c66f 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java @@ -65,9 +65,9 @@ public final class Dme2PropertiesProvider { private static final String PROXY_URLS_VALUE_SEPARATOR = ","; /** - * the key for aafUsername + * the key for aafUserName */ - static final String AAF_USERNAME_KEY = "aafUsername"; + static final String AAF_USERNAME_KEY = "aafUserName"; /** * the key for aafPassword -- cgit 1.2.3-korg From 99e39ee2677760ab49f7939568aa50946e8bd31e Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 7 Sep 2017 14:55:19 -0400 Subject: Update dblib service name Update name of dblib service to match the DbLibService interface name rather than implemtation class (previous advertised name). Change-Id: I999298c089e75fe3bd467241a473abcc04138852 Issue-ID: CCSDK-83 Signed-off-by: Dan Timoney --- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index de3682d8a..f11b362c1 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -8,9 +8,9 @@ * 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. @@ -55,7 +55,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { .getLogger(SvcLogicDblibStore.class); private static final String DBLIB_SERVICE = - "org.onap.ccsdk.sli.core.dblib.DBResourceManager"; + "org.onap.ccsdk.sli.core.dblib.DbLibService"; Properties props = null; -- cgit 1.2.3-korg From f28ba9bec18a636a9d5ecb38851f8af973e91f63 Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Thu, 7 Sep 2017 16:21:23 -0700 Subject: Fix sonar blocker issues in ccsdk/core module Sonarqube report for CCSDK core identfied some blcoker issues. This fix addresses those bugs. Issue-Id: CCSDK-84 Change-Id: Ie6ff19b7b0815a129f9809243e8e3eb0a64144ab Signed-off-by: Arun S. Yerra --- .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 22 ++++++++++++++++++---- .../ccsdk/sli/core/sli/recording/FileRecorder.java | 12 +++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index f11b362c1..9216519a8 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -132,7 +132,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { String mode) throws SvcLogicException { DbLibService dbSvc = getDbLibService(); - + PreparedStatement fetchGraphStmt = null; Connection dbConn = null; SvcLogicGraph retval = null; ResultSet results = null; @@ -146,7 +146,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { try { dbConn = ((DBResourceManager) dbSvc).getConnection(); - PreparedStatement fetchGraphStmt; + ArrayList args = new ArrayList(); args.add(module); @@ -193,6 +193,13 @@ public class SvcLogicDblibStore implements SvcLogicStore { } catch (Exception e) { throw new ConfigurationException("Graph processing failed", e); } finally { + try { + if (fetchGraphStmt != null) { + fetchGraphStmt.close(); + } + } catch (SQLException e) { + LOG.info(e.getMessage()); + } if (results != null) { try { results.close(); @@ -267,12 +274,12 @@ public class SvcLogicDblibStore implements SvcLogicStore { } Connection dbConn = null; - + PreparedStatement storeGraphStmt = null; try { dbConn = ((DBResourceManager) dbSvc).getConnection(); boolean oldAutoCommit = dbConn.getAutoCommit(); dbConn.setAutoCommit(false); - PreparedStatement storeGraphStmt = dbConn + storeGraphStmt = dbConn .prepareStatement(storeGraphSql); storeGraphStmt.setString(1, graph.getModule()); storeGraphStmt.setString(2, graph.getRpc()); @@ -288,6 +295,13 @@ public class SvcLogicDblibStore implements SvcLogicStore { } catch (Exception e) { throw new SvcLogicException("Could not write object to database", e); } finally { + try { + if (storeGraphStmt != null) { + storeGraphStmt.close(); + } + } catch (SQLException e) { + LOG.info(e.getMessage()); + } try { if (dbConn != null && !dbConn.isClosed()) { dbConn.close(); 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 index 1143ef749..4a60de950 100644 --- 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 @@ -24,6 +24,7 @@ package org.onap.ccsdk.sli.core.sli.recording; import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; +import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -82,6 +83,7 @@ public class FileRecorder implements SvcLogicRecorder { File recordFile = new File(fileName); PrintWriter recPrinter = null; + FileWriter fileWriter = null; Date now = new Date(); TimeZone tz = TimeZone.getTimeZone("UTC"); @@ -95,7 +97,7 @@ public class FileRecorder implements SvcLogicRecorder { try { - recPrinter = new PrintWriter(new FileWriter(recordFile, true)); + recPrinter = new PrintWriter(fileWriter = new FileWriter(recordFile, true)); recPrinter.println(record); } catch (Exception e) @@ -108,6 +110,14 @@ public class FileRecorder implements SvcLogicRecorder { { recPrinter.close(); } + if (fileWriter != null) + { + try { + fileWriter.close(); + } catch (IOException e) { + + } + } } -- cgit 1.2.3-korg From aa5441ed5a583c3b0c9e487108cd691310c1e78a Mon Sep 17 00:00:00 2001 From: "Arun S. Yerra" Date: Thu, 7 Sep 2017 11:09:06 -0700 Subject: Fix Sonar issues within SliPluginUtils module Sonarqube report for SliPluginUtils identified some critical bugs. This fix will address these bugs. Issue-Id: CCSDK-81 Change-Id: I9a1738c02f1364b17a0895b94f26c373e4a19f1f Signed-off-by: Arun S. Yerra --- .../sli/core/slipluginutils/SliPluginUtils.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index e6811e789..488dc395b 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -26,6 +26,7 @@ import java.io.FileOutputStream; import java.io.PrintStream; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -489,6 +490,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { switch( logLevel ) { case TRACE: log.trace(log_message); + break; case DEBUG: log.debug(log_message); break; @@ -648,6 +650,38 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { return 0; } + + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (!(object instanceof SortableCtxListElement)) { + return false; + } + if (!super.equals(object)) { + return false; + } + + SortableCtxListElement that = (SortableCtxListElement) object; + + if (child_elements != null ? !child_elements.equals(that.child_elements) + : that.child_elements != null) { + return false; + } + // Probably incorrect - comparing Object[] arrays with Arrays.equals + if (!Arrays.equals(sort_fields, that.sort_fields)) { + return false; + } + + return true; + } + + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (child_elements != null ? child_elements.hashCode() : 0); + result = 31 * result + Arrays.hashCode(sort_fields); + return result; + } } /** -- cgit 1.2.3-korg From cce6f1cd01d319d7d01b3bc9be0ff903621ce1ec Mon Sep 17 00:00:00 2001 From: shashikanth Date: Fri, 8 Sep 2017 14:24:06 +0530 Subject: Fix Blocker/Critical sonar issues Fix Blocker/Critical sonar issues in vnfapi module https://sonar.onap.org/component_issues?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#severities=BLOCKER Issue-Id: CCSDK-67 Change-Id: I0b779cb0db33f0742776062bd7fa7173f08d5e62 Signed-off-by: shashikanth.vh --- .../core/dblib/factory/AbstractResourceManagerFactory.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java index 6fc7e7a04..486d0ccc1 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java @@ -21,13 +21,8 @@ package org.onap.ccsdk.sli.core.dblib.factory; -import java.sql.SQLException; -import java.util.Set; -import java.util.concurrent.Callable; - import org.onap.ccsdk.sli.core.dblib.CachedDataSource; import org.onap.ccsdk.sli.core.dblib.CachedDataSourceFactory; -import org.onap.ccsdk.sli.core.dblib.DBConfigException; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; @@ -35,6 +30,10 @@ import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.SQLException; +import java.util.Set; +import java.util.concurrent.Callable; + /** * @version $Revision: 1.6 $ * Change Log @@ -85,7 +84,8 @@ public abstract class AbstractResourceManagerFactory { } }; if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Completed CachedDataSource.Call and notifyAll from " + ds.getDbConnectionName()); + LOGGER.debug("Completed CachedDataSource.Call and notifyAll from " + (ds != null ? ds + .getDbConnectionName() : null)); } Thread worker = new Thread(closure); worker.setDaemon(true); -- cgit 1.2.3-korg From d74c0195215fd495fa37e4e3712f634f06e4e0b3 Mon Sep 17 00:00:00 2001 From: shashikanth Date: Thu, 7 Sep 2017 18:15:52 +0530 Subject: Fix Blocker/Critical sonar issues Fix Blocker/Critical sonar issues in vnfapi module https://sonar.onap.org/component_issues?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#severities=BLOCKER Issue-Id: CCSDK-67 Change-Id: I9f1a7dc8144a2a3a777a2a4f24793bbf9317de33 Signed-off-by: shashikanth.vh --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 9dc262d07..1729bcec0 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -20,6 +20,18 @@ package org.onap.ccsdk.sli.core.dblib; +import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor.TestObject; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetProvider; import java.io.Closeable; import java.io.IOException; import java.io.PrintWriter; @@ -36,20 +48,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Observer; -import javax.sql.DataSource; -import javax.sql.rowset.CachedRowSet; -import javax.sql.rowset.RowSetProvider; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.tomcat.jdbc.pool.PoolExhaustedException; -import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor.TestObject; - -import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; - /** * @version $Revision: 1.13 $ @@ -565,7 +563,9 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito retValue = false; } finally { try { - lock.close(); + if (lock != null) { + lock.close(); + } } catch(Exception exc) { } -- cgit 1.2.3-korg From 03332a17a549438d204d8f0068a995a7c8708ed3 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Fri, 8 Sep 2017 14:49:09 -0700 Subject: Cleanup project's name in Sonar The name parameter in the root pom.xml should match the project name in gerrit to reflect consistency in Sonar. Change-Id: I73a561752044b0d1b03a1b52f4b432f4c3329269 Issue-id: CIMAN-65 Signed-off-by: Jessica Wagantall --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eba735f5d..6b022cd5c 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - CCSDK Core Components + ccsdk-sli-core https://wiki.onap.org CCSDK core components contains the SLI, dblib -- cgit 1.2.3-korg From ce8c59f72c30cc7e1f9b657795ad396fe325ba52 Mon Sep 17 00:00:00 2001 From: shashikanth Date: Mon, 11 Sep 2017 18:52:19 +0530 Subject: Fix Blocker/Critical sonar issues Fix Blocker/Critical sonar issues in ccsdk/core module https://sonar.onap.org/component_issues?id=org.openecomp.sdnc.core%3Asdnc-core#resolved=false|severities=BLOCKER Issue-Id: CCSDK-67 Change-Id: Iec86b90f7085f4b96d4f92adf4064b70640fcf22 Signed-off-by: shashikanth.vh --- .../ccsdk/sli/core/dblib/DBResourceManager.java | 44 +++++++++------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 46c003a5a..7ed54306a 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -20,6 +20,19 @@ package org.onap.ccsdk.sli.core.dblib; +import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; +import org.onap.ccsdk.sli.core.dblib.factory.AbstractDBResourceManagerFactory; +import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory; +import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; +import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLDataException; @@ -38,26 +51,9 @@ import java.util.PriorityQueue; import java.util.Properties; import java.util.Queue; import java.util.Set; -import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; -import javax.sql.DataSource; -import javax.sql.rowset.CachedRowSet; - -import org.apache.tomcat.jdbc.pool.PoolExhaustedException; -import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; -import org.onap.ccsdk.sli.core.dblib.factory.AbstractDBResourceManagerFactory; -import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory; -import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; -import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; - -import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * @version $Revision: 1.15 $ @@ -336,11 +332,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } sources.remove(active); return active.getData(statement, arguments); - } catch(SQLDataException exc){ - throw exc; - } catch(SQLSyntaxErrorException exc){ - throw exc; - } catch(SQLIntegrityConstraintViolationException exc){ + } catch(SQLDataException | SQLSyntaxErrorException | SQLIntegrityConstraintViolationException exc){ throw exc; } catch(Throwable exc){ lastException = exc; @@ -432,7 +424,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } CachedDataSource findMaster() throws PoolExhaustedException, MySQLNonTransientConnectionException { - CachedDataSource master = null; + CachedDataSource master; CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); for(int i=0; i Date: Fri, 8 Sep 2017 18:52:46 -0400 Subject: Expose getConnection from DblibSeervice Exposed getConnection from DbLibService class so that it can be accessed from OSGi client. Prior to blueprint refactoring, this was accessible by casting DbLibService as DBResourceManager, but that cast no longer works if OSGi service is advertised by blueprint. It's cleaner to expose that method in the interface anyway. Change-Id: I36ed7fe82b0393a952d307a1c79d1d8c0ba11dd4 Issue-ID: CCSDK-86 Signed-off-by: Dan Timoney --- .../src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java index de9846679..0dea664d5 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java @@ -7,9 +7,9 @@ * 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. @@ -20,6 +20,7 @@ package org.onap.ccsdk.sli.core.dblib; +import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; @@ -43,4 +44,6 @@ public interface DbLibService { public abstract boolean isActive(); + public abstract Connection getConnection() throws SQLException; + } -- cgit 1.2.3-korg From c4b09e567dbf14e4c181ad2a248faf242ac313b8 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 11 Sep 2017 11:19:51 -0400 Subject: Remove cast to DBResourceManager Remove cast to DBResourceManager, which no longer works after DbLibService is advertised via Aries Blueprint and which is no longer needed after DbLibService interface exposes getConnection() method. Updated version number - seems like an older 0.1.1-SNAPSHOT without DbLibService change is being used, so trying to see if bumping version will help. Change-Id: Ia411d1514bca396cc052f4f16eda6c79e0d13648 Issue-ID: CCSDK-86 Signed-off-by: Dan Timoney --- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java | 4 ++-- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 2 +- 25 files changed, 32 insertions(+), 32 deletions(-) diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 2be6c8dbe..4053efaf9 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT dblib-features DBLIB Adaptor - Features diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 10845db17..a2d7362a9 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT dblib-installer DBLIB Adaptor - Karaf Installer diff --git a/dblib/pom.xml b/dblib/pom.xml index 9e1516374..8e7afabb5 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT @@ -16,7 +16,7 @@ DBLIB Adaptor The DBLIB adaptor allows service logic to access persistent data in a local sql database - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 11e0ff748..07fc61ab1 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -4,10 +4,10 @@ org.onap.ccsdk.sli.core dblib - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT dblib-provider - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT bundle DBLIB Adaptor - Provider http://maven.apache.org diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 0d71e9167..95ccdfcd3 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -4,7 +4,7 @@ filters org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT filters-features Filters - Features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 1e839d93e..e2eb43060 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT filters-installer Filters - Karaf Installer diff --git a/filters/pom.xml b/filters/pom.xml index 2e159c410..f79787ea4 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT 4.0.0 @@ -16,7 +16,7 @@ Filters Servlet filter to implement ECOMP logging spec - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 240966e8b..a59071937 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT filters-provider bundle diff --git a/pom.xml b/pom.xml index 6b022cd5c..3bf8b1e64 100755 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ ONAP - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 52bfd53f4..f71ca35f6 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -3,7 +3,7 @@ sli org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sli-common bundle diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 9216519a8..712c64aba 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -145,7 +145,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { try { - dbConn = ((DBResourceManager) dbSvc).getConnection(); + dbConn = dbSvc.getConnection(); ArrayList args = new ArrayList(); @@ -276,7 +276,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { Connection dbConn = null; PreparedStatement storeGraphStmt = null; try { - dbConn = ((DBResourceManager) dbSvc).getConnection(); + dbConn = dbSvc.getConnection(); boolean oldAutoCommit = dbConn.getAutoCommit(); dbConn.setAutoCommit(false); storeGraphStmt = dbConn diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 975839fc0..dc7a95dc1 100755 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sli-features SLI - Features diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 0319f5bcf..0eec3324a 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sli-installer SLI - Karaf Installer diff --git a/sli/pom.xml b/sli/pom.xml index b8ce1e3a0..7257e9ee4 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT 4.0.0 pom @@ -59,7 +59,7 @@ ONAP - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 5ef47ef19..f665c56a1 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sli-provider bundle diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 932e3ccab..97c99188c 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sli-recording bundle diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index ce87536df..41381b6f0 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -8,7 +8,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT SliPluginUtils Plugin - Features diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index a92c9cd9a..dd904e40d 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -4,7 +4,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sliPluginUtils-installer SLI Plugin Utilities - Karaf Installer diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 5e084af8d..3d80b7231 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT pom 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT Service Logic Interface Plugin Utilities A package of static utility functions to be used when developing SLI plugins diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 430221fcb..ad950c0c8 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -8,7 +8,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT SliPluginUtils Plugin - Provider diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 531315e8d..caa6a8b39 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sliapi-features diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 249520569..dff580b62 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sliapi-installer pom diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 8fed20036..fc9b76377 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sliapi-model bundle diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 64f84b9ac..a58596a93 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT pom org.onap.ccsdk.sli.core sliapi - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index e679f3687..7e0bd2642 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.1-SNAPSHOT + 0.1.2-SNAPSHOT sliapi-provider bundle -- cgit 1.2.3-korg From 9eb50a48faf45d5f1dc01b1209778c1c1d5ed0ae Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Mon, 11 Sep 2017 16:36:49 +0530 Subject: Fix Sonar issues Few major issues in sli/core module Issue-id: CCSDK-67 Change-Id: Iad65b30a6b27814c1984d8db42d36f8569c5cb3f Signed-off-by: surya-huawei --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 37 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 1729bcec0..ee8ab2f33 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -92,12 +92,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#getConnection() */ + @Override public Connection getConnection() throws SQLException { return ds.getConnection(); } - public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable + public CachedRowSet getData(String statement, ArrayList arguments) + throws SQLException, Throwable { TestObject testObject = null; testObject = monitor.registerRequest(); @@ -126,7 +128,8 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } } - public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable + public boolean writeData(String statement, ArrayList arguments) + throws SQLException, Throwable { TestObject testObject = null; testObject = monitor.registerRequest(); @@ -155,7 +158,8 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } } - CachedRowSet executePreparedStatement(Connection conn, String statement, ArrayList arguments, boolean close) throws SQLException, Throwable + CachedRowSet executePreparedStatement(Connection conn, String statement, + ArrayList arguments, boolean close) throws SQLException, Throwable { long time = System.currentTimeMillis(); @@ -168,9 +172,10 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } ResultSet rs = null; + PreparedStatement ps = null; try { data = RowSetProvider.newFactory().createCachedRowSet(); - PreparedStatement ps = conn.prepareStatement(statement); + ps = conn.prepareStatement(statement); if(arguments != null) { for(int i = 0, max = arguments.size(); i < max; i++){ @@ -220,6 +225,13 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } } catch(Exception exc){ + } + try { + if (ps != null){ + ps.close(); + } + } catch (Exception exc){ + } } @@ -296,6 +308,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) */ + @Override public Connection getConnection(String username, String password) throws SQLException { @@ -305,6 +318,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#getLogWriter() */ + @Override public PrintWriter getLogWriter() throws SQLException { return ds.getLogWriter(); @@ -313,6 +327,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#getLoginTimeout() */ + @Override public int getLoginTimeout() throws SQLException { return ds.getLoginTimeout(); @@ -321,6 +336,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) */ + @Override public void setLogWriter(PrintWriter out) throws SQLException { ds.setLogWriter(out); @@ -329,12 +345,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#setLoginTimeout(int) */ + @Override public void setLoginTimeout(int seconds) throws SQLException { ds.setLoginTimeout(seconds); } + @Override public final String getDbConnectionName(){ return connectionName; } @@ -418,10 +436,12 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito return true; } + @Override public boolean isWrapperFor(Class iface) throws SQLException { return false; } + @Override public T unwrap(Class iface) throws SQLException { return null; } @@ -445,34 +465,42 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito monitor.deleteObserver(observer); } + @Override public long getInterval() { return interval; } + @Override public long getInitialDelay() { return initialDelay; } + @Override public void setInterval(long value) { interval = value; } + @Override public void setInitialDelay(long value) { initialDelay = value; } + @Override public long getExpectedCompletionTime() { return expectedCompletionTime; } + @Override public void setExpectedCompletionTime(long value) { expectedCompletionTime = value; } + @Override public long getUnprocessedFailoverThreshold() { return unprocessedFailoverThreshold; } + @Override public void setUnprocessedFailoverThreshold(long value) { this.unprocessedFailoverThreshold = value; } @@ -485,6 +513,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito canTakeOffLine = false; final Thread offLineTimer = new Thread() { + @Override public void run(){ try { Thread.sleep(30000L); -- cgit 1.2.3-korg From efe32de47055db3223c0fa2c84494a677a28935e Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 12 Sep 2017 09:47:40 +0530 Subject: Fix Sonar Issues few major issues in sli/core module Issue-Id: CCSDK-87 Change-Id: Id563cd2fb31f477f96e14b180501feeb37fb24a7 Signed-off-by: surya-huawei --- .../sli/core/sli/recording/RecordingActivator.java | 4 ++-- .../sli/core/slipluginutils/SliPluginUtils.java | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java b/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java index 9228d15c2..fd857f56b 100644 --- a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java +++ b/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java @@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory; public class RecordingActivator implements BundleActivator { - private LinkedList registrations = new LinkedList(); + private LinkedList registrations = new LinkedList<>(); private static final Logger LOG = LoggerFactory .getLogger(RecordingActivator.class); @@ -43,7 +43,7 @@ public class RecordingActivator implements BundleActivator { if (registrations == null) { - registrations = new LinkedList(); + registrations = new LinkedList<>(); } diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 488dc395b..323758681 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -138,7 +138,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { // Obtain key-value pairs to check from parameters LOG.trace("reading keys parameter list"); - HashMap keys_values = new HashMap(); + HashMap keys_values = new HashMap<>(); for( int i = 0; i < keys_length; i++ ) { keys_values.put(parameters.get("keys[" + i + "].key"), parameters.get("keys[" + i + "].value")); } @@ -174,7 +174,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { */ public void ctxSortList( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { checkParameters(parameters, new String[]{"list","delimiter"}, LOG); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); String[] sort_fields = null; if( parameters.containsKey("sort-fields") ) { @@ -205,7 +205,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { i++; } // Reset list length (removed by ctxBulkErase above) - ctx.setAttribute(ctx_list_str+"_length", ""+listSz); + ctx.setAttribute(ctx_list_str+"_length", Integer.toString(listSz)); } /** @@ -284,7 +284,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { log.debug("required parameters was empty, exiting early."); return; } - if (parametersMap == null || parametersMap.keySet().size() < 1){ + if (parametersMap == null || parametersMap.keySet().isEmpty()){ String errorMessage = "This method requires the parameters [" + StringUtils.join(requiredParams,",") + "], but no parameters were passed in."; log.error(errorMessage); throw new SvcLogicException(errorMessage); @@ -307,7 +307,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { * @since 1.0 */ public static final void ctxBulkErase( SvcLogicContext ctx, String pfx ) { - ArrayList Keys = new ArrayList( ctx.getAttributeKeySet() ); + ArrayList Keys = new ArrayList<>(ctx.getAttributeKeySet()); for( String key : Keys ) { if( key.startsWith( pfx ) ) { ctx.setAttribute( pfx + key.substring(pfx.length()) , null); @@ -337,7 +337,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { // For each context key that begins with src_pfx, set the value of the // key dest_pfx + the suffix of the key to the key's value - ArrayList Keys = new ArrayList(ctx.getAttributeKeySet()); + ArrayList Keys = new ArrayList<>(ctx.getAttributeKeySet()); for( String key : Keys ) { if( key.startsWith(src_pfx) ) { // Get suffix (no leading period) @@ -361,7 +361,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { * in ctx whose key begins with prefix. */ public static final Map ctxGetBeginsWith( SvcLogicContext ctx, String prefix ) { - Map prefixMap = new HashMap(); + Map prefixMap = new HashMap<>(); for( String key : ctx.getAttributeKeySet() ) { if( key.startsWith(prefix) ) { @@ -481,7 +481,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { * @since 1.0 */ public static final int getArrayLength( SvcLogicContext ctx, String key, Logger log, LogLevel logLevel, String log_message ) { - String ctxKey = ( key.endsWith("_length") ) ? key : key + "_length"; + String ctxKey = key.endsWith("_length") ? key : key + "_length"; try { return Integer.parseInt(ctx.getAttribute(ctxKey)); } @@ -525,7 +525,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { logLevelIsEnabled( log, logLevel ); // Print sorted context memory key-value pairs to the log - ArrayList keys = new ArrayList(ctx.getAttributeKeySet()); + ArrayList keys = new ArrayList<>(ctx.getAttributeKeySet()); Collections.sort(keys); for( String key : keys ) { logMessageAtLevel( log, logLevel, key + " = " + ctx.getAttribute(key) ); @@ -616,7 +616,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { // ========== LOCAL CLASSES ========== private class SortableCtxListElement implements Comparable { - HashMap child_elements = new HashMap(); + HashMap child_elements = new HashMap<>(); String[] sort_fields; public SortableCtxListElement( SvcLogicContext ctx, String root, String[] sort_fields ) { @@ -729,7 +729,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void requiredParameters(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - if (parameters == null || parameters.keySet().size() < 1) { + if (parameters == null || parameters.keySet().isEmpty()) { String errorMessage = "requiredParameters should not be called if the parameters hashmap is null or empty!"; LOG.error(errorMessage); throw new SvcLogicException(errorMessage); -- cgit 1.2.3-korg From 98cc3655f6632b4140fd1a419819d3a72ba1add7 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 12 Sep 2017 11:07:35 +0530 Subject: Fix Sonar Issues few major issues in sli/core module Issue-Id: CCSDK-87 Change-Id: I1fb86f084d270906dcf61d33701da54a82f2c3a4 Signed-off-by: surya-huawei --- .../src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java | 2 +- .../org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java index 326490d9d..6bdd87e24 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java @@ -124,7 +124,7 @@ public class DME2 implements SvcLogicJavaPlugin { sb.append("&dme2.partner=" + this.partner); } sb.append("&dme2.allowhttpcode=true"); - return (sb.toString()); + return sb.toString(); } public synchronized String acquireHostName() { diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java index aa25fe374..32e1aebdc 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextList.java @@ -60,7 +60,7 @@ public class SvcLogicContextList { // Initialize list int capacity = getCtxListLength(ctx, prefix); - this.list = new ArrayList>(capacity); + this.list = new ArrayList<>(capacity); for( int i = 0; i < capacity; i++ ) { this.list.add(i, new HashMap()); } @@ -158,7 +158,7 @@ public class SvcLogicContextList { for( int i = 0; i < this.list.size(); i++ ) { for( Map.Entry entry : this.list.get(i).entrySet() ) { - if( entry.getKey().equals("") ) { + if("".equals(entry.getKey())) { ctx.setAttribute(prefix + '[' + i + ']', entry.getValue()); } else { ctx.setAttribute(prefix + '[' + i + "]." + entry.getKey(), entry.getValue()); -- cgit 1.2.3-korg From 223514867e05ce022705b6a42a4ed19bf88ee6ee Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 12 Sep 2017 15:50:07 +0530 Subject: Fix sonar issues few major issues in dblib module Issue-Id: CCSDK-87 Change-Id: I6bc1fe2cf04cec0a5ad3bfb65bc3a10e5f488eea Signed-off-by: surya-huawei --- .../org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java | 5 ----- .../onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java | 10 ++++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java index 201cc4019..c7f760053 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java @@ -24,7 +24,6 @@ import com.google.common.annotations.VisibleForTesting; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Optional; import java.util.Properties; @@ -35,10 +34,6 @@ import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibEnvVarFileResol import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibJREFileResolver; import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibKarafRootFileResolver; import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibPropertiesFileResolver; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java index 127e6d376..b4d1ef679 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java @@ -33,38 +33,47 @@ public class TerminatingCachedDataSource extends CachedDataSource implements SQL super(jdbcElem); } + @Override protected void configure(BaseDBConfiguration jdbcElem) throws DBConfigException { // no action } + @Override public long getInterval() { return 1000; } + @Override public long getInitialDelay() { return 1000; } + @Override public long getExpectedCompletionTime() { return 50; } + @Override public void setExpectedCompletionTime(long value) { } + @Override public void setInterval(long value) { } + @Override public void setInitialDelay(long value) { } + @Override public long getUnprocessedFailoverThreshold() { return 3; } + @Override public void setUnprocessedFailoverThreshold(long value) { } @@ -74,6 +83,7 @@ public class TerminatingCachedDataSource extends CachedDataSource implements SQL return 0; } + @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { // TODO Auto-generated method stub return null; -- cgit 1.2.3-korg From 2b433d67493ee2afcce619cc0cf2707ba3152491 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 12 Sep 2017 11:52:59 +0530 Subject: Fix Sonar Issues few major issues in sli/core/filters module Issue-Id- CCSDK-87 Change-Id: Idbf2b12b866d48161f089271a2403aaee6b8d04f Signed-off-by: surya-huawei --- .../src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java index 4b14b21df..abbb7c66e 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java @@ -144,7 +144,7 @@ public class LogFilter implements Filter { String authzHeader = request.getHeader("Authorization"); String usernameAndPassword = new String(Base64.decodeBase64(authzHeader.substring(6).getBytes())); - int userNameIndex = usernameAndPassword.indexOf(":"); + int userNameIndex = usernameAndPassword.indexOf(':'); String username = usernameAndPassword.substring(0, userNameIndex); userName = username; @@ -171,7 +171,7 @@ public class LogFilter implements Filter { MDC.put(END_TIMESTAMP,asIso8601(System.currentTimeMillis())); //MDC.put(REQUEST_ID,"already done above"); MDC.put(SERVICE_NAME,request.getRequestURL().toString()); - int idx = request.getPathInfo().toString().lastIndexOf(":"); + int idx = request.getPathInfo().lastIndexOf(':'); String instance = ""; if ( idx != -1 ) { instance = request.getPathInfo().substring(idx+1); @@ -186,13 +186,13 @@ public class LogFilter implements Filter { MDC.put(STATUS_CODE,"COMPLETE"); } - MDC.put(RESP_CODE,"" + response.getStatus()); + MDC.put(RESP_CODE, Integer.toString(response.getStatus())); MDC.put(RESP_DESC,""); MDC.put(INSTANCE_UUID,""); MDC.put(CATEGORY,""); MDC.put(SEVERITY,""); //MDC.put(SERVER_IP,""); //by chef - MDC.put(ELAPSED_TIME,"" + (System.currentTimeMillis() - startTime)); + MDC.put(ELAPSED_TIME,Long.toString(System.currentTimeMillis() - startTime)); //MDC.put(SERVER_HOST,""); //by chef MDC.put(CLIENT_IP,request.getRemoteHost()); MDC.put(CLASS,""); -- cgit 1.2.3-korg From 1ed8c1f3b0345fe28c61844df2a189a8b9b53594 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 12 Sep 2017 15:29:44 +0530 Subject: Fix Sonar Issues few major issues in sli/core/dblib module Issue-id: CCSDK-87 Change-Id: Ie3b13468d23c1e7dc2228bb7a0cd1bde5cc632e8 Signed-off-by: surya-huawei --- .../onap/ccsdk/sli/core/dblib/DBLibConnection.java | 11 ++++---- .../ccsdk/sli/core/dblib/DBResourceManager.java | 32 ++++++++++------------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java index 8181b1300..40d1a2382 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java @@ -43,7 +43,6 @@ import java.util.concurrent.Executor; import javax.sql.rowset.CachedRowSet; import org.apache.tomcat.jdbc.pool.PooledConnection; -import org.apache.tomcat.jdbc.pool.ProxyConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,7 +64,8 @@ public class DBLibConnection implements Connection { public boolean lockTable(String tablename) { this.tableName = tablename; - return locked = dataSource.lockTable(connection, tableName); + locked = dataSource.lockTable(connection, tableName); + return locked; } public void resetInactivityTimer() { @@ -80,12 +80,13 @@ public class DBLibConnection implements Connection { public boolean unlock() { dataSource.unlockTable(connection); - return locked = false; + locked = false; + return locked; } public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable { - ArrayList newList=new ArrayList(); + ArrayList newList= new ArrayList<>(); if(arguments != null && !arguments.isEmpty()) { newList.addAll(arguments); } @@ -95,7 +96,7 @@ public class DBLibConnection implements Connection { public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable { - ArrayList newList=new ArrayList(); + ArrayList newList= new ArrayList<>(); if(arguments != null && !arguments.isEmpty()) { newList.addAll(arguments); } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 46c003a5a..ac67c3f94 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -38,9 +38,7 @@ import java.util.PriorityQueue; import java.util.Properties; import java.util.Queue; import java.util.Set; -import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; import javax.sql.DataSource; @@ -76,23 +74,22 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb protected final AtomicBoolean dsSelector = new AtomicBoolean(); // Queue dsQueue = new ConcurrentLinkedQueue(); - Queue dsQueue = new PriorityQueue(4, new Comparator(){ - + Queue dsQueue = new PriorityQueue<>(4, new Comparator() { @Override public int compare(CachedDataSource left, CachedDataSource right) { try { - if(!left.isSlave()) + if (!left.isSlave()) { return -1; - if(!right.isSlave()) + } + if (!right.isSlave()) { return 1; - + } } catch (Throwable e) { LOGGER.warn("", e); } return 0; } - - }); + }); protected final Set broken = Collections.synchronizedSet(new HashSet()); protected final Object monitor = new Object(); protected final Properties configProps; @@ -240,6 +237,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb class RecoveryMgr extends Thread { + @Override public void run() { while(!terminating) { @@ -295,7 +293,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb */ @Override public CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) throws SQLException { - ArrayList newList=new ArrayList(); + ArrayList newList= new ArrayList<>(); if(arguments != null && !arguments.isEmpty()) { newList.addAll(arguments); } @@ -310,7 +308,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb CachedDataSource active = null; // test if there are any connection pools available - LinkedList sources = new LinkedList(this.dsQueue); + LinkedList sources = new LinkedList<>(this.dsQueue); if(sources.isEmpty()){ LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); @@ -356,7 +354,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb handleGetConnectionException(active, exc); } finally { if(LOGGER.isDebugEnabled()){ - time = (System.currentTimeMillis() - time); + time = System.currentTimeMillis() - time; LOGGER.debug("getData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); } } @@ -410,7 +408,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } finally { if(LOGGER.isDebugEnabled()){ - time = (System.currentTimeMillis() - time); + time = System.currentTimeMillis() - time; LOGGER.debug(">> getData : "+ active.getDbConnectionName()+" "+time+" miliseconds."); } } @@ -423,7 +421,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb @Override public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException { - ArrayList newList=new ArrayList(); + ArrayList newList= new ArrayList<>(); if(arguments != null && !arguments.isEmpty()) { newList.addAll(arguments); } @@ -498,7 +496,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } finally { if(LOGGER.isDebugEnabled()){ - time = (System.currentTimeMillis() - time); + time = System.currentTimeMillis() - time; LOGGER.debug("writeData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); } } @@ -710,7 +708,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public String getDBStatus(boolean htmlFormat) { StringBuilder buffer = new StringBuilder(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll(dsQueue); list.addAll(broken); if (htmlFormat) @@ -795,7 +793,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public String getPreferredDataSourceName(AtomicBoolean flipper) { - LinkedList snapshot = new LinkedList(dsQueue); + LinkedList snapshot = new LinkedList<>(dsQueue); if(snapshot.size() > 1){ CachedDataSource first = snapshot.getFirst(); CachedDataSource last = snapshot.getLast(); -- cgit 1.2.3-korg From 14e10898473c9df8fb4ffc26bb1cd67ee2116a61 Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Tue, 12 Sep 2017 15:13:44 -0400 Subject: Remove unused imports in java files Code sanitation-- remove unused imports. Issue-Id: SDNC-79 Change-Id: I5306a9b90f302086459fcac98d04f541ba7c79a4 Signed-off-by: Ryan Goulding --- .../onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java | 1 - .../onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java | 8 -------- .../org/onap/ccsdk/sli/core/dblib/DBLibConnection.java | 1 - .../org/onap/ccsdk/sli/core/dblib/DBResourceManager.java | 2 -- .../core/dblib/factory/AbstractResourceManagerFactory.java | 1 - .../ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java | 1 - .../sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java | 3 --- .../ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java | 1 - .../propertiesfileresolver/DblibEnvVarFileResolver.java | 1 + .../propertiesfileresolver/DblibJREFileResolverTest.java | 2 -- .../java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java | 4 ---- .../org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java | 1 - .../org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java | 14 +++++--------- .../java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java | 2 -- .../java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java | 1 - .../org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 6 ------ .../org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java | 4 ---- .../ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java | 3 --- .../ccsdk/sli/core/slipluginutils/CheckParametersTest.java | 1 - .../slipluginutils/SliPluginUtils_StaticFunctionsTest.java | 1 - .../core/slipluginutils/SliPluginUtils_ctxSortList.java | 1 - .../slipluginutils/SliPluginUtils_ctxSortListTest.java | 1 - .../ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java | 1 - .../sli/core/slipluginutils/SvcLogicContextListTest.java | 1 - 24 files changed, 6 insertions(+), 56 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java index 07e3dfab1..296fe70f1 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java @@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.core.dblib; import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; import org.onap.ccsdk.sli.core.dblib.jdbc.JdbcDBCachedDataSource; -import org.onap.ccsdk.sli.core.dblib.jdbc.MySQLCachedDataSource; /** * @version $Revision: 1.1 $ diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java index 201cc4019..062cd8408 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java @@ -20,11 +20,8 @@ package org.onap.ccsdk.sli.core.dblib; -import com.google.common.annotations.VisibleForTesting; - import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Optional; import java.util.Properties; @@ -35,10 +32,6 @@ import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibEnvVarFileResol import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibJREFileResolver; import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibKarafRootFileResolver; import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibPropertiesFileResolver; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -146,7 +139,6 @@ public class DBLIBResourceProvider { *
  • A dblib.properties file located in the karaf root directory
  • * */ - @VisibleForTesting File determinePropertiesFile(final DBLIBResourceProvider dblibResourceProvider) { for (final DblibPropertiesFileResolver dblibPropertiesFileResolver : dblibPropertiesFileResolvers) { diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java index 8181b1300..ccef4819c 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java @@ -43,7 +43,6 @@ import java.util.concurrent.Executor; import javax.sql.rowset.CachedRowSet; import org.apache.tomcat.jdbc.pool.PooledConnection; -import org.apache.tomcat.jdbc.pool.ProxyConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 46c003a5a..8e8bdb8a8 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -38,9 +38,7 @@ import java.util.PriorityQueue; import java.util.Properties; import java.util.Queue; import java.util.Set; -import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; import javax.sql.DataSource; diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java index 6fc7e7a04..741169c3b 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java @@ -27,7 +27,6 @@ import java.util.concurrent.Callable; import org.onap.ccsdk.sli.core.dblib.CachedDataSource; import org.onap.ccsdk.sli.core.dblib.CachedDataSourceFactory; -import org.onap.ccsdk.sli.core.dblib.DBConfigException; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java index c024d0021..ffe834456 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java @@ -30,7 +30,6 @@ import org.apache.tomcat.jdbc.pool.PoolProperties; import org.onap.ccsdk.sli.core.dblib.CachedDataSource; import org.onap.ccsdk.sli.core.dblib.DBConfigException; import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; -import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java index 978de0eb3..803e6b3e7 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java @@ -22,9 +22,7 @@ package org.onap.ccsdk.sli.core.dblib.jdbc; import java.sql.SQLException; -import java.util.Arrays; import java.util.HashSet; -import java.util.List; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -35,7 +33,6 @@ import java.util.concurrent.FutureTask; import org.onap.ccsdk.sli.core.dblib.CachedDataSource; import org.onap.ccsdk.sli.core.dblib.CachedDataSourceFactory; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; -import org.onap.ccsdk.sli.core.dblib.DataSourceComparator; import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory; diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java index 407209850..bea0d631f 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java @@ -26,7 +26,6 @@ import java.util.Properties; import org.onap.ccsdk.sli.core.dblib.CachedDataSource; import org.onap.ccsdk.sli.core.dblib.DBConfigException; import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; -import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java index 17c42ec83..0b69109f9 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; import com.google.common.base.Strings; + import java.io.File; import java.nio.file.Paths; import java.util.Optional; diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java index 117492d0b..65ebfbae2 100644 --- a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java +++ b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java @@ -2,8 +2,6 @@ package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; import static org.junit.Assert.*; -import java.io.File; -import java.util.Optional; import org.junit.Test; public class DblibJREFileResolverTest { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java index 699ace2e8..5e19a52c6 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java @@ -21,10 +21,6 @@ package org.onap.ccsdk.sli.core.sli; -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - public class SvcLogicAtom extends SvcLogicExpression { public enum AtomType { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java index b8a47c45e..26783e70f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java @@ -22,7 +22,6 @@ package org.onap.ccsdk.sli.core.sli; import java.io.Serializable; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java index 451277576..23dff3e6e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJavaPlugin.java @@ -21,14 +21,10 @@ package org.onap.ccsdk.sli.core.sli; -import java.util.Map; - +/** + * A marker interface, used to indicate that a class exposes methods that can be + * called from an node. Such methods must have the signature: + * void methodName(Map, SvcLogicContext) + */ public interface SvcLogicJavaPlugin { - - /** - * A marker interface, used to indicate that a class exposes methods that can be - * called from an node. Such methods must have the signature: - * void methodName(Map, SvcLogicContext) - */ - } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java index 56ed53054..160107fea 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java @@ -36,8 +36,6 @@ import java.util.TreeMap; import org.apache.commons.lang3.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.xml.sax.Locator; - public class SvcLogicNode implements Serializable { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java index 40295bd75..0e2c42574 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicResource.java @@ -21,7 +21,6 @@ package org.onap.ccsdk.sli.core.sli; -import java.sql.SQLException; import java.util.Map; public interface SvcLogicResource { diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index ec18b8765..0e6000fb2 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -28,12 +28,6 @@ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.util.LinkedList; - -import org.onap.ccsdk.sli.core.sli.SvcLogicParser; -import org.onap.ccsdk.sli.core.sli.SvcLogicParserException; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; import junit.framework.TestCase; diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java index 60d70460d..3b9fff75e 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java @@ -21,17 +21,13 @@ package org.onap.ccsdk.sli.core.sli; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.io.InputStreamReader; import java.util.Enumeration; import java.util.Properties; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java index 125ac5618..80df10cee 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionParserTest.java @@ -25,9 +25,6 @@ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; -import org.onap.ccsdk.sli.core.sli.SvcLogicExprListener; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java index 106b0cf46..166a60e90 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java @@ -27,7 +27,6 @@ import java.util.Map; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java index a46c85129..774aa1c84 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java @@ -32,7 +32,6 @@ import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java index ba7a7660d..f9d70f2fb 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java @@ -30,7 +30,6 @@ import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java index 9768108de..bf7cc1399 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortListTest.java @@ -30,7 +30,6 @@ import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index 09683ac36..72b3264e9 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -35,7 +35,6 @@ import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils; /** * @author km991u diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java index 263ba1f1d..f916bbfca 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextListTest.java @@ -29,7 +29,6 @@ import java.util.HashMap; import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.slipluginutils.SvcLogicContextList; public class SvcLogicContextListTest { //private static final Logger LOG = LoggerFactory.getLogger(SvcLogicContextTest.class); -- cgit 1.2.3-korg From 3fa9671f720dd95bf15a5a4668aa89a7c3dd93e7 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 13 Sep 2017 16:32:45 -0400 Subject: Use oparent-odlparent in sli/core Update sli/core to use oparent-odlparent. To prevent verify builds from failing due to unit test errors, also changed unit tests that require database access to use MariaDB4j to start up a local MariaDB database. Change-Id: I928b7e1e83bdb328ca9e0785c8b81f67f982eeda Issue-ID: CCSDK-43 Signed-off-by: Dan Timoney --- .../DblibDefaultFileResolverTest.java | 24 ++ .../DblibEnvVarFileResolverTest.java | 23 ++ .../DblibJREFileResolverTest.java | 15 ++ .../DblibKarafRootFileResolverTest.java | 14 + .../DblibDefaultFileResolverTest.java | 24 -- .../DblibEnvVarFileResolverTest.java | 23 -- .../DblibJREFileResolverTest.java | 15 -- .../DblibKarafRootFileResolverTest.java | 14 - pom.xml | 2 +- sli/common/pom.xml | 297 +++++++++++---------- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 78 ++++-- sli/common/src/test/resources/svclogic.properties | 12 +- sli/provider/pom.xml | 6 + .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 100 ++++--- 14 files changed, 340 insertions(+), 307 deletions(-) create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java delete mode 100644 dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java delete mode 100644 dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java delete mode 100644 dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java delete mode 100644 dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java new file mode 100644 index 000000000..41011e55b --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; + +public class DblibDefaultFileResolverTest { + + @Test + public void resolveFile() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java new file mode 100644 index 000000000..775898930 --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java @@ -0,0 +1,23 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; + +public class DblibEnvVarFileResolverTest { + @Test + public void resolveFile() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java new file mode 100644 index 000000000..65ebfbae2 --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java @@ -0,0 +1,15 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class DblibJREFileResolverTest { + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibJREFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java new file mode 100644 index 000000000..0a032e8b7 --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class DblibKarafRootFileResolverTest { + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final DblibPropertiesFileResolver resolver = new DblibKarafRootFileResolver("success", null); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java deleted file mode 100644 index 41011e55b..000000000 --- a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; - -import static org.junit.Assert.*; - -import java.io.File; -import java.util.Optional; -import org.junit.Test; - -public class DblibDefaultFileResolverTest { - - @Test - public void resolveFile() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java deleted file mode 100644 index 775898930..000000000 --- a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; - -import static org.junit.Assert.*; - -import java.io.File; -import java.util.Optional; -import org.junit.Test; - -public class DblibEnvVarFileResolverTest { - @Test - public void resolveFile() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java deleted file mode 100644 index 65ebfbae2..000000000 --- a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class DblibJREFileResolverTest { - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibJREFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java b/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java deleted file mode 100644 index 0a032e8b7..000000000 --- a/dblib/provider/src/test/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class DblibKarafRootFileResolverTest { - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibKarafRootFileResolver("success", null); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3bf8b1e64..469a2a696 100755 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.parent odlparent-carbon-sr1 - 0.0.1-SNAPSHOT + 0.0.2-SNAPSHOT diff --git a/sli/common/pom.xml b/sli/common/pom.xml index f71ca35f6..c367dd779 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -1,150 +1,157 @@ - - 4.0.0 - - sli - org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT - - sli-common - bundle + + 4.0.0 + + sli + org.onap.ccsdk.sli.core + 0.1.2-SNAPSHOT + + sli-common + bundle - SLI - Common Classes - The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter + SLI - Common Classes + The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter - - - junit - junit - 3.8.1 - test - - - org.antlr - antlr4 - ${antlr.version} - jar - compile - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-simple - 1.7.5 - compile - - - org.apache.commons - commons-lang3 - ${commons.lang3.version} - - - org.opendaylight.mdsal - yang-binding - ${odl.mdsal.yang.binding.version} - - - org.opendaylight.yangtools - yang-common - ${odl.yangtools.version} - - - org.opendaylight.mdsal.model - ietf-inet-types - ${odl.ietf-inet-types.version} - - - org.opendaylight.mdsal.model - ietf-yang-types - ${odl.ietf-yang-types.version} - - - org.opendaylight.controller - sal-core-api - ${odl.mdsal.version} - - - org.opendaylight.yangtools - yang-data-impl - ${odl.yangtools.version} - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - mysql - mysql-connector-java - ${mysql.connector.version} - jar - compile - - - org.onap.ccsdk.sli.core - dblib-provider - ${sdnctl.dblib.version} - - + + + junit + junit + 3.8.1 + test + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + org.antlr + antlr4 + ${antlr.version} + jar + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + 1.7.5 + compile + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + + + org.opendaylight.mdsal + yang-binding + ${odl.mdsal.yang.binding.version} + + + org.opendaylight.yangtools + yang-common + ${odl.yangtools.version} + + + org.opendaylight.mdsal.model + ietf-inet-types + ${odl.ietf-inet-types.version} + + + org.opendaylight.mdsal.model + ietf-yang-types + ${odl.ietf-yang-types.version} + + + org.opendaylight.controller + sal-core-api + ${odl.mdsal.version} + + + org.opendaylight.yangtools + yang-data-impl + ${odl.yangtools.version} + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + mysql + mysql-connector-java + ${mysql.connector.version} + jar + compile + + + org.onap.ccsdk.sli.core + dblib-provider + ${sdnctl.dblib.version} + + - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - **/*.xsd - - - org.onap.ccsdk.sli.core.sli.SvcLogicParser - org.onap.ccsdk.sli.core.sli - true - - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.onap.ccsdk.sli.core.sli;version=${project.version} - * - *;scope=compile;artifactId=commons-lang|commons-lang3 - true - - - - - org.antlr - antlr4-maven-plugin - ${antlr.version} - - - - ${project.basedir}/src/main/java/ - - antlr - - antlr4 - - - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + **/*.xsd + + + org.onap.ccsdk.sli.core.sli.SvcLogicParser + org.onap.ccsdk.sli.core.sli + true + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.core.sli;version=${project.version} + * + *;scope=compile;artifactId=commons-lang|commons-lang3 + true + + + + + org.antlr + antlr4-maven-plugin + ${antlr.version} + + + + ${project.basedir}/src/main/java/ + + antlr + + antlr4 + + + + + + diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 0e6000fb2..07f40a2ec 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -8,9 +8,9 @@ * 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. @@ -20,7 +20,7 @@ */ /** - * + * */ package org.onap.ccsdk.sli.core.sli; @@ -28,7 +28,10 @@ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.util.Properties; +import ch.vorburger.mariadb4j.DB; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; import junit.framework.TestCase; /** @@ -40,22 +43,43 @@ public class ITCaseSvcLogicParser extends TestCase { /** * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}. */ - - + + public void testParse() { - + try { + + URL propUrl = getClass().getResource("/svclogic.properties"); - + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - + + Properties props = new Properties(); + + props.load(propStr); + + + // Start MariaDB4j database + DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); + config.setPort(0); // 0 => autom. detect free port + DB db = DB.newEmbeddedDB(config.build()); + db.start(); + + + + // Override jdbc URL and database name + props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + + + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(props); + assertNotNull(store); - + store.registerNodeType("switch"); store.registerNodeType("block"); store.registerNodeType("get-resource"); @@ -69,15 +93,15 @@ public class ITCaseSvcLogicParser extends TestCase { store.registerNodeType("release"); store.registerNodeType("for"); store.registerNodeType("set"); - - + + InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); String testCaseFile = null; while ((testCaseFile = testsReader.readLine()) != null) { - + testCaseFile = testCaseFile.trim(); - + if (testCaseFile.length() > 0) { if (!testCaseFile.startsWith("/")) @@ -94,23 +118,23 @@ public class ITCaseSvcLogicParser extends TestCase { SvcLogicParser.validate(testCaseUrl.getPath(), store); } catch (Exception e) { fail("Validation failure ["+e.getMessage()+"]"); - + } - - - + + + } } - + testStr = getClass().getResourceAsStream("/parser-bad.tests"); testsReader = new BufferedReader(new InputStreamReader(testStr)); testCaseFile = null; while ((testCaseFile = testsReader.readLine()) != null) { - + testCaseFile = testCaseFile.trim(); - + if (testCaseFile.length() > 0) { if (!testCaseFile.startsWith("/")) @@ -134,7 +158,7 @@ public class ITCaseSvcLogicParser extends TestCase { if (valid) { fail("Expected compiler error on "+testCaseFile+", but got success"); } - + } } @@ -148,10 +172,10 @@ public class ITCaseSvcLogicParser extends TestCase { e.printStackTrace(); fail("Caught exception processing test cases"); } - - + + } - - + + } diff --git a/sli/common/src/test/resources/svclogic.properties b/sli/common/src/test/resources/svclogic.properties index 25eb3bd47..33d7ae6e4 100644 --- a/sli/common/src/test/resources/svclogic.properties +++ b/sli/common/src/test/resources/svclogic.properties @@ -8,9 +8,9 @@ # 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. @@ -20,7 +20,7 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url = jdbc:mysql://localhost:3306/sdnctl -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = sdnctl -org.onap.ccsdk.sli.jdbc.password = gamma +org.onap.ccsdk.sli.jdbc.url = jdbc:mysql://localhost:3306/test +org.onap.ccsdk.sli.jdbc.database = test +org.onap.ccsdk.sli.jdbc.user = test +org.onap.ccsdk.sli.jdbc.password = test123 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index f665c56a1..529f97690 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -19,6 +19,12 @@ 3.8.1 test + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + org.onap.ccsdk.sli.core sli-common diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 5e895aa3e..cdf837afe 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -8,9 +8,9 @@ * 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. @@ -31,43 +31,22 @@ import java.util.LinkedList; import java.util.Map; import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicParser; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.onap.ccsdk.sli.core.sli.provider.BlockNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.CallNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ConfigureNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.DeleteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ExistsNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ForNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.GetResourceNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.IsAvailableNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.NotifyNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.RecordNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReleaseNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReserveNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReturnNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SaveNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SetNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; -import org.onap.ccsdk.sli.core.sli.provider.SwitchNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.UpdateNodeExecutor; -import org.osgi.framework.ServiceRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import ch.vorburger.mariadb4j.DB; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; import junit.framework.TestCase; public class ITCaseSvcLogicGraphExecutor extends TestCase { private static final Logger LOG = LoggerFactory .getLogger(SvcLogicGraph.class); - + private static final Map BUILTIN_NODES = new HashMap() { { put("block", new BlockNodeExecutor()); @@ -91,19 +70,36 @@ public class ITCaseSvcLogicGraphExecutor extends TestCase { } }; - + public void testExecute() { - + try { InputStream testStr = getClass().getResourceAsStream("/executor.tests"); BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - + + Properties svcprops = new Properties(); + svcprops.load(propStr); + + // Start MariaDB4j database + DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); + config.setPort(0); // 0 => autom. detect free port + DB db = DB.newEmbeddedDB(config.build()); + db.start(); + + + + // Override jdbc URL and database name + svcprops.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + svcprops.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + + + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); + assertNotNull(store); - + store.registerNodeType("switch"); store.registerNodeType("block"); store.registerNodeType("get-resource"); @@ -118,26 +114,26 @@ public class ITCaseSvcLogicGraphExecutor extends TestCase { store.registerNodeType("for"); store.registerNodeType("set"); SvcLogicParser parser = new SvcLogicParser(store); - + // Loop through executor tests SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); - + for (String nodeType : BUILTIN_NODES.keySet()) { LOG.info("SLI - registering node executor for node type "+nodeType); - + svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } String testCaseLine = null; while ((testCaseLine = testsReader.readLine()) != null) { - + String[] testCaseFields = testCaseLine.split(":"); String testCaseFile = testCaseFields[0]; String testCaseMethod = testCaseFields[1]; String testCaseParameters = null; - + if (testCaseFields.length > 2) { testCaseParameters = testCaseFields[2]; } @@ -145,7 +141,7 @@ public class ITCaseSvcLogicGraphExecutor extends TestCase { SvcLogicContext ctx = new SvcLogicContext(); if (testCaseParameters != null) { String[] testCaseParameterSettings = testCaseParameters.split(","); - + for (int i = 0 ; i < testCaseParameterSettings.length ; i++) { String[] nameValue = testCaseParameterSettings[i].split("="); if (nameValue != null) { @@ -154,14 +150,14 @@ public class ITCaseSvcLogicGraphExecutor extends TestCase { if (nameValue.length > 1) { value = nameValue[1]; } - + ctx.setAttribute(name, value); } } } - + testCaseFile = testCaseFile.trim(); - + if (testCaseFile.length() > 0) { if (!testCaseFile.startsWith("/")) { testCaseFile = "/"+testCaseFile; @@ -170,12 +166,12 @@ public class ITCaseSvcLogicGraphExecutor extends TestCase { if (testCaseUrl == null) { fail("Could not resolve test case file "+testCaseFile); } - + LinkedList graphs = parser.parse(testCaseUrl.getPath()); - + assertNotNull(graphs); - + for (SvcLogicGraph graph: graphs) { if (graph.getRpc().equals(testCaseMethod)) { Properties props = ctx.toProperties(); @@ -184,9 +180,9 @@ public class ITCaseSvcLogicGraphExecutor extends TestCase { String propName = (String) e1.nextElement(); LOG.info(propName+" = "+props.getProperty(propName)); } - + svc.execute(graph, ctx); - + props = ctx.toProperties(); LOG.info("SvcLogicContext after executing "+testCaseMethod+":"); for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements() ; ) { @@ -197,16 +193,16 @@ public class ITCaseSvcLogicGraphExecutor extends TestCase { } } - - + + } - - + + } catch (Exception e) { LOG.error("Caught exception executing directed graphs", e); fail("Exception executing graphs"); } } - + } -- cgit 1.2.3-korg From 222513c30f3c0c0e7bfce48b6c96d9ddfba75dba Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Wed, 13 Sep 2017 16:58:19 -0400 Subject: Clean up BaseDBConfiguration class This change isn't too big; it mainly just attempts to clean up the BaseDBConfiguration class using best practices. For example: * documentation is added surrounding public methods, public constants, protected variables, and class headers. * code logic for parsing "optional" integer properties is abstracted into a separate private static function, which returns a default value if the given input property cannot be parsed or is not present. * public functions where the NumberFormatException RuntimeException might be thrown have the appriorate "throws" modifier added to their function signatures to indicate that the consumer is responsible for exception handling. * constants are extracted in place of "magic numbers" This is really just code sanitation work. Change-Id: Ifaf092e10b17f54c7cce0a888aa49bfe8377cdd3 Issue-Id: SDNC-79 Signed-off-by: Ryan Goulding --- .../sli/core/dblib/config/BaseDBConfiguration.java | 289 +++++++++++++++------ 1 file changed, 211 insertions(+), 78 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java index 4b738d426..d53be0e7f 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java @@ -22,83 +22,216 @@ package org.onap.ccsdk.sli.core.dblib.config; import java.util.Properties; +/** + * Base class responsible for parsing business logic for database configuration from given Properties. + */ public abstract class BaseDBConfiguration { - public static final String DATABASE_TYPE = "org.onap.ccsdk.sli.dbtype"; - public static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url"; - public static final String DATABASE_NAME = "org.onap.ccsdk.sli.jdbc.database"; - public static final String CONNECTION_NAME = "org.onap.ccsdk.sli.jdbc.connection.name"; - public static final String DATABASE_USER = "org.onap.ccsdk.sli.jdbc.user"; - public static final String DATABASE_PSSWD = "org.onap.ccsdk.sli.jdbc.password"; - public static final String CONNECTION_TIMEOUT="org.onap.ccsdk.sli.jdbc.connection.timeout"; - public static final String REQUEST_TIMEOUT = "org.onap.ccsdk.sli.jdbc.request.timeout"; - public static final String MIN_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.min"; - public static final String MAX_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.max"; - public static final String INIT_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.init"; - public static final String DATABASE_HOSTS = "org.onap.ccsdk.sli.jdbc.hosts"; - - - protected final Properties props; - - public BaseDBConfiguration(Properties properties) { - this.props = properties; - } - - public int getConnTimeout() { - try { - String value = props.getProperty(CONNECTION_TIMEOUT); - return Integer.parseInt(value); - } catch(Exception exc) { - return -1; - } - } - - public int getRequestTimeout() { - try { - String value = props.getProperty(REQUEST_TIMEOUT); - if(value == null) - return -1; - return Integer.parseInt(value); - } catch(Exception exc) { - return -1; - } - } - - public String getDbConnectionName() { - return props.getProperty(CONNECTION_NAME); - } - - public String getDatabaseName() { - return props.getProperty(DATABASE_NAME); - } - - public String getDbUserId() { - return props.getProperty(DATABASE_USER); - } - - public String getDbPasswd() { - return props.getProperty(DATABASE_PSSWD); - } - - public int getDbMinLimit() { - String value = props.getProperty(MIN_LIMIT); - return Integer.parseInt(value); - } - - public int getDbMaxLimit() { - String value = props.getProperty(MAX_LIMIT); - return Integer.parseInt(value); - } - - public int getDbInitialLimit() { - String value = props.getProperty(INIT_LIMIT); - return Integer.parseInt(value); - } - - public String getDbUrl() { - return props.getProperty(DATABASE_URL); - } - - public String getServerGroup() { - return null; - } + + /** + * Property key within a properties configuration File for db type + */ + public static final String DATABASE_TYPE = "org.onap.ccsdk.sli.dbtype"; + + /** + * Property key with a properties configuration File for db url + */ + public static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url"; + + /** + * Property key with a properties configuration File for database name + */ + public static final String DATABASE_NAME = "org.onap.ccsdk.sli.jdbc.database"; + + /** + * Property key with a properties configuration File for db database connection name + */ + public static final String CONNECTION_NAME = "org.onap.ccsdk.sli.jdbc.connection.name"; + + /** + * Property key with a properties configuration File for database user + */ + public static final String DATABASE_USER = "org.onap.ccsdk.sli.jdbc.user"; + + /** + * Property key with a properties configuration File for database password for associated with + * org.onap.ccsdk.sli.jdbc.user. + */ + public static final String DATABASE_PSSWD = "org.onap.ccsdk.sli.jdbc.password"; + + /** + * Property key with a properties configuration File for database connection timeout + */ + public static final String CONNECTION_TIMEOUT="org.onap.ccsdk.sli.jdbc.connection.timeout"; + + /** + * Property key with a properties configuration File for database request timeout + */ + public static final String REQUEST_TIMEOUT = "org.onap.ccsdk.sli.jdbc.request.timeout"; + + /** + * Property key with a properties configuration File for database minimum limit + */ + public static final String MIN_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.min"; + + /** + * Property key with a properties configuration File for database maximum limit + */ + public static final String MAX_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.max"; + + /** + * Property key with a properties configuration File for database initial limit + */ + public static final String INIT_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.init"; + + /** + * Property key with a properties configuration File for database hosts + */ + public static final String DATABASE_HOSTS = "org.onap.ccsdk.sli.jdbc.hosts"; + + /** + * default value when the connection timeout is not present or cannot be parsed + */ + private static final int DEFAULT_CONNECTION_TIMEOUT = -1; + + /** + * default value when the request timeout is not present or cannot be parsed + */ + private static final int DEFAULT_REQUEST_TIMEOUT = -1; + + /** + * A set of properties with database configuration information. + */ + protected final Properties properties; + + /** + * Builds a configuration based on given properties + * + * @param properties properties represented by the public constant keys defined by this class + */ + public BaseDBConfiguration(final Properties properties) { + this.properties = properties; + } + + /** + * Extracts the connection timeout. + * + * @return the connection timeout, or DEFAULT_CONNECTION_TIMEOUT if not present + */ + public int getConnTimeout() { + return extractProperty(properties, CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); + } + + /** + * Extracts the request timeout. + * + * @return the request timeout, or DEFAULT_REQUEST_TIMEOUT if not present + */ + public int getRequestTimeout() { + return extractProperty(properties, REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT); + } + + /** + * A utility method to extract int property from Properties. + * + * @param properties a set of Properties + * @param propertyKey the key in question + * @param defaultValue the value to return if the key does not exist + * @return Either the property value for propertyKey or defaultValue if not present + */ + private static int extractProperty(final Properties properties, final String propertyKey, final int defaultValue) { + try { + final String valueString = properties.getProperty(propertyKey, Integer.toString(defaultValue)); + return Integer.parseInt(valueString); + } catch(final NumberFormatException e) { + return defaultValue; + } + } + + /** + * Extracts the db connection name. + * + * @return the db connection name, or null if not present + */ + public String getDbConnectionName() { + return properties.getProperty(CONNECTION_NAME); + } + + /** + * Extracts the db name. + * + * @return the db name, or null if not present + */ + public String getDatabaseName() { + return properties.getProperty(DATABASE_NAME); + } + + /** + * Extracts the db user id. + * + * @return the db user id, or null if not present + */ + public String getDbUserId() { + return properties.getProperty(DATABASE_USER); + } + + /** + * Extracts the db password. + * + * @return the db password, or null if not present + */ + public String getDbPasswd() { + return properties.getProperty(DATABASE_PSSWD); + } + + /** + * Extracts the db min limit. + * + * @return the db min limit + * @throws NumberFormatException if the property is not specified, or cannot be parsed as an Integer. + */ + public int getDbMinLimit() throws NumberFormatException { + String value = properties.getProperty(MIN_LIMIT); + return Integer.parseInt(value); + } + + /** + * Extracts the db max limit. + * + * @return the db max limit + * @throws NumberFormatException if the property is not specified, or cannot be parsed as an Integer. + */ + public int getDbMaxLimit() throws NumberFormatException { + String value = properties.getProperty(MAX_LIMIT); + return Integer.parseInt(value); + } + + /** + * Extracts the db initial limit. + * + * @return the db initial limit + * @throws NumberFormatException if the property is not specified, or cannot be parsed as an Integer. + */ + public int getDbInitialLimit() throws NumberFormatException { + String value = properties.getProperty(INIT_LIMIT); + return Integer.parseInt(value); + } + + /** + * Extracts the db url. + * + * @return the db url, or null if not present + */ + public String getDbUrl() { + return properties.getProperty(DATABASE_URL); + } + + /** + * Extracts the db server group. + * + * @return null + */ + @Deprecated + public String getServerGroup() { + return null; + } } -- cgit 1.2.3-korg From 8a2cc38d7e8a3c259d3872655732a15051022c4e Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 14 Sep 2017 11:38:05 +0530 Subject: Fix critical issues few critical/major issues in core/sli module Issue-Id: CCSDK-87 Change-Id: Ib7ef026ecb7fcf658ea8fc66ad5d9b739f02c55b Signed-off-by: surya-huawei --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 8ab308ebc..60dd6b46a 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -65,23 +65,13 @@ public class MdsalHelper { public static void loadProperties(String propertiesFile) { File file = new File(propertiesFile); Properties properties = new Properties(); - InputStream input = null; if (file.isFile() && file.canRead()) { - try { - input = new FileInputStream(file); - properties.load(input); - MdsalHelper.setYangMappingProperties(properties); - LOG.info("Loaded properties from " + propertiesFile); + try (InputStream input = new FileInputStream(file)) { + properties.load(input); + MdsalHelper.setYangMappingProperties(properties); + LOG.info("Loaded properties from " + propertiesFile); } catch (Exception e) { - LOG.error("Failed to load properties " + propertiesFile + "\n", e); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - LOG.error("Failed to close properties file " + propertiesFile + "\n", e); - } - } + LOG.error("Failed to load properties " + propertiesFile + "\n", e); } }else{ LOG.error("Failed to load the properties file " + propertiesFile + "\n"); @@ -127,7 +117,7 @@ public class MdsalHelper { for (int i = 0; i < fromList.size(); i++) { toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); } - props.setProperty(pfx + "_length", "" + fromList.size()); + props.setProperty(pfx + "_length", Integer.toString(fromList.size())); } else if (isYangGenerated(fromClass)) { // Class is yang generated. -- cgit 1.2.3-korg From b5eb016eb6b64a39ded0290412aef895d527ef0a Mon Sep 17 00:00:00 2001 From: shashikanth Date: Mon, 11 Sep 2017 18:21:17 +0530 Subject: Fix Blocker/Critical sonar issues Fix Blocker/Critical sonar issues in vnfapi module https://sonar.onap.org/component_issues?id=org.openecomp.sdnc.core%3Asdnc-core#resolved=false|severities=BLOCKER Issue-Id: CCSDK-67 Change-Id: Ie2ace1bc30bbb50d2b6f25a56e716c7a952e7ea0 Signed-off-by: shashikanth.vh --- .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 5270143a6..26d45ce9a 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -21,17 +21,6 @@ package org.onap.ccsdk.sli.core.sli; -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.util.LinkedList; - -import javax.xml.XMLConstants; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.Attributes; @@ -41,6 +30,16 @@ import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; +import javax.xml.XMLConstants; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import java.io.File; +import java.io.InputStream; +import java.net.URL; +import java.util.LinkedList; + /** * @author dt5972 * @@ -336,7 +335,7 @@ public class SvcLogicParser { Schema schema = null; String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true"); - if (validateSchema != null || validateSchema.equalsIgnoreCase("true")) { + if ("true".equalsIgnoreCase(validateSchema)) { xsdUrl = getClass().getResource(SVCLOGIC_XSD); } @@ -362,7 +361,7 @@ public class SvcLogicParser { SAXParser saxParser = factory.newSAXParser(); if (saxParser.isValidating()) { - LOGGER.info("Validating against schema " + xsdUrl.getPath()); + LOGGER.info("Parser not configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null)); } graphs = new LinkedList<>(); -- cgit 1.2.3-korg From 207b29089b970e9ab2e8cd7d65a25cadc9c23074 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Thu, 14 Sep 2017 21:05:22 +0530 Subject: Fix few sonar issues Fix few sonar issues in CCSDK SLI Core module Change-Id: I0e2454f7e23e73087ac42880c5e0b1e4c089dde8 Issue-Id: CCSDK-67 Signed-off-by: Ramu N --- .../onap/ccsdk/sli/core/sli/CommonConstants.java | 27 +++++ .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 132 ++++++++++----------- 2 files changed, 93 insertions(+), 66 deletions(-) create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java new file mode 100644 index 000000000..d30b2b626 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java @@ -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========================================================= + */ + +package org.onap.ccsdk.sli.core.sli; + +public interface CommonConstants { + + public static final String SERVICE_LOGIC_STATUS = "SvcLogic.status"; +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index eaf57428f..232774396 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -8,9 +8,9 @@ * 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. @@ -38,39 +38,38 @@ import org.w3c.dom.Text; public class SvcLogicContext { - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicContext.class); - + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicContext.class); + private HashMap attributes; - + private DOMDataBroker domDataBroker; - + private String status = "success"; - + public SvcLogicContext() { - this.attributes = new HashMap (); - + this.attributes = new HashMap<> (); + } - + public SvcLogicContext(Properties props) { - this.attributes = new HashMap (); - - if (props.containsKey("SvcLogic.status")) + this.attributes = new HashMap<> (); + + if (props.containsKey(CommonConstants.SERVICE_LOGIC_STATUS)) { - this.status = props.getProperty("SvcLogic.status"); + this.status = props.getProperty(CommonConstants.SERVICE_LOGIC_STATUS); } - + for (Object nameObj : props.keySet()) { String propName = (String) nameObj; attributes.put(propName, props.getProperty(propName)); } } - - - + + + public DOMDataBroker getDomDataBroker() { return domDataBroker; } @@ -83,14 +82,14 @@ public class SvcLogicContext { { if (attributes.containsKey(name)) { - return(attributes.get(name)); + return attributes.get(name); } else { - return(null); + return null; } } - + public void setAttribute(String name, String value) { if (value == null) { @@ -101,10 +100,10 @@ public class SvcLogicContext { attributes.put(name, value); } } - + public Set getAttributeKeySet() { - return(attributes.keySet()); + return attributes.keySet(); } public String getStatus() { @@ -114,86 +113,88 @@ public class SvcLogicContext { public void setStatus(String status) { this.status = status; } - + public Properties toProperties() { Properties props = new Properties(); - + if (status != null) { - props.setProperty("SvcLogic.status", status); + props.setProperty(CommonConstants.SERVICE_LOGIC_STATUS, status); } - - for (String attrName : attributes.keySet()) + + String attrName; + String attrVal; + for (Map.Entry entry : attributes.entrySet()) { - String attrVal = attributes.get(attrName); + attrName = entry.getKey(); + attrVal = entry.getValue(); if (attrVal == null) { - LOG.warn("attribute " + attrName - + "null - setting to empty string"); + LOG.warn("attribute {} value is null - setting to empty string", attrName); props.setProperty(attrName, ""); } else { - props.setProperty(attrName, attributes.get(attrName)); + props.setProperty(attrName, attrVal); } } - - return(props); + + return props; } - + public void mergeDocument(String pfx, Document doc) { String prefix = ""; - + if (pfx != null) { prefix = pfx; } - + Element root = doc.getDocumentElement(); - + mergeElement(prefix, root, null); } - + public void mergeElement(String pfx, Element element, Map nodeMap) { - + // In XML, cannot tell the difference between containers and lists. // So, have to treat each element as both (ugly but necessary). - // We do this by passing a nodeMap to be used to count instance of each tag, - // which will be used to set _length and to set index - - LOG.trace("mergeElement("+pfx+","+element.getTagName()+","+nodeMap+")"); + // We do this by passing a nodeMap to be used to count instance of each tag, + // which will be used to set _length and to set index + + LOG.trace("mergeElement({},{},{})", pfx, element.getTagName(), nodeMap); String curTagName = element.getTagName(); String prefix = curTagName; - + if (pfx != null) { prefix = pfx + "." + prefix; } - + int myIdx = 0; - + if (nodeMap != null) { if (nodeMap.containsKey(curTagName)) { - myIdx = nodeMap.get(curTagName).intValue(); + myIdx = nodeMap.get(curTagName); } - nodeMap.put(curTagName, new Integer(myIdx+1)); - this.setAttribute(prefix+"_length", ""+(myIdx+1)); + nodeMap.put(curTagName, myIdx+1); + this.setAttribute(prefix+"_length", Integer.toString(myIdx+1)); } - + NodeList children = element.getChildNodes(); - + int numChildren = children.getLength(); - - Map childMap = new HashMap(); - Map idxChildMap = new HashMap(); - + + Map childMap = new HashMap<>(); + Map idxChildMap = new HashMap<>(); + for (int i = 0 ; i < numChildren ; i++) { Node curNode = children.item(i); - + if (curNode instanceof Text) { Text curText = (Text) curNode; String curTextValue = curText.getTextContent(); - LOG.trace("Setting ctx variable "+prefix+" = "+curTextValue); + LOG.trace("Setting ctx variable {} = {}", prefix, curTextValue); this.setAttribute(prefix, curText.getTextContent()); - + } else if (curNode instanceof Element) { mergeElement(prefix, (Element) curNode, childMap); @@ -204,9 +205,9 @@ public class SvcLogicContext { } } } - + } - + public String resolve(String ctxVarName) { if (ctxVarName.indexOf('[') == -1) { @@ -215,16 +216,15 @@ public class SvcLogicContext { } // Resolve any array references - StringBuffer sbuff = new StringBuffer(); + StringBuilder sbuff = new StringBuilder(); String[] ctxVarParts = ctxVarName.split("\\["); sbuff.append(ctxVarParts[0]); for (int i = 1; i < ctxVarParts.length; i++) { if (ctxVarParts[i].startsWith("$")) { - int endBracketLoc = ctxVarParts[i].indexOf("]"); + int endBracketLoc = ctxVarParts[i].indexOf(']'); if (endBracketLoc == -1) { // Missing end bracket ... give up parsing - LOG.warn("Variable reference " + ctxVarName - + " seems to be missing a ']'"); + LOG.warn("Variable reference {} seems to be missing a ']'", ctxVarName); return (this.getAttribute(ctxVarName)); } -- cgit 1.2.3-korg From 7ea02fe1a8f40ffba9e54eb92391ee5dd6382ff5 Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Thu, 14 Sep 2017 12:14:12 -0400 Subject: Clean up public interfaces The Java programming language assigns certain defaults for methods and constants defined in interfaces. This change removes the unnecessary redundant modifiers appropriately. For example: * interface methods are public by default * interface constants are public by default * interface methods are abstract unless "default" is specifically used (as of JDK8+). This is really just to get rid of annoying warnings present in IDE(s). Issue-Id: SDNC-79 Change-Id: I2e6b3e4fa02bad1beee2cbb49d3766722eff1ba0 Signed-off-by: Ryan Goulding --- .../ccsdk/sli/core/dblib/DBResourceObserver.java | 2 +- .../onap/ccsdk/sli/core/dblib/DataAccessor.java | 4 +- .../ccsdk/sli/core/dblib/DataSourceComparator.java | 6 +- .../onap/ccsdk/sli/core/dblib/DbLibService.java | 34 ++++----- .../core/dblib/pm/SQLExecutionMonitorObserver.java | 18 ++--- .../sli/core/sli/provider/SvcLogicService.java | 82 +++++++++++----------- .../core/slipluginutils/SvcLogicContextObject.java | 2 +- 7 files changed, 74 insertions(+), 74 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java index 2e1a6e953..f30212dca 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceObserver.java @@ -23,5 +23,5 @@ package org.onap.ccsdk.sli.core.dblib; import java.util.Observer; public interface DBResourceObserver extends Observer { - public boolean isMonitorDbResponse(); + boolean isMonitorDbResponse(); } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java index 7921fa5c5..fdfb47bca 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java @@ -27,7 +27,7 @@ import javax.sql.rowset.CachedRowSet; public interface DataAccessor { - public abstract CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) - throws SQLException; + CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) + throws SQLException; } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java index bc14fb8b9..4cfcc7318 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataSourceComparator.java @@ -24,10 +24,10 @@ import java.util.Comparator; public interface DataSourceComparator extends Comparator { - public abstract CachedDataSource getLastUsed(); + CachedDataSource getLastUsed(); - public abstract void setLastUsed(CachedDataSource lastUsed); + void setLastUsed(CachedDataSource lastUsed); - public abstract int compare(CachedDataSource ds1, CachedDataSource ds2); + int compare(CachedDataSource ds1, CachedDataSource ds2); } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java index 0dea664d5..b31de3547 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java @@ -28,22 +28,22 @@ import javax.sql.rowset.CachedRowSet; public interface DbLibService { - /* (non-Javadoc) - * @see DataAccessor#getData(java.lang.String, java.util.ArrayList) - */ - public abstract CachedRowSet getData(String statement, - ArrayList arguments, String preferredDS) - throws SQLException; - - /* (non-Javadoc) - * @see DataAccessor#writeData(java.lang.String, java.util.ArrayList) - */ - public abstract boolean writeData(String statement, - ArrayList arguments, String preferredDS) - throws SQLException; - - public abstract boolean isActive(); - - public abstract Connection getConnection() throws SQLException; + /* (non-Javadoc) + * @see DataAccessor#getData(java.lang.String, java.util.ArrayList) + */ + CachedRowSet getData(String statement, + ArrayList arguments, String preferredDS) + throws SQLException; + + /* (non-Javadoc) + * @see DataAccessor#writeData(java.lang.String, java.util.ArrayList) + */ + boolean writeData(String statement, + ArrayList arguments, String preferredDS) + throws SQLException; + + boolean isActive(); + + Connection getConnection() throws SQLException; } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java index c17696a80..2fdde1ee4 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitorObserver.java @@ -21,17 +21,17 @@ package org.onap.ccsdk.sli.core.dblib.pm; public interface SQLExecutionMonitorObserver { - public String getDbConnectionName(); + String getDbConnectionName(); - public long getInterval(); - public void setInterval(long value); + long getInterval(); + void setInterval(long value); - public long getInitialDelay(); - public void setInitialDelay(long value); + long getInitialDelay(); + void setInitialDelay(long value); - public long getExpectedCompletionTime(); - public void setExpectedCompletionTime(long value); + long getExpectedCompletionTime(); + void setExpectedCompletionTime(long value); - public long getUnprocessedFailoverThreshold(); - public void setUnprocessedFailoverThreshold(long value); + long getUnprocessedFailoverThreshold(); + void setUnprocessedFailoverThreshold(long value); } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java index 23911b683..19d985dd4 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java @@ -28,49 +28,49 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; public interface SvcLogicService { - public static final String NAME = "org.onap.ccsdk.sli.core.sli.provider.SvcLogicService"; + String NAME = "org.onap.ccsdk.sli.core.sli.provider.SvcLogicService"; - // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException; - /** - * Check for existence of a directed graph - * @param module - module name - * @param rpc - rpc name - * @param version - version. If null, looks for active version - * @param mode - mode (sync/async) - * @return true if directed graph found, false otherwise - * @throws SvcLogicException - */ - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; + // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException; + /** + * Check for existence of a directed graph + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, looks for active version + * @param mode - mode (sync/async) + * @return true if directed graph found, false otherwise + * @throws SvcLogicException + */ + boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; - /** - * Execute a directed graph - * - * @param module - module name - * @param rpc - rpc name - * @param version - version. If null, use active version - * @param mode - mode (sync/async) - * @param parms - parameters, used to set SvcLogicContext attributes - * @return final values of attributes from SvcLogicContext, as Properties - * @throws SvcLogicException - * - * - * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead - */ - @Deprecated - public Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; + /** + * Execute a directed graph + * + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, use active version + * @param mode - mode (sync/async) + * @param parms - parameters, used to set SvcLogicContext attributes + * @return final values of attributes from SvcLogicContext, as Properties + * @throws SvcLogicException + * + * + * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead + */ + @Deprecated + Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; - /** - * Execute a directed graph - * - * @param module - module name - * @param rpc - rpc name - * @param version - version. If null, use active version - * @param mode - mode (sync/async) - * @param parms - parameters, used to set SvcLogicContext attributes - * @param domDataBroker - DOMDataBroker object - * @return final values of attributes from SvcLogicContext, as Properties - * @throws SvcLogicException - */ - public Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException; + /** + * Execute a directed graph + * + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, use active version + * @param mode - mode (sync/async) + * @param parms - parameters, used to set SvcLogicContext attributes + * @param domDataBroker - DOMDataBroker object + * @return final values of attributes from SvcLogicContext, as Properties + * @throws SvcLogicException + */ + Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException; } diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java index eaa92c3f3..aa41a5c60 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SvcLogicContextObject.java @@ -24,5 +24,5 @@ package org.onap.ccsdk.sli.core.slipluginutils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; public interface SvcLogicContextObject { - public void writeToContext( SvcLogicContext ctx, String root ); + void writeToContext(SvcLogicContext ctx, String root ); } -- cgit 1.2.3-korg From eb790498dacf46fc594b93bf62a6e17f686af62e Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Thu, 14 Sep 2017 12:37:10 -0400 Subject: Fix SDNC service registration Instead of registgering services via BundleActivator(s), use blueprint instead. This change deletes the RecordingActivator, as it was just used to kickstart the service registration using felix dm. The idea here is to instead use blueprint through recording-blueprint.xml. The decision was also made to register the Service(s) using the implementation class name instead of the interface class name for backwards compatibility reasons. In all reality, registering Service(s) under the implementation name is less future proof since clients are no longer able to easily swap in a separate implementation Service. In the future, we should consider finding usages of this Service and ensuring that they poll for the interface rather than the implementation. However, that is separate from this change and is considered future work. Issue-Id: SDNC-54 Change-Id: I757bb90f91d114668c153ec5debb5c65af44452a Signed-off-by: Ryan Goulding --- sli/recording/pom.xml | 2 - .../sli/core/sli/recording/RecordingActivator.java | 75 ---------------------- .../opendaylight/blueprint/recording-blueprint.xml | 20 ++++++ 3 files changed, 20 insertions(+), 77 deletions(-) delete mode 100644 sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java create mode 100644 sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 97c99188c..f0bc09706 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -59,9 +59,7 @@ true - org.onap.ccsdk.sli.core.sli.recording.RecordingActivator org.onap.ccsdk.sli.core.sli.recording;version=${project.version} - * true diff --git a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java b/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java deleted file mode 100644 index fd857f56b..000000000 --- a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/RecordingActivator.java +++ /dev/null @@ -1,75 +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.util.LinkedList; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class RecordingActivator implements BundleActivator { - - private LinkedList registrations = new LinkedList<>(); - - private static final Logger LOG = LoggerFactory - .getLogger(RecordingActivator.class); - - @Override - public void start(BundleContext ctx) throws Exception { - - if (registrations == null) - { - registrations = new LinkedList<>(); - } - - - FileRecorder fileRecorder = new FileRecorder(); - String regName = fileRecorder.getClass().getName(); - LOG.debug("Registering FileRecorder service "+regName); - ServiceRegistration reg =ctx.registerService(regName, fileRecorder, null); - registrations.add(reg); - - Slf4jRecorder slf4jRecorder = new Slf4jRecorder(); - regName = slf4jRecorder.getClass().getName(); - LOG.debug("Registering Slf4jRecorder service "+regName); - reg =ctx.registerService(regName, slf4jRecorder, null); - registrations.add(reg); - - } - - @Override - public void stop(BundleContext arg0) throws Exception { - if (registrations != null) { - for (ServiceRegistration reg : registrations) { - ServiceReference regRef = reg.getReference(); - reg.unregister(); - } - registrations = null; - } - } - -} 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 new file mode 100644 index 000000000..d8035376d --- /dev/null +++ b/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg From 871e2b160680d521a6fc96abe745b96d91c9cee6 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 14 Sep 2017 16:16:12 -0400 Subject: Remove pom.xml sections inherited from oparent Remove pom.xml sections inherited from oparent. In particular, comment out distributionManagement so that it is inherited from oparent. Change-Id: I702e70eb712ecfcf02f6707830b1268586c34e09 Issue-ID: CCSDK-43 Signed-off-by: Dan Timoney --- pom.xml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 469a2a696..1c6cd4ae5 100755 --- a/pom.xml +++ b/pom.xml @@ -16,12 +16,6 @@ 0.0.2-SNAPSHOT - - JIRA - http://jira.onap.org/ - - - scm:git:ssh://git@${onap.git.host}/sdnc-code.git scm:git:ssh://${onap.git.host}:${onap.git.port}/${onap.git.project}/sdnc-core.git @@ -29,12 +23,8 @@ sdnc-core-1.1.0 - - Jenkins - https://jenkins.onap.org/ - - + -- cgit 1.2.3-korg From f18123043c576a74d1123ec767d4219818da3b75 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Thu, 14 Sep 2017 15:25:57 -0700 Subject: Log current DG & NodeId using MDC Uses MDC.put to add current directed graph and current nodeId to MDC context which is then logged into the standard karaf log. Issue-Id: CCSDK-71 Change-Id: Ieeeea6a89761cdf0ee7a3e63f4e58e182f37ff28 Signed-off-by: Marcus G K Williams --- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 437 +++++++++++---------- 1 file changed, 221 insertions(+), 216 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index a904eb855..4bb460d78 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -44,230 +44,235 @@ import org.slf4j.MDC; public class SvcLogicServiceImpl implements SvcLogicService { - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicServiceImpl.class); - - private HashMap nodeExecutors = null; - - private BundleContext bctx = null; - - private void registerExecutors() { - - LOG.info("Entered register executors"); - if (bctx == null) { - bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - } - - if (nodeExecutors == null) { - nodeExecutors = new HashMap(); - } - - LOG.info("Opening service tracker"); - ServiceTracker tracker = new ServiceTracker(bctx, - SvcLogicNodeExecutor.class.getName(), null); - - tracker.open(); - - ServiceListener listener = new ServiceListener() { - - public void serviceChanged(ServiceEvent ev) { - ServiceReference sr = ev.getServiceReference(); - switch (ev.getType()) { - case ServiceEvent.REGISTERED: { - registerExecutor(sr); - } - break; - case ServiceEvent.UNREGISTERING: { - unregisterExecutor(sr); - } - break; - } - } - }; - - LOG.info("Adding service listener"); - String filter = "(objectclass=" + SvcLogicNodeExecutor.class.getName() - + ")"; - try { - bctx.addServiceListener(listener, filter); - ServiceReference[] srl = bctx.getServiceReferences( - SvcLogicNodeExecutor.class.getName(), null); - for (int i = 0; srl != null && i < srl.length; i++) { - listener.serviceChanged(new ServiceEvent( - ServiceEvent.REGISTERED, srl[i])); - } - } catch (InvalidSyntaxException e) { - e.printStackTrace(); - } - LOG.info("Done registerExecutors"); - } - - public void registerExecutor(ServiceReference sr) { - - String nodeName = (String) sr.getProperty("nodeType"); - if (nodeName != null) { - - SvcLogicNodeExecutor executor = null; - - try { - executor = (SvcLogicNodeExecutor) bctx.getService(sr); - } catch (Exception e) { - LOG.error("Cannot get service executor for " + nodeName); - return; - } + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicServiceImpl.class); + + private HashMap nodeExecutors = null; + + private BundleContext bctx = null; + + private void registerExecutors() { + + LOG.info("Entered register executors"); + if (bctx == null) { + bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + } + + if (nodeExecutors == null) { + nodeExecutors = new HashMap(); + } + + LOG.info("Opening service tracker"); + ServiceTracker tracker = new ServiceTracker(bctx, + SvcLogicNodeExecutor.class.getName(), null); + + tracker.open(); + + ServiceListener listener = new ServiceListener() { + + public void serviceChanged(ServiceEvent ev) { + ServiceReference sr = ev.getServiceReference(); + switch (ev.getType()) { + case ServiceEvent.REGISTERED: { + registerExecutor(sr); + } + break; + case ServiceEvent.UNREGISTERING: { + unregisterExecutor(sr); + } + break; + } + } + }; + + LOG.info("Adding service listener"); + String filter = "(objectclass=" + SvcLogicNodeExecutor.class.getName() + + ")"; + try { + bctx.addServiceListener(listener, filter); + ServiceReference[] srl = bctx.getServiceReferences( + SvcLogicNodeExecutor.class.getName(), null); + for (int i = 0; srl != null && i < srl.length; i++) { + listener.serviceChanged(new ServiceEvent( + ServiceEvent.REGISTERED, srl[i])); + } + } catch (InvalidSyntaxException e) { + e.printStackTrace(); + } + LOG.info("Done registerExecutors"); + } + + public void registerExecutor(ServiceReference sr) { + + String nodeName = (String) sr.getProperty("nodeType"); + if (nodeName != null) { + + SvcLogicNodeExecutor executor = null; + + try { + executor = (SvcLogicNodeExecutor) bctx.getService(sr); + } catch (Exception e) { + LOG.error("Cannot get service executor for " + nodeName); + return; + } registerExecutor(nodeName, executor); - } - } - - public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) - { - if (nodeExecutors == null) { - nodeExecutors = new HashMap(); - } - LOG.info("SLI - registering executor for node type "+nodeName); - nodeExecutors.put(nodeName, executor); - } - - public void unregisterExecutor(ServiceReference sr) { - String nodeName = (String) sr.getProperty("nodeType"); - - if (nodeName != null) { - + } + } + + public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) + { + if (nodeExecutors == null) { + nodeExecutors = new HashMap(); + } + LOG.info("SLI - registering executor for node type "+nodeName); + nodeExecutors.put(nodeName, executor); + } + + public void unregisterExecutor(ServiceReference sr) { + String nodeName = (String) sr.getProperty("nodeType"); + + if (nodeName != null) { + unregisterExecutor(nodeName); - } - - } - - public void unregisterExecutor(String nodeName) - { - - LOG.info("SLI - unregistering executor for node type "+nodeName); - nodeExecutors.remove(nodeName); - } - - - - - public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) - throws SvcLogicException { - - if (nodeExecutors == null) { - registerExecutors(); - } - - // Set service name in MDC to reference current working directed graph - MDC.put(MetricLogger.SERVICE_NAME, graph.getModule()+":"+graph.getRpc()+"/v"+graph.getVersion()); - - SvcLogicNode curNode = graph.getRootNode(); - LOG.info("About to execute graph " + graph.toString()); - - - - while (curNode != null) { - LOG.info("About to execute node # "+curNode.getNodeId()+" ("+curNode.getNodeType()+")"); - - SvcLogicNode nextNode = executeNode(curNode, ctx); - curNode = nextNode; - } - - return (ctx); - } - - - public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - if (node == null) { - return (null); - } - - if (LOG.isDebugEnabled()) { - LOG.debug("Executing node " + node.getNodeId()); - } - - SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); - - if (executor != null) { - LOG.debug("Executing node executor for node type "+node.getNodeType()+" - "+executor.getClass().getName()); - return (executor.execute(this, node, ctx)); - } else { - if (LOG.isDebugEnabled()) { - LOG.debug(node.getNodeType() + " node not implemented"); - } - SvcLogicNode nextNode = node.getOutcomeValue("failure"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute failure branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no failure or Other branch found"); - } - } - return (nextNode); - } - - } - - @Override - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException - { - SvcLogicStore store = SvcLogicActivator.getStore(); - - return (store.hasGraph(module, rpc, version, mode)); - } - - @Override - public Properties execute(String module, String rpc, String version, String mode, Properties props) - throws SvcLogicException { - return(execute(module, rpc, version, mode, props, null)); - } - - - @Override - public Properties execute(String module, String rpc, String version, String mode, - Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { - - - // See if there is a service logic defined - // - SvcLogicStore store = SvcLogicActivator.getStore(); - - LOG.info("Fetching service logic from data store"); - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - - - - if (graph == null) - { - Properties retProps = new Properties(); - retProps.setProperty("error-code", "401"); - retProps.setProperty("error-message", "No service logic found for ["+module+","+rpc+","+version+","+mode+"]"); - return(retProps); - - } - - SvcLogicContext ctx = new SvcLogicContext(props); + } + + } + + public void unregisterExecutor(String nodeName) + { + + LOG.info("SLI - unregistering executor for node type "+nodeName); + nodeExecutors.remove(nodeName); + } + + + + + public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) + throws SvcLogicException { + + if (nodeExecutors == null) { + registerExecutors(); + } + + // Set service name in MDC to reference current working directed graph + MDC.put(MetricLogger.SERVICE_NAME, graph.getModule()+":"+graph.getRpc()+"/v"+graph.getVersion()); + + MDC.put("currentGraph", graph.toString()); + + SvcLogicNode curNode = graph.getRootNode(); + LOG.info("About to execute graph " + graph.toString()); + + + + while (curNode != null) { + MDC.put("nodeId", curNode.getNodeId()+" ("+curNode.getNodeType()+")"); + LOG.info("About to execute node # "+curNode.getNodeId()+" ("+curNode.getNodeType()+")"); + + SvcLogicNode nextNode = executeNode(curNode, ctx); + curNode = nextNode; + } + MDC.remove("nodeId"); + MDC.remove("currentGraph"); + + return (ctx); + } + + + public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + if (node == null) { + return (null); + } + + if (LOG.isDebugEnabled()) { + LOG.debug("Executing node " + node.getNodeId()); + } + + SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); + + if (executor != null) { + LOG.debug("Executing node executor for node type "+node.getNodeType()+" - "+executor.getClass().getName()); + return (executor.execute(this, node, ctx)); + } else { + if (LOG.isDebugEnabled()) { + LOG.debug(node.getNodeType() + " node not implemented"); + } + SvcLogicNode nextNode = node.getOutcomeValue("failure"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute failure branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no failure or Other branch found"); + } + } + return (nextNode); + } + + } + + @Override + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException + { + SvcLogicStore store = SvcLogicActivator.getStore(); + + return (store.hasGraph(module, rpc, version, mode)); + } + + @Override + public Properties execute(String module, String rpc, String version, String mode, Properties props) + throws SvcLogicException { + return(execute(module, rpc, version, mode, props, null)); + } + + + @Override + public Properties execute(String module, String rpc, String version, String mode, + Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { + + + // See if there is a service logic defined + // + SvcLogicStore store = SvcLogicActivator.getStore(); + + LOG.info("Fetching service logic from data store"); + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + + + + if (graph == null) + { + Properties retProps = new Properties(); + retProps.setProperty("error-code", "401"); + retProps.setProperty("error-message", "No service logic found for ["+module+","+rpc+","+version+","+mode+"]"); + return(retProps); + + } + + SvcLogicContext ctx = new SvcLogicContext(props); ctx.setAttribute("currentGraph", graph.toString()); ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); - ctx.setDomDataBroker(domDataBroker); - - execute(graph, ctx); + ctx.setDomDataBroker(domDataBroker); + + execute(graph, ctx); + + return(ctx.toProperties()); + } + - return(ctx.toProperties()); - } - - } -- cgit 1.2.3-korg From d3913648518ce15fe7a74275394b86d0ecfb32a4 Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Fri, 15 Sep 2017 01:02:37 +0000 Subject: Prepared DBLIB for multi-verndor JDBC Driver Changes made: 1. removed hardcoded JDBC driver's name and made it a property. 2. Optimized connection pool initialization 3. Removed unused factories. Change-Id: Id1d1868f7f1a6ae5a0429a97403042a8f6ee78d3 Issue-ID: CCSDK-92 Signed-off-by: Rich Tabedzki --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 5 +- .../ccsdk/sli/core/dblib/DBResourceManager.java | 169 +++++++++++++++---- .../sli/core/dblib/config/BaseDBConfiguration.java | 126 +++++++------- .../factory/AbstractDBResourceManagerFactory.java | 39 ----- .../factory/AbstractResourceManagerFactory.java | 104 ------------ .../dblib/factory/FactoryNotDefinedException.java | 37 ----- .../core/dblib/jdbc/JdbcDBCachedDataSource.java | 46 +----- .../dblib/jdbc/JdbcDbResourceManagerFactory.java | 183 --------------------- 8 files changed, 210 insertions(+), 499 deletions(-) mode change 100644 => 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java mode change 100644 => 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java mode change 100644 => 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractDBResourceManagerFactory.java delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/FactoryNotDefinedException.java mode change 100644 => 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java old mode 100644 new mode 100755 index ee8ab2f33..a5902d54b --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -20,7 +20,6 @@ package org.onap.ccsdk.sli.core.dblib; -import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; import org.apache.tomcat.jdbc.pool.PoolExhaustedException; import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; @@ -535,7 +534,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito return monitor; } - protected boolean isSlave() throws PoolExhaustedException, MySQLNonTransientConnectionException { + protected boolean isSlave() throws PoolExhaustedException { CachedRowSet rs = null; boolean isSlave = true; String hostname = "UNDETERMINED"; @@ -547,7 +546,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito hostname = rs.getString(2); } isSlave = localSlave; - } catch(PoolExhaustedException | MySQLNonTransientConnectionException peexc){ + } catch(PoolExhaustedException peexc){ throw peexc; } catch (SQLException e) { LOGGER.error("", e); diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java old mode 100644 new mode 100755 index 7a27a20ce..a2eb0f9c1 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -7,9 +7,9 @@ * 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. @@ -20,11 +20,8 @@ package org.onap.ccsdk.sli.core.dblib; -import com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException; import org.apache.tomcat.jdbc.pool.PoolExhaustedException; import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; -import org.onap.ccsdk.sli.core.dblib.factory.AbstractDBResourceManagerFactory; -import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory; import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; @@ -52,8 +49,21 @@ import java.util.Properties; import java.util.Queue; import java.util.Set; import java.util.TimerTask; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; + +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; +import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @version $Revision: 1.15 $ @@ -72,11 +82,18 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb protected final AtomicBoolean dsSelector = new AtomicBoolean(); // Queue dsQueue = new ConcurrentLinkedQueue(); - Queue dsQueue = new PriorityQueue<>(4, new Comparator() { + Queue dsQueue = new PriorityQueue(4, new Comparator() { @Override public int compare(CachedDataSource left, CachedDataSource right) { try { - if (!left.isSlave()) { + if(left == null){ + return 1; + } + if(right == null){ + return -1; + } + + if(!left.isSlave()) { return -1; } if (!right.isSlave()) { @@ -144,31 +161,108 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } private void config(Properties configProps) throws Exception { - + final ConcurrentLinkedQueue semaphore = new ConcurrentLinkedQueue(); final DbConfigPool dbConfig = DBConfigFactory.createConfig(configProps); - final AbstractResourceManagerFactory factory = - AbstractDBResourceManagerFactory.getFactory(dbConfig.getType()); - LOGGER.info("Default DB config is : {}", dbConfig.getType()); - LOGGER.info("Using factory : {}", factory.getClass().getName()); - final CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, this); - if (cachedDS == null || cachedDS.length == 0) { - LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); - throw new Exception("Failed to initialize DB Library. No data source was created."); + long startTime = System.currentTimeMillis(); + + try { + JDBCConfiguration[] config = dbConfig.getJDBCbSourceArray(); + CachedDataSource[] cachedDS = new CachedDataSource[config.length]; + if (cachedDS == null || cachedDS.length == 0) { + LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); + throw new Exception("Failed to initialize DB Library. No data source was created."); + } + + for(int i = 0; i < config.length; i++) { + cachedDS[i] = CachedDataSourceFactory.createDataSource(config[i]); + if(cachedDS[i] == null) + continue; + semaphore.add(cachedDS[i]); + cachedDS[i].setInterval(monitoringInterval); + cachedDS[i].setInitialDelay(monitoringInitialDelay); + cachedDS[i].setExpectedCompletionTime(expectedCompletionTime); + cachedDS[i].setUnprocessedFailoverThreshold(unprocessedFailoverThreshold); + cachedDS[i].addObserver(DBResourceManager.this); + } + +// CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, DBResourceManager.this, semaphore); + DataSourceTester[] tester = new DataSourceTester[config.length]; + + for(int i=0; i semaphoreQ; + + public DataSourceTester(CachedDataSource ds, DBResourceManager manager, ConcurrentLinkedQueue semaphore) { + this.ds = ds; + this.manager = manager; + this.semaphoreQ = semaphore; } - for (final CachedDataSource ds : cachedDS) { - if(ds != null && ds.isInitialized()){ - setDataSource(ds); - ds.setInterval(monitoringInterval); - ds.setInitialDelay(monitoringInitialDelay); - ds.setExpectedCompletionTime(expectedCompletionTime); - ds.setUnprocessedFailoverThreshold(unprocessedFailoverThreshold); - ds.addObserver(this); + @Override + public void run() { + manager.setDataSource(ds); + boolean slave = true; + if(ds != null) { + try { + slave = ds.isSlave(); + } catch (Exception exc) { + LOGGER.warn("", exc); + } } + if(!slave) { + LOGGER.info(String.format("Adding MASTER (%s) to active queue", ds.getDbConnectionName())); + try { + synchronized (semaphoreQ) { + semaphoreQ.notifyAll(); + } + } catch(Exception exc) { + LOGGER.warn("", exc); + } } + try { + synchronized (semaphoreQ) { + semaphoreQ.remove(ds); + } + if(semaphoreQ.isEmpty()) { + synchronized (semaphoreQ) { + semaphoreQ.notifyAll(); + } + } + } catch(Exception exc) { + LOGGER.warn("", exc); + } + LOGGER.info(String.format("Thread DataSourceTester terminated %s for %s", this.getName(), ds.getDbConnectionName())); + } + } + private long getLongFromProperties(Properties props, String property, long defaultValue) { String value = null; @@ -306,7 +400,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb CachedDataSource active = null; // test if there are any connection pools available - LinkedList sources = new LinkedList<>(this.dsQueue); + LinkedList sources = new LinkedList(this.dsQueue); if(sources.isEmpty()){ LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); @@ -423,8 +517,8 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb return writeDataNoRecovery(statement, newList, preferredDS); } - CachedDataSource findMaster() throws PoolExhaustedException, MySQLNonTransientConnectionException { - CachedDataSource master; + CachedDataSource findMaster() throws PoolExhaustedException { + CachedDataSource master = null; CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); for(int i=0; i list = new ArrayList<>(); + ArrayList list = new ArrayList(); list.addAll(dsQueue); list.addAll(broken); if (htmlFormat) @@ -785,7 +880,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public String getPreferredDataSourceName(AtomicBoolean flipper) { - LinkedList snapshot = new LinkedList<>(dsQueue); + LinkedList snapshot = new LinkedList(dsQueue); if(snapshot.size() > 1){ CachedDataSource first = snapshot.getFirst(); CachedDataSource last = snapshot.getLast(); @@ -849,4 +944,8 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb ds.getPoolInfo(false); } } + + public int poolSize() { + return dsQueue.size(); + } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java old mode 100644 new mode 100755 index d53be0e7f..a8bc58b8b --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java @@ -7,9 +7,9 @@ * 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. @@ -30,58 +30,68 @@ public abstract class BaseDBConfiguration { /** * Property key within a properties configuration File for db type */ - public static final String DATABASE_TYPE = "org.onap.ccsdk.sli.dbtype"; + public static final String DATABASE_TYPE = "org.onap.ccsdk.sli.dbtype"; /** * Property key with a properties configuration File for db url */ - public static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url"; + public static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url"; /** * Property key with a properties configuration File for database name */ - public static final String DATABASE_NAME = "org.onap.ccsdk.sli.jdbc.database"; + public static final String DATABASE_NAME = "org.onap.ccsdk.sli.jdbc.database"; + + /** + * Property key with a properties configuration File for jdbc driver + */ + public static final String DRIVER_NAME = "org.onap.ccsdk.sli.jdbc.driver"; /** * Property key with a properties configuration File for db database connection name */ - public static final String CONNECTION_NAME = "org.onap.ccsdk.sli.jdbc.connection.name"; + public static final String CONNECTION_NAME = "org.onap.ccsdk.sli.jdbc.connection.name"; /** * Property key with a properties configuration File for database user */ - public static final String DATABASE_USER = "org.onap.ccsdk.sli.jdbc.user"; + public static final String DATABASE_USER = "org.onap.ccsdk.sli.jdbc.user"; /** - * Property key with a properties configuration File for database password for associated with - * org.onap.ccsdk.sli.jdbc.user. + * Property key with a properties configuration File for database password + * for associated with org.onap.ccsdk.sli.jdbc.user. */ - public static final String DATABASE_PSSWD = "org.onap.ccsdk.sli.jdbc.password"; + public static final String DATABASE_PSSWD = "org.onap.ccsdk.sli.jdbc.password"; /** - * Property key with a properties configuration File for database connection timeout + * Property key with a properties configuration File for database connection + * timeout */ public static final String CONNECTION_TIMEOUT="org.onap.ccsdk.sli.jdbc.connection.timeout"; /** - * Property key with a properties configuration File for database request timeout + * Property key with a properties configuration File for database request + * timeout */ - public static final String REQUEST_TIMEOUT = "org.onap.ccsdk.sli.jdbc.request.timeout"; + public static final String REQUEST_TIMEOUT = "org.onap.ccsdk.sli.jdbc.request.timeout"; /** - * Property key with a properties configuration File for database minimum limit + * Property key with a properties configuration File for database minimum + * limit */ - public static final String MIN_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.min"; + public static final String MIN_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.min"; /** - * Property key with a properties configuration File for database maximum limit + * Property key with a properties configuration File for database maximum + * limit */ - public static final String MAX_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.max"; + public static final String MAX_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.max"; /** - * Property key with a properties configuration File for database initial limit + * Property key with a properties configuration File for database initial + * limit */ - public static final String INIT_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.init"; + public static final String INIT_LIMIT = "org.onap.ccsdk.sli.jdbc.limit.init"; /** * Property key with a properties configuration File for database hosts @@ -89,14 +99,10 @@ public abstract class BaseDBConfiguration { public static final String DATABASE_HOSTS = "org.onap.ccsdk.sli.jdbc.hosts"; /** - * default value when the connection timeout is not present or cannot be parsed - */ - private static final int DEFAULT_CONNECTION_TIMEOUT = -1; - - /** - * default value when the request timeout is not present or cannot be parsed + * default value when the connection timeout is not present or cannot be + * parsed. */ - private static final int DEFAULT_REQUEST_TIMEOUT = -1; + private static final String DEFAULT_REJECT_CHANGE_VALUE = "-1"; /** * A set of properties with database configuration information. @@ -106,7 +112,9 @@ public abstract class BaseDBConfiguration { /** * Builds a configuration based on given properties * - * @param properties properties represented by the public constant keys defined by this class + * @param properties + * properties represented by the public constant keys defined by + * this class */ public BaseDBConfiguration(final Properties properties) { this.properties = properties; @@ -115,35 +123,30 @@ public abstract class BaseDBConfiguration { /** * Extracts the connection timeout. * - * @return the connection timeout, or DEFAULT_CONNECTION_TIMEOUT if not present + * @return the connection timeout, or + * DEFAULT_REJECT_CHANGE_VALUE if not present */ public int getConnTimeout() { - return extractProperty(properties, CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); + try { + String value = properties.getProperty(CONNECTION_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE); + return Integer.parseInt(value); + } catch (Exception exc) { + return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE); + } } /** * Extracts the request timeout. * - * @return the request timeout, or DEFAULT_REQUEST_TIMEOUT if not present + * @return the request timeout, or DEFAULT_REQUEST_TIMEOUT if + * not present */ public int getRequestTimeout() { - return extractProperty(properties, REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT); - } - - /** - * A utility method to extract int property from Properties. - * - * @param properties a set of Properties - * @param propertyKey the key in question - * @param defaultValue the value to return if the key does not exist - * @return Either the property value for propertyKey or defaultValue if not present - */ - private static int extractProperty(final Properties properties, final String propertyKey, final int defaultValue) { try { - final String valueString = properties.getProperty(propertyKey, Integer.toString(defaultValue)); - return Integer.parseInt(valueString); - } catch(final NumberFormatException e) { - return defaultValue; + String value = properties.getProperty(REQUEST_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE); + return Integer.parseInt(value); + } catch (Exception exc) { + return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE); } } @@ -165,6 +168,15 @@ public abstract class BaseDBConfiguration { return properties.getProperty(DATABASE_NAME); } + /** + * Extracts the jdbc driver's name. + * + * @return the jdbc name, or com.mysql.jdbc.Driver if not present + */ + public String getDriverName() { + return properties.getProperty(DRIVER_NAME, "com.mysql.jdbc.Driver"); + } + /** * Extracts the db user id. * @@ -187,7 +199,9 @@ public abstract class BaseDBConfiguration { * Extracts the db min limit. * * @return the db min limit - * @throws NumberFormatException if the property is not specified, or cannot be parsed as an Integer. + * @throws NumberFormatException + * if the property is not specified, or cannot be parsed as an + * Integer. */ public int getDbMinLimit() throws NumberFormatException { String value = properties.getProperty(MIN_LIMIT); @@ -198,7 +212,9 @@ public abstract class BaseDBConfiguration { * Extracts the db max limit. * * @return the db max limit - * @throws NumberFormatException if the property is not specified, or cannot be parsed as an Integer. + * @throws NumberFormatException + * if the property is not specified, or cannot be parsed as an + * Integer. */ public int getDbMaxLimit() throws NumberFormatException { String value = properties.getProperty(MAX_LIMIT); @@ -209,7 +225,9 @@ public abstract class BaseDBConfiguration { * Extracts the db initial limit. * * @return the db initial limit - * @throws NumberFormatException if the property is not specified, or cannot be parsed as an Integer. + * @throws NumberFormatException + * if the property is not specified, or cannot be parsed as an + * Integer. */ public int getDbInitialLimit() throws NumberFormatException { String value = properties.getProperty(INIT_LIMIT); @@ -224,14 +242,4 @@ public abstract class BaseDBConfiguration { public String getDbUrl() { return properties.getProperty(DATABASE_URL); } - - /** - * Extracts the db server group. - * - * @return null - */ - @Deprecated - public String getServerGroup() { - return null; - } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractDBResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractDBResourceManagerFactory.java deleted file mode 100644 index e88734d2e..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractDBResourceManagerFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.factory; - -import org.onap.ccsdk.sli.core.dblib.jdbc.JdbcDbResourceManagerFactory; - -/** - * @version $Revision: 1.1 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public class AbstractDBResourceManagerFactory { - - public static AbstractResourceManagerFactory getFactory(String type) throws FactoryNotDefinedException { - - // JDBC - return JdbcDbResourceManagerFactory.createIntstance(); - } -} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java deleted file mode 100644 index 486d0ccc1..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/AbstractResourceManagerFactory.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.factory; - - -import org.onap.ccsdk.sli.core.dblib.CachedDataSource; -import org.onap.ccsdk.sli.core.dblib.CachedDataSourceFactory; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; -import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; -import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; -import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.SQLException; -import java.util.Set; -import java.util.concurrent.Callable; - -/** - * @version $Revision: 1.6 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public abstract class AbstractResourceManagerFactory { - private static Logger LOGGER = LoggerFactory.getLogger(AbstractResourceManagerFactory.class); - - public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager) throws Exception; - public abstract CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager dbResourceManager, String sourceName) throws SQLException ; - - - public static AbstractResourceManagerFactory createIntstance() throws FactoryNotDefinedException { - throw new FactoryNotDefinedException("Factory method 'createIntstance' needs to be overriden in DBResourceManagerFactory"); - } - - public class DBInitTask implements Callable - { - private BaseDBConfiguration config = null; - private Set activeTasks; - - public DBInitTask(JDBCConfiguration jdbcconfig, Set tasks) { - this.config = jdbcconfig; - this.activeTasks = tasks; - } - - public CachedDataSource call() throws Exception { - CachedDataSource ds = null; - try { - ds = CachedDataSourceFactory.createDataSource(config); - return ds; - } finally { - synchronized(activeTasks) { - activeTasks.remove(this); - if (activeTasks.isEmpty()) { - final Runnable closure = new Runnable() { - - public void run() { - try { - Thread.sleep(300); - } catch (Exception e) { - } - synchronized(activeTasks) { - activeTasks.notifyAll(); - } - } - }; - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Completed CachedDataSource.Call and notifyAll from " + (ds != null ? ds - .getDbConnectionName() : null)); - } - Thread worker = new Thread(closure); - worker.setDaemon(true); - worker.start(); - } else { - if (LOGGER.isDebugEnabled()) { - if (ds != null) { - LOGGER.debug("Completed CachedDataSource.Call from " + ds.getDbConnectionName()); - } - } - } - } - } - } - } -} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/FactoryNotDefinedException.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/FactoryNotDefinedException.java deleted file mode 100644 index b6383a53b..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/FactoryNotDefinedException.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.factory; - - -/** - * @version 1.3 - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki 01/16/08 Initial version - */ -public class FactoryNotDefinedException extends Exception { - - public FactoryNotDefinedException(String message) { - super(message); - } - -} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java old mode 100644 new mode 100755 index ffe834456..3ec4f2edf --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java @@ -33,19 +33,10 @@ import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.mysql.jdbc.Driver; - - -/** - * @version $Revision: 1.7 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ public class JdbcDBCachedDataSource extends CachedDataSource { + private String dbDriver; private String dbUserId; private String dbPasswd; private String dbUrl; @@ -96,15 +87,14 @@ public class JdbcDBCachedDataSource extends CachedDataSource LOGGER.error(AS_CONF_ERROR + errorMsg); throw new DBConfigException(errorMsg); } - /* - dbDriver = jdbcConfig.getDbDriver(); + + dbDriver = jdbcConfig.getDriverName(); if (dbDriver == null) { String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new ScpTblUpdateError(errorMsg); + throw new DBConfigException(errorMsg); } - */ minLimit = jdbcConfig.getDbMinLimit(); // if (minLimit == null) @@ -136,11 +126,10 @@ public class JdbcDBCachedDataSource extends CachedDataSource } try { - Driver dr = new com.mysql.jdbc.Driver(); - Class clazz = Class.forName("com.mysql.jdbc.Driver") ; + Class clazz = Class.forName(dbDriver) ; PoolProperties p = new PoolProperties(); - p.setDriverClassName("com.mysql.jdbc.Driver"); + p.setDriverClassName(dbDriver); p.setUrl(dbUrl); p.setUsername(dbUserId); p.setPassword(dbPasswd); @@ -172,30 +161,9 @@ public class JdbcDBCachedDataSource extends CachedDataSource PreparedStatement st = null; ResultSet rs = null; - try { - con = dataSource.getConnection(); - st = con.prepareStatement("Select 1 FROM DUAL"); - rs = st.executeQuery(); - } catch(Exception exc) { - LOGGER.error(exc.getMessage()); - } finally { - if(rs != null) rs.close(); - if(st != null) st.close(); - if(con != null) con.close(); - } - initialized = true; - LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); + LOGGER.info("JdbcDBCachedDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); } - -// } catch (SQLException exc) { -// initialized = false; -// StringBuffer sb = new StringBuffer(); -// sb.append("Failed to initialize MySQLDataSource<"); -// sb.append(dbConnectionName).append(">. Reason: "); -// sb.append(exc.getMessage()); -// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); -//// throw new DBConfigException(e.getMessage()); } catch (Exception exc) { initialized = false; StringBuffer sb = new StringBuffer(); diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java deleted file mode 100644 index 803e6b3e7..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDbResourceManagerFactory.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.jdbc; - - -import java.sql.SQLException; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; - -import org.onap.ccsdk.sli.core.dblib.CachedDataSource; -import org.onap.ccsdk.sli.core.dblib.CachedDataSourceFactory; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; -import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; -import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; -import org.onap.ccsdk.sli.core.dblib.factory.AbstractResourceManagerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @version $Revision: 1.6 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ -public class JdbcDbResourceManagerFactory extends AbstractResourceManagerFactory { - private static Logger LOGGER = LoggerFactory.getLogger(JdbcDbResourceManagerFactory.class ); - private JdbcDbResourceManagerFactory(){ - - } - - class MyFutureTask extends FutureTask - { - - public MyFutureTask(Callable result) { - super(result); - } - - } - - public CachedDataSource[] initDBResourceManager(DbConfigPool dbConfig, DBResourceManager manager, String sourceName) throws SQLException - { - // here create the data sources objects - JDBCConfiguration[] list = dbConfig.getJDBCbSourceArray(); - CachedDataSource[] cachedDS = new CachedDataSource[1]; - - for(int i=0, max=list.length; i tasks = new HashSet(); - if(LOGGER.isDebugEnabled()) { - LOGGER.debug("Creating " + list.length + " datasources."); - } - - for(int i=0, max=list.length; i Date: Fri, 15 Sep 2017 18:45:29 +0530 Subject: Fix few Major sonar issues Fix few Major sonar issues in CCSDK SLI Core module * Remove useless parentheses * Either log or rethrow the exception * Remove unused variables * Add the "@Override" annotation * Change "try" to a try-with-resources Change-Id: I64c4bd3c746bb2f226f4f58c39f28a8b2d178953 Issue-Id: CCSDK-67 Signed-off-by: Ramu N --- .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 135 +++++++-------------- 1 file changed, 41 insertions(+), 94 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 712c64aba..ab5773c06 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -25,7 +25,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.sql.Blob; @@ -51,14 +50,11 @@ public class SvcLogicDblibStore implements SvcLogicStore { private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicDblibStore.class); + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicDblibStore.class); - private static final String DBLIB_SERVICE = - "org.onap.ccsdk.sli.core.dblib.DbLibService"; - - Properties props = null; + private static final String DBLIB_SERVICE = "org.onap.ccsdk.sli.core.dblib.DbLibService"; + @Override public void init(Properties props) throws ConfigurationException { DbLibService dbSvc = getDbLibService(); @@ -74,6 +70,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { } } + @Override public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { @@ -87,9 +84,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { String hasActiveGraphSql = "SELECT count(*) FROM SVC_LOGIC" + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; - PreparedStatement hasGraphStmt = null; - - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(module); args.add(rpc); args.add(mode); @@ -109,23 +104,21 @@ public class SvcLogicDblibStore implements SvcLogicStore { if (cnt > 0) { retval = true; } - } } catch (Exception e) { throw new ConfigurationException("SQL query failed", e); } finally { if (results != null) { try { - results.close(); } catch (SQLException x) { + LOG.error("Failed to close CachedRowSet", x); } } } - return (retval); - + return retval; } public SvcLogicGraph fetch(String module, String rpc, String version, @@ -147,12 +140,6 @@ public class SvcLogicDblibStore implements SvcLogicStore { try { dbConn = dbSvc.getConnection(); - - ArrayList args = new ArrayList(); - args.add(module); - args.add(rpc); - args.add(mode); - if (version == null) { fetchGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); } else { @@ -171,8 +158,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { if (results.next()) { Blob graphBlob = results.getBlob("graph"); - ObjectInputStream gStream = new ObjectInputStream( - graphBlob.getBinaryStream()); + ObjectInputStream gStream = new ObjectInputStream(graphBlob.getBinaryStream()); Object graphObj = gStream.readObject(); gStream.close(); @@ -186,7 +172,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { } } else { - return (null); + return null; } } catch (SQLException e) { throw new ConfigurationException("SQL query failed", e); @@ -198,28 +184,28 @@ public class SvcLogicDblibStore implements SvcLogicStore { fetchGraphStmt.close(); } } catch (SQLException e) { - LOG.info(e.getMessage()); + LOG.error("PreparedStatement close error", e); } if (results != null) { try { results.close(); } catch (SQLException x) { + LOG.error("ResultSet close error", x); } } try { if (dbConn != null && !dbConn.isClosed()) { dbConn.close(); } - } catch (Throwable exc) { - // the exception not monitored + } catch (Exception exc) { + LOG.error("dbConn close error", exc); } finally { dbConn = null; } } - return (retval); - + return retval; } public void store(SvcLogicGraph graph) throws SvcLogicException { @@ -235,35 +221,15 @@ public class SvcLogicDblibStore implements SvcLogicStore { byte[] graphBytes = null; - ByteArrayOutputStream byteStr = null; - ObjectOutputStream goutStr = null; + try (ByteArrayOutputStream byteStr = new ByteArrayOutputStream(); + ObjectOutputStream goutStr = new ObjectOutputStream(byteStr)) { - try { - byteStr = new ByteArrayOutputStream(); - goutStr = new ObjectOutputStream(byteStr); goutStr.writeObject(graph); graphBytes = byteStr.toByteArray(); } catch (Exception e) { throw new SvcLogicException("could not serialize graph", e); - } finally { - - if (goutStr != null) { - try { - goutStr.close(); - } catch (IOException e) { - - } - } - - if (byteStr != null) { - try { - byteStr.close(); - } catch (IOException e) { - - } - } } // If object already stored in database, delete it @@ -279,8 +245,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { dbConn = dbSvc.getConnection(); boolean oldAutoCommit = dbConn.getAutoCommit(); dbConn.setAutoCommit(false); - storeGraphStmt = dbConn - .prepareStatement(storeGraphSql); + storeGraphStmt = dbConn.prepareStatement(storeGraphSql); storeGraphStmt.setString(1, graph.getModule()); storeGraphStmt.setString(2, graph.getRpc()); storeGraphStmt.setString(3, graph.getVersion()); @@ -300,14 +265,14 @@ public class SvcLogicDblibStore implements SvcLogicStore { storeGraphStmt.close(); } } catch (SQLException e) { - LOG.info(e.getMessage()); + LOG.error("PreparedStatement close error", e); } try { if (dbConn != null && !dbConn.isClosed()) { dbConn.close(); } - } catch (Throwable exc) { - // the exception not monitored + } catch (Exception exc) { + LOG.error("dbConn close error", exc); } finally { dbConn = null; } @@ -322,7 +287,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(module); args.add(rpc); @@ -332,8 +297,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { try { dbSvc.writeData(deleteGraphSql, args, null); } catch (Exception e) { - throw new SvcLogicException( - "Could not delete object from database", e); + throw new SvcLogicException("Could not delete object from database", e); } } @@ -344,7 +308,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(graph.getModule()); args.add(graph.getRpc()); @@ -372,15 +336,14 @@ public class SvcLogicDblibStore implements SvcLogicStore { } DbLibService dbSvc = getDbLibService(); - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(nodeType); try { dbSvc.writeData(registerNodeSql, args, null); } catch (Exception e) { - throw new SvcLogicException("Could not add node type to database", - e); + throw new SvcLogicException("Could not add node type to database", e); } } @@ -395,7 +358,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { String unregisterNodeSql = "DELETE FROM NODE_TYPES WHERE nodetype = ?"; DbLibService dbSvc = getDbLibService(); - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(nodeType); @@ -415,38 +378,26 @@ public class SvcLogicDblibStore implements SvcLogicStore { DbLibService dbSvc = getDbLibService(); - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(nodeType); boolean isValid = false; - CachedRowSet results = null; - try { - results = dbSvc.getData(validateNodeSql, args, null); - if (results != null) { - if (results.next()) { - int cnt = results.getInt(1); + try (CachedRowSet results = dbSvc.getData(validateNodeSql, args, null)) { + + if (results != null && results.next()) { + int cnt = results.getInt(1); - if (cnt > 0) { - isValid = true; - } + if (cnt > 0) { + isValid = true; } } } catch (Exception e) { - throw new SvcLogicException( - "Cannot select node type from database", e); - } finally { - if (results != null) { - try { - results.close(); - } catch (SQLException x) { - } - } - + throw new SvcLogicException("Cannot select node type from database", e); } - return (isValid); + return isValid; } private DbLibService getDbLibService() { @@ -466,14 +417,12 @@ public class SvcLogicDblibStore implements SvcLogicStore { } if (sref == null) { - LOG.warn("Could not find service reference for DBLIB service (" - + DBLIB_SERVICE + ")"); + LOG.warn("Could not find service reference for DBLIB service ({})", DBLIB_SERVICE); } else { dblibSvc = (DbLibService) bctx.getService(sref); if (dblibSvc == null) { - LOG.warn("Could not find service reference for DBLIB service (" - + DBLIB_SERVICE + ")"); + LOG.warn("Could not find service reference for DBLIB service ({})", DBLIB_SERVICE); } } } @@ -495,10 +444,8 @@ public class SvcLogicDblibStore implements SvcLogicStore { if (!propFile.exists()) { - LOG.warn( - "Missing configuration properties file : " - + propFile); - return(null); + LOG.warn("Missing configuration properties file : {}", propFile); + return null; } try { @@ -507,7 +454,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { } catch (Exception e) { LOG.warn( "Could not load properties file " + propPath, e); - return(null); + return null; } @@ -521,7 +468,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { dblibSvc = JavaSingleton.getInstance(); } } - return (dblibSvc); + return dblibSvc; } -- cgit 1.2.3-korg From 9f1561461d60f6187e0ee8eaddf168a9efc2fc52 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 15 Sep 2017 14:03:17 -0400 Subject: Fix service tag in sli/recording blueprint One of the service tags in sli/recording blueprint uses attribute 'class' instead of 'interface' to advertise the service. This is preventing SDNC container from loading sdnc-sli-recording feature. Change-Id: I4f6863d74dd6fb8babd91fde53b9680594aa7a31 Issue-ID: SDNC-54 Signed-off-by: Dan Timoney --- .../main/resources/org/opendaylight/blueprint/recording-blueprint.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index d8035376d..6786b955b 100644 --- a/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml +++ b/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml @@ -15,6 +15,6 @@ was previously registered using the implementation name rather than the interface name. To ensure backwards compatibility with abstractions polling the Service Registry for the slf4jRecorder, the implementation name was chosen here. --> - + \ No newline at end of file -- cgit 1.2.3-korg From 148c15b82dfc2025dc1c4a19b55293cdf3e9db2f Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Sun, 17 Sep 2017 22:53:41 +0530 Subject: Fix Sonar issues in sli/core module One major issue * Use try with resources instead of try Issue-Id: CCSDK-87 Change-Id: Ic30016f70ebc355f80a73c9e4632b7971d2b87be Signed-off-by: surya-huawei --- .../org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 index 4a60de950..772906e59 100644 --- 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 @@ -82,7 +82,6 @@ public class FileRecorder implements SvcLogicRecorder { } File recordFile = new File(fileName); - PrintWriter recPrinter = null; FileWriter fileWriter = null; Date now = new Date(); @@ -94,10 +93,9 @@ public class FileRecorder implements SvcLogicRecorder { record = record.replaceFirst("__TIMESTAMP__", dateFmt.format(now)); } - try + try ( PrintWriter recPrinter = new PrintWriter(fileWriter = new + FileWriter(recordFile, true))) { - - recPrinter = new PrintWriter(fileWriter = new FileWriter(recordFile, true)); recPrinter.println(record); } catch (Exception e) @@ -106,10 +104,6 @@ public class FileRecorder implements SvcLogicRecorder { } finally { - if (recPrinter != null) - { - recPrinter.close(); - } if (fileWriter != null) { try { -- cgit 1.2.3-korg From 53ab0a5cb73d3ebe5d6142cda1052abac30fb906 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Mon, 18 Sep 2017 12:42:25 +0530 Subject: Fix few Major sonar issues Fix few Major sonar issues in CCSDK SLI Core module * Remove useless parentheses * Either log or rethrow the exception * Add the "@Override" annotation * Change "try" to a try-with-resources * Replace duplicate string literals with constants Change-Id: If52163220d7231ae42ef42b0313d56435f6745e1 Issue-Id: CCSDK-67 Signed-off-by: Ramu N --- .../onap/ccsdk/sli/core/sli/CommonConstants.java | 13 +- .../onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 296 ++++++++------------- 2 files changed, 128 insertions(+), 181 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java index d30b2b626..b1a7320d7 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java @@ -23,5 +23,16 @@ package org.onap.ccsdk.sli.core.sli; public interface CommonConstants { - public static final String SERVICE_LOGIC_STATUS = "SvcLogic.status"; + String SERVICE_LOGIC_STATUS = "SvcLogic.status"; + String JDBC_CONN_ERR = "no jdbc connection"; + String JDBC_STATEMENT_ERR = "could not prepare statement "; + String SVCLOGIC_TABLE = ".SVC_LOGIC"; + String JDBC_SELECT_COUNT = "SELECT count(*) FROM "; + String RESULTSET_CLOSE_ERR = "ResultSet close error: "; + String JDBC_SELECT_GRAPGH = "SELECT graph FROM "; + String JDBC_INSERT = "INSERT INTO "; + String JDBC_DELETE = "DELETE FROM "; + String JDBC_UPDATE = "UPDATE "; + String JDBC_GRAPH_QUERY = " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + String JDBC_ACTIVE_GRAPH_QUERY = " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index b4b77660d..71926e415 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -8,9 +8,9 @@ * 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. @@ -23,7 +23,6 @@ package org.onap.ccsdk.sli.core.sli; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.sql.Blob; @@ -42,8 +41,7 @@ import org.slf4j.LoggerFactory; public class SvcLogicJdbcStore implements SvcLogicStore { - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicJdbcStore.class); + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicJdbcStore.class); private String dbUrl = null; private String dbName = null; @@ -78,19 +76,16 @@ public class SvcLogicJdbcStore implements SvcLogicStore { Driver dvr = new com.mysql.jdbc.Driver(); if (dvr.acceptsURL(dbUrl)) { - LOG.debug("Driver com.mysql.jdbc.Driver accepts "+dbUrl); + LOG.debug("Driver com.mysql.jdbc.Driver accepts {}", dbUrl); } else { - LOG.warn("Driver com.mysql.jdbc.Driver does not accept "+dbUrl); + LOG.warn("Driver com.mysql.jdbc.Driver does not accept {}", dbUrl); } } catch (SQLException e1) { LOG.error("Caught exception trying to load com.mysql.jdbc.Driver", e1); - - } - try { this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps); @@ -105,9 +100,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { private void createTable() throws ConfigurationException { - - DatabaseMetaData dbm = null; - + DatabaseMetaData dbm; try { dbm = dbConn.getMetaData(); @@ -117,108 +110,84 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } // See if table SVC_LOGIC exists. If not, create it. + Statement stmt = null; try { - ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null); if (tables.next()) { - // Table exists + LOG.debug("SVC_LOGIC table already exists"); } else { - - String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC (" - + "module varchar(80) NOT NULL," - + "rpc varchar(80) NOT NULL," - + "version varchar(40) NOT NULL," - + "mode varchar(5) NOT NULL," - + "active varchar(1) NOT NULL," - + "graph BLOB," - + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; - - Statement stmt = null; - ConfigurationException myExc = null; - try - { - stmt = dbConn.createStatement(); - stmt.executeUpdate(crTableCmd); - } - catch (SQLException e1) - { - myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1); - } - finally - { - if (stmt != null) - { - stmt.close(); - } - } - - if (myExc != null) - { - throw myExc; - } + String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC (" + + "module varchar(80) NOT NULL," + + "rpc varchar(80) NOT NULL," + + "version varchar(40) NOT NULL," + + "mode varchar(5) NOT NULL," + + "active varchar(1) NOT NULL," + + "graph BLOB," + + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; + + stmt = dbConn.createStatement(); + stmt.executeUpdate(crTableCmd); } } catch (Exception e) { throw new ConfigurationException("could not create SVC_LOGIC table", e); } + finally + { + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + LOG.error("Statement close error ", e); + } + } + } // See if NODE_TYPES table exists and, if not, create it - + stmt = null; try { - ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null); if (tables.next()) { - // Table exists + LOG.debug("NODE_TYPES table already exists"); } else { + String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES (" + + "nodetype varchar(80) NOT NULL," + + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))"; - String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES (" - + "nodetype varchar(80) NOT NULL," - + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))"; + stmt = dbConn.createStatement(); - Statement stmt = null; - ConfigurationException myExc = null; - try - { - stmt = dbConn.createStatement(); - stmt.executeUpdate(crTableCmd); - } - catch (SQLException e1) - { - myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1); - } - finally - { - if (stmt != null) - { - stmt.close(); - } - } - - if (myExc != null) - { - throw myExc; - } + stmt.executeUpdate(crTableCmd); } } catch (Exception e) { throw new ConfigurationException("could not create SVC_LOGIC table", e); } + finally + { + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + LOG.error("Statement close error ", e); + } + } + } } private void prepStatements() throws ConfigurationException { // Prepare statements - String hasVersionGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + String hasVersionGraphSql = CommonConstants.JDBC_SELECT_COUNT + dbName + CommonConstants.SVCLOGIC_TABLE + + CommonConstants.JDBC_GRAPH_QUERY; try { @@ -226,12 +195,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + hasVersionGraphSql, e); } - String hasActiveGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + String hasActiveGraphSql = CommonConstants.JDBC_SELECT_COUNT + dbName + CommonConstants.SVCLOGIC_TABLE + + CommonConstants.JDBC_ACTIVE_GRAPH_QUERY; try { @@ -239,12 +208,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + hasVersionGraphSql, e); } - String fetchVersionGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + String fetchVersionGraphSql = CommonConstants.JDBC_SELECT_GRAPGH + dbName+CommonConstants.SVCLOGIC_TABLE + + CommonConstants.JDBC_GRAPH_QUERY; try { @@ -252,12 +221,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + fetchVersionGraphSql, e); } - String fetchActiveGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC" - + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'"; + String fetchActiveGraphSql = CommonConstants.JDBC_SELECT_GRAPGH + dbName + CommonConstants.SVCLOGIC_TABLE + + CommonConstants.JDBC_ACTIVE_GRAPH_QUERY; try { @@ -265,12 +234,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + fetchVersionGraphSql, e); } - String storeGraphSql = "INSERT INTO "+dbName+".SVC_LOGIC (module, rpc, version, mode, active, graph)" - + " VALUES(?, ?, ?, ?, ?, ?)"; + String storeGraphSql = CommonConstants.JDBC_INSERT+dbName + + ".SVC_LOGIC (module, rpc, version, mode, active, graph) VALUES(?, ?, ?, ?, ?, ?)"; try { @@ -278,10 +247,11 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+storeGraphSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + storeGraphSql, e); } - String deleteGraphSql = "DELETE FROM "+dbName+".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + String deleteGraphSql = CommonConstants.JDBC_DELETE+dbName + + ".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; try { @@ -289,10 +259,11 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+deleteGraphSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + deleteGraphSql, e); } - String deactivateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; + String deactivateSql = CommonConstants.JDBC_UPDATE + dbName + +".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; try { @@ -300,10 +271,11 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+deactivateSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + deactivateSql, e); } - String activateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + String activateSql = CommonConstants.JDBC_UPDATE + dbName + +".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; try { @@ -311,37 +283,37 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+activateSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + activateSql, e); } - String registerNodeSql = "INSERT INTO "+dbName+".NODE_TYPES (nodetype) VALUES(?)"; + String registerNodeSql = CommonConstants.JDBC_INSERT + dbName + ".NODE_TYPES (nodetype) VALUES(?)"; try { registerNodeStmt = dbConn.prepareStatement(registerNodeSql); } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+registerNodeSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + registerNodeSql, e); } - String unregisterNodeSql = "DELETE FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; + String unregisterNodeSql = CommonConstants.JDBC_DELETE + dbName + ".NODE_TYPES WHERE nodetype = ?"; try { unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql); } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+unregisterNodeSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + unregisterNodeSql, e); } - String validateNodeSql = "SELECT count(*) FROM "+dbName+".NODE_TYPES WHERE nodetype = ?"; + String validateNodeSql = CommonConstants.JDBC_SELECT_COUNT + dbName + ".NODE_TYPES WHERE nodetype = ?"; try { validateNodeStmt = dbConn.prepareStatement(validateNodeSql); } catch (Exception e) { - throw new ConfigurationException("could not prepare statement "+validateNodeSql, e); + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + validateNodeSql, e); } } @@ -365,6 +337,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } + @Override public void init(Properties props) throws ConfigurationException { @@ -413,14 +386,15 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } } catch (SQLException e) - {} + { + LOG.error("Not a valid db connection: ", e); + } - return(isValid); + return isValid; } -public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - - + @Override + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { if (!isDbConnValid()) { @@ -430,16 +404,14 @@ public boolean hasGraph(String module, String rpc, String version, String mode) if (!isDbConnValid()) { - throw new ConfigurationException("no jdbc connection"); + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); } } - - boolean retval = false; ResultSet results = null; - PreparedStatement hasGraphStmt = null; + PreparedStatement hasGraphStmt; if (version == null) { hasGraphStmt = hasActiveGraphStmt; @@ -449,8 +421,6 @@ public boolean hasGraph(String module, String rpc, String version, String mode) hasGraphStmt = hasVersionGraphStmt; } - - try { hasGraphStmt.setString(1, module); @@ -489,26 +459,24 @@ public boolean hasGraph(String module, String rpc, String version, String mode) { try { - results.close(); } catch (SQLException x) - {} + { + LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x); + } } } - - return(retval); - + return retval; } + @Override public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { - - if (!isDbConnValid()) { @@ -517,16 +485,14 @@ public boolean hasGraph(String module, String rpc, String version, String mode) if (!isDbConnValid()) { - throw new ConfigurationException("no jdbc connection"); + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); } } - - SvcLogicGraph retval = null; ResultSet results = null; - PreparedStatement fetchGraphStmt = null; + PreparedStatement fetchGraphStmt; if (version == null) { fetchGraphStmt = fetchActiveGraphStmt; @@ -570,12 +536,8 @@ public boolean hasGraph(String module, String rpc, String version, String mode) throw new ConfigurationException("invalid type for graph ("+graphObj.getClass().getName()); } - - } - else - { - return(null); } + } catch (Exception e) { @@ -590,15 +552,14 @@ public boolean hasGraph(String module, String rpc, String version, String mode) results.close(); } catch (SQLException x) - {} + { + LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x); + } } } - - return(retval); - - + return retval; } public void store(SvcLogicGraph graph) throws SvcLogicException { @@ -612,7 +573,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) if (!isDbConnValid()) { - throw new ConfigurationException("no jdbc connection"); + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); } } @@ -621,15 +582,12 @@ public boolean hasGraph(String module, String rpc, String version, String mode) throw new SvcLogicException("graph cannot be null"); } - byte[] graphBytes = null; - - ByteArrayOutputStream byteStr = null; - ObjectOutputStream goutStr = null; + byte[] graphBytes; - try + try (ByteArrayOutputStream byteStr = new ByteArrayOutputStream(); + ObjectOutputStream goutStr = new ObjectOutputStream(byteStr)) { - byteStr = new ByteArrayOutputStream(); - goutStr = new ObjectOutputStream(byteStr); + goutStr.writeObject(graph); graphBytes = byteStr.toByteArray(); @@ -639,28 +597,6 @@ public boolean hasGraph(String module, String rpc, String version, String mode) { throw new SvcLogicException("could not serialize graph", e); } - finally - { - - if (goutStr != null) - { - try { - goutStr.close(); - } catch (IOException e) { - - } - } - - if (byteStr != null) - { - try { - byteStr.close(); - } catch (IOException e) { - - } - } - } - // If object already stored in database, delete it if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode())) @@ -690,6 +626,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) } } + @Override public void delete(String module, String rpc, String version, String mode) throws SvcLogicException { if (!isDbConnValid()) @@ -700,7 +637,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) if (!isDbConnValid()) { - throw new ConfigurationException("no jdbc connection"); + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); } } @@ -724,6 +661,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) } } + @Override public void activate(SvcLogicGraph graph) throws SvcLogicException { try @@ -772,7 +710,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) if (!isDbConnValid()) { - throw new ConfigurationException("no jdbc connection"); + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); } } @@ -808,7 +746,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) if (!isDbConnValid()) { - throw new ConfigurationException("no jdbc connection"); + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); } } @@ -841,7 +779,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode) if (!isDbConnValid()) { - throw new ConfigurationException("no jdbc connection"); + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); } } @@ -856,16 +794,13 @@ public boolean hasGraph(String module, String rpc, String version, String mode) dbConn.commit(); dbConn.setAutoCommit(oldAutoCommit); - if (results != null) + if (results.next()) { - if (results.next()) - { - int cnt = results.getInt(1); + int cnt = results.getInt(1); - if (cnt > 0) - { - isValid = true; - } + if (cnt > 0) + { + isValid = true; } } @@ -883,7 +818,9 @@ public boolean hasGraph(String module, String rpc, String version, String mode) results.close(); } catch (SQLException x) - {} + { + LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x); + } } } @@ -891,5 +828,4 @@ public boolean hasGraph(String module, String rpc, String version, String mode) return(isValid); } - } -- cgit 1.2.3-korg From a74b012e58223276e9903db3b0905ba72e4cb259 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Mon, 18 Sep 2017 19:07:17 +0530 Subject: Fix few Major sonar issues Fix few Major sonar issues in CCSDK SLI Core module * Remove useless parentheses * Remove useless assignment to local variable * Use logger method instead of string formatting Change-Id: Ie9958d0bc4e754c36c127d465a1953160c2c3e2b Issue-Id: CCSDK-67 Signed-off-by: Ramu N --- .../org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java | 92 +++++++++++----------- .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 6 +- .../ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 14 ++-- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java index 5e19a52c6..b9ad19e25 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java @@ -8,9 +8,9 @@ * 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. @@ -22,7 +22,7 @@ package org.onap.ccsdk.sli.core.sli; public class SvcLogicAtom extends SvcLogicExpression { - + public enum AtomType { NUMBER, STRING, @@ -30,7 +30,7 @@ public class SvcLogicAtom extends SvcLogicExpression { CONTEXT_VAR } - + private AtomType atomType; private String atom; @@ -39,9 +39,9 @@ public class SvcLogicAtom extends SvcLogicExpression { { this.atomType = AtomType.valueOf(atomType); this.atom = atom; - + } - + public SvcLogicAtom(String atom) { @@ -73,9 +73,9 @@ public class SvcLogicAtom extends SvcLogicExpression { { this.atomType = AtomType.IDENTIFIER; this.atom = atom; - + } - + } } } @@ -83,7 +83,7 @@ public class SvcLogicAtom extends SvcLogicExpression { public AtomType getAtomType() { return atomType; } - + public void setAtomType(String newType) { atomType = AtomType.valueOf(newType); @@ -92,9 +92,9 @@ public class SvcLogicAtom extends SvcLogicExpression { public String getAtom() { return atom; } - - - + + + public void setAtomType(AtomType atomType) { this.atomType = atomType; } @@ -110,27 +110,27 @@ public class SvcLogicAtom extends SvcLogicExpression { StringBuffer sbuff = new StringBuffer(); switch(getAtomType()) { - case CONTEXT_VAR: - sbuff.append("$"); - case IDENTIFIER: - boolean needDot = false; - for (SvcLogicExpression term: this.getOperands()) - { - if (needDot) + case CONTEXT_VAR: + sbuff.append("$"); + case IDENTIFIER: + boolean needDot = false; + for (SvcLogicExpression term: this.getOperands()) { - sbuff.append("."); + if (needDot) + { + sbuff.append("."); + } + sbuff.append(term.toString()); + needDot = true; } - sbuff.append(term.toString()); - needDot = true; - } - return(sbuff.toString()); - case STRING: - case NUMBER: - default: - return(atom); + return sbuff.toString(); + case STRING: + case NUMBER: + default: + return atom; } } - + public String asParsedExpr() { // simplify debugging output for NUMBER type @@ -139,32 +139,32 @@ public class SvcLogicAtom extends SvcLogicExpression { } StringBuffer sbuff = new StringBuffer(); - + sbuff.append("(atom"); sbuff.append("<"); sbuff.append(atomType.toString()); sbuff.append(">"); - + switch(atomType) { - case IDENTIFIER: - case CONTEXT_VAR: - for (SvcLogicExpression term : getOperands()) - { + case IDENTIFIER: + case CONTEXT_VAR: + for (SvcLogicExpression term : getOperands()) + { + sbuff.append(" "); + sbuff.append(term.asParsedExpr()); + + } + break; + default: sbuff.append(" "); - sbuff.append(term.asParsedExpr()); - - } - break; - default: - sbuff.append(" "); - sbuff.append(atom); + sbuff.append(atom); } - + sbuff.append(")"); - return(sbuff.toString()); + return sbuff.toString(); } - - + + } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index 232774396..aca904d14 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -212,7 +212,7 @@ public class SvcLogicContext { if (ctxVarName.indexOf('[') == -1) { // Ctx variable contains no arrays - return (this.getAttribute(ctxVarName)); + return getAttribute(ctxVarName); } // Resolve any array references @@ -225,7 +225,7 @@ public class SvcLogicContext { if (endBracketLoc == -1) { // Missing end bracket ... give up parsing LOG.warn("Variable reference {} seems to be missing a ']'", ctxVarName); - return (this.getAttribute(ctxVarName)); + return getAttribute(ctxVarName); } String idxVarName = ctxVarParts[i].substring(1, endBracketLoc); @@ -242,7 +242,7 @@ public class SvcLogicContext { } } - return (this.getAttribute(sbuff.toString())); + return getAttribute(sbuff.toString()); } } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index 11b5fdea4..532ad31b4 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -8,9 +8,9 @@ * 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. @@ -43,7 +43,7 @@ public class SvcLogicStoreFactory { } try { - return (getSvcLogicStore(new FileInputStream(propFile))); + return getSvcLogicStore(new FileInputStream(propFile)); } catch (Exception e) { throw new ConfigurationException( "Could load service store from properties file " + propfile, @@ -62,7 +62,7 @@ public class SvcLogicStoreFactory { throw new ConfigurationException("Could not get load properties from input stream", e); } - return(getSvcLogicStore(props)); + return getSvcLogicStore(props); } public static SvcLogicStore getSvcLogicStore(Properties props) @@ -74,8 +74,8 @@ public class SvcLogicStoreFactory { } - SvcLogicStore retval = null; - LOG.debug(String.format("Using org.onap.ccsdk.sli.dbtype=%s", storeType)); + SvcLogicStore retval; + LOG.debug("Using org.onap.ccsdk.sli.dbtype={}", storeType); if ("jdbc".equalsIgnoreCase(storeType)) { retval = new SvcLogicJdbcStore(); @@ -90,7 +90,7 @@ public class SvcLogicStoreFactory { retval.init(props); - return (retval); + return retval; } } -- cgit 1.2.3-korg From c487026f1e72e78efd1cffca4935be34b8f2b8f4 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Mon, 18 Sep 2017 20:17:36 +0530 Subject: Fix few Major sonar issues Fix few Major sonar issues in CCSDK SLI Core module * Use logger method's built-in string formatting instead of string concatination * code formatting * Use Integer.toString() instead of concatenating empty string "" to a primitive Change-Id: I5a15c9b0049b71d7b0fa06c6791abe766a035c46 Issue-Id: CCSDK-67 Signed-off-by: Ramu N --- .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 611 +++++++++++---------- 1 file changed, 314 insertions(+), 297 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 26d45ce9a..03cb50b59 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -8,9 +8,9 @@ * 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. @@ -53,10 +53,10 @@ public class SvcLogicParser { static final String JAXP_DYNAMIC_VALIDATION = "http://apache.org/xml/features/validation/dynamic"; static final String JAXP_SCHEMA_VALIDATION = "http://apache.org/xml/features/validation/schema"; - private static final String LOAD_MESSAGE = "Getting SvcLogicGraph from database - "; - private static final String LOAD_ERROR_MESSAGE = "SvcLogicGraph not found - "; - private static final String ACTIVATION_ERROR_MESSAGE = "Could not activate SvcLogicGraph - "; - private static final String PRINT_ERROR_MESSAGE = "Could not print SvcLogicGraph - "; + private static final String LOAD_MESSAGE = "Getting SvcLogicGraph from database - {}"; + private static final String LOAD_ERROR_MESSAGE = "SvcLogicGraph not found - {}"; + private static final String ACTIVATION_ERROR_MESSAGE = "Could not activate SvcLogicGraph - {}"; + private static final String PRINT_ERROR_MESSAGE = "Could not print SvcLogicGraph - {}"; private static final String SVC_LOGIC_STORE_ERROR = "Could not get service logic store"; private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicParser.class); @@ -98,86 +98,96 @@ public class SvcLogicParser { // Handle service-logic (graph) tag if ("service-logic".equalsIgnoreCase(qName)) { - module = attributes.getValue("module"); - if (module == null || module.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'module' attribute from service-logic tag"); - } + module = attributes.getValue("module"); + if (module == null || module.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Missing 'module' attribute from service-logic tag"); + } - version = attributes.getValue("version"); - if (version == null || version.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'version' attribute from service-logic tag"); - } + version = attributes.getValue("version"); + if (version == null || version.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Missing 'version' attribute from service-logic tag"); + } - return; + return; } if ("method".equalsIgnoreCase(qName)) { - if (curGraph != null) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot nest module tags"); - } - curGraph = new SvcLogicGraph(); - curGraph.setModule(module); - curGraph.setVersion(version); - this.curNodeId = 1; - String attrValue = attributes.getValue("rpc"); - if (attrValue == null || attrValue.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'rpc' attribute for method tag"); - } - curGraph.setRpc(attrValue); + if (curGraph != null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Cannot nest module tags"); + } - attrValue = attributes.getValue("mode"); - if (attrValue == null || attrValue.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Missing 'mode' attribute for method tag"); - } - curGraph.setMode(attrValue); + curGraph = new SvcLogicGraph(); + curGraph.setModule(module); + curGraph.setVersion(version); + this.curNodeId = 1; - return; + String attrValue = attributes.getValue("rpc"); + if (attrValue == null || attrValue.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Missing 'rpc' attribute for method tag"); + } + curGraph.setRpc(attrValue); + + attrValue = attributes.getValue("mode"); + if (attrValue == null || attrValue.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Missing 'mode' attribute for method tag"); + } + curGraph.setMode(attrValue); + + return; } // Handle outcome (edge) tag if ("outcome".equalsIgnoreCase(qName)) { - String refValue = attributes.getValue("ref"); - - if (refValue != null) { - SvcLogicNode refNode = curGraph.getNamedNode(refValue); - - if (refNode != null) { - try { - curNode.addOutcome(attributes.getValue("value"), refNode); - } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot add outcome", e); - } - } else { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "ref to unknown node " + refValue); + String refValue = attributes.getValue("ref"); + + if (refValue != null) { + SvcLogicNode refNode = curGraph.getNamedNode(refValue); + + if (refNode != null) { + try { + curNode.addOutcome(attributes.getValue("value"), refNode); + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Cannot add outcome", e); + } + } else { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "ref to unknown node " + refValue); + } + return; } - return; - } - if (outcomeValue != null) { - outcomeStack.push(outcomeValue); - } - outcomeValue = attributes.getValue("value"); + if (outcomeValue != null) { + outcomeStack.push(outcomeValue); + } + outcomeValue = attributes.getValue("value"); - return; + return; } // Handle parameter tag if ("parameter".equalsIgnoreCase(qName)) { - String parmName = attributes.getValue("name"); - String parmValue = attributes.getValue("value"); + String parmName = attributes.getValue("name"); + String parmValue = attributes.getValue("value"); - if (parmName != null && parmName.length() > 0 && parmValue != null) { - try { + if (parmName != null && parmName.length() > 0 && parmValue != null) { + try { - curNode.mapParameter(parmName, parmValue); - } catch (Exception e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + " cannot set parameter " + parmName + " to " + parmValue + " [" + e.getMessage() + "]"); + curNode.mapParameter(parmName, parmValue); + } catch (Exception e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + " cannot set parameter " + parmName + " to " + parmValue + " [" + e.getMessage() + "]"); + } } - } - return; + return; } // Handle node tags @@ -187,10 +197,12 @@ public class SvcLogicParser { try { if (!svcLogicStore.isValidNodeType(qName)) { - throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Unknown tag " + qName); + throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + + " " + "Unknown tag " + qName); } } catch (Exception e) { - throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot validate node type " + qName); + throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Cannot validate node type " + qName); } try { @@ -204,7 +216,8 @@ public class SvcLogicParser { curGraph.setRootNode(thisNode); } } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + e.getMessage()); } @@ -218,7 +231,7 @@ public class SvcLogicParser { String attrValueStr = attributes.getValue(i); SvcLogicExpression attrValue = null; if (attrValueStr.trim().startsWith("`")) { - int lastParen = attrValueStr.lastIndexOf("`"); + int lastParen = attrValueStr.lastIndexOf('`'); String evalExpr = attrValueStr.trim().substring(1, lastParen); attrValue = SvcLogicExpressionFactory.parse(evalExpr); @@ -231,23 +244,27 @@ public class SvcLogicParser { } thisNode.setAttribute(attrName, attrValue); } catch (Exception e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + "Cannot set attribute " + attrName, e); + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Cannot set attribute " + attrName, e); } } } if (curNode != null) { try { - if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) || "while".equalsIgnoreCase(curNode.getNodeType())) { - curNode.addOutcome("" + (curNode.getNumOutcomes() + 1), thisNode); + if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) + || "while".equalsIgnoreCase(curNode.getNodeType())) { + curNode.addOutcome(Integer.toString(curNode.getNumOutcomes() + 1), thisNode); } else { - if (outcomeValue == null) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType()); - } - curNode.addOutcome(outcomeValue, thisNode); + if (outcomeValue == null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType()); + } + curNode.addOutcome(outcomeValue, thisNode); } } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + e.getMessage()); } nodeStack.push(curNode); } @@ -260,338 +277,338 @@ public class SvcLogicParser { // Handle close of service-logic tag if ("service-logic".equalsIgnoreCase(qName)) { - // Nothing more to do - return; + // Nothing more to do + return; } // Handle close of method tag if ("method".equalsIgnoreCase(qName)) { - graphs.add(curGraph); - curGraph = null; - return; + graphs.add(curGraph); + curGraph = null; + return; } // Handle close of outcome tag if ("outcome".equalsIgnoreCase(qName)) { - // Finished this outcome - pop the outcome stack - if (outcomeStack.isEmpty()) { - outcomeValue = null; - } else { - outcomeValue = outcomeStack.pop(); - } - return; + // Finished this outcome - pop the outcome stack + if (outcomeStack.isEmpty()) { + outcomeValue = null; + } else { + outcomeValue = outcomeStack.pop(); + } + return; } // Handle close of parameter tag - do nothing if ("parameter".equalsIgnoreCase(qName)) { - return; + return; } // Handle close of a node tag if (nodeStack.isEmpty()) { - curNode = null; + curNode = null; } else { - curNode = nodeStack.pop(); + curNode = nodeStack.pop(); } } @Override public void error(SAXParseException arg0) throws SAXException { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + arg0.getMessage()); + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + arg0.getMessage()); } } public SvcLogicParser(SvcLogicStore store) { - this.store = store; + this.store = store; } public SvcLogicParser(String propFile) { - try { - this.store = SvcLogicStoreFactory.getSvcLogicStore(propFile); - } catch (Exception e) { - LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + try { + this.store = SvcLogicStoreFactory.getSvcLogicStore(propFile); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); - } + } } public SvcLogicParser(InputStream propStr) { - try { - this.store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - } catch (Exception e) { - LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + try { + this.store = SvcLogicStoreFactory.getSvcLogicStore(propStr); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); - } + } } public LinkedList parse(String fileName) throws SvcLogicException { - LinkedList graphs = null; + LinkedList graphs = null; - URL xsdUrl = null; - Schema schema = null; - String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true"); + URL xsdUrl = null; + Schema schema = null; + String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true"); - if ("true".equalsIgnoreCase(validateSchema)) { - xsdUrl = getClass().getResource(SVCLOGIC_XSD); + if ("true".equalsIgnoreCase(validateSchema)) { + xsdUrl = getClass().getResource(SVCLOGIC_XSD); - } + } - if (xsdUrl != null) { - try { - SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - schema = schemaFactory.newSchema(xsdUrl); - } catch (Exception e) { - LOGGER.warn("Could not validate using schema " + xsdUrl.getPath(), e); + if (xsdUrl != null) { + try { + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + schema = schemaFactory.newSchema(xsdUrl); + } catch (Exception e) { + LOGGER.warn("Could not validate using schema " + xsdUrl.getPath(), e); + } + } else { + LOGGER.warn("Could not find resource {}", SVCLOGIC_XSD); } - } else { - LOGGER.warn("Could not find resource " + SVCLOGIC_XSD); - } - try { - SAXParserFactory factory = SAXParserFactory.newInstance(); + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); - if (schema != null) { - factory.setNamespaceAware(true); - factory.setSchema(schema); - } - SAXParser saxParser = factory.newSAXParser(); + if (schema != null) { + factory.setNamespaceAware(true); + factory.setSchema(schema); + } + SAXParser saxParser = factory.newSAXParser(); - if (saxParser.isValidating()) { - LOGGER.info("Parser not configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null)); - } - graphs = new LinkedList<>(); + if (saxParser.isValidating()) { + LOGGER.info("Parser not configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null)); + } + graphs = new LinkedList<>(); - saxParser.parse(fileName, new SvcLogicHandler(graphs, store)); + saxParser.parse(fileName, new SvcLogicHandler(graphs, store)); - } catch (Exception e) { - String msg = e.getMessage(); - if (msg != null) { - LOGGER.error(msg); - throw new SvcLogicException("Compiler error: " + fileName + " @ " + msg); - } else { - LOGGER.info("Caught exception parsing " + fileName, e); - throw new SvcLogicException("Compiler error: " + fileName, e); + } catch (Exception e) { + String msg = e.getMessage(); + if (msg != null) { + LOGGER.error(msg); + throw new SvcLogicException("Compiler error: " + fileName + " @ " + msg); + } else { + LOGGER.info("Caught exception parsing " + fileName, e); + throw new SvcLogicException("Compiler error: " + fileName, e); + } } - } - return graphs; + return graphs; } public static void main(String argv[]) { - if (argv.length == 0) { - SvcLogicParser.usage(); - } + if (argv.length == 0) { + SvcLogicParser.usage(); + } - if ("load".equalsIgnoreCase(argv[0])) { - if (argv.length == 3) { - String xmlfile = argv[1]; - String propfile = argv[2]; + if ("load".equalsIgnoreCase(argv[0])) { + if (argv.length == 3) { + String xmlfile = argv[1]; + String propfile = argv[2]; - SvcLogicStore store = SvcLogicParser.getStore(propfile); - try { - SvcLogicParser.load(xmlfile, store); - } catch (Exception e) { - LOGGER.error(e.getMessage(), e); - } - } else { - SvcLogicParser.usage(); - } - } else if ("print".equalsIgnoreCase(argv[0])) { - String version = null; - String propfile = null; - - switch (argv.length) { - case 6: - version = argv[4]; - propfile = argv[5]; - case 5: - if (propfile == null) { - propfile = argv[4]; - } - SvcLogicStore store = SvcLogicParser.getStore(propfile); - SvcLogicParser.print(argv[1], argv[2], argv[3], version, store); - break; - default: - SvcLogicParser.usage(); - } - } else if ("get-source".equalsIgnoreCase(argv[0])) { - - switch (argv.length) { - case 6: - SvcLogicStore store = SvcLogicParser.getStore(argv[5]); - SvcLogicParser.getSource(argv[1], argv[2], argv[3], argv[4], store); - break; - default: - SvcLogicParser.usage(); - } - } else if ("activate".equalsIgnoreCase(argv[0])) { - if (argv.length == 6) { - SvcLogicStore store = SvcLogicParser.getStore(argv[5]); - SvcLogicParser.activate(argv[1], argv[2], argv[3], argv[4], store); - } else { - SvcLogicParser.usage(); - } - } else if ("validate".equalsIgnoreCase(argv[0])) { - if (argv.length == 3) { - String xmlfile = argv[1]; - String propfile = argv[2]; + SvcLogicStore store = SvcLogicParser.getStore(propfile); + try { + SvcLogicParser.load(xmlfile, store); + } catch (Exception e) { + LOGGER.error(e.getMessage(), e); + } + } else { + SvcLogicParser.usage(); + } + } else if ("print".equalsIgnoreCase(argv[0])) { + String version = null; + String propfile = null; + + switch (argv.length) { + case 6: + version = argv[4]; + propfile = argv[5]; + case 5: + if (propfile == null) { + propfile = argv[4]; + } + SvcLogicStore store = SvcLogicParser.getStore(propfile); + SvcLogicParser.print(argv[1], argv[2], argv[3], version, store); + break; + default: + SvcLogicParser.usage(); + } + } else if ("get-source".equalsIgnoreCase(argv[0])) { - System.setProperty(SLI_VALIDATING_PARSER, "true"); - SvcLogicStore store = SvcLogicParser.getStore(propfile); - try { - SvcLogicParser.validate(xmlfile, store); - } catch (Exception e) { - LOGGER.error(e.getMessage(), e); - } - } else { - SvcLogicParser.usage(); + if (argv.length == 6) { + SvcLogicStore store = SvcLogicParser.getStore(argv[5]); + SvcLogicParser.getSource(argv[1], argv[2], argv[3], argv[4], store); + } else { + SvcLogicParser.usage(); + } + } else if ("activate".equalsIgnoreCase(argv[0])) { + if (argv.length == 6) { + SvcLogicStore store = SvcLogicParser.getStore(argv[5]); + SvcLogicParser.activate(argv[1], argv[2], argv[3], argv[4], store); + } else { + SvcLogicParser.usage(); + } + } else if ("validate".equalsIgnoreCase(argv[0])) { + if (argv.length == 3) { + String xmlfile = argv[1]; + String propfile = argv[2]; + + System.setProperty(SLI_VALIDATING_PARSER, "true"); + SvcLogicStore store = SvcLogicParser.getStore(propfile); + try { + SvcLogicParser.validate(xmlfile, store); + } catch (Exception e) { + LOGGER.error(e.getMessage(), e); + } + } else { + SvcLogicParser.usage(); + } } - } - System.exit(0); + System.exit(0); } private static SvcLogicStore getStore(String propfile) { - SvcLogicStore store = null; + SvcLogicStore store = null; - try { - store = SvcLogicStoreFactory.getSvcLogicStore(propfile); - } catch (Exception e) { - LOGGER.error(SVC_LOGIC_STORE_ERROR, e); - System.exit(1); - } + try { + store = SvcLogicStoreFactory.getSvcLogicStore(propfile); + } catch (Exception e) { + LOGGER.error(SVC_LOGIC_STORE_ERROR, e); + System.exit(1); + } - return store; + return store; } public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException { - File xmlFile = new File(xmlfile); - if (!xmlFile.canRead()) { - throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); - } - - SvcLogicParser parser = new SvcLogicParser(store); - LinkedList graphs = null; - try { - graphs = parser.parse(xmlfile); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); - } - - if (graphs == null) { - throw new SvcLogicException("Could not parse " + xmlfile); - } - - for (SvcLogicGraph graph : graphs) { + File xmlFile = new File(xmlfile); + if (!xmlFile.canRead()) { + throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); + } - String module = graph.getModule(); - String rpc = graph.getRpc(); - String version = graph.getVersion(); - String mode = graph.getMode(); + SvcLogicParser parser = new SvcLogicParser(store); + LinkedList graphs = null; try { - LOGGER.info("Saving SvcLogicGraph to database (module:" + module + ",rpc:" + rpc + ",version:" + version + ",mode:" + mode + ")"); - store.store(graph); + graphs = parser.parse(xmlfile); } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); + throw new SvcLogicException(e.getMessage(), e); } - } + if (graphs == null) { + throw new SvcLogicException("Could not parse " + xmlfile); + } + + for (SvcLogicGraph graph : graphs) { + + String module = graph.getModule(); + String rpc = graph.getRpc(); + String version = graph.getVersion(); + String mode = graph.getMode(); + try { + LOGGER.info("Saving SvcLogicGraph to database (module:{},rpc:{},mode:{},version:{})", module, rpc, + mode, version); + store.store(graph); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + } } public static void validate(String xmlfile, SvcLogicStore store) throws SvcLogicException { - File xmlFile = new File(xmlfile); - if (!xmlFile.canRead()) { - throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); - } + File xmlFile = new File(xmlfile); + if (!xmlFile.canRead()) { + throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); + } - SvcLogicParser parser = new SvcLogicParser(store); - LinkedList graphs = null; - try { - LOGGER.info("Validating " + xmlfile); - graphs = parser.parse(xmlfile); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); - } + SvcLogicParser parser = new SvcLogicParser(store); + LinkedList graphs = null; + try { + LOGGER.info("Validating {}", xmlfile); + graphs = parser.parse(xmlfile); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } - if (graphs == null) { - throw new SvcLogicException("Could not parse " + xmlfile); - } else { - LOGGER.info("Compilation successful for " + xmlfile); - } + if (graphs == null) { + throw new SvcLogicException("Could not parse " + xmlfile); + } else { + LOGGER.info("Compilation successful for {}", xmlfile); + } } private static void print(String module, String rpc, String mode, String version, SvcLogicStore store) { - String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; - try { - LOGGER.info(LOAD_MESSAGE + details); + try { + LOGGER.info(LOAD_MESSAGE, details); - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - if (graph == null) { - LOGGER.error(LOAD_ERROR_MESSAGE + details); - System.exit(1); + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE, details); + System.exit(1); + } + graph.printAsGv(System.out); + } catch (Exception e) { + LOGGER.error(PRINT_ERROR_MESSAGE, details, e); + System.exit(1); } - graph.printAsGv(System.out); - } catch (Exception e) { - LOGGER.error(PRINT_ERROR_MESSAGE + details, e); - System.exit(1); - } } private static void getSource(String module, String rpc, String mode, String version, SvcLogicStore store) { - String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; - try { - LOGGER.info(LOAD_MESSAGE + details); + try { + LOGGER.info(LOAD_MESSAGE, details); - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - if (graph == null) { - LOGGER.error(LOAD_ERROR_MESSAGE + details); - System.exit(1); + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE, details); + System.exit(1); + } + graph.printAsXml(System.out); + } catch (Exception e) { + LOGGER.error(PRINT_ERROR_MESSAGE, details, e); + System.exit(1); } - graph.printAsXml(System.out); - } catch (Exception e) { - LOGGER.error(PRINT_ERROR_MESSAGE + details, e); - System.exit(1); - } } private static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) { - String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; + String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; - try { - LOGGER.info(LOAD_MESSAGE + details); + try { + LOGGER.info(LOAD_MESSAGE, details); - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - if (graph == null) { - LOGGER.error(LOAD_ERROR_MESSAGE + details); - System.exit(1); + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (graph == null) { + LOGGER.error(LOAD_ERROR_MESSAGE, details); + System.exit(1); + } + store.activate(graph); + } catch (Exception e) { + LOGGER.error(ACTIVATION_ERROR_MESSAGE, details, e); + System.exit(1); } - store.activate(graph); - } catch (Exception e) { - LOGGER.error(ACTIVATION_ERROR_MESSAGE + details, e); - System.exit(1); - } } private static void usage() { - System.err.println("Usage: SvcLogicParser load "); - System.err.println(" OR SvcLogicParser print [] "); - System.err.println(" OR SvcLogicParser get-source "); - System.err.println(" OR SvcLogicParser activate "); - System.exit(1); + System.err.println("Usage: SvcLogicParser load "); + System.err.println(" OR SvcLogicParser print [] "); + System.err.println(" OR SvcLogicParser get-source "); + System.err.println(" OR SvcLogicParser activate "); + System.exit(1); } } -- cgit 1.2.3-korg From aa202d6221e4f4d07b25e9b703de1125f6a6f0e3 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 18 Sep 2017 11:33:49 -0400 Subject: Explicitly import com.mysql.jdbc package Need to explicitly add com.mysql.jdbc to Import-Package in dblib/provider pom.xml, so that Class.forName() can resolve com.mysql.jdbc.Driver. Will also need to add org.mariadb.jdbc,but will do that in a separate commit Change-Id: I6a4be5d4e1841690919484940af75a2cb15c357b Issue-ID: CCSDK-94 Signed-off-by: Dan Timoney --- dblib/provider/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 07fc61ab1..01d7f97d3 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -76,6 +76,7 @@ org.onap.ccsdk.sli.core.dblib org.onap.ccsdk.sli.core.dblib;version=${project.version} + *,com.mysql.jdbc true -- cgit 1.2.3-korg From 2c60d26db70ffce626ba391a27ec8f5152d0557b Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 18 Sep 2017 14:56:39 -0400 Subject: Update sli/core to use Mariadb connectori Update sli/core (including dblib, notably) to use mariadb-connector for any jUnit tests. Update Import-Package in dblib provider pom.xml to import org.mariadb.jdbc so that org.mariadb.jdbc.Driver will be resolved Change-Id: I39dfe2cafb955ba1bf05b0ecdb0212d766fcc96c Issue-ID: CCSDK-95 Signed-off-by: Dan Timoney --- dblib/features/src/main/resources/features.xml | 4 ++-- dblib/provider/pom.xml | 7 ++++++- filters/provider/pom.xml | 8 +------- sli/common/pom.xml | 6 +++--- sli/features/src/main/resources/features.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/dblib/features/src/main/resources/features.xml b/dblib/features/src/main/resources/features.xml index 5f339cba0..3e41e8eeb 100755 --- a/dblib/features/src/main/resources/features.xml +++ b/dblib/features/src/main/resources/features.xml @@ -10,9 +10,9 @@ odl-mdsal-broker - wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=com.mysql.*&overwrite=merge + wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*&overwrite=merge mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} - mvn:mysql/mysql-connector-java/${mysql.connector.version} + mvn:org/mariadb/jdbc/mariadb-connector-java/${mariadb.connector.version} diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 01d7f97d3..765f73798 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -47,6 +47,11 @@ mysql-connector-java ${mysql.connector.version} + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + org.apache.tomcat tomcat-jdbc @@ -76,7 +81,7 @@ org.onap.ccsdk.sli.core.dblib org.onap.ccsdk.sli.core.dblib;version=${project.version} - *,com.mysql.jdbc + *,org.mariadb.jdbc true diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index a59071937..e6d91c903 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -54,13 +54,7 @@ sli-common ${project.version} - + diff --git a/sli/common/pom.xml b/sli/common/pom.xml index c367dd779..e6bac8ada 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -84,9 +84,9 @@ ${equinox.osgi.version} - mysql - mysql-connector-java - ${mysql.connector.version} + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} jar compile diff --git a/sli/features/src/main/resources/features.xml b/sli/features/src/main/resources/features.xml index fef113317..c43c90155 100644 --- a/sli/features/src/main/resources/features.xml +++ b/sli/features/src/main/resources/features.xml @@ -33,7 +33,7 @@ mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version} mvn:org.onap.ccsdk.sli.core/sli-recording/${project.version} sdnc-dblib - mvn:mysql/mysql-connector-java/${mysql.connector.version} + mvn:org/mariadb/jdbc/mariadb-connector-java/${mariadb.connector.version} diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index ad950c0c8..16940dbfe 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -72,7 +72,7 @@ org.onap.ccsdk.sli.core.slipluginutils org.onap.ccsdk.sli.core.slipluginutils org.onap.ccsdk.sli.core.*,org.osgi.framework.*,org.slf4j.*,java.net.* - *;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mysql-connector-java|slf4j-api|jcl-over-slf4j + *;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mariadb-connector-java|slf4j-api|jcl-over-slf4j true -- cgit 1.2.3-korg From 2935b1b029267cc6a8cc040ccd44f01994a1baa3 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 18 Sep 2017 15:43:56 -0400 Subject: Fix mariadb-connector-java references Correct mariadb JDBC connector artifactId should be mariadb-java-client, not mariadb-connector-java Change-Id: If58a33a1ef22d47e1d5c138bad164b0ad89219eb Issue-ID: CCSDK-95 Signed-off-by: Dan Timoney --- sli/features/src/main/resources/features.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sli/features/src/main/resources/features.xml b/sli/features/src/main/resources/features.xml index c43c90155..692d9ff0a 100644 --- a/sli/features/src/main/resources/features.xml +++ b/sli/features/src/main/resources/features.xml @@ -33,7 +33,7 @@ mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version} mvn:org.onap.ccsdk.sli.core/sli-recording/${project.version} sdnc-dblib - mvn:org/mariadb/jdbc/mariadb-connector-java/${mariadb.connector.version} + mvn:org/mariadb/jdbc/mariadb-java-client/${mariadb.connector.version} diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 16940dbfe..d105036b3 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -72,7 +72,7 @@ org.onap.ccsdk.sli.core.slipluginutils org.onap.ccsdk.sli.core.slipluginutils org.onap.ccsdk.sli.core.*,org.osgi.framework.*,org.slf4j.*,java.net.* - *;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mariadb-connector-java|slf4j-api|jcl-over-slf4j + *;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mariadb-java-client|slf4j-api|jcl-over-slf4j true -- cgit 1.2.3-korg From 207c9a6e9d1dfa8153fe82a815c7044873cc1bc2 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 19 Sep 2017 13:34:33 -0400 Subject: Fix mariadb-connector-java references Remove mariadb-connector-java reference in dblib features.xml Change-Id: I29f7466a82b25e35b180eb48911dd553c86460fa Issue-ID: CCSDK-95 Signed-off-by: Dan Timoney --- dblib/features/src/main/resources/features.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dblib/features/src/main/resources/features.xml b/dblib/features/src/main/resources/features.xml index 3e41e8eeb..36d794139 100755 --- a/dblib/features/src/main/resources/features.xml +++ b/dblib/features/src/main/resources/features.xml @@ -12,7 +12,7 @@ odl-mdsal-broker wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*&overwrite=merge mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} - mvn:org/mariadb/jdbc/mariadb-connector-java/${mariadb.connector.version} + mvn:org/mariadb/jdbc/mariadb-java-client/${mariadb.connector.version} -- cgit 1.2.3-korg From a07f58226c3a42ed2e658d06806df74252e909cc Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Wed, 20 Sep 2017 02:17:00 +0530 Subject: Use Junit4 instead of Junit3 in sli/common Modified sli/common pom.xml file to take Junit version from parent pom file and modified one Testfile as per Junit4 Change-Id: Iee4397125d9873def60c77ba8be5d541e0df62fa Issue-Id: CCSDK-98 Signed-off-by: Ramu N --- sli/common/pom.xml | 2 +- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 137 +++++++++++++-------- 2 files changed, 85 insertions(+), 54 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index e6bac8ada..bd9ec696a 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -16,7 +16,7 @@ junit junit - 3.8.1 + ${junit.version} test diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 07f40a2ec..8bf748aa4 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -24,6 +24,9 @@ */ package org.onap.ccsdk.sli.core.sli; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; @@ -32,69 +35,92 @@ import java.util.Properties; import ch.vorburger.mariadb4j.DB; import ch.vorburger.mariadb4j.DBConfigurationBuilder; -import junit.framework.TestCase; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author dt5972 * */ -public class ITCaseSvcLogicParser extends TestCase { - - /** - * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}. - */ +public class ITCaseSvcLogicParser { + private static SvcLogicStore store; + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicJdbcStore.class); - public void testParse() { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + LOG.info("before class"); - try - { - + URL propUrl = ITCaseSvcLogicParser.class.getResource("/svclogic.properties"); + InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/svclogic.properties"); - URL propUrl = getClass().getResource("/svclogic.properties"); + Properties props = new Properties(); - InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + props.load(propStr); - Properties props = new Properties(); - props.load(propStr); + // Start MariaDB4j database + DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); + config.setPort(0); // 0 => autom. detect free port + DB db = DB.newEmbeddedDB(config.build()); + db.start(); - // Start MariaDB4j database - DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); - config.setPort(0); // 0 => autom. detect free port - DB db = DB.newEmbeddedDB(config.build()); - db.start(); + // Override jdbc URL and database name + props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + store = SvcLogicStoreFactory.getSvcLogicStore(props); - // Override jdbc URL and database name - props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); - props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); - + assertNotNull(store); + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + } - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(props); + @Before + public void setUp() throws Exception { + LOG.info("before"); + } - assertNotNull(store); + @After + public void tearDown() throws Exception { + LOG.info("after"); + } - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); + @AfterClass + public static void tearDownAfterClass() throws Exception { + LOG.info("after class"); + } + /** + * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}. + */ + @Test + public void testParseValidXml() { + try + { InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); String testCaseFile = null; @@ -118,19 +144,29 @@ public class ITCaseSvcLogicParser extends TestCase { SvcLogicParser.validate(testCaseUrl.getPath(), store); } catch (Exception e) { fail("Validation failure ["+e.getMessage()+"]"); - } - - - - - } } + } + catch (SvcLogicParserException e) + { + fail("Parser error : "+e.getMessage()); + } + catch (Exception e) + { + LOG.error("", e); + fail("Caught exception processing test cases"); + } + } + + @Test + public void testParseInvalidXml() { - testStr = getClass().getResourceAsStream("/parser-bad.tests"); - testsReader = new BufferedReader(new InputStreamReader(testStr)); - testCaseFile = null; + try + { + InputStream testStr = getClass().getResourceAsStream("/parser-bad.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + String testCaseFile = null; while ((testCaseFile = testsReader.readLine()) != null) { testCaseFile = testCaseFile.trim(); @@ -158,8 +194,6 @@ public class ITCaseSvcLogicParser extends TestCase { if (valid) { fail("Expected compiler error on "+testCaseFile+", but got success"); } - - } } } @@ -169,13 +203,10 @@ public class ITCaseSvcLogicParser extends TestCase { } catch (Exception e) { - e.printStackTrace(); + LOG.error("", e); fail("Caught exception processing test cases"); } - } - - } -- cgit 1.2.3-korg From 5469072378877daa9e9d709fa0f49bacc04e3e1d Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 19 Sep 2017 17:33:48 -0400 Subject: Remove mysql dependencies in sli/core Remove lingering mysql dependencies in sli/core, which prevented odlsli container from starting up clean. Note: tested this using bareodl container and verified that these changes install clean AFTER changing incorrect driver property name in dblib.properties. This patch is fine, but a second patch to ccsdk/distribution is needed to fix that property file. Change-Id: I6a900d1c29998867bfbae29d5e113c4e392a8bb9 Issue-ID: CCSDK-95 Signed-off-by: Dan Timoney --- dblib/features/src/main/resources/features.xml | 2 +- dblib/provider/pom.xml | 5 - .../sli/core/dblib/jdbc/MySQLCachedDataSource.java | 216 --------------------- .../onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 2 +- sli/features/src/main/resources/features.xml | 2 +- .../sli/core/sli/provider/SvcLogicActivator.java | 46 +++-- .../features/src/main/resources/features.xml | 5 +- 7 files changed, 27 insertions(+), 251 deletions(-) delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java diff --git a/dblib/features/src/main/resources/features.xml b/dblib/features/src/main/resources/features.xml index 36d794139..aa31db751 100755 --- a/dblib/features/src/main/resources/features.xml +++ b/dblib/features/src/main/resources/features.xml @@ -12,7 +12,7 @@ odl-mdsal-broker wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*&overwrite=merge mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} - mvn:org/mariadb/jdbc/mariadb-java-client/${mariadb.connector.version} + mvn:org.mariadb.jdbc/mariadb-java-client/${mariadb.connector.version} diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 765f73798..8ff109417 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -42,11 +42,6 @@ ${slf4j.version} test - - mysql - mysql-connector-java - ${mysql.connector.version} - org.mariadb.jdbc mariadb-java-client diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java deleted file mode 100644 index bea0d631f..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/MySQLCachedDataSource.java +++ /dev/null @@ -1,216 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.jdbc; - -import java.sql.SQLFeatureNotSupportedException; -import java.util.Properties; - -import org.onap.ccsdk.sli.core.dblib.CachedDataSource; -import org.onap.ccsdk.sli.core.dblib.DBConfigException; -import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; - - - - -/** - * @version $Revision: 1.7 $ - * Change Log - * Author Date Comments - * ============== ======== ==================================================== - * Rich Tabedzki - */ - -public class MySQLCachedDataSource extends CachedDataSource -{ - private String dbUserId; - private String dbPasswd; - private String dbUrl; - - private String minLimit; - private String maxLimit; - private String initialLimit; - - private static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; - - private static Logger LOGGER = LoggerFactory.getLogger(MySQLCachedDataSource.class); - - /** - * @param jdbcElem - */ - public MySQLCachedDataSource(BaseDBConfiguration jdbcElem) - { - super(jdbcElem); - } - - @Override - protected void configure(BaseDBConfiguration xmlElem) throws DBConfigException - { - BaseDBConfiguration jdbcConfig = (BaseDBConfiguration)xmlElem; - if(jdbcConfig.getConnTimeout() > 0){ - this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); - } - if(jdbcConfig.getRequestTimeout() > 0){ - this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); - } - - // set connection pool name - String dbConnectionName = jdbcConfig.getDbConnectionName(); - super.setDbConnectionName(dbConnectionName); - // Configure the JDBC connection - dbUserId = jdbcConfig.getDbUserId(); - if (dbUserId == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - - dbPasswd = jdbcConfig.getDbPasswd(); - if (dbPasswd == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - /* - dbDriver = jdbcConfig.getDbDriver(); - if (dbDriver == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new ScpTblUpdateError(errorMsg); - } - */ - - minLimit = Integer.toString(jdbcConfig.getDbMinLimit()); - if (minLimit == null) - { - String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - maxLimit = Integer.toString(jdbcConfig.getDbMaxLimit()); - if (maxLimit == null) - { - String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - initialLimit = Integer.toString(jdbcConfig.getDbInitialLimit()); - if (initialLimit == null) - { - String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - - dbUrl = jdbcConfig.getDbUrl(); - if(dbUrl == null){ - String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); - } - - try { - - MysqlDataSource dataSource = new MysqlDataSource(); - dataSource.setUser(dbUserId); - dataSource.setPassword(dbPasswd); - dataSource.setURL(dbUrl); -// dataSource.setInitialSize(5); -// dataSource.setMaxTotal(60); -// dataSource.setMaxActive(100); -// dataSource.setMaxWait(10000); -// dataSource.setMaxIdle(10); - - Properties connAttr = new Properties(); - - connAttr.setProperty("MinLimit", minLimit); - connAttr.setProperty("MaxLimit", maxLimit); - connAttr.setProperty("InitialLimit", initialLimit); - connAttr.setProperty("TRANSACTION_ISOLATION","SERIALIZABLE"); - connAttr.setProperty("CONNECTION_TAG", dbConnectionName.toUpperCase()+"_CONNECTION"); - connAttr.setProperty("InactivityTimeout", "900"); - connAttr.setProperty("AbandonedConnectionTimeout", "600"); - connAttr.setProperty("PropertyCheckInterval", "60"); - connAttr.setProperty("ValidateConnection", "true"); - - - synchronized(this) - { - this.ds = dataSource; - - initialized = true; - LOGGER.info("MySQLDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); - } - -// } catch (SQLException exc) { -// initialized = false; -// StringBuffer sb = new StringBuffer(); -// sb.append("Failed to initialize MySQLDataSource<"); -// sb.append(dbConnectionName).append(">. Reason: "); -// sb.append(exc.getMessage()); -// LOGGER.error("AS_CONF_ERROR: " + sb.toString()); -//// throw new DBConfigException(e.getMessage()); - } catch (Exception exc) { - initialized = false; - StringBuffer sb = new StringBuffer(); - sb.append("Failed to initialize MySQLCachedDataSource <"); - sb.append(dbConnectionName).append(">. Reason: "); - sb.append(exc.getMessage()); - LOGGER.error("AS_CONF_ERROR: " + sb.toString()); -// throw new DBConfigException(e.getMessage()); - } - } - - public final String getDbUrl() - { - return dbUrl; - } - - public final String getDbUserId() - { - return dbUserId; - } - - public final String getDbPasswd() - { - return dbPasswd; - } - - public static MySQLCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { - return new MySQLCachedDataSource(config); - } - - public String toString(){ - return getDbConnectionName(); - } - - public java.util.logging.Logger getParentLogger() - throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub - return null; - } -} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index 71926e415..1e4b71cd8 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -73,7 +73,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { jdbcProps.setProperty("password", dbPasswd); try { - Driver dvr = new com.mysql.jdbc.Driver(); + Driver dvr = new org.mariadb.jdbc.Driver(); if (dvr.acceptsURL(dbUrl)) { LOG.debug("Driver com.mysql.jdbc.Driver accepts {}", dbUrl); diff --git a/sli/features/src/main/resources/features.xml b/sli/features/src/main/resources/features.xml index 692d9ff0a..1f17c1a95 100644 --- a/sli/features/src/main/resources/features.xml +++ b/sli/features/src/main/resources/features.xml @@ -33,7 +33,7 @@ mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version} mvn:org.onap.ccsdk.sli.core/sli-recording/${project.version} sdnc-dblib - mvn:org/mariadb/jdbc/mariadb-java-client/${mariadb.connector.version} + mvn:org.mariadb.jdbc/mariadb-java-client/${mariadb.connector.version} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java index 4a13000aa..a578dc6ae 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java @@ -8,9 +8,9 @@ * 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. @@ -41,7 +41,6 @@ import org.osgi.framework.ServiceRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.mysql.jdbc.Driver; public class SvcLogicActivator implements BundleActivator { @@ -76,47 +75,47 @@ public class SvcLogicActivator implements BundleActivator { private static LinkedList registrations = new LinkedList(); private static HashMap adaptorMap = null; - + private static final Logger LOG = LoggerFactory .getLogger(SvcLogicActivator.class); - + private static Properties props = null; private static BundleContext bundleCtx = null; - + private static SvcLogicService svcLogicServiceImpl = null; - + @Override public void start(BundleContext ctx) throws Exception { LOG.info("Activating SLI"); - + bundleCtx = ctx; // Read properties props = new Properties(); String propPath = System.getenv(SVCLOGIC_PROP_VAR); - + if (propPath == null) { String propDir = System.getenv(SDNC_CONFIG_DIR); if (propDir == null) { - + propDir = "/opt/sdnc/data/properties"; } propPath = propDir + "/svclogic.properties"; LOG.warn("Environment variable "+SVCLOGIC_PROP_VAR+" unset - defaulting to "+propPath); } - + File propFile = new File(propPath); - + if (!propFile.exists()) { - + throw new ConfigurationException( "Missing configuration properties file : " + propFile); } try { - + props.load(new FileInputStream(propFile)); } catch (Exception e) { throw new ConfigurationException( @@ -168,15 +167,14 @@ public class SvcLogicActivator implements BundleActivator { registrations = null; } } - + public static SvcLogicStore getStore() throws SvcLogicException { // Create and initialize SvcLogicStore object - used to access // saved service logic. - + SvcLogicStore store = null; - + try { - Driver dvr = new Driver(); store = SvcLogicStoreFactory.getSvcLogicStore(props); } catch (Exception e) { throw new ConfigurationException( @@ -190,12 +188,12 @@ public class SvcLogicActivator implements BundleActivator { throw new ConfigurationException( "Could not get service logic store", e); } - + return(store); } - + private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException { - + if (store == null) { return; } @@ -213,13 +211,13 @@ public class SvcLogicActivator implements BundleActivator { registrations.add(reg); store.registerNodeType(nodeType); - + LOG.info("SLI - registering node executor"); - + ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } - + } } diff --git a/sliPluginUtils/features/src/main/resources/features.xml b/sliPluginUtils/features/src/main/resources/features.xml index e8d0d3cc2..f59cea423 100644 --- a/sliPluginUtils/features/src/main/resources/features.xml +++ b/sliPluginUtils/features/src/main/resources/features.xml @@ -9,9 +9,9 @@ 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. @@ -33,7 +33,6 @@ odl-mdsal-broker sdnc-sli mvn:org.onap.ccsdk.sli.core/sliPluginUtils-provider/${project.version} - mvn:mysql/mysql-connector-java/${mysql.connector.version} -- cgit 1.2.3-korg From da4bfcac8a56eb123565ea1f979217e75b6a6e1c Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Wed, 20 Sep 2017 11:12:43 +0530 Subject: Fix few Major sonar issues Fix few Major sonar issues in CCSDK SLI Core module * Remove useless assignment to local variable * Use built-in logger method string formatting instead of string concatination * code indentation Change-Id: I20fc9d8f4c510f6169e6f989c6f5595371e5f2dd Issue-Id: CCSDK-67 Signed-off-by: Ramu N --- .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 89 +++++++++++----------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 03cb50b59..ee192d620 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -46,7 +46,7 @@ import java.util.LinkedList; */ public class SvcLogicParser { - SvcLogicStore store = null; + private SvcLogicStore store = null; static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; @@ -140,7 +140,6 @@ public class SvcLogicParser { curGraph.setMode(attrValue); return; - } // Handle outcome (edge) tag @@ -191,33 +190,32 @@ public class SvcLogicParser { } // Handle node tags - String nodeName = attributes.getValue("name"); - SvcLogicNode thisNode = null; + SvcLogicNode thisNode; try { - if (!svcLogicStore.isValidNodeType(qName)) { - throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() - + " " + "Unknown tag " + qName); - } + if (!svcLogicStore.isValidNodeType(qName)) { + throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + + " " + "Unknown tag " + qName); + } } catch (Exception e) { - throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "Cannot validate node type " + qName); + throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + + " " + "Cannot validate node type " + qName); } try { - if (nodeName != null && nodeName.length() > 0) { - thisNode = new SvcLogicNode(curNodeId++, qName, nodeName, curGraph); - } else { - thisNode = new SvcLogicNode(curNodeId++, qName, curGraph); - } + if (nodeName != null && nodeName.length() > 0) { + thisNode = new SvcLogicNode(curNodeId++, qName, nodeName, curGraph); + } else { + thisNode = new SvcLogicNode(curNodeId++, qName, curGraph); + } - if (curGraph.getRootNode() == null) { - curGraph.setRootNode(thisNode); - } + if (curGraph.getRootNode() == null) { + curGraph.setRootNode(thisNode); + } } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + e.getMessage()); + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + e.getMessage()); } @@ -229,7 +227,7 @@ public class SvcLogicParser { try { String attrValueStr = attributes.getValue(i); - SvcLogicExpression attrValue = null; + SvcLogicExpression attrValue; if (attrValueStr.trim().startsWith("`")) { int lastParen = attrValueStr.lastIndexOf('`'); String evalExpr = attrValueStr.trim().substring(1, lastParen); @@ -251,22 +249,22 @@ public class SvcLogicParser { } if (curNode != null) { - try { - if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) - || "while".equalsIgnoreCase(curNode.getNodeType())) { - curNode.addOutcome(Integer.toString(curNode.getNumOutcomes() + 1), thisNode); - } else { - if (outcomeValue == null) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType()); + try { + if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) + || "while".equalsIgnoreCase(curNode.getNodeType())) { + curNode.addOutcome(Integer.toString(curNode.getNumOutcomes() + 1), thisNode); + } else { + if (outcomeValue == null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType()); + } + curNode.addOutcome(outcomeValue, thisNode); } - curNode.addOutcome(outcomeValue, thisNode); + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + e.getMessage()); } - } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + e.getMessage()); - } - nodeStack.push(curNode); + nodeStack.push(curNode); } curNode = thisNode; @@ -347,7 +345,7 @@ public class SvcLogicParser { } public LinkedList parse(String fileName) throws SvcLogicException { - LinkedList graphs = null; + LinkedList graphs; URL xsdUrl = null; Schema schema = null; @@ -355,15 +353,15 @@ public class SvcLogicParser { if ("true".equalsIgnoreCase(validateSchema)) { xsdUrl = getClass().getResource(SVCLOGIC_XSD); - } if (xsdUrl != null) { try { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); schema = schemaFactory.newSchema(xsdUrl); + LOGGER.info("Schema path {}", xsdUrl.getPath()); } catch (Exception e) { - LOGGER.warn("Could not validate using schema " + xsdUrl.getPath(), e); + LOGGER.warn("Could not validate using schema {}", xsdUrl.getPath(), e); } } else { LOGGER.warn("Could not find resource {}", SVCLOGIC_XSD); @@ -379,19 +377,19 @@ public class SvcLogicParser { SAXParser saxParser = factory.newSAXParser(); if (saxParser.isValidating()) { - LOGGER.info("Parser not configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null)); + LOGGER.info("Parser configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null)); } + graphs = new LinkedList<>(); saxParser.parse(fileName, new SvcLogicHandler(graphs, store)); } catch (Exception e) { + LOGGER.error("Parsing failed {}", e); String msg = e.getMessage(); if (msg != null) { - LOGGER.error(msg); throw new SvcLogicException("Compiler error: " + fileName + " @ " + msg); } else { - LOGGER.info("Caught exception parsing " + fileName, e); throw new SvcLogicException("Compiler error: " + fileName, e); } } @@ -414,7 +412,7 @@ public class SvcLogicParser { try { SvcLogicParser.load(xmlfile, store); } catch (Exception e) { - LOGGER.error(e.getMessage(), e); + LOGGER.error("Load failed {}", e); } } else { SvcLogicParser.usage(); @@ -462,7 +460,7 @@ public class SvcLogicParser { try { SvcLogicParser.validate(xmlfile, store); } catch (Exception e) { - LOGGER.error(e.getMessage(), e); + LOGGER.error("Validate failed", e); } } else { SvcLogicParser.usage(); @@ -494,8 +492,9 @@ public class SvcLogicParser { } SvcLogicParser parser = new SvcLogicParser(store); - LinkedList graphs = null; + LinkedList graphs; try { + LOGGER.info("Loading {}", xmlfile); graphs = parser.parse(xmlfile); } catch (Exception e) { throw new SvcLogicException(e.getMessage(), e); @@ -530,7 +529,7 @@ public class SvcLogicParser { } SvcLogicParser parser = new SvcLogicParser(store); - LinkedList graphs = null; + LinkedList graphs; try { LOGGER.info("Validating {}", xmlfile); graphs = parser.parse(xmlfile); -- cgit 1.2.3-korg From 5e31510dba7647b0d0873d9864a0ee6c309e2247 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 19 Sep 2017 14:57:17 +0530 Subject: Fix Sonar Issue One blocker issue in sli/core module *Check for null dereferencing Issue-Id: CCSDK-87 Change-Id: I5ebaef24b3fd6534b5e818c3087e3d8213ed770c Signed-off-by: surya-huawei --- .../java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index a5902d54b..4d920e6a0 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -603,22 +603,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito protected boolean unlockTable(Connection conn) { boolean retValue = false; - Statement lock = null; - try { + try (Statement lock = conn.createStatement()){ if(LOGGER.isDebugEnabled()) { LOGGER.debug("Executing 'UNLOCK TABLES' on connection " + conn.toString()); } - lock = conn.createStatement(); retValue = lock.execute("UNLOCK TABLES"); } catch(Exception exc){ LOGGER.error("", exc); retValue = false; - } finally { - try { - lock.close(); - } catch(Exception exc) { - - } } return retValue; } -- cgit 1.2.3-korg From ea411bc4b719c9b048018d84b3fcb00d19e1364c Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Wed, 20 Sep 2017 15:10:54 +0530 Subject: Fixes for MdsalHelper util 1. Convert tabs to 4 spaces. 2. Break lines to be less than 120 characters 3. Remove extraneous spaces and parenthesis 4. Fixed blocker/critical sonar issues. https://sonar.onap.org/component_issues/index?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#resolved=false|severities=BLOCKER%2CCRITICAL Change-Id: I8b40784ecb178409a6fe9a00d28ccd03873044c5 Issue-Id: CCSDK-67 Signed-off-by: Gaurav Agrawal --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 2064 ++++++++++---------- 1 file changed, 1062 insertions(+), 1002 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 60dd6b46a..3eeb398f4 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -23,7 +23,6 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.lang.reflect.Constructor; @@ -34,7 +33,6 @@ import java.lang.reflect.Type; import java.util.LinkedList; import java.util.List; import java.util.Properties; - import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; @@ -54,7 +52,7 @@ public class MdsalHelper { public static void setProperties(Properties input) { setYangMappingProperties(input); } - + public static void setYangMappingProperties(Properties properties) { for (Object propNameObj : properties.keySet()) { String propName = (String) propNameObj; @@ -63,1104 +61,1167 @@ public class MdsalHelper { } public static void loadProperties(String propertiesFile) { - File file = new File(propertiesFile); - Properties properties = new Properties(); - if (file.isFile() && file.canRead()) { - try (InputStream input = new FileInputStream(file)) { - properties.load(input); - MdsalHelper.setYangMappingProperties(properties); - LOG.info("Loaded properties from " + propertiesFile); - } catch (Exception e) { - LOG.error("Failed to load properties " + propertiesFile + "\n", e); - } - }else{ - LOG.error("Failed to load the properties file " + propertiesFile + "\n"); - LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); - } + File file = new File(propertiesFile); + Properties properties = new Properties(); + if (file.isFile() && file.canRead()) { + try (InputStream input = new FileInputStream(file)) { + properties.load(input); + MdsalHelper.setYangMappingProperties(properties); + LOG.info("Loaded properties from " + propertiesFile); + } catch (Exception e) { + LOG.error("Failed to load properties " + propertiesFile + "\n", e); + } + } else { + LOG.error("Failed to load the properties file " + propertiesFile + "\n"); + LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); + } } public static Properties toProperties(Properties props, Object fromObj) { - Class fromClass = null; + Class fromClass = null; - if (fromObj != null) { - fromClass = fromObj.getClass(); - } - return (toProperties(props, "", fromObj, fromClass)); + if (fromObj != null) { + fromClass = fromObj.getClass(); + } + return toProperties(props, "", fromObj, fromClass); } public static Properties toProperties(Properties props, String pfx, Object fromObj) { - Class fromClass = null; + Class fromClass = null; - if (fromObj != null) { - fromClass = fromObj.getClass(); - } + if (fromObj != null) { + fromClass = fromObj.getClass(); + } - return (toProperties(props, pfx, fromObj, fromClass)); + return toProperties(props, pfx, fromObj, fromClass); } public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { - if (fromObj == null) { - return (props); - } - - String simpleName = fromClass.getSimpleName(); - - LOG.trace("Extracting properties from " + fromClass.getName() + " class"); - if (fromObj instanceof List) { - - // Class is a List. List should contain yang-generated classes. - LOG.trace(fromClass.getName() + " is a List"); - - List fromList = (List) fromObj; - - for (int i = 0; i < fromList.size(); i++) { - toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); - } - props.setProperty(pfx + "_length", Integer.toString(fromList.size())); - - } else if (isYangGenerated(fromClass)) { - // Class is yang generated. - LOG.trace(fromClass.getName() + " is a Yang-generated class"); - - String propNamePfx = null; - - // If called from a list (so prefix ends in ']'), don't - // add class name again - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx; - } else { - propNamePfx = toLowerHyphen(fromClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - // Iterate through getter methods to figure out values we need to - // save from - - int numGetters = 0; - String lastGetterName = null; - String propVal = null; - - for (Method m : fromClass.getMethods()) { - if (isGetter(m)) { - - numGetters++; - lastGetterName = m.getName(); - - Class returnType = m.getReturnType(); - String fieldName; - if (m.getName().startsWith("get")) { - fieldName = toLowerHyphen(m.getName().substring(3)); - } else { - - fieldName = toLowerHyphen(m.getName().substring(2)); - } - - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - // Is the return type a yang generated class? - if (isYangGenerated(returnType)) { - // Is it an enum? - if (returnType.isEnum()) { - // Return type is a typedef. Save its value. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - Object retValue = m.invoke(fromObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - String propName = propNamePfx + "." + fieldName; - propVal = retValue.toString(); - props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert Yang-generated enum returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpv4Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = retValue.getValue().toString(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpv6Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = retValue.getValue().toString(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpAddress(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - IpAddress retValue = (IpAddress) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = new String(retValue.getValue()); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpPrefix(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - IpPrefix retValue = (IpPrefix) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = new String(retValue.getValue()); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retValue = m.invoke(fromObj); - - if (retValue instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); - retValue = new String((byte[]) retValue, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + retValue); - } - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); - } - } catch (Exception e) { - - if (m.getName().equals("getKey")) { - LOG.trace("Caught " + e.getClass().getName() + " exception trying to convert results from getKey() - ignoring"); - } else { - LOG.error("Caught exception trying to convert Yang-generated class returned by" + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - } else if (returnType.equals(Class.class)) { - - LOG.trace(m.getName() + " returns a Class object - not interested"); - - } else if (List.class.isAssignableFrom(returnType)) { - - // This getter method returns a list. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retList = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - // Figure out what type of elements are stored in - // this array. - Type paramType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; - toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType); - } catch (Exception e) { - LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - - } else { - - // Method returns something that is not a List and not - // yang-generated. - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object propValObj = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (propValObj != null) { - if (propValObj instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); - propVal = new String((byte[]) propValObj, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + propVal); - - } else { - propVal = propValObj.toString(); - } - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - if (m.getName().equals("getKey")) { - LOG.trace("Caught " + e.getClass().getName() + " exception trying to convert results from getKey() - ignoring"); - } else { - LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - - } - } - - // End of method loop. If there was only one getter, named - // "getValue", then - // set value identified by "prefix" to that one value. - if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { - LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + " = " + propVal); - props.setProperty(propNamePfx, propVal); - } else { - LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " + lastGetterName); - - } - - } else { - // Class is not yang generated and not a list - // It must be an element of a leaf list - set "prefix" to value - String fromVal = null; - if (fromObj instanceof byte[]) { - try { - fromVal = new String((byte[]) fromObj, "UTF-8"); - LOG.trace("Converted byte array " + pfx + "to string " + fromVal); - } catch (Exception e) { - LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); - fromVal = fromObj.toString(); - } - - } else { - fromVal = fromObj.toString(); - } - LOG.debug("Setting property " + pfx + " to " + fromVal); - props.setProperty(pfx, fromVal); - } - - return (props); + if (fromObj == null) { + return props; + } + + LOG.trace("Extracting properties from " + fromClass.getName() + " class"); + if (fromObj instanceof List) { + + // Class is a List. List should contain yang-generated classes. + LOG.trace(fromClass.getName() + " is a List"); + + List fromList = (List) fromObj; + + for (int i = 0; i < fromList.size(); i++) { + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); + } + props.setProperty(pfx + "_length", Integer.toString(fromList.size())); + + } else if (isYangGenerated(fromClass)) { + // Class is yang generated. + LOG.trace(fromClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + + // If called from a list (so prefix ends in ']'), don't + // add class name again + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx; + } else { + propNamePfx = toLowerHyphen(fromClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // save from + + int numGetters = 0; + String lastGetterName = null; + String propVal = null; + + for (Method m : fromClass.getMethods()) { + if (isGetter(m)) { + + numGetters++; + lastGetterName = m.getName(); + + Class returnType = m.getReturnType(); + String fieldName; + if (m.getName().startsWith("get")) { + fieldName = toLowerHyphen(m.getName().substring(3)); + } else { + + fieldName = toLowerHyphen(m.getName().substring(2)); + } + + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + // Is the return type a yang generated class? + if (isYangGenerated(returnType)) { + // Is it an enum? + if (returnType.isEnum()) { + // Return type is a typedef. Save its value. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + Object retValue = m.invoke(fromObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + String propName = propNamePfx + "." + fieldName; + propVal = retValue.toString(); + props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated enum returned by " + fromClass + .getName() + "." + m.getName() + "() to Properties entry", e); + } + } else if (isIpv4Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = retValue.getValue().toString(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + fromClass.getName() + "." + + m.getName() + "() to Properties entry", e); + } + } else if (isIpv6Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = retValue.getValue().toString(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + fromClass.getName() + "." + + m.getName() + "() to Properties entry", e); + } + } else if (isIpAddress(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + IpAddress retValue = (IpAddress) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = new String(retValue.getValue()); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + fromClass.getName() + "." + + m.getName() + "() to Properties entry", e); + } + } else if (isIpPrefix(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + IpPrefix retValue = (IpPrefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = new String(retValue.getValue()); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + fromClass.getName() + "." + + m.getName() + "() to Properties entry", e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + + if (retValue instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + retValue = new String((byte[]) retValue, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + + retValue); + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); + } + } catch (Exception e) { + + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert Yang-generated class returned by" + + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } else if (returnType.equals(Class.class)) { + + LOG.trace(m.getName() + " returns a Class object - not interested"); + + } else if (List.class.isAssignableFrom(returnType)) { + + // This getter method returns a list. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retList = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + // Figure out what type of elements are stored in + // this array. + Type paramType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType); + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert List returned by " + fromClass.getName() + "." + m + .getName() + "() to Properties entry", e); + } + + } else { + + // Method returns something that is not a List and not + // yang-generated. + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object propValObj = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (propValObj != null) { + if (propValObj instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + propVal = new String((byte[]) propValObj, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + + propVal); + + } else { + propVal = propValObj.toString(); + } + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error( + "Caught exception trying to convert value returned by" + fromClass.getName() + "." + + m.getName() + "() to Properties entry", e); + } + } + } + + } + } + + // End of method loop. If there was only one getter, named + // "getValue", then + // set value identified by "prefix" to that one value. + if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { + LOG.trace( + "getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + " = " + + propVal); + props.setProperty(propNamePfx, propVal); + } else { + LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " + + lastGetterName); + + } + + } else { + // Class is not yang generated and not a list + // It must be an element of a leaf list - set "prefix" to value + String fromVal = null; + if (fromObj instanceof byte[]) { + try { + fromVal = new String((byte[]) fromObj, "UTF-8"); + LOG.trace("Converted byte array " + pfx + "to string " + fromVal); + } catch (Exception e) { + LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); + fromVal = fromObj.toString(); + } + + } else { + fromVal = fromObj.toString(); + } + LOG.debug("Setting property " + pfx + " to " + fromVal); + props.setProperty(pfx, fromVal); + } + + return (props); } public static Object toBuilder(Properties props, Object toObj) { - return (toBuilder(props, "", toObj)); + return (toBuilder(props, "", toObj)); } public static List toList(Properties props, String pfx, List toObj, Class elemType) { - int maxIdx = -1; - boolean foundValue = false; - - LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); - - if (props.contains(pfx + "_length")) { - try { - int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); - - if (listLength > 0) { - maxIdx = listLength - 1; - } - } catch (Exception e) { - // Ignore exception - } - } - - if (maxIdx == -1) { - // Figure out array size - for (Object pNameObj : props.keySet()) { - String key = (String) pNameObj; - - if (key.startsWith(pfx + "[")) { - String idxStr = key.substring(pfx.length() + 1); - int endloc = idxStr.indexOf("]"); - if (endloc != -1) { - idxStr = idxStr.substring(0, endloc); - } - - try { - int curIdx = Integer.parseInt(idxStr); - if (curIdx > maxIdx) { - maxIdx = curIdx; - } - } catch (Exception e) { - LOG.error("Illegal subscript in property " + key); - } - - } - } - } - - LOG.trace(pfx + " has max index of " + maxIdx); - for (int i = 0; i <= maxIdx; i++) { - - String curBase = pfx + "[" + i + "]"; - - if (isYangGenerated(elemType)) { - String builderName = elemType.getName() + "Builder"; - try { - Class builderClass = Class.forName(builderName); - Object builderObj = builderClass.newInstance(); - Method buildMethod = builderClass.getMethod("build"); - builderObj = toBuilder(props, curBase, builderObj, true); - if (builderObj != null) { - LOG.trace("Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(builderObj); - toObj.add(builtObj); - foundValue = true; - } - - } catch (ClassNotFoundException e) { - LOG.warn("Could not find builder class " + builderName, e); - } catch (Exception e) { - LOG.error("Caught exception trying to populate list from " + pfx); - } - } else { - // Must be a leaf list - String curValue = props.getProperty(curBase, ""); - - toObj.add(curValue); - - if ((curValue != null) && (curValue.length() > 0)) { - foundValue = true; - } - } - - } - - if (foundValue) { - return (toObj); - } else { - return (null); - } + int maxIdx = -1; + boolean foundValue = false; + + LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); + + if (props.contains(pfx + "_length")) { + try { + int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); + + if (listLength > 0) { + maxIdx = listLength - 1; + } + } catch (NumberFormatException e) { + LOG.info("Invalid input for length ", e); + } + } + + if (maxIdx == -1) { + // Figure out array size + for (Object pNameObj : props.keySet()) { + String key = (String) pNameObj; + + if (key.startsWith(pfx + "[")) { + String idxStr = key.substring(pfx.length() + 1); + int endloc = idxStr.indexOf("]"); + if (endloc != -1) { + idxStr = idxStr.substring(0, endloc); + } + + try { + int curIdx = Integer.parseInt(idxStr); + if (curIdx > maxIdx) { + maxIdx = curIdx; + } + } catch (Exception e) { + LOG.error("Illegal subscript in property {}", key, e); + } + + } + } + } + + LOG.trace(pfx + " has max index of " + maxIdx); + for (int i = 0; i <= maxIdx; i++) { + + String curBase = pfx + "[" + i + "]"; + + if (isYangGenerated(elemType)) { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + LOG.trace("Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class {}", builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from {}", pfx, e); + } + } else { + // Must be a leaf list + String curValue = props.getProperty(curBase, ""); + + toObj.add(curValue); + + if ((curValue != null) && (curValue.length() > 0)) { + foundValue = true; + } + } + + } + + if (foundValue) { + return (toObj); + } else { + return (null); + } } public static Object toBuilder(Properties props, String pfx, Object toObj) { - return (toBuilder(props, pfx, toObj, false)); + return (toBuilder(props, pfx, toObj, false)); } public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { - Class toClass = toObj.getClass(); - boolean foundValue = false; - - LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); - - Ipv4Address addr; - - if (isYangGenerated(toClass)) { - // Class is yang generated. - LOG.trace(toClass.getName() + " is a Yang-generated class"); - - String propNamePfx = null; - if (preservePfx) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - if (toObj instanceof Identifier) { - LOG.trace(toClass.getName() + " is a Key - skipping"); - return (toObj); - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - if (isSetter(m)) { - Class paramTypes[] = m.getParameterTypes(); - Class paramClass = paramTypes[0]; - - String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - - String paramValue = props.getProperty(propName); - if (paramValue == null) { - LOG.trace(propName + " is unset"); - } else { - LOG.trace(propName + " = " + paramValue); - } - - // Is the return type a yang generated class? - if (isYangGenerated(paramClass)) { - // Is it an enum? - if (paramClass.isEnum()) { - - LOG.trace(m.getName() + " expects an Enum"); - // Param type is a typedef. - if ((paramValue != null) && (paramValue.length() > 0)) { - Object paramObj = null; - - try { - paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); - } catch (Exception e) { - LOG.error("Caught exception trying to convert field " + propName + " to enum " + paramClass.getName(), e); - } - - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to create Yang-generated enum expected by" + toClass.getName() + "." + m.getName() + "() from Properties entry", e); - } - } - } else { - - String simpleName = paramClass.getSimpleName(); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName)) { - - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); - - if ("Ipv4Address".equals(simpleName)) { - m.invoke(toObj, ipAddr.getIpv4Address()); - } else if ("Ipv6Address".equals(simpleName)) { - m.invoke(toObj, ipAddr.getIpv6Address()); - - } else { - m.invoke(toObj, ipAddr); - } - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + paramValue + ")", e); - - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to call " + toClass.getName() + "." + m.getName() + "() with Properties entry", e); - } - } - } else if ("IpPrefix".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); - m.invoke(toObj, ipPrefix); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + paramValue + ")", e); - } - } - } else { - // setter expects a yang-generated class. Need - // to - // create a builder to set it. - - String builderName = paramClass.getName() + "Builder"; - Class builderClass = null; - Object builderObj = null; - Object paramObj = null; - - Object constObj = null; - - LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " + builderName); - try { - builderClass = Class.forName(builderName); - builderObj = builderClass.newInstance(); - paramObj = toBuilder(props, propNamePfx, builderObj); - } catch (ClassNotFoundException e) { - - if (paramValue == null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(null)"); - m.invoke(toObj, new Object[] { null }); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e1) { - LOG.error("Caught exception trying to cally" + toClass.getName() + "." + m.getName() + "() with Properties entry", e1); - } - } else { - try { - // See if I can find a constructor I - // can - // use - Constructor[] constructors = paramClass.getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (String.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (Long.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(Long.parseLong(paramValue)); - } - } - } - - } - - if (constObj == null) { - - // Last chance - see if - // parameter class has a static - // method - // getDefaultInstance(String) - try { - Method gm = paramClass.getMethod("getDefaultInstance", String.class); - - int gmodifier = gm.getModifiers(); - if (Modifier.isStatic(gmodifier)) { - // Invoke static - // getDefaultInstance(String) - paramObj = gm.invoke(null, paramValue); - } - - } catch (Exception gme) { - // Ignore exceptions - } - } - - } catch (Exception e1) { - LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); - } - - if (constObj == null) { - LOG.warn("Could not find builder class " + builderName + " and could not find a String or Long constructor or static getDefaultInstance(String) - trying just to set passing paramValue"); - - } - } - } catch (Exception e) { - LOG.error("Caught exception trying to create builder " + builderName, e); - } - - if (paramObj != null) { - - try { - - Method buildMethod = builderClass.getMethod("build"); - LOG.trace("Calling " + paramObj.getClass().getName() + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(paramObj); - - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); - m.invoke(toObj, builtObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to set Yang-generated class expected by" + toClass.getName() + "." + m.getName() + "() from Properties entry", e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - if (constObj != null) { - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + constObj.toString() + ")"); - m.invoke(toObj, constObj); - } else { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramValue); - - } - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(paramClass)) { - - LOG.trace("Parameter class " + paramClass.getName() + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type paramType = m.getGenericParameterTypes()[0]; - Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; - Object paramObj = new LinkedList(); - try { - paramObj = toList(props, propName, (List) paramObj, (Class) elementType); - } catch (Exception e) { - LOG.error("Caught exception trying to create list expected as argument to " + toClass.getName() + "." + m.getName()); - } - - if (paramObj != null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert List returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } else { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + paramClass.getName() + " is not a yang-generated class or a List"); - - if ((paramValue != null) && (paramValue.length() > 0)) { - - Object constObj = null; - - try { - // See if I can find a constructor I can use - Constructor[] constructors = paramClass.getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (String.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (Long.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(Long.parseLong(paramValue)); - } - } - } - - } - - if (constObj != null) { - try { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + constObj + ")"); - m.invoke(toObj, constObj); - foundValue = true; - } catch (Exception e2) { - LOG.error("Caught exception trying to call " + m.getName(), e2); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" + toClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } catch (Exception e1) { - LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); - } - - } - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - if (foundValue) { - return (toObj); - } else { - return (null); - } + Class toClass = toObj.getClass(); + boolean foundValue = false; + + LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); + + Ipv4Address addr; + + if (isYangGenerated(toClass)) { + // Class is yang generated. + LOG.trace(toClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + if (preservePfx) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + if (toObj instanceof Identifier) { + LOG.trace(toClass.getName() + " is a Key - skipping"); + return (toObj); + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + if (isSetter(m)) { + Class paramTypes[] = m.getParameterTypes(); + Class paramClass = paramTypes[0]; + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + String paramValue = props.getProperty(propName); + if (paramValue == null) { + LOG.trace(propName + " is unset"); + } else { + LOG.trace(propName + " = " + paramValue); + } + + // Is the return type a yang generated class? + if (isYangGenerated(paramClass)) { + // Is it an enum? + if (paramClass.isEnum()) { + + LOG.trace(m.getName() + " expects an Enum"); + // Param type is a typedef. + if ((paramValue != null) && (paramValue.length() > 0)) { + Object paramObj = null; + + try { + paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); + } catch (Exception e) { + LOG.error("Caught exception trying to convert field " + propName + " to enum " + + paramClass.getName(), e); + } + + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace( + "Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + + ")"); + m.invoke(toObj, paramObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to create Yang-generated enum expected by" + toClass + .getName() + "." + m.getName() + "() from Properties entry", e); + } + } + } else { + + String simpleName = paramClass.getSimpleName(); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress" + .equals(simpleName)) { + + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); + + if ("Ipv4Address".equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv4Address()); + } else if ("Ipv6Address".equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv6Address()); + + } else { + m.invoke(toObj, ipAddr); + } + foundValue = true; + } catch (Exception e) { + LOG.error( + "Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + + paramValue + ")", e); + + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to call " + toClass.getName() + "." + m.getName() + + "() with Properties entry", e); + } + } + } else if ("IpPrefix".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); + m.invoke(toObj, ipPrefix); + foundValue = true; + } catch (Exception e) { + LOG.error( + "Caught exception calling " + toClass.getName() + "." + m.getName() + "(" + + paramValue + ")", e); + } + } + } else { + // setter expects a yang-generated class. Need + // to + // create a builder to set it. + + String builderName = paramClass.getName() + "Builder"; + Class builderClass = null; + Object builderObj = null; + Object paramObj = null; + + Object constObj = null; + + LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " + + builderName); + try { + builderClass = Class.forName(builderName); + builderObj = builderClass.newInstance(); + paramObj = toBuilder(props, propNamePfx, builderObj); + } catch (ClassNotFoundException e) { + LOG.info("Builder class {} not found ", builderName, e); + if (paramValue == null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace( + "Calling " + toObj.getClass().getName() + "." + m.getName() + "(null)"); + m.invoke(toObj, new Object[]{null}); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e1) { + LOG.error("Caught exception trying to cally" + toClass.getName() + "." + m + .getName() + "() with Properties entry", e1); + } + } else { + try { + // See if I can find a constructor I + // can + // use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj == null) { + + // Last chance - see if + // parameter class has a static + // method + // getDefaultInstance(String) + try { + Method gm = paramClass + .getMethod("getDefaultInstance", String.class); + + int gmodifier = gm.getModifiers(); + if (Modifier.isStatic(gmodifier)) { + // Invoke static + // getDefaultInstance(String) + paramObj = gm.invoke(null, paramValue); + } + + } catch (Exception gme) { + LOG.info("Unable to find static method getDefaultInstance for " + + "class {}", paramClass.getSimpleName(), e); + } + } + + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + paramClass.getName(), + e1); + } + + if (constObj == null) { + LOG.warn("Could not find builder class " + builderName + + " and could not find a String or Long constructor or static " + + "getDefaultInstance(String) - trying just to set passing paramValue"); + + } + } + } catch (Exception e) { + LOG.error("Caught exception trying to create builder " + builderName, e); + } + + if (paramObj != null && builderClass != null) { + + try { + Method buildMethod = builderClass.getMethod("build"); + LOG.trace( + "Calling " + paramObj.getClass().getName() + "." + buildMethod.getName() + + "()"); + Object builtObj = buildMethod.invoke(paramObj); + + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); + m.invoke(toObj, builtObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to set Yang-generated class expected by" + toClass + .getName() + "." + m.getName() + "() from Properties entry", e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + if (constObj != null) { + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + constObj.toString() + ")"); + m.invoke(toObj, constObj); + } else { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by" + toClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } + } + } + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(paramClass)) { + + LOG.trace("Parameter class " + paramClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type paramType = m.getGenericParameterTypes()[0]; + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + Object paramObj = new LinkedList(); + try { + paramObj = toList(props, propName, (List) paramObj, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to create list expected as argument to {}.{}", + toClass.getName(), m.getName(), e); + } + + if (paramObj != null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace( + "Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue + + ")"); + m.invoke(toObj, paramObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert List returned by" + toClass.getName() + "." + + m.getName() + "() to Properties entry", e); + } + } + } else { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace( + "Parameter class " + paramClass.getName() + " is not a yang-generated class or a List"); + + if ((paramValue != null) && (paramValue.length() > 0)) { + + Object constObj = null; + + try { + // See if I can find a constructor I can use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + constObj + ")"); + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error("Caught exception trying to call " + m.getName(), e2); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + toClass + .getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } catch (Exception e1) { + LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); + } + + } + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + if (foundValue) { + return (toObj); + } else { + return (null); + } } public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { - boolean foundValue = false; - - LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); + boolean foundValue = false; - if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { - // Class is yang generated. - LOG.trace(toClass.getName() + " is a Yang-generated class"); + LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); - if (toClass.getName().endsWith("Key")) { - if (Identifier.class.isAssignableFrom(toClass)) { - LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); - } else { + if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { + // Class is yang generated. + LOG.trace(toClass.getName() + " is a Yang-generated class"); - LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); - } - } + if (toClass.getName().endsWith("Key")) { + if (Identifier.class.isAssignableFrom(toClass)) { + LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); + } else { - String propNamePfx = null; - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { + LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); + } + } - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } + String propNamePfx = null; + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } - // Iterate through getter methods to figure out values we need to - // set + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } - for (Method m : toClass.getMethods()) { - LOG.trace("Is " + m.getName() + " method a getter?"); - if (isGetter(m)) { - LOG.trace(m.getName() + " is a getter"); - Class returnClass = m.getReturnType(); + // Iterate through getter methods to figure out values we need to + // set - String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + for (Method m : toClass.getMethods()) { + LOG.trace("Is " + m.getName() + " method a getter?"); + if (isGetter(m)) { + LOG.trace(m.getName() + " is a getter"); + Class returnClass = m.getReturnType(); - String propName = propNamePfx + "." + fieldName; + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - // Is the return type a yang generated class? - if (isYangGenerated(returnClass)) { - // Is it an enum? - if (returnClass.isEnum()) { + String propName = propNamePfx + "." + fieldName; - LOG.trace(m.getName() + " is an Enum"); - pstr.print("\n\n * " + propName); + // Is the return type a yang generated class? + if (isYangGenerated(returnClass)) { + // Is it an enum? + if (returnClass.isEnum()) { - } else { + LOG.trace(m.getName() + " is an Enum"); + pstr.print("\n\n * " + propName); - String simpleName = returnClass.getSimpleName(); + } else { - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName)) { - LOG.trace(m.getName() + " is an " + simpleName); - pstr.print("\n\n * " + propName); - } else { - printPropertyList(pstr, propNamePfx, returnClass); - } + String simpleName = returnClass.getSimpleName(); - } - } else { + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress" + .equals(simpleName) || "IpPrefix".equals(simpleName)) { + LOG.trace(m.getName() + " is an " + simpleName); + pstr.print("\n\n * " + propName); + } else { + printPropertyList(pstr, propNamePfx, returnClass); + } - // Setter's argument is not a yang-generated class. See - // if it is a List. + } + } else { - if (List.class.isAssignableFrom(returnClass)) { + // Setter's argument is not a yang-generated class. See + // if it is a List. - LOG.trace("Parameter class " + returnClass.getName() + " is a List"); + if (List.class.isAssignableFrom(returnClass)) { - // Figure out what type of args are in List and pass - // that to toList(). + LOG.trace("Parameter class " + returnClass.getName() + " is a List"); - Type returnType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; - Class elementClass = (Class) elementType; - LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); - printPropertyList(pstr, propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", elementClass); + // Figure out what type of args are in List and pass + // that to toList(). - } else if (!returnClass.equals(Class.class)) { + Type returnType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + Class elementClass = (Class) elementType; + LOG.trace( + "Calling printPropertyList on list type (" + elementClass.getName() + "), pfx is (" + + pfx + "), toClass is (" + toClass.getName() + ")"); + printPropertyList(pstr, + propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", elementClass); - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value + } else if (!returnClass.equals(Class.class)) { - LOG.trace("Parameter class " + returnClass.getName() + " is not a yang-generated class or a List"); + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value - pstr.print("\n\n * " + propName); + LOG.trace("Parameter class " + returnClass.getName() + + " is not a yang-generated class or a List"); - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class + pstr.print("\n\n * " + propName); + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class } public static boolean isYangGenerated(Class c) { - if (c == null) { - return (false); - } else { - return (c.getName().startsWith("org.opendaylight.yang.gen.")); - } + if (c == null) { + return (false); + } else { + return (c.getName().startsWith("org.opendaylight.yang.gen.")); + } } public static boolean isIpPrefix(Class c) { - if (c == null) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("IpPrefix".equals(simpleName)); + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("IpPrefix".equals(simpleName)); } public static boolean isIpv4Address(Class c) { - if (c == null) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv4Address".equals(simpleName)); + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv4Address".equals(simpleName)); } public static boolean isIpv6Address(Class c) { - if (c == null) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv6Address".equals(simpleName)); + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv6Address".equals(simpleName)); } public static boolean isIpAddress(Class c) { - if (c == null) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("IpAddress".equals(simpleName)); + if (c == null) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("IpAddress".equals(simpleName)); } public static String toLowerHyphen(String inStr) { - if (inStr == null) { - return (null); - } + if (inStr == null) { + return (null); + } - String str = inStr.substring(0, 1).toLowerCase(); - if (inStr.length() > 1) { - str = str + inStr.substring(1); - } + String str = inStr.substring(0, 1).toLowerCase(); + if (inStr.length() > 1) { + str = str + inStr.substring(1); + } - String regex = "(([a-z0-9])([A-Z]))"; - String replacement = "$2-$3"; + String regex = "(([a-z0-9])([A-Z]))"; + String replacement = "$2-$3"; - String retval = str.replaceAll(regex, replacement).toLowerCase(); + String retval = str.replaceAll(regex, replacement).toLowerCase(); - LOG.trace("Converting " + inStr + " => " + str + " => " + retval); - return (retval); + LOG.trace("Converting " + inStr + " => " + str + " => " + retval); + return (retval); } //This is called when mapping the yang value back to a valid java enumeration public static String toJavaEnum(String inStr) { - if (inStr == null) { - return (null); - } else if (inStr.length() == 0) { - return (inStr); - } - - //This will strip out all periods, which cannot be in a java enum - inStr = inStr.replaceAll("\\.", ""); - - String[] terms = inStr.split("-"); - StringBuffer sbuff = new StringBuffer(); - - //appends an _ if the string starts with a digit to make it a valid java enum - if (Character.isDigit(inStr.charAt(0))) { - sbuff.append('_'); - } - //If the string contains hyphens it will convert the string to upperCamelCase without hyphens - for (String term : terms) { - sbuff.append(term.substring(0, 1).toUpperCase()); - if (term.length() > 1) { - sbuff.append(term.substring(1)); - } - } - return (sbuff.toString()); + if (inStr == null) { + return (null); + } else if (inStr.length() == 0) { + return (inStr); + } + + //This will strip out all periods, which cannot be in a java enum + inStr = inStr.replaceAll("\\.", ""); + + String[] terms = inStr.split("-"); + StringBuffer sbuff = new StringBuffer(); + + //appends an _ if the string starts with a digit to make it a valid java enum + if (Character.isDigit(inStr.charAt(0))) { + sbuff.append('_'); + } + //If the string contains hyphens it will convert the string to upperCamelCase without hyphens + for (String term : terms) { + sbuff.append(term.substring(0, 1).toUpperCase()); + if (term.length() > 1) { + sbuff.append(term.substring(1)); + } + } + return (sbuff.toString()); } public static boolean isGetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { - if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { - if (!"getClass".equals(m.getName())) { - return (true); - } - } - - if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { - return (true); - } - - if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { - return (true); - } - } - - return (false); + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { + if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { + if (!"getClass".equals(m.getName())) { + return (true); + } + } + + if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { + return (true); + } + + if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { + return (true); + } + } + + return (false); } public static boolean isSetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { - if (m.getName().matches("^set[A-Z].*")) { - Class[] paramTypes = m.getParameterTypes(); - if (paramTypes[0].isAssignableFrom(Identifier.class) || Identifier.class.isAssignableFrom(paramTypes[0])) { - return (false); - } else { - return (true); - } - } - - } - - return (false); + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { + if (m.getName().matches("^set[A-Z].*")) { + Class[] paramTypes = m.getParameterTypes(); + if (paramTypes[0].isAssignableFrom(Identifier.class) || Identifier.class + .isAssignableFrom(paramTypes[0])) { + return (false); + } else { + return (true); + } + } + + } + + return (false); } public static String getFullPropertiesPath(String propertiesFileName) { - return "/opt/bvc/controller/configuration/" + propertiesFileName; + return "/opt/bvc/controller/configuration/" + propertiesFileName; } - + //This is called when mapping a valid java enumeration back to the yang model value public static String mapEnumeratedValue(String propertyName, String propertyValue) { LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); @@ -1172,5 +1233,4 @@ public class MdsalHelper { return propertyValue; } } - } -- cgit 1.2.3-korg From 297671bfc3682d09962d24ab9b7788ccb1e9359b Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Wed, 20 Sep 2017 15:35:23 +0530 Subject: Fix Sonar Issues in sli/core module Few major issues *Remove unused imports To increase code readability *Replace the type specification with the diamond operator To reduce the verbosity of generics code *Add the "@Override" annotation above this method signature To increase code readability *Remove this unnecessary cast to "String" Unnecessary casting expressions pollutes code Issue-Id: CCSDK-87 Change-Id: I38952f5026a5c61af73ac16706e8ddc278566b13 Signed-off-by: surya-huawei --- .../ccsdk/sli/core/dblib/DBResourceManager.java | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index a2eb0f9c1..014dab31a 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -52,18 +52,7 @@ import java.util.TimerTask; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; -import javax.sql.DataSource; -import javax.sql.rowset.CachedRowSet; - -import org.apache.tomcat.jdbc.pool.PoolExhaustedException; -import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; -import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; -import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @version $Revision: 1.15 $ @@ -161,7 +150,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } private void config(Properties configProps) throws Exception { - final ConcurrentLinkedQueue semaphore = new ConcurrentLinkedQueue(); + final ConcurrentLinkedQueue semaphore = new ConcurrentLinkedQueue<>(); final DbConfigPool dbConfig = DBConfigFactory.createConfig(configProps); long startTime = System.currentTimeMillis(); @@ -268,7 +257,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb String value = null; long tmpLongValue = defaultValue; try { - value = (String)props.getProperty(property); + value = props.getProperty(property); if(value != null) tmpLongValue = Long.parseLong(value); @@ -288,7 +277,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb String value = null; try { - value = (String)props.getProperty(property); + value = props.getProperty(property); if(value != null) tmpValue = Boolean.parseBoolean(value); @@ -303,6 +292,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } + @Override public void update(Observable observable, Object data) { // if observable is active and there is a standby available, switch if(observable instanceof SQLExecutionMonitor) @@ -400,7 +390,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb CachedDataSource active = null; // test if there are any connection pools available - LinkedList sources = new LinkedList(this.dsQueue); + LinkedList sources = new LinkedList<>(this.dsQueue); if(sources.isEmpty()){ LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); @@ -603,6 +593,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } + @Override public Connection getConnection() throws SQLException { Throwable lastException = null; CachedDataSource active = null; @@ -664,6 +655,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } + @Override public Connection getConnection(String username, String password) throws SQLException { CachedDataSource active = null; @@ -754,18 +746,22 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } + @Override public PrintWriter getLogWriter() throws SQLException { return ((CachedDataSource)this.dsQueue.peek()).getLogWriter(); } + @Override public int getLoginTimeout() throws SQLException { return ((CachedDataSource)this.dsQueue.peek()).getLoginTimeout(); } + @Override public void setLogWriter(PrintWriter out) throws SQLException { ((CachedDataSource)this.dsQueue.peek()).setLogWriter(out); } + @Override public void setLoginTimeout(int seconds) throws SQLException { ((CachedDataSource)this.dsQueue.peek()).setLoginTimeout(seconds); } @@ -795,7 +791,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public String getDBStatus(boolean htmlFormat) { StringBuilder buffer = new StringBuilder(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll(dsQueue); list.addAll(broken); if (htmlFormat) @@ -843,10 +839,12 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb return buffer.toString(); } + @Override public boolean isWrapperFor(Class iface) throws SQLException { return false; } + @Override public T unwrap(Class iface) throws SQLException { return null; } @@ -854,6 +852,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb /** * @return the monitorDbResponse */ + @Override public final boolean isMonitorDbResponse() { return recoveryMode && monitorDbResponse; } @@ -880,7 +879,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public String getPreferredDataSourceName(AtomicBoolean flipper) { - LinkedList snapshot = new LinkedList(dsQueue); + LinkedList snapshot = new LinkedList<>(dsQueue); if(snapshot.size() > 1){ CachedDataSource first = snapshot.getFirst(); CachedDataSource last = snapshot.getLast(); @@ -901,6 +900,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb return snapshot.peek().getDbConnectionName(); } + @Override public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { return null; @@ -916,7 +916,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb private String getMasterDataSourceName(AtomicBoolean flipper) { - LinkedList snapshot = new LinkedList(dsQueue); + LinkedList snapshot = new LinkedList<>(dsQueue); if(snapshot.size() > 1){ CachedDataSource first = snapshot.getFirst(); CachedDataSource last = snapshot.getLast(); @@ -938,7 +938,8 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } class RemindTask extends TimerTask { - public void run() { + @Override + public void run() { CachedDataSource ds = dsQueue.peek(); if(ds != null) ds.getPoolInfo(false); -- cgit 1.2.3-korg From 03235aa6cc35871630ee3e09fe467eca79ce315e Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Tue, 19 Sep 2017 11:14:41 -0400 Subject: Abstract utility classes for re-use When looking at the existing uses of BundleActivator(s), it became immediately clear that other parts of the code have a strategy based properties file resolution very similar to those abstracted by dblib. This change aggregates a separate utils bundle for this functionality, which is further abstracted for potential reuse with other use cases. The next use case is in the sli bundle, which will be handled in a follow-up patch. Issue-Id: SDNC-54 Change-Id: Ie4d4bb679617474b1983e6044c08cca1742b9893 Signed-off-by: Ryan Goulding --- dblib/provider/pom.xml | 5 ++ .../sli/core/dblib/DBLIBResourceProvider.java | 20 +++--- .../DblibDefaultFileResolver.java | 63 ------------------ .../DblibEnvVarFileResolver.java | 69 -------------------- .../DblibJREFileResolver.java | 73 --------------------- .../DblibKarafRootFileResolver.java | 64 ------------------- .../DblibPropertiesFileResolver.java | 45 ------------- .../DblibDefaultFileResolverTest.java | 24 ------- .../DblibEnvVarFileResolverTest.java | 23 ------- .../DblibJREFileResolverTest.java | 15 ----- .../DblibKarafRootFileResolverTest.java | 14 ---- pom.xml | 1 + utils/pom.xml | 56 ++++++++++++++++ .../ccsdk/sli/core/utils/DefaultFileResolver.java | 61 ++++++++++++++++++ .../ccsdk/sli/core/utils/EnvVarFileResolver.java | 70 ++++++++++++++++++++ .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 74 ++++++++++++++++++++++ .../sli/core/utils/KarafRootFileResolver.java | 63 ++++++++++++++++++ .../sli/core/utils/PropertiesFileResolver.java | 45 +++++++++++++ .../core/utils/dblib/DblibDefaultFileResolver.java | 17 +++++ .../core/utils/dblib/DblibEnvVarFileResolver.java | 15 +++++ .../ccsdk/sli/core/utils/JREFileResolverTest.java | 15 +++++ .../sli/core/utils/KarafRootFileResolverTest.java | 14 ++++ .../utils/dblib/DblibDefaultFileResolverTest.java | 25 ++++++++ .../utils/dblib/DblibEnvVarFileResolverTest.java | 24 +++++++ 24 files changed, 495 insertions(+), 400 deletions(-) delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolver.java delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolver.java delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolver.java delete mode 100644 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibPropertiesFileResolver.java delete mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java delete mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java delete mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java delete mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java create mode 100644 utils/pom.xml create mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java create mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java create mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java create mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java create mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java create mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java create mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java create mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java create mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java create mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java create mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 8ff109417..ad1cc9d28 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -56,6 +56,11 @@ com.google.guava guava + + org.onap.ccsdk.sli.core + utils + ${project.version} + diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java index 062cd8408..8e0b534f0 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java @@ -27,11 +27,11 @@ import java.util.Optional; import java.util.Properties; import java.util.Vector; -import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibDefaultFileResolver; -import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibEnvVarFileResolver; -import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibJREFileResolver; -import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibKarafRootFileResolver; -import org.onap.ccsdk.sli.core.dblib.propertiesfileresolver.DblibPropertiesFileResolver; +import org.onap.ccsdk.sli.core.utils.dblib.DblibDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.dblib.DblibEnvVarFileResolver; +import org.onap.ccsdk.sli.core.utils.JREFileResolver; +import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +58,7 @@ public class DBLIBResourceProvider { /** * A prioritized list of strategies for resolving dblib properties files. */ - private Vector dblibPropertiesFileResolvers = new Vector(); + private Vector dblibPropertiesFileResolvers = new Vector(); /** * The configuration properties for the db connection. @@ -75,10 +75,10 @@ public class DBLIBResourceProvider { dblibPropertiesFileResolvers.add(new DblibDefaultFileResolver( "Using property file (1) from default directory" )); - dblibPropertiesFileResolvers.add(new DblibJREFileResolver( - "Using property file (2) from JRE argument" + dblibPropertiesFileResolvers.add(new JREFileResolver( + "Using property file (2) from JRE argument", DBLIBResourceProvider.class )); - dblibPropertiesFileResolvers.add(new DblibKarafRootFileResolver( + dblibPropertiesFileResolvers.add(new KarafRootFileResolver( "Using property file (4) from karaf root", this)); // determines properties file as according to the priority described in the class header comment @@ -141,7 +141,7 @@ public class DBLIBResourceProvider { */ File determinePropertiesFile(final DBLIBResourceProvider dblibResourceProvider) { - for (final DblibPropertiesFileResolver dblibPropertiesFileResolver : dblibPropertiesFileResolvers) { + for (final PropertiesFileResolver dblibPropertiesFileResolver : dblibPropertiesFileResolvers) { final Optional fileOptional = dblibPropertiesFileResolver.resolveFile(DBLIB_PROP_FILE_NAME); if (fileOptional.isPresent()) { return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolver.java deleted file mode 100644 index a7797d9f7..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolver.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.propertiesfileresolver; - -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; - -/** - * Resolves dblib properties files relative to the default file path. In Unix, this is represented by: - * /opt/sdnc/data/properties - */ -public class DblibDefaultFileResolver implements DblibPropertiesFileResolver { - - /** - * Default path to look for the configuration directory - */ - private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("opt", "sdnc", "data", "properties"); - - private final String successMessage; - - public DblibDefaultFileResolver(final String successMessage) { - this.successMessage = successMessage; - } - - /** - * Parse a properties file location based on the default properties location - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String dblibFileName) { - final File fileFromDefaultDblibDir = DEFAULT_DBLIB_PROP_DIR.resolve(dblibFileName).toFile(); - if (fileFromDefaultDblibDir.exists()) { - Optional.of(fileFromDefaultDblibDir); - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java deleted file mode 100644 index 0b69109f9..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolver.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.propertiesfileresolver; - -import com.google.common.base.Strings; - -import java.io.File; -import java.nio.file.Paths; -import java.util.Optional; - -/** - * Resolves dblib properties files relative to the directory identified by the SDNC_CONFIG_DIR - * environment variable. - */ -public class DblibEnvVarFileResolver implements DblibPropertiesFileResolver { - - /** - * Key for environment variable representing the configuration directory - */ - private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; - - private final String successMessage; - - public DblibEnvVarFileResolver(final String successMessage) { - this.successMessage = successMessage; - } - - /** - * Parse a properties file location based on System environment variable - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String dblibFileName) { - // attempt to resolve the property directory from the corresponding environment variable - final String propDirectoryFromEnvVariable = System.getenv(SDNC_CONFIG_DIR_PROP_KEY); - final File fileFromEnvVariable; - if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { - fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(dblibFileName).toFile(); - if(fileFromEnvVariable.exists()) { - return Optional.of(fileFromEnvVariable); - } - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolver.java deleted file mode 100644 index 673ccbf03..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolver.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.propertiesfileresolver; - -import java.io.File; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; -import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProvider; -import org.osgi.framework.FrameworkUtil; - -/** - * Resolves dblib properties files relative to the directory identified by the JRE property - * dblib.properties. - */ -public class DblibJREFileResolver implements DblibPropertiesFileResolver { - - /** - * Key for JRE argument representing the configuration directory - */ - private static final String DBLIB_JRE_PROPERTY_KEY = "dblib.properties"; - - private final String successMessage; - - public DblibJREFileResolver(final String successMessage) { - this.successMessage = successMessage; - } - - /** - * Parse a properties file location based on JRE argument - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String dblibFileName) { - final URL jreArgumentUrl = FrameworkUtil.getBundle(DBLIBResourceProvider.class) - .getResource(DBLIB_JRE_PROPERTY_KEY); - try { - if (jreArgumentUrl == null) { - return Optional.empty(); - } - final Path dblibPath = Paths.get(jreArgumentUrl.toURI()); - return Optional.of(dblibPath.resolve(dblibFileName).toFile()); - } catch(final URISyntaxException e) { - return Optional.empty(); - } - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolver.java deleted file mode 100644 index d2b164e3b..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolver.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.propertiesfileresolver; - -import java.io.File; -import java.net.URL; -import java.util.Optional; -import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProvider; - -/** - * Resolves dblib properties files relative to the karaf root directory. - */ -public class DblibKarafRootFileResolver implements DblibPropertiesFileResolver { - - final DBLIBResourceProvider dblibResourceProvider; - - private final String successMessage; - - public DblibKarafRootFileResolver(final String successMessage, final DBLIBResourceProvider dblibResourceProvider) { - this.successMessage = successMessage; - this.dblibResourceProvider = dblibResourceProvider; - } - - /** - * Parse a properties file location relative to the karaf root - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String dblibFileName) { - final URL fromKarafRoot = dblibResourceProvider.getClass().getResource(dblibFileName); - if (fromKarafRoot != null) { - final File propertiesFile = new File(fromKarafRoot.getFile()); - if (propertiesFile.exists()) { - return Optional.of(propertiesFile); - } - return Optional.empty(); - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibPropertiesFileResolver.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibPropertiesFileResolver.java deleted file mode 100644 index 97ab08acf..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibPropertiesFileResolver.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib.propertiesfileresolver; - -import java.io.File; -import java.util.Optional; - -/** - * Strategy for resolving dblib properties. - */ -public interface DblibPropertiesFileResolver { - - /** - * Resolve dblib properties file. - * - * @param dblibFileName the name of the file to look for at the specific location. - * @return An optional File or empty. - */ - Optional resolveFile(final String dblibFileName); - - /** - * A success message, used only for logging now. - * - * @return a success message, used only for logging now. - */ - String getSuccessfulResolutionMessage(); -} diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java deleted file mode 100644 index 41011e55b..000000000 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibDefaultFileResolverTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; - -import static org.junit.Assert.*; - -import java.io.File; -import java.util.Optional; -import org.junit.Test; - -public class DblibDefaultFileResolverTest { - - @Test - public void resolveFile() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java deleted file mode 100644 index 775898930..000000000 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibEnvVarFileResolverTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; - -import static org.junit.Assert.*; - -import java.io.File; -import java.util.Optional; -import org.junit.Test; - -public class DblibEnvVarFileResolverTest { - @Test - public void resolveFile() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java deleted file mode 100644 index 65ebfbae2..000000000 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibJREFileResolverTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class DblibJREFileResolverTest { - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibJREFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java deleted file mode 100644 index 0a032e8b7..000000000 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/propertiesfileresolver/DblibKarafRootFileResolverTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib.propertiesfileresolver; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class DblibKarafRootFileResolverTest { - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final DblibPropertiesFileResolver resolver = new DblibKarafRootFileResolver("success", null); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1c6cd4ae5..a36918109 100755 --- a/pom.xml +++ b/pom.xml @@ -114,6 +114,7 @@ filters sliPluginUtils sliapi + utils ONAP diff --git a/utils/pom.xml b/utils/pom.xml new file mode 100644 index 000000000..93326a9dc --- /dev/null +++ b/utils/pom.xml @@ -0,0 +1,56 @@ + + + + + org.onap.ccsdk.sli.core + ccsdk-sli-core + 0.1.2-SNAPSHOT + + + 4.0.0 + bundle + utils + SLI Core Utilities Package + + + The SLI Core Utilities Package provides common functionality for setting up SLI connectivity. + + + + + com.google.guava + guava + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + + + org.mockito + mockito-core + test + + + junit + junit + test + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + + + + + Inocybe Technologies and Others + + diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java new file mode 100644 index 000000000..8938aa6e7 --- /dev/null +++ b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; + +/** + * Resolves dblib properties files relative to the default file path. In Unix, this is represented by: + * /opt/sdnc/data/properties + */ +public abstract class DefaultFileResolver implements PropertiesFileResolver { + + private final String successMessage; + + private final Path propertyPath; + + public DefaultFileResolver(final String successMessage, final Path propertyPath) { + this.successMessage = successMessage; + this.propertyPath = propertyPath; + } + + /** + * Parse a properties file location based on the default properties location + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + final File fileFromDefaultDblibDir = propertyPath.resolve(filename).toFile(); + if (fileFromDefaultDblibDir.exists()) { + return Optional.of(fileFromDefaultDblibDir); + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java new file mode 100644 index 000000000..3e438d1a9 --- /dev/null +++ b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import com.google.common.base.Strings; + +import java.io.File; +import java.nio.file.Paths; +import java.util.Optional; + +/** + * Resolves dblib properties files relative to the directory identified by the SDNC_CONFIG_DIR + * environment variable. + */ +public abstract class EnvVarFileResolver implements PropertiesFileResolver { + + /** + * Key for environment variable representing the configuration directory + */ + private final String propertyKey; + + private final String successMessage; + + public EnvVarFileResolver(final String successMessage, final String propertyKey) { + this.successMessage = successMessage; + this.propertyKey = propertyKey; + } + + /** + * Parse a properties file location based on System environment variable + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + // attempt to resolve the property directory from the corresponding environment variable + final String propDirectoryFromEnvVariable = System.getenv(propertyKey); + final File fileFromEnvVariable; + if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { + fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(filename).toFile(); + if(fileFromEnvVariable.exists()) { + return Optional.of(fileFromEnvVariable); + } + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java new file mode 100644 index 000000000..5cd6c3606 --- /dev/null +++ b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import java.io.File; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; +import org.osgi.framework.FrameworkUtil; + +/** + * Resolves dblib properties files relative to the directory identified by the JRE property + * dblib.properties. + */ +public class JREFileResolver implements PropertiesFileResolver { + + /** + * Key for JRE argument representing the configuration directory + */ + private static final String DBLIB_JRE_PROPERTY_KEY = "dblib.properties"; + + private final String successMessage; + private final Class clazz; + + public JREFileResolver(final String successMessage, final Class clazz) { + this.successMessage = successMessage; + this.clazz = clazz; + } + + /** + * Parse a properties file location based on JRE argument + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + final URL jreArgumentUrl = FrameworkUtil.getBundle(this.clazz) + .getResource(DBLIB_JRE_PROPERTY_KEY); + try { + if (jreArgumentUrl == null) { + return Optional.empty(); + } + final Path dblibPath = Paths.get(jreArgumentUrl.toURI()); + return Optional.of(dblibPath.resolve(filename).toFile()); + } catch(final URISyntaxException e) { + return Optional.empty(); + } + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java new file mode 100644 index 000000000..0cb754504 --- /dev/null +++ b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import java.io.File; +import java.net.URL; +import java.util.Optional; + +/** + * Resolves dblib properties files relative to the karaf root directory. + */ +public class KarafRootFileResolver implements PropertiesFileResolver { + + final Object provider; + + private final String successMessage; + + public KarafRootFileResolver(final String successMessage, final Object provider) { + this.successMessage = successMessage; + this.provider = provider; + } + + /** + * Parse a properties file location relative to the karaf root + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + final URL fromKarafRoot = provider.getClass().getResource(filename); + if (fromKarafRoot != null) { + final File propertiesFile = new File(fromKarafRoot.getFile()); + if (propertiesFile.exists()) { + return Optional.of(propertiesFile); + } + return Optional.empty(); + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java new file mode 100644 index 000000000..bfb417dca --- /dev/null +++ b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import java.io.File; +import java.util.Optional; + +/** + * Strategy for resolving dblib properties. + */ +public interface PropertiesFileResolver { + + /** + * Resolve dblib properties file. + * + * @param filename the name of the file to look for at the specific location. + * @return An optional File or empty. + */ + Optional resolveFile(final String filename); + + /** + * A success message, used only for logging now. + * + * @return a success message, used only for logging now. + */ + String getSuccessfulResolutionMessage(); +} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java new file mode 100644 index 000000000..56b4ca1b6 --- /dev/null +++ b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java @@ -0,0 +1,17 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import java.nio.file.Path; +import java.nio.file.Paths; +import org.onap.ccsdk.sli.core.utils.DefaultFileResolver; + +public class DblibDefaultFileResolver extends DefaultFileResolver { + + /** + * Default path to look for the configuration directory + */ + private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("opt", "sdnc", "data", "properties"); + + public DblibDefaultFileResolver(final String successMessage) { + super(successMessage, DEFAULT_DBLIB_PROP_DIR); + } +} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java new file mode 100644 index 000000000..9eef4cee2 --- /dev/null +++ b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java @@ -0,0 +1,15 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import org.onap.ccsdk.sli.core.utils.EnvVarFileResolver; + +public class DblibEnvVarFileResolver extends EnvVarFileResolver { + + /** + * Key for environment variable representing the configuration directory + */ + private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; + + public DblibEnvVarFileResolver(final String successMessage) { + super(successMessage, SDNC_CONFIG_DIR_PROP_KEY); + } +} diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java new file mode 100644 index 000000000..e5051d65a --- /dev/null +++ b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java @@ -0,0 +1,15 @@ +package org.onap.ccsdk.sli.core.utils; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class JREFileResolverTest { + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new JREFileResolver("success", JREFileResolverTest.class); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java new file mode 100644 index 000000000..5e407daf6 --- /dev/null +++ b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.utils; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class KarafRootFileResolverTest { + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new KarafRootFileResolver("success", null); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java new file mode 100644 index 000000000..4b28d449d --- /dev/null +++ b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java @@ -0,0 +1,25 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class DblibDefaultFileResolverTest { + + @Test + public void resolveFile() throws Exception { + final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java new file mode 100644 index 000000000..bae4168d8 --- /dev/null +++ b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class DblibEnvVarFileResolverTest { + @Test + public void resolveFile() throws Exception { + final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file -- cgit 1.2.3-korg From ed6aaf35dabae4070dba5c41798e351c25e8ce4d Mon Sep 17 00:00:00 2001 From: Bharat saraswal Date: Thu, 21 Sep 2017 11:17:57 +0530 Subject: Fix Sonar Issues in sli/core module Few major issues *Remove unused variables To increase code readability *Replace the type specification with the diamond operator *Add the "@Override" annotation above this method signature To increase code readability" Issue-Id: CCSDK-87 Change-Id: I2f0c16a83ab10a0a3e39a2a1d4db3c195ec2bba8 Signed-off-by: Bharat saraswal --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 4 +- .../ccsdk/sli/core/dblib/DBResourceManager.java | 4 +- .../sli/core/dblib/factory/DBConfigFactory.java | 120 +++---- .../sli/core/dblib/pm/SQLExecutionMonitor.java | 383 ++++++++++----------- 4 files changed, 249 insertions(+), 262 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 4d920e6a0..072a6f470 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -123,7 +123,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito connection = null; } - monitor.deregisterReguest(testObject); + monitor.deregisterRequest(testObject); } } @@ -153,7 +153,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito connection = null; } - monitor.deregisterReguest(testObject); + monitor.deregisterRequest(testObject); } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 014dab31a..e7a94e64c 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -884,7 +884,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb CachedDataSource first = snapshot.getFirst(); CachedDataSource last = snapshot.getLast(); - int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount(); + int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount(); if(delta < 0) { flipper.set(false); } else if(delta > 0) { @@ -921,7 +921,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb CachedDataSource first = snapshot.getFirst(); CachedDataSource last = snapshot.getLast(); - int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount(); + int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount(); if(delta < 0) { flipper.set(false); } else if(delta > 0) { diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java index 3caa7767e..c3503576e 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java @@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.core.dblib.factory; import java.util.ArrayList; import java.util.Iterator; import java.util.Properties; - import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; @@ -39,61 +38,66 @@ import org.slf4j.LoggerFactory; */ public class DBConfigFactory { - public static DbConfigPool createConfig(Properties resource) { - return getConfigparams(resource); - } - - static DbConfigPool getConfigparams(Properties properties){ - DbConfigPool xmlConfig = new DbConfigPool(properties); - ArrayList propertySets = new ArrayList(); - - if("JDBC".equalsIgnoreCase(xmlConfig.getType())) { - String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS); - if(hosts == null || hosts.isEmpty()) { - propertySets.add(properties); - } else { - String[] newhost = hosts.split(","); - for(int i=0; i< newhost.length; i++) { - Properties localset = new Properties(); - localset.putAll(properties); - String url = localset.getProperty(BaseDBConfiguration.DATABASE_URL); - if(url.contains("DBHOST")) - url = url.replace("DBHOST", newhost[i]); - if(url.contains("dbhost")) - url = url.replace("dbhost", newhost[i]); - localset.setProperty(BaseDBConfiguration.DATABASE_URL, url); - localset.setProperty(BaseDBConfiguration.CONNECTION_NAME, newhost[i]); - propertySets.add(localset); - } - } - } else { - propertySets.add(properties); - } - try { - Iterator it = propertySets.iterator(); - while(it.hasNext()) { - BaseDBConfiguration config = parse(it.next()); - xmlConfig.addConfiguration(config); - } - - } catch (Exception e) { - LoggerFactory.getLogger(DBConfigFactory.class).warn("",e); - } - - return xmlConfig; - } - - public static BaseDBConfiguration parse(Properties props) throws Exception { - - String type = props.getProperty(BaseDBConfiguration.DATABASE_TYPE); - - BaseDBConfiguration config = null; - - if("JDBC".equalsIgnoreCase(type)) { - config = new JDBCConfiguration(props); - } - - return config; - - } + public static DbConfigPool createConfig(Properties resource) { + return getConfigparams(resource); + } + + static DbConfigPool getConfigparams(Properties properties) { + DbConfigPool xmlConfig = new DbConfigPool(properties); + ArrayList propertySets = new ArrayList(); + + if ("JDBC".equalsIgnoreCase(xmlConfig.getType())) { + String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS); + if (hosts == null || hosts.isEmpty()) { + propertySets.add(properties); + } else { + setPropertyWhenHostsNonEmpty(hosts, properties, propertySets); + } + } else { + propertySets.add(properties); + } + try { + Iterator it = propertySets.iterator(); + while (it.hasNext()) { + BaseDBConfiguration config = parse(it.next()); + xmlConfig.addConfiguration(config); + } + } catch (Exception e) { + LoggerFactory.getLogger(DBConfigFactory.class).warn("", e); + } + + return xmlConfig; + } + + private static void setPropertyWhenHostsNonEmpty(String hosts, Properties properties, ArrayList + propertySets) { + String[] newhost = hosts.split(","); + for (String aNewhost : newhost) { + Properties localSet = new Properties(); + localSet.putAll(properties); + String url = localSet.getProperty(BaseDBConfiguration.DATABASE_URL); + if (url.contains("DBHOST")) { + url = url.replace("DBHOST", aNewhost); + } + if (url.contains("dbhost")) { + url = url.replace("dbhost", aNewhost); + } + localSet.setProperty(BaseDBConfiguration.DATABASE_URL, url); + localSet.setProperty(BaseDBConfiguration.CONNECTION_NAME, aNewhost); + propertySets.add(localSet); + } + } + + public static BaseDBConfiguration parse(Properties props) throws Exception { + + String type = props.getProperty(BaseDBConfiguration.DATABASE_TYPE); + + BaseDBConfiguration config = null; + + if ("JDBC".equalsIgnoreCase(type)) { + config = new JDBCConfiguration(props); + } + + return config; + } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java index bcd4360e4..95172ad7a 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java @@ -23,6 +23,7 @@ package org.onap.ccsdk.sli.core.dblib.pm; import java.io.Serializable; import java.util.Arrays; import java.util.Collections; +import java.util.Objects; import java.util.Observable; import java.util.Observer; import java.util.SortedSet; @@ -30,208 +31,190 @@ import java.util.Timer; import java.util.TimerTask; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicLong; - import org.onap.ccsdk.sli.core.dblib.DBResourceObserver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SQLExecutionMonitor extends Observable -{ - private static Logger LOGGER = LoggerFactory.getLogger(SQLExecutionMonitor.class); - - final static long MILISECOND = 1000000L; - final static long SECOND = 1000L*MILISECOND; - - private final Timer timer; - // collection - private final SortedSet innerSet; - private SQLExecutionMonitorObserver parent = null; - private final AtomicLong completionCounter; - private boolean activeState = false; - private final long interval; - private final long initialDelay; - private final long EXPECTED_TIME_TO_COMPLETE; - private final long UNPROCESSED_FAILOVER_THRESHOLD; - - private final class MonitoringTask extends TimerTask - { - - public void run() - { - try { - TestObject testObj = new TestObject(); - testObj.setStartTime(testObj.getStartTime() - EXPECTED_TIME_TO_COMPLETE); - - // take a snapshot of the current task list - TestObject[] array = innerSet.toArray(new TestObject[0]); - SortedSet copyCurrent = new TreeSet(Arrays.asList(array)); - // get the list of the tasks that are older than the specified - // interval. - SortedSet unprocessed = copyCurrent.headSet(testObj); - - long succesfulCount = completionCounter.get(); - int unprocessedCount = unprocessed.size(); - - if (!unprocessed.isEmpty() && unprocessedCount > UNPROCESSED_FAILOVER_THRESHOLD && succesfulCount == 0) - { - // switch the Connection Pool to passive - setChanged(); - notifyObservers("Open JDBC requests=" + unprocessedCount+" in "+SQLExecutionMonitor.this.parent.getDbConnectionName()); - } - } catch (Exception exc) { - LOGGER.error("", exc); - } finally { - completionCounter.set(0L); - } - } - } - - public static class TestObject implements Comparable, Serializable - { - - private static final long serialVersionUID = 1L; - private long starttime; - private long randId; - - public TestObject() - { - starttime = System.nanoTime(); - } - - public long getStartTime() - { - return starttime; - } - - public void setStartTime(long newTime) - { - starttime = newTime; - } - - public int compareTo(TestObject o) - { - if( this == o) - return 0; - if(this.starttime > o.getStartTime()) - return 1; - if(this.starttime < o.getStartTime()) - return -1; - - if(this.hashCode() > o.hashCode()) - return 1; - if(this.hashCode() < o.hashCode()) - return -1; - - return 0; - } - - public String toString() - { - return Long.toString(starttime)+"#"+ this.hashCode(); - } - - public boolean equals(Object obj) - { - if (this == obj) - return true; - - return (obj instanceof TestObject - && starttime == ((TestObject) obj).getStartTime() - && hashCode() == ((TestObject) obj).hashCode()); - } - } - - public SQLExecutionMonitor(SQLExecutionMonitorObserver parent) - { - this.parent = parent; - completionCounter = new AtomicLong(0L); - interval = parent.getInterval(); - initialDelay = parent.getInitialDelay(); - this.UNPROCESSED_FAILOVER_THRESHOLD = parent.getUnprocessedFailoverThreshold(); - this.EXPECTED_TIME_TO_COMPLETE = parent.getExpectedCompletionTime()*MILISECOND; - - innerSet = Collections.synchronizedSortedSet(new TreeSet()); - timer = new Timer(); - } - - public void cleanup() - { - timer.cancel(); - } - - // registerRequest - public TestObject registerRequest() - { - if(activeState) - { - TestObject test = new TestObject(); - if(innerSet.add(test)) - return test; - } - return null; - } - - // deregisterSuccessfulReguest - public boolean deregisterReguest(TestObject test) - { - if(test == null) - return false; - // remove from the collection - if(innerSet.remove(test) && activeState) - { - completionCounter.incrementAndGet(); - return true; - } - return false; - } - - public void terminate() { - timer.cancel(); - } - - /** - * @return the parent - */ - public final Object getParent() { - return parent; - } - - public void addObserver(Observer observer) - { - if(observer instanceof DBResourceObserver) - { - DBResourceObserver dbObserver = (DBResourceObserver)observer; - if(dbObserver.isMonitorDbResponse()) - { - if(countObservers() == 0) - { - TimerTask remindTask = new MonitoringTask(); - timer.schedule(remindTask, initialDelay, interval); - activeState = true; - } - } - } - super.addObserver(observer); - } - - public void deleteObserver(Observer observer) - { - super.deleteObserver(observer); - if(observer instanceof DBResourceObserver) - { - DBResourceObserver dbObserver = (DBResourceObserver)observer; - if(dbObserver.isMonitorDbResponse()) - { - if(countObservers() == 0) - { - timer.cancel(); - activeState = false; - } - } - } - } - - public final int getPorcessedConnectionsCount() { - return innerSet.size(); - } +public class SQLExecutionMonitor extends Observable { + + private static final Logger LOGGER = LoggerFactory.getLogger(SQLExecutionMonitor.class); + + static final long MILISECOND = 1000000L; + static final long SECOND = 1000L * MILISECOND; + + private final Timer timer; + // collection + private final SortedSet innerSet; + private SQLExecutionMonitorObserver parent = null; + private final AtomicLong completionCounter; + private boolean activeState = false; + private final long interval; + private final long initialDelay; + private final long EXPECTED_TIME_TO_COMPLETE; + private final long UNPROCESSED_FAILOVER_THRESHOLD; + + private final class MonitoringTask extends TimerTask { + + public void run() { + try { + TestObject testObj = new TestObject(); + testObj.setStartTime(testObj.getStartTime() - EXPECTED_TIME_TO_COMPLETE); + + // take a snapshot of the current task list + TestObject[] array = innerSet.toArray(new TestObject[0]); + SortedSet copyCurrent = new TreeSet<>(Arrays.asList(array)); + // get the list of the tasks that are older than the specified + // interval. + SortedSet unprocessed = copyCurrent.headSet(testObj); + + long successfulCount = completionCounter.get(); + int unprocessedCount = unprocessed.size(); + + if (!unprocessed.isEmpty() && unprocessedCount > UNPROCESSED_FAILOVER_THRESHOLD + && successfulCount == 0) { + // switch the Connection Pool to passive + setChanged(); + notifyObservers("Open JDBC requests=" + unprocessedCount + " in " + SQLExecutionMonitor.this.parent + .getDbConnectionName()); + } + } catch (Exception exc) { + LOGGER.error("", exc); + } finally { + completionCounter.set(0L); + } + } + } + + public static class TestObject implements Comparable, Serializable { + + private static final long serialVersionUID = 1L; + private long startTime; + private long randId; + + public TestObject() { + startTime = System.nanoTime(); + } + + public long getStartTime() { + return startTime; + } + + public void setStartTime(long newTime) { + startTime = newTime; + } + + public int compareTo(TestObject o) { + if (this == o) { + return 0; + } + if (this.startTime > o.getStartTime()) { + return 1; + } + if (this.startTime < o.getStartTime()) { + return -1; + } + + if (this.hashCode() > o.hashCode()) { + return 1; + } + if (this.hashCode() < o.hashCode()) { + return -1; + } + + return 0; + } + + public String toString() { + return Long.toString(startTime) + "#" + this.hashCode(); + } + + public int hashCode() { + return Objects.hash(startTime, randId); + } + + public boolean equals(Object obj) { + return this == obj || (obj instanceof TestObject && startTime == ((TestObject) obj).getStartTime() + && hashCode() == obj.hashCode()); + } + } + + public SQLExecutionMonitor(SQLExecutionMonitorObserver parent) { + this.parent = parent; + completionCounter = new AtomicLong(0L); + interval = parent.getInterval(); + initialDelay = parent.getInitialDelay(); + this.UNPROCESSED_FAILOVER_THRESHOLD = parent.getUnprocessedFailoverThreshold(); + this.EXPECTED_TIME_TO_COMPLETE = parent.getExpectedCompletionTime() * MILISECOND; + + innerSet = Collections.synchronizedSortedSet(new TreeSet()); + timer = new Timer(); + } + + public void cleanup() { + timer.cancel(); + } + + // registerRequest + public TestObject registerRequest() { + if (activeState) { + TestObject test = new TestObject(); + if (innerSet.add(test)) { + return test; + } + } + return null; + } + + // deregisterSuccessfulRequest + public boolean deregisterRequest(TestObject test) { + if (test == null) { + return false; + } + // remove from the collection + if (innerSet.remove(test) && activeState) { + completionCounter.incrementAndGet(); + return true; + } + return false; + } + + public void terminate() { + timer.cancel(); + } + + /** + * @return the parent + */ + public final Object getParent() { + return parent; + } + + @Override + public void addObserver(Observer observer) { + if (observer instanceof DBResourceObserver) { + DBResourceObserver dbObserver = (DBResourceObserver) observer; + if (dbObserver.isMonitorDbResponse() && countObservers() == 0) { + TimerTask remindTask = new MonitoringTask(); + timer.schedule(remindTask, initialDelay, interval); + activeState = true; + } + } + super.addObserver(observer); + } + + @Override + public void deleteObserver(Observer observer) { + super.deleteObserver(observer); + if (observer instanceof DBResourceObserver) { + DBResourceObserver dbObserver = (DBResourceObserver) observer; + if (dbObserver.isMonitorDbResponse() && countObservers() == 0) { + timer.cancel(); + activeState = false; + } + } + } + + public final int getProcessedConnectionsCount() { + return innerSet.size(); + } } -- cgit 1.2.3-korg From 0d59ee8e61cdfc9de37a6f96f73719888e03cb9e Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 21 Sep 2017 15:33:03 +0530 Subject: Remove unnecessary parentheses *Useless parentheses can sometimes be misleading and hence removed Issue-Id: CCSDK-87 Change-Id: I018d791500a42356296d07d04de45517d061bb7f Signed-off-by: surya-huawei --- .../org/onap/ccsdk/sli/core/sli/SvcLogicNode.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java index 160107fea..45f683516 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java @@ -87,28 +87,28 @@ public class SvcLogicNode implements Serializable { public String getNodeName() { - return(nodeName); + return nodeName; } public String getNodeType() { - return(nodeType); + return nodeType; } public SvcLogicGraph getGraph() { - return(graph); + return graph; } public int getNumOutcomes() { if (outcomes == null) { - return(0); + return 0; } else { - return(outcomes.size()); + return outcomes.size(); } } @@ -116,11 +116,11 @@ public class SvcLogicNode implements Serializable { { if (attributes.containsKey(name)) { - return(attributes.get(name)); + return attributes.get(name); } else { - return(null); + return null; } } @@ -151,7 +151,7 @@ public class SvcLogicNode implements Serializable { try { SvcLogicExpression parmValue; - if ((value == null) || (value.length() == 0)) + if (value == null || value.length() == 0) { parmValue = new SvcLogicAtom("STRING", ""); } @@ -187,11 +187,11 @@ public class SvcLogicNode implements Serializable { { if (parameters.containsKey(name)) { - return(parameters.get(name)); + return parameters.get(name); } else { - return(null); + return null; } } @@ -245,7 +245,7 @@ public class SvcLogicNode implements Serializable { return null; } - return(outcomes.entrySet()); + return outcomes.entrySet(); } @@ -256,7 +256,7 @@ public class SvcLogicNode implements Serializable { return null; } - return(parameters.entrySet()); + return parameters.entrySet(); } @@ -346,8 +346,8 @@ public class SvcLogicNode implements Serializable { pstr.print("'`"); } - if (((parameters == null) || (parameters.isEmpty())) && - ((outcomes == null) || outcomes.isEmpty())) + if ((parameters == null || parameters.isEmpty()) && + (outcomes == null || outcomes.isEmpty())) { pstr.print("/>\n"); pstr.flush(); @@ -424,12 +424,12 @@ public class SvcLogicNode implements Serializable { } if (outcomes == null) { - return(null); + return null; } if (outcomes.containsKey(value)) { - return(outcomes.get(value)); + return outcomes.get(value); } else { @@ -443,11 +443,11 @@ public class SvcLogicNode implements Serializable { if (outcomes.containsKey("Other")) { - return(outcomes.get("Other")); + return outcomes.get("Other"); } else { - return(null); + return null; } } } -- cgit 1.2.3-korg From c2eaae773f3a76ecf585a24172692da0bf00445f Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Thu, 21 Sep 2017 16:29:34 +0530 Subject: Improve code coverage for MdsalHelper Changes includes 1. Modified pom to take JUNIT version from parent pom. 2. Added basic testcases for MdsalHelper utilities with test YANG. 3. Made necessary pom additions. Change-Id: Ib46bd9c8a87db33c90aaaf36736d709a7c17cbdd Issue-Id: CCSDK-101 Signed-off-by: Gaurav Agrawal --- sli/provider/pom.xml | 240 ++++++++++++++------- .../core/sli/provider/TestMdsalHelperUtils.java | 79 +++++++ .../l3vpnyang/ietf-l3vpn-svc-part@2017-09-21.yang | 68 ++++++ 3 files changed, 309 insertions(+), 78 deletions(-) create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/TestMdsalHelperUtils.java create mode 100755 sli/provider/src/test/resources/l3vpnyang/ietf-l3vpn-svc-part@2017-09-21.yang diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 529f97690..51db628c7 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -1,98 +1,182 @@ - - 4.0.0 - - org.onap.ccsdk.sli.core - sli - 0.1.2-SNAPSHOT - - sli-provider - bundle - SLI - Provider - - UTF-8 - - - - junit - junit - 3.8.1 - test - + + 4.0.0 + + org.onap.ccsdk.sli.core + sli + 0.1.2-SNAPSHOT + + sli-provider + bundle + SLI - Provider + + UTF-8 + + + + junit + junit + ${junit.version} + test + ch.vorburger.mariaDB4j mariaDB4j 2.2.3 test - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - compile - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - commons-lang - commons-lang - ${commons.lang.version} - compile - - + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + compile + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + commons-lang + commons-lang + ${commons.lang.version} + compile + - + - + - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - org.onap.ccsdk.sli.core.sli.provider.SvcLogicActivator - org.onap.ccsdk.sli.core.sli.provider;version=${project.version} + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.onap.ccsdk.sli.core.sli.provider.SvcLogicActivator + org.onap.ccsdk.sli.core.sli.provider;version=${project.version} - * + * org.onap.ccsdk.sli.core.sli;version="${project.version}",* - *;scope=compile;artifactId=commons-lang|commons-lang3 + *;scope=compile;artifactId=commons-lang|commons-lang3 - true - + true + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${odl.yangtools.yang.maven.plugin.version} + + + config + + generate-sources + + + src/test/resources + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${jmxGeneratorPath} + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + + org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl + + ${salGeneratorPath} + + + true + + + + + + org.opendaylight.mdsal + maven-sal-api-gen-plugin + ${odl.sal.api.gen.plugin.version} + jar + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${odl.yang.jmx.generator.version} + + + - + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + prepare-package + + run + + + + + + + + + + + + + + - - - - SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. + + + SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/TestMdsalHelperUtils.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/TestMdsalHelperUtils.java new file mode 100644 index 000000000..dca6b54c6 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/TestMdsalHelperUtils.java @@ -0,0 +1,79 @@ +/*- + * ============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========================================================= + */ + +package org.onap.ccsdk.sli.core.sli.provider; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.L3vpnSvcBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.SvcId; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.l3vpn.svc.VpnServicesBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.l3vpn.svc.vpn.services.VpnSvc; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.l3vpn.svc.vpn.services.VpnSvcBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.l3vpn.svc.vpn.services.VpnSvcKey; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestMdsalHelperUtils { + + private static final Logger log = LoggerFactory.getLogger(TestMdsalHelperUtils.class); + + @Test + public void testL3vpnSvcToBuilder() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("l3vpn-svc.vpn-services.vpn-svc[0].vpn-id", "1"); + + L3vpnSvcBuilder svcBuilder = new L3vpnSvcBuilder(); + + MdsalHelper.toBuilder(ctx.toProperties(), "", svcBuilder); + + assertThat(svcBuilder.getVpnServices().getVpnSvc().get(0).getKey().getVpnId().getValue(), is("1")); + log.info(svcBuilder.toString()); + } + + @Test + public void testL3vpnSvcToProperties() throws SvcLogicException { + VpnSvcBuilder vpnSvcBuilder = new VpnSvcBuilder(); + vpnSvcBuilder.setKey(new VpnSvcKey(new SvcId("1"))); + List vpnSvcList = new ArrayList<>(); + vpnSvcList.add(vpnSvcBuilder.build()); + VpnServicesBuilder vpnServicesBuilder = new VpnServicesBuilder(); + vpnServicesBuilder.setVpnSvc(vpnSvcList); + L3vpnSvcBuilder l3vpnSvcBuilder = new L3vpnSvcBuilder(); + l3vpnSvcBuilder.setVpnServices(vpnServicesBuilder.build()); + + Properties properties = new Properties(); + + MdsalHelper.toProperties(properties, "", l3vpnSvcBuilder.build()); + + assertThat(properties.getProperty("l3vpn-svc.vpn-services.vpn-svc[0].vpn-id"), is("1")); + log.info(properties.toString()); + } + + // TODO add more detailed testcases. +} diff --git a/sli/provider/src/test/resources/l3vpnyang/ietf-l3vpn-svc-part@2017-09-21.yang b/sli/provider/src/test/resources/l3vpnyang/ietf-l3vpn-svc-part@2017-09-21.yang new file mode 100755 index 000000000..4af080608 --- /dev/null +++ b/sli/provider/src/test/resources/l3vpnyang/ietf-l3vpn-svc-part@2017-09-21.yang @@ -0,0 +1,68 @@ +module ietf-l3vpn-svc-part { + + namespace "urn:ietf:params:xml:ns:yang:ietf-l3vpn-svc-part"; + + prefix l3vpn-svc; + + organization + "IETF L3SM Working Group"; + + contact + "WG List: <mailto:l3sm@ietf.org> + + Editor: + + "; + + description + "The YANG module defines a generic service configuration + model for Layer 3 VPN common across all of the vendor + implementations."; + + revision 2017-09-21 { + description + "Part of draft-ietf-l3sm-l3vpn-service-yang-11"; + reference + "draft-ietf-l3sm-l3vpn-service-yang-11"; + } + + /* Typedefs */ + + typedef svc-id { + type string; + description + "Defining a type of service component + identificators."; + } + + /* Main blocks */ + + container l3vpn-svc { + container vpn-services { + list vpn-svc { + key vpn-id; + + uses vpn-svc-cfg; /*Not used*/ + + description " + List of VPN services."; + } + description + "top level container + for the VPN services."; + } + } + + grouping vpn-svc-cfg { + leaf vpn-id { + type svc-id; + description + "VPN identifier. Local administration meaning."; + } + leaf customer-name { + type string; + description + "Name of the customer."; + } + } +} -- cgit 1.2.3-korg From 91c7a03545690834a2b7d8b5fac6f677e9c2bc20 Mon Sep 17 00:00:00 2001 From: Bharat saraswal Date: Thu, 21 Sep 2017 16:23:11 +0530 Subject: Resolved sonar issue. Related to exception handling. @Override method Redundant code and resulable parameters Issue-Id:CCSDK-87 Change-Id: I82e2aad453edf5cd647c87322fc75b2a56c37566 Signed-off-by: Bharat saraswal --- .../sli/core/dblib/DBLIBResourceProvider.java | 12 +- .../onap/ccsdk/sli/core/dblib/DBLibConnection.java | 680 ++++++++++----------- 2 files changed, 345 insertions(+), 347 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java index 8e0b534f0..411f04705 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java @@ -84,8 +84,7 @@ public class DBLIBResourceProvider { // determines properties file as according to the priority described in the class header comment final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { - try { - final FileInputStream fileInputStream = new FileInputStream(propertiesFile); + try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { properties = new Properties(); properties.load(fileInputStream); } catch (final IOException e) { @@ -113,9 +112,12 @@ public class DBLIBResourceProvider { * @return the file location of the chosen properties file */ private static File reportSuccess(final String message, final Optional fileOptional) { - final File file = fileOptional.get(); - LOG.info("{} {}", message, file.getPath()); - return file; + if(fileOptional.isPresent()) { + final File file = fileOptional.get(); + LOG.info("{} {}", message, file.getPath()); + return file; + } + return null; } /** diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java index 40d1a2382..65d0b9512 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLibConnection.java @@ -36,356 +36,352 @@ import java.sql.Savepoint; import java.sql.Statement; import java.sql.Struct; import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.Executor; - import javax.sql.rowset.CachedRowSet; - import org.apache.tomcat.jdbc.pool.PooledConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DBLibConnection implements Connection { - private static Logger LOGGER = LoggerFactory.getLogger(DBLibConnection.class); - - private final Connection connection; - private final CachedDataSource dataSource; - private boolean locked = false; - private String tableName = null; - - public DBLibConnection(Connection con, CachedDataSource dataSource){ - this.connection = con; - this.dataSource = dataSource; - locked = false; - dataSource.getPoolInfo(true); - } - - public boolean lockTable(String tablename) { - this.tableName = tablename; - locked = dataSource.lockTable(connection, tableName); - return locked; - } - - public void resetInactivityTimer() { - Class iface = PooledConnection.class; - try { - PooledConnection pc = connection.unwrap(iface); - pc.setTimestamp(System.currentTimeMillis()); - } catch (SQLException e) { - LOGGER.warn("Failed resetting timeout timer", e); - } - } - - public boolean unlock() { - dataSource.unlockTable(connection); - locked = false; - return locked; - } - - public boolean writeData(String statement, ArrayList arguments) throws SQLException, Throwable - { - ArrayList newList= new ArrayList<>(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - resetInactivityTimer(); - return dataSource.executeUpdatePreparedStatement(connection, statement, newList, false); - } - - public CachedRowSet getData(String statement, ArrayList arguments) throws SQLException, Throwable - { - ArrayList newList= new ArrayList<>(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - resetInactivityTimer(); - return dataSource.executePreparedStatement(connection, statement, newList, false); - } - - @Override - public T unwrap(Class iface) throws SQLException { - return connection.unwrap(iface); - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return connection.isWrapperFor(iface); - } - - @Override - public Statement createStatement() throws SQLException { - return connection.createStatement(); - } - - @Override - public PreparedStatement prepareStatement(String sql) throws SQLException { - return connection.prepareStatement(sql); - } - - @Override - public CallableStatement prepareCall(String sql) throws SQLException { - return connection.prepareCall(sql); - } - - @Override - public String nativeSQL(String sql) throws SQLException { - return connection.nativeSQL(sql); - } - - @Override - public void setAutoCommit(boolean autoCommit) throws SQLException { - connection.setAutoCommit(autoCommit); - } - - @Override - public boolean getAutoCommit() throws SQLException { - return connection.getAutoCommit(); - } - - @Override - public void commit() throws SQLException { - connection.commit(); - } - - @Override - public void rollback() throws SQLException { - connection.rollback(); - } - - @Override - public void close() throws SQLException { - if(this.locked) { - try { - this.unlock(); - } catch(Throwable th) { - LOGGER.error("Failed unlocking",th); - } - } - if(connection != null && !connection.isClosed()) { - connection.close(); - } - dataSource.getPoolInfo(false); - } - - @Override - public boolean isClosed() throws SQLException { - return connection.isClosed(); - } - - @Override - public DatabaseMetaData getMetaData() throws SQLException { - return connection.getMetaData(); - } - - @Override - public void setReadOnly(boolean readOnly) throws SQLException { - connection.setReadOnly(readOnly); - } - - @Override - public boolean isReadOnly() throws SQLException { - return connection.isReadOnly(); - } - - @Override - public void setCatalog(String catalog) throws SQLException { - connection.setCatalog(catalog); - } - - @Override - public String getCatalog() throws SQLException { - return connection.getCatalog(); - } - - @Override - public void setTransactionIsolation(int level) throws SQLException { - connection.setTransactionIsolation(level); - } - - @Override - public int getTransactionIsolation() throws SQLException { - return connection.getTransactionIsolation(); - } - - @Override - public SQLWarning getWarnings() throws SQLException { - return connection.getWarnings(); - } - - @Override - public void clearWarnings() throws SQLException { - connection.clearWarnings(); - } - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { - return connection.createStatement(resultSetType, resultSetConcurrency); - } - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) - throws SQLException { - return connection.prepareStatement(sql, resultSetType, resultSetConcurrency); - } - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { - return connection.prepareCall(sql, resultSetType, resultSetConcurrency); - } - - @Override - public Map> getTypeMap() throws SQLException { - return connection.getTypeMap(); - } - - @Override - public void setTypeMap(Map> map) throws SQLException { - connection.setTypeMap(map); - } - - @Override - public void setHoldability(int holdability) throws SQLException { - connection.setHoldability(holdability); - } - - @Override - public int getHoldability() throws SQLException { - return connection.getHoldability(); - } - - @Override - public Savepoint setSavepoint() throws SQLException { - return connection.setSavepoint(); - } - - @Override - public Savepoint setSavepoint(String name) throws SQLException { - return connection.setSavepoint(name); - } - - @Override - public void rollback(Savepoint savepoint) throws SQLException { - connection.rollback(savepoint); - } - - @Override - public void releaseSavepoint(Savepoint savepoint) throws SQLException { - connection.releaseSavepoint(savepoint); - } - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) - throws SQLException { - return connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return connection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { - return connection.prepareStatement(sql, autoGeneratedKeys); - } - - @Override - public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { - return connection.prepareStatement(sql, columnIndexes); - } - - @Override - public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { - return connection.prepareStatement(sql, columnNames); - } - - @Override - public Clob createClob() throws SQLException { - return connection.createClob(); - } - - @Override - public Blob createBlob() throws SQLException { - return connection.createBlob(); - } - - @Override - public NClob createNClob() throws SQLException { - return connection.createNClob(); - } - - @Override - public SQLXML createSQLXML() throws SQLException { - return connection.createSQLXML(); - } - - @Override - public boolean isValid(int timeout) throws SQLException { - return connection.isValid(timeout); - } - - @Override - public void setClientInfo(String name, String value) throws SQLClientInfoException { - connection.setClientInfo(name, value); - } - - @Override - public void setClientInfo(Properties properties) throws SQLClientInfoException { - connection.setClientInfo(properties); - } - - @Override - public String getClientInfo(String name) throws SQLException { - return connection.getClientInfo(name); - } - - @Override - public Properties getClientInfo() throws SQLException { - return connection.getClientInfo(); - } - - @Override - public Array createArrayOf(String typeName, Object[] elements) throws SQLException { - return connection.createArrayOf(typeName, elements); - } - - @Override - public Struct createStruct(String typeName, Object[] attributes) throws SQLException { - return connection.createStruct(typeName, attributes); - } - - @Override - public void setSchema(String schema) throws SQLException { - connection.setSchema(schema); - } - - @Override - public String getSchema() throws SQLException { - return connection.getSchema(); - } - - @Override - public void abort(Executor executor) throws SQLException { - connection.abort(executor); - } - - @Override - public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { - connection.setNetworkTimeout(executor, milliseconds); - } - - @Override - public int getNetworkTimeout() throws SQLException { - return connection.getNetworkTimeout(); - } - + private static final Logger LOGGER = LoggerFactory.getLogger(DBLibConnection.class); + + private final Connection connection; + private final CachedDataSource dataSource; + private boolean locked = false; + private String tableName = null; + + public DBLibConnection(Connection con, CachedDataSource dataSource) { + this.connection = con; + this.dataSource = dataSource; + locked = false; + dataSource.getPoolInfo(true); + } + + public boolean lockTable(String tablename) { + this.tableName = tablename; + locked = dataSource.lockTable(connection, tableName); + return locked; + } + + public void resetInactivityTimer() { + Class iface = PooledConnection.class; + try { + PooledConnection pc = connection.unwrap(iface); + pc.setTimestamp(System.currentTimeMillis()); + } catch (SQLException e) { + LOGGER.warn("Failed resetting timeout timer", e); + } + } + + public boolean unlock() { + dataSource.unlockTable(connection); + locked = false; + return false; + } + + public boolean writeData(String statement, List arguments) throws Throwable { + ArrayList newList = new ArrayList<>(); + if (arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + resetInactivityTimer(); + return dataSource.executeUpdatePreparedStatement(connection, statement, newList, false); + } + + public CachedRowSet getData(String statement, List arguments) throws Throwable { + ArrayList newList = new ArrayList<>(); + if (arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + resetInactivityTimer(); + return dataSource.executePreparedStatement(connection, statement, newList, false); + } + + @Override + public T unwrap(Class iFace) throws SQLException { + return connection.unwrap(iFace); + } + + @Override + public boolean isWrapperFor(Class iFace) throws SQLException { + return connection.isWrapperFor(iFace); + } + + @Override + public Statement createStatement() throws SQLException { + return connection.createStatement(); + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + return connection.prepareStatement(sql); + } + + @Override + public CallableStatement prepareCall(String sql) throws SQLException { + return connection.prepareCall(sql); + } + + @Override + public String nativeSQL(String sql) throws SQLException { + return connection.nativeSQL(sql); + } + + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + connection.setAutoCommit(autoCommit); + } + + @Override + public boolean getAutoCommit() throws SQLException { + return connection.getAutoCommit(); + } + + @Override + public void commit() throws SQLException { + connection.commit(); + } + + @Override + public void rollback() throws SQLException { + connection.rollback(); + } + + @Override + public void close() throws SQLException { + if (this.locked) { + try { + this.unlock(); + } catch (Exception th) { + LOGGER.error("Failed unlocking", th); + } + } + if (connection != null && !connection.isClosed()) { + connection.close(); + } + dataSource.getPoolInfo(false); + } + + @Override + public boolean isClosed() throws SQLException { + return connection.isClosed(); + } + + @Override + public DatabaseMetaData getMetaData() throws SQLException { + return connection.getMetaData(); + } + + @Override + public void setReadOnly(boolean readOnly) throws SQLException { + connection.setReadOnly(readOnly); + } + + @Override + public boolean isReadOnly() throws SQLException { + return connection.isReadOnly(); + } + + @Override + public void setCatalog(String catalog) throws SQLException { + connection.setCatalog(catalog); + } + + @Override + public String getCatalog() throws SQLException { + return connection.getCatalog(); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + connection.setTransactionIsolation(level); + } + + @Override + public int getTransactionIsolation() throws SQLException { + return connection.getTransactionIsolation(); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return connection.getWarnings(); + } + + @Override + public void clearWarnings() throws SQLException { + connection.clearWarnings(); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { + return connection.createStatement(resultSetType, resultSetConcurrency); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + return connection.prepareStatement(sql, resultSetType, resultSetConcurrency); + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { + return connection.prepareCall(sql, resultSetType, resultSetConcurrency); + } + + @Override + public Map> getTypeMap() throws SQLException { + return connection.getTypeMap(); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + connection.setTypeMap(map); + } + + @Override + public void setHoldability(int holdability) throws SQLException { + connection.setHoldability(holdability); + } + + @Override + public int getHoldability() throws SQLException { + return connection.getHoldability(); + } + + @Override + public Savepoint setSavepoint() throws SQLException { + return connection.setSavepoint(); + } + + @Override + public Savepoint setSavepoint(String name) throws SQLException { + return connection.setSavepoint(name); + } + + @Override + public void rollback(Savepoint savepoint) throws SQLException { + connection.rollback(savepoint); + } + + @Override + public void releaseSavepoint(Savepoint savepoint) throws SQLException { + connection.releaseSavepoint(savepoint); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) + throws SQLException { + return connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return connection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { + return connection.prepareStatement(sql, autoGeneratedKeys); + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + return connection.prepareStatement(sql, columnIndexes); + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { + return connection.prepareStatement(sql, columnNames); + } + + @Override + public Clob createClob() throws SQLException { + return connection.createClob(); + } + + @Override + public Blob createBlob() throws SQLException { + return connection.createBlob(); + } + + @Override + public NClob createNClob() throws SQLException { + return connection.createNClob(); + } + + @Override + public SQLXML createSQLXML() throws SQLException { + return connection.createSQLXML(); + } + + @Override + public boolean isValid(int timeout) throws SQLException { + return connection.isValid(timeout); + } + + @Override + public void setClientInfo(String name, String value) throws SQLClientInfoException { + connection.setClientInfo(name, value); + } + + @Override + public void setClientInfo(Properties properties) throws SQLClientInfoException { + connection.setClientInfo(properties); + } + + @Override + public String getClientInfo(String name) throws SQLException { + return connection.getClientInfo(name); + } + + @Override + public Properties getClientInfo() throws SQLException { + return connection.getClientInfo(); + } + + @Override + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + return connection.createArrayOf(typeName, elements); + } + + @Override + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { + return connection.createStruct(typeName, attributes); + } + + @Override + public void setSchema(String schema) throws SQLException { + connection.setSchema(schema); + } + + @Override + public String getSchema() throws SQLException { + return connection.getSchema(); + } + + @Override + public void abort(Executor executor) throws SQLException { + connection.abort(executor); + } + + @Override + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + connection.setNetworkTimeout(executor, milliseconds); + } + + @Override + public int getNetworkTimeout() throws SQLException { + return connection.getNetworkTimeout(); + } } -- cgit 1.2.3-korg From 6d585c2900751d0269772de6ca21476c51fcc942 Mon Sep 17 00:00:00 2001 From: Bharat saraswal Date: Thu, 21 Sep 2017 15:09:52 +0530 Subject: Sql query blocker issue fixed. Rdundant code and complextity of methods reduced. @override annotaiton added. Exception handling and logging impoved. Issue-ID:CCSDK-87 Change-Id: I3907be73a2f6ccdfadeaed79c87705ae7afdb4ab Signed-off-by: Bharat saraswal --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 1087 +++++++++----------- .../core/dblib/jdbc/JdbcDBCachedDataSource.java | 269 +++-- 2 files changed, 627 insertions(+), 729 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 072a6f470..356f5ee8b 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -20,17 +20,6 @@ package org.onap.ccsdk.sli.core.dblib; -import org.apache.tomcat.jdbc.pool.PoolExhaustedException; -import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor.TestObject; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.sql.DataSource; -import javax.sql.rowset.CachedRowSet; -import javax.sql.rowset.RowSetProvider; import java.io.Closeable; import java.io.IOException; import java.io.PrintWriter; @@ -45,8 +34,18 @@ import java.sql.Statement; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Observer; - +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetProvider; +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor.TestObject; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @version $Revision: 1.13 $ @@ -56,582 +55,502 @@ import java.util.Observer; * Rich Tabedzki */ -public abstract class CachedDataSource implements DataSource, SQLExecutionMonitorObserver -{ - private static Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); - - protected static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; - - protected long CONN_REQ_TIMEOUT = 30L; - protected long DATA_REQ_TIMEOUT = 100L; - - private final SQLExecutionMonitor monitor; - protected DataSource ds = null; - protected String connectionName = null; - protected boolean initialized = false; - - private long interval = 1000; - private long initialDelay = 5000; - private long expectedCompletionTime = 50L; - private boolean canTakeOffLine = true; - private long unprocessedFailoverThreshold = 3L; - - private long nextErrorReportTime = 0L; - - private String globalHostName = null; - - - public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException - { - configure(jdbcElem); - monitor = new SQLExecutionMonitor(this); - } - - protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; - /* (non-Javadoc) - * @see javax.sql.DataSource#getConnection() - */ - @Override - public Connection getConnection() throws SQLException - { - return ds.getConnection(); - } - - public CachedRowSet getData(String statement, ArrayList arguments) - throws SQLException, Throwable - { - TestObject testObject = null; - testObject = monitor.registerRequest(); - - Connection connection = null; - try { - connection = this.getConnection(); - if(connection == null ) { - throw new SQLException("Connection invalid"); - } - if(LOGGER.isDebugEnabled()) - LOGGER.debug("Obtained connection <" + connectionName + ">: "+connection.toString()); - return executePreparedStatement(connection, statement, arguments, true); - } finally { - try { - if(connection != null && !connection.isClosed()) { - connection.close(); - } - } catch(Throwable exc) { - // the exception not monitored - } finally { - connection = null; - } - - monitor.deregisterRequest(testObject); - } - } - - public boolean writeData(String statement, ArrayList arguments) - throws SQLException, Throwable - { - TestObject testObject = null; - testObject = monitor.registerRequest(); - - Connection connection = null; - try { - connection = this.getConnection(); - if(connection == null ) { - throw new SQLException("Connection invalid"); - } - if(LOGGER.isDebugEnabled()) - LOGGER.debug("Obtained connection <" + connectionName + ">: "+connection.toString()); - return executeUpdatePreparedStatement(connection, statement, arguments, true); - } finally { - try { - if(connection != null && !connection.isClosed()) { - connection.close(); - } - } catch(Throwable exc) { - // the exception not monitored - } finally { - connection = null; - } - - monitor.deregisterRequest(testObject); - } - } - - CachedRowSet executePreparedStatement(Connection conn, String statement, - ArrayList arguments, boolean close) throws SQLException, Throwable - { - long time = System.currentTimeMillis(); - - CachedRowSet data = null; - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL Statement: "+ statement); - if(arguments != null && !arguments.isEmpty()) { - LOGGER.debug("Argunments: "+ Arrays.toString(arguments.toArray())); - } - } - - ResultSet rs = null; - PreparedStatement ps = null; - try { - data = RowSetProvider.newFactory().createCachedRowSet(); - ps = conn.prepareStatement(statement); - if(arguments != null) - { - for(int i = 0, max = arguments.size(); i < max; i++){ - ps.setObject(i+1, arguments.get(i)); - } - } - rs = ps.executeQuery(); - data.populate(rs); - // Point the rowset Cursor to the start - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL SUCCESS. rows returned: " + data.size()+ ", time(ms): "+ (System.currentTimeMillis() - time)); } - } catch(SQLException exc){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); - } - try { conn.rollback(); } catch(Throwable thr){} - if(arguments != null && !arguments.isEmpty()) { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); - } else { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); - } - throw exc; - } catch(Throwable exc){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); - } - if(arguments != null && !arguments.isEmpty()) { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); - } else { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); - } - throw exc; // new SQLException(exc); - } finally { - - try { - if(rs != null){ - rs.close(); - rs = null; - } - } catch(Exception exc){ - - } - try { - if(conn != null && close){ - conn.close(); - conn = null; - } - } catch(Exception exc){ - - } - try { - if (ps != null){ - ps.close(); - } - } catch (Exception exc){ - - } - } - - return data; - } - - boolean executeUpdatePreparedStatement(Connection conn, String statement, ArrayList arguments, boolean close) throws SQLException, Throwable { - long time = System.currentTimeMillis(); - - CachedRowSet data = null; - - int rs = -1; - try { - data = RowSetProvider.newFactory().createCachedRowSet(); - PreparedStatement ps = conn.prepareStatement(statement); - if(arguments != null) - { - for(int i = 0, max = arguments.size(); i < max; i++){ - if(arguments.get(i) instanceof Blob) { - ps.setBlob(i+1, (Blob)arguments.get(i)); - } else if(arguments.get(i) instanceof Timestamp) { - ps.setTimestamp(i+1, (Timestamp)arguments.get(i)); - } else if(arguments.get(i) instanceof Integer) { - ps.setInt(i+1, (Integer)arguments.get(i)); - } else if(arguments.get(i) instanceof Long) { - ps.setLong(i+1, (Long)arguments.get(i)); - } else if(arguments.get(i) instanceof Date) { - ps.setDate(i+1, (Date)arguments.get(i)); - } else { - ps.setObject(i+1, arguments.get(i)); - } - } - } - rs = ps.executeUpdate(); - // Point the rowset Cursor to the start - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL SUCCESS. rows returned: " + data.size()+ ", time(ms): "+ (System.currentTimeMillis() - time)); - } - } catch(SQLException exc){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); - } - try { conn.rollback(); } catch(Throwable thr){} - if(arguments != null && !arguments.isEmpty()) { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); - } else { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); - } - throw exc; - } catch(Throwable exc){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL FAILURE. time(ms): "+ (System.currentTimeMillis() - time)); - } - if(arguments != null && !arguments.isEmpty()) { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with arguments: "+arguments.toString(), exc); - } else { - LOGGER.error("<"+connectionName+"> Failed to execute: "+ statement + " with no arguments. ", exc); - } - throw exc; // new SQLException(exc); - } finally { - try { - if(conn != null && close){ - conn.close(); - conn = null; - } - } catch(Exception exc){ - - } - } - - return true; - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) - */ - @Override - public Connection getConnection(String username, String password) - throws SQLException - { - return ds.getConnection(username, password); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getLogWriter() - */ - @Override - public PrintWriter getLogWriter() throws SQLException - { - return ds.getLogWriter(); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getLoginTimeout() - */ - @Override - public int getLoginTimeout() throws SQLException - { - return ds.getLoginTimeout(); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) - */ - @Override - public void setLogWriter(PrintWriter out) throws SQLException - { - ds.setLogWriter(out); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#setLoginTimeout(int) - */ - @Override - public void setLoginTimeout(int seconds) throws SQLException - { - ds.setLoginTimeout(seconds); - } - - - @Override - public final String getDbConnectionName(){ - return connectionName; - } - - protected final void setDbConnectionName(String name) { - this.connectionName = name; - } - - public void cleanUp(){ - if(ds != null && ds instanceof Closeable) { - try { - ((Closeable)ds).close(); - } catch (IOException e) { - LOGGER.warn(e.getMessage()); - } - } - ds = null; - monitor.deleteObservers(); - monitor.cleanup(); - } - - public boolean isInitialized() { - return initialized; - } - - protected boolean testConnection(){ - return testConnection(false); - } - - protected boolean testConnection(boolean error_level){ - Connection conn = null; - ResultSet rs = null; - Statement stmt = null; - try - { - Boolean readOnly = null; - String hostname = null; - conn = this.getConnection(); - stmt = conn.createStatement(); - rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); //("SELECT 1 FROM DUAL"); //"select BANNER from SYS.V_$VERSION" - while(rs.next()) - { - readOnly = rs.getBoolean(1); - hostname = rs.getString(2); - - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("SQL DataSource <"+getDbConnectionName() + "> connected to " + hostname + ", read-only is " + readOnly + ", tested successfully "); - } - } - - } catch (Throwable exc) { - if(error_level) { - LOGGER.error("SQL DataSource <" + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); - } else { - LOGGER.info("SQL DataSource <" + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); - } - return false; - } finally { - if(rs != null) { - try { - rs.close(); - rs = null; - } catch (SQLException e) { - } - } - if(stmt != null) { - try { - stmt.close(); - stmt = null; - } catch (SQLException e) { - } - } - if(conn !=null){ - try { - conn.close(); - conn = null; - } catch (SQLException e) { - } - } - } - return true; - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } - - @Override - public T unwrap(Class iface) throws SQLException { - return null; - } - - @SuppressWarnings("deprecation") - public void setConnectionCachingEnabled(boolean state) - { +public abstract class CachedDataSource implements DataSource, SQLExecutionMonitorObserver { + + private static final Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); + + private static final String SQL_FAILURE = "SQL FAILURE. time(ms): "; + private static final String FAILED_TO_EXECUTE = "> Failed to execute: "; + private static final String WITH_ARGUMENTS = " with arguments: "; + private static final String WITH_NO_ARGUMENTS = " with no arguments. "; + private static final String SQL_DATA_SOURCE = "SQL DataSource <"; + + + protected long connReqTimeout = 30L; + protected long dataReqTimeout = 100L; + + private final SQLExecutionMonitor monitor; + protected DataSource ds = null; + protected String connectionName = null; + protected boolean initialized = false; + + private long interval = 1000; + private long initialDelay = 5000; + private long expectedCompletionTime = 50L; + private boolean canTakeOffLine = true; + private long unprocessedFailoverThreshold = 3L; + + private long nextErrorReportTime = 0L; + + private String globalHostName = null; + + + public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { + configure(jdbcElem); + monitor = new SQLExecutionMonitor(this); + } + + protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; + + /* (non-Javadoc) + * @see javax.sql.DataSource#getConnection() + */ + @Override + public Connection getConnection() throws SQLException { + return ds.getConnection(); + } + + public CachedRowSet getData(String statement, List arguments) + throws SQLException { + TestObject testObject = monitor.registerRequest(); + + try (Connection connection = this.getConnection()) { + if (connection == null) { + throw new SQLException("Connection invalid"); + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Obtained connection <" + connectionName + ">: " + connection.toString()); + } + return executePreparedStatement(connection, statement, arguments, true); + } finally { + monitor.deregisterRequest(testObject); + } + } + + public boolean writeData(String statement, List arguments) + throws SQLException { + TestObject testObject = monitor.registerRequest(); + + try (Connection connection = this.getConnection()) { + if (connection == null) { + throw new SQLException("Connection invalid"); + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Obtained connection <" + connectionName + ">: " + connection.toString()); + } + return executeUpdatePreparedStatement(connection, statement, arguments, true); + } finally { + monitor.deregisterRequest(testObject); + } + } + + CachedRowSet executePreparedStatement(Connection conn, String statement, + List arguments, boolean close) throws SQLException { + long time = System.currentTimeMillis(); + + CachedRowSet data = null; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL Statement: " + statement); + if (arguments != null && !arguments.isEmpty()) { + LOGGER.debug("Argunments: " + Arrays.toString(arguments.toArray())); + } + } + + ResultSet rs = null; + try (PreparedStatement ps = conn.prepareStatement(statement)) { + data = RowSetProvider.newFactory().createCachedRowSet(); + if (arguments != null) { + for (int i = 0, max = arguments.size(); i < max; i++) { + ps.setObject(i + 1, arguments.get(i)); + } + } + rs = ps.executeQuery(); + data.populate(rs); + // Point the rowset Cursor to the start + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL SUCCESS. rows returned: " + data.size() + ", time(ms): " + (System.currentTimeMillis() + - time)); + } + } catch (SQLException exc) { + handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); + } finally { + handleFinallyBlockForExecutePreparedStatement(rs, conn, close); + } + + return data; + } + + private void handleSqlExceptionForExecuteStatement(Connection conn, String statement, + List arguments, SQLException exc, long time) throws SQLException { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(SQL_FAILURE + (System.currentTimeMillis() - time)); + } + try { + conn.rollback(); + } catch (Exception thr) { + LOGGER.error(thr.getLocalizedMessage(), thr); + } + if (arguments != null && !arguments.isEmpty()) { + LOGGER.error(String.format("<%s%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_ARGUMENTS, + arguments.toString()), exc); + } else { + LOGGER.error(String.format("<%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_NO_ARGUMENTS), + exc); + } + throw exc; + } + + private void handleFinallyBlockForExecutePreparedStatement(ResultSet rs, Connection conn, boolean close) { + try { + if (rs != null) { + rs.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + try { + if (conn != null && close) { + conn.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + } + + boolean executeUpdatePreparedStatement(Connection conn, String statement, List arguments, + boolean close) throws SQLException { + long time = System.currentTimeMillis(); + + CachedRowSet data; + + try (PreparedStatement ps = conn.prepareStatement(statement)) { + data = RowSetProvider.newFactory().createCachedRowSet(); + if (arguments != null) { + prepareStatementForExecuteUpdate(arguments, ps); + } + ps.executeUpdate(); + // Point the rowset Cursor to the start + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL SUCCESS. rows returned: " + data.size() + ", time(ms): " + (System.currentTimeMillis() + - time)); + } + ps.close(); + } catch (SQLException exc) { + handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); + } finally { + try { + if (close) { + conn.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + } + + return true; + } + + private void prepareStatementForExecuteUpdate(List arguments, PreparedStatement ps) + throws SQLException { + for (int i = 0, max = arguments.size(); i < max; i++) { + Object value = arguments.get(i); + if (value instanceof Blob) { + ps.setBlob(i + 1, (Blob) value); + } else if (value instanceof Timestamp) { + ps.setTimestamp(i + 1, (Timestamp) value); + } else if (value instanceof Integer) { + ps.setInt(i + 1, (Integer) value); + } else if (value instanceof Long) { + ps.setLong(i + 1, (Long) value); + } else if (value instanceof Date) { + ps.setDate(i + 1, (Date) value); + } else { + ps.setObject(i + 1, value); + } + } + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) + */ + @Override + public Connection getConnection(String username, String password) + throws SQLException { + return ds.getConnection(username, password); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getLogWriter() + */ + @Override + public PrintWriter getLogWriter() throws SQLException { + return ds.getLogWriter(); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#getLoginTimeout() + */ + @Override + public int getLoginTimeout() throws SQLException { + return ds.getLoginTimeout(); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) + */ + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + ds.setLogWriter(out); + } + + /* (non-Javadoc) + * @see javax.sql.DataSource#setLoginTimeout(int) + */ + @Override + public void setLoginTimeout(int seconds) throws SQLException { + ds.setLoginTimeout(seconds); + } + + + @Override + public final String getDbConnectionName() { + return connectionName; + } + + protected final void setDbConnectionName(String name) { + this.connectionName = name; + } + + public void cleanUp() { + if (ds != null && ds instanceof Closeable) { + try { + ((Closeable) ds).close(); + } catch (IOException e) { + LOGGER.warn(e.getMessage()); + } + } + ds = null; + monitor.deleteObservers(); + monitor.cleanup(); + } + + public boolean isInitialized() { + return initialized; + } + + protected boolean testConnection() { + return testConnection(false); + } + + protected boolean testConnection(boolean errorLevel) { + ResultSet rs = null; + try (Connection conn = this.getConnection(); Statement stmt = conn.createStatement()) { + Boolean readOnly; + String hostname; + rs = stmt.executeQuery( + "SELECT @@global.read_only, @@global.hostname"); //("SELECT 1 FROM DUAL"); //"select BANNER from SYS.V_$VERSION" + while (rs.next()) { + readOnly = rs.getBoolean(1); + hostname = rs.getString(2); + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug( + SQL_DATA_SOURCE + getDbConnectionName() + "> connected to " + hostname + ", read-only is " + + readOnly + ", tested successfully "); + } + } + } catch (Exception exc) { + if (errorLevel) { + LOGGER.error( + SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } else { + LOGGER.info( + SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } + return false; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + LOGGER.error(e.getLocalizedMessage(), e); + } + } + } + return true; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @SuppressWarnings("deprecation") + public void setConnectionCachingEnabled(boolean state) { // if(ds != null && ds instanceof OracleDataSource) // try { // ((OracleDataSource)ds).setConnectionCachingEnabled(true); // } catch (SQLException exc) { // LOGGER.warn("", exc); // } - } - - public void addObserver(Observer observer) { - monitor.addObserver(observer); - } - - public void deleteObserver(Observer observer) { - monitor.deleteObserver(observer); - } - - @Override - public long getInterval() { - return interval; - } - - @Override - public long getInitialDelay() { - return initialDelay; - } - - @Override - public void setInterval(long value) { - interval = value; - } - - @Override - public void setInitialDelay(long value) { - initialDelay = value; - } - - @Override - public long getExpectedCompletionTime() { - return expectedCompletionTime; - } - - @Override - public void setExpectedCompletionTime(long value) { - expectedCompletionTime = value; - } - - @Override - public long getUnprocessedFailoverThreshold() { - return unprocessedFailoverThreshold; - } - - @Override - public void setUnprocessedFailoverThreshold(long value) { - this.unprocessedFailoverThreshold = value; - } - - public boolean canTakeOffLine() { - return canTakeOffLine; - } - - public void blockImmediateOffLine() { - canTakeOffLine = false; - final Thread offLineTimer = new Thread() - { - @Override - public void run(){ - try { - Thread.sleep(30000L); - }catch(Throwable exc){ - - }finally{ - canTakeOffLine = true; - } - } - }; - offLineTimer.setDaemon(true); - offLineTimer.start(); - } - - /** - * @return the monitor - */ - final SQLExecutionMonitor getMonitor() { - return monitor; - } - - protected boolean isSlave() throws PoolExhaustedException { - CachedRowSet rs = null; - boolean isSlave = true; - String hostname = "UNDETERMINED"; - try { - boolean localSlave = true; - rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList()); - while(rs.next()) { - localSlave = rs.getBoolean(1); - hostname = rs.getString(2); - } - isSlave = localSlave; - } catch(PoolExhaustedException peexc){ - throw peexc; - } catch (SQLException e) { - LOGGER.error("", e); - isSlave = true; - } catch (Throwable e) { - LOGGER.error("", e); - isSlave = true; - } - if(isSlave){ - LOGGER.debug("SQL SLAVE : "+connectionName + " on server " + hostname); - } else { - LOGGER.debug("SQL MASTER : "+connectionName + " on server " + hostname); - } - return isSlave; - } - - public boolean isFabric() { - return false; - } - - protected boolean lockTable(Connection conn, String tableName) { - boolean retValue = false; - Statement lock = null; - try { - if(tableName != null) { - if(LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); - if("SVC_LOGIC".equals(tableName)) { - Exception e = new Exception(); - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - LOGGER.debug(sw.toString()); - } - } - lock = conn.createStatement(); - lock.execute("LOCK TABLES " + tableName + " WRITE"); - retValue = true; - } - } catch(Exception exc){ - LOGGER.error("", exc); - retValue = false; - } finally { - try { - if (lock != null) { - lock.close(); - } - } catch(Exception exc) { - - } - } - return retValue; - } - - protected boolean unlockTable(Connection conn) { - boolean retValue = false; - try (Statement lock = conn.createStatement()){ - if(LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'UNLOCK TABLES' on connection " + conn.toString()); - } - retValue = lock.execute("UNLOCK TABLES"); - } catch(Exception exc){ - LOGGER.error("", exc); - retValue = false; - } - return retValue; - } - - public void getPoolInfo(boolean allocation) { - - } - - public long getNextErrorReportTime() { - return nextErrorReportTime; - } - - public void setNextErrorReportTime(long nextTime) { - this.nextErrorReportTime = nextTime; - } - - public void setGlobalHostName(String hostname) { - this.globalHostName = hostname; - } - - public String getGlobalHostName() { - return globalHostName; - } + } + + public void addObserver(Observer observer) { + monitor.addObserver(observer); + } + + public void deleteObserver(Observer observer) { + monitor.deleteObserver(observer); + } + + @Override + public long getInterval() { + return interval; + } + + @Override + public long getInitialDelay() { + return initialDelay; + } + + @Override + public void setInterval(long value) { + interval = value; + } + + @Override + public void setInitialDelay(long value) { + initialDelay = value; + } + + @Override + public long getExpectedCompletionTime() { + return expectedCompletionTime; + } + + @Override + public void setExpectedCompletionTime(long value) { + expectedCompletionTime = value; + } + + @Override + public long getUnprocessedFailoverThreshold() { + return unprocessedFailoverThreshold; + } + + @Override + public void setUnprocessedFailoverThreshold(long value) { + this.unprocessedFailoverThreshold = value; + } + + public boolean canTakeOffLine() { + return canTakeOffLine; + } + + public void blockImmediateOffLine() { + canTakeOffLine = false; + final Thread offLineTimer = new Thread(() -> { + try { + Thread.sleep(30000L); + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } finally { + canTakeOffLine = true; + } + }); + offLineTimer.setDaemon(true); + offLineTimer.start(); + } + + /** + * @return the monitor + */ + final SQLExecutionMonitor getMonitor() { + return monitor; + } + + protected boolean isSlave() throws PoolExhaustedException { + CachedRowSet rs = null; + boolean isSlave = true; + String hostname = "UNDETERMINED"; + try { + boolean localSlave = true; + rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList()); + while (rs.next()) { + localSlave = rs.getBoolean(1); + hostname = rs.getString(2); + } + isSlave = localSlave; + } catch (PoolExhaustedException peexc) { + throw peexc; + } catch (Exception e) { + LOGGER.error("", e); + isSlave = true; + } + if (isSlave) { + LOGGER.debug(String.format("SQL SLAVE : %s on server %s", connectionName, hostname)); + } else { + LOGGER.debug(String.format("SQL MASTER : %s on server %s", connectionName, hostname)); + } + return isSlave; + } + + public boolean isFabric() { + return false; + } + + protected boolean lockTable(Connection conn, String tableName) { + boolean retValue = false; + String query = "LOCK TABLES " + tableName + " WRITE"; + try (Statement preStmt = conn.createStatement(); Statement lock = conn.prepareStatement(query); + ResultSet rs = preStmt.executeQuery("GETDATE()")) { + if (tableName != null) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); + if ("SVC_LOGIC".equals(tableName)) { + Exception e = new Exception(); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + LOGGER.debug(sw.toString()); + } + } + lock.execute(query); + retValue = true; + } + } catch (Exception exc) { + LOGGER.error("", exc); + retValue = false; + } + return retValue; + } + + protected boolean unlockTable(Connection conn) { + boolean retValue; + try (Statement lock = conn.createStatement()) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'UNLOCK TABLES' on connection " + conn.toString()); + } + retValue = lock.execute("UNLOCK TABLES"); + } catch (Exception exc) { + LOGGER.error("", exc); + retValue = false; + } + return retValue; + } + + public void getPoolInfo(boolean allocation) { + + } + + public long getNextErrorReportTime() { + return nextErrorReportTime; + } + + public void setNextErrorReportTime(long nextTime) { + this.nextErrorReportTime = nextTime; + } + + public void setGlobalHostName(String hostname) { + this.globalHostName = hostname; + } + + public String getGlobalHostName() { + return globalHostName; + } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java index 3ec4f2edf..ca16834c4 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java @@ -20,11 +20,7 @@ package org.onap.ccsdk.sli.core.dblib.jdbc; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLFeatureNotSupportedException; - import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.PoolProperties; import org.onap.ccsdk.sli.core.dblib.CachedDataSource; @@ -34,66 +30,61 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class JdbcDBCachedDataSource extends CachedDataSource -{ - private String dbDriver; - private String dbUserId; - private String dbPasswd; - private String dbUrl; - - private int minLimit; - private int maxLimit; - private int initialLimit; - - private static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; - - private static Logger LOGGER = LoggerFactory.getLogger(JdbcDBCachedDataSource.class); - - /** - * @param jdbcElem - */ - public JdbcDBCachedDataSource(BaseDBConfiguration jdbcElem) - { - super(jdbcElem); - } - - @Override - protected void configure(BaseDBConfiguration xmlElem) throws DBConfigException - { - BaseDBConfiguration jdbcConfig = (BaseDBConfiguration)xmlElem; - if(jdbcConfig.getConnTimeout() > 0){ - this.CONN_REQ_TIMEOUT = jdbcConfig.getConnTimeout(); - } - if(jdbcConfig.getRequestTimeout() > 0){ - this.DATA_REQ_TIMEOUT = jdbcConfig.getRequestTimeout(); - } - - // set connection pool name - String dbConnectionName = jdbcConfig.getDbConnectionName(); - super.setDbConnectionName(dbConnectionName); - // Configure the JDBC connection - dbUserId = jdbcConfig.getDbUserId(); - if (dbUserId == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); +public class JdbcDBCachedDataSource extends CachedDataSource { + + private String dbDriver; + private String dbUserId; + private String dbPasswd; + private String dbUrl; + + private int minLimit; + private int maxLimit; + private int initialLimit; + + private static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; + + private static final Logger LOGGER = LoggerFactory.getLogger(JdbcDBCachedDataSource.class); + + /** + * @param jdbcElem + */ + public JdbcDBCachedDataSource(BaseDBConfiguration jdbcElem) { + super(jdbcElem); + } + + @Override + protected void configure(BaseDBConfiguration xmlElem) throws DBConfigException { + BaseDBConfiguration jdbcConfig = xmlElem; + if (jdbcConfig.getConnTimeout() > 0) { + this.connReqTimeout = jdbcConfig.getConnTimeout(); + } + if (jdbcConfig.getRequestTimeout() > 0) { + this.dataReqTimeout = jdbcConfig.getRequestTimeout(); + } + + // set connection pool name + String dbConnectionName = jdbcConfig.getDbConnectionName(); + super.setDbConnectionName(dbConnectionName); + // Configure the JDBC connection + dbUserId = jdbcConfig.getDbUserId(); + if (dbUserId == null) { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUserId attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); throw new DBConfigException(errorMsg); } dbPasswd = jdbcConfig.getDbPasswd(); - if (dbPasswd == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); + if (dbPasswd == null) { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbPasswd attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); throw new DBConfigException(errorMsg); } dbDriver = jdbcConfig.getDriverName(); - if (dbDriver == null) - { - String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); - throw new DBConfigException(errorMsg); + if (dbDriver == null) { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbDriver attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + throw new DBConfigException(errorMsg); } minLimit = jdbcConfig.getDbMinLimit(); @@ -103,14 +94,14 @@ public class JdbcDBCachedDataSource extends CachedDataSource // LOGGER.error(AS_CONF_ERROR + errorMsg); // throw new DBConfigException(errorMsg); // } - maxLimit = jdbcConfig.getDbMaxLimit(); + maxLimit = jdbcConfig.getDbMaxLimit(); // if (maxLimit == null) // { // String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; // LOGGER.error(AS_CONF_ERROR + errorMsg); // throw new DBConfigException(errorMsg); // } - initialLimit = jdbcConfig.getDbInitialLimit(); + initialLimit = jdbcConfig.getDbInitialLimit(); // if (initialLimit == null) // { // String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; @@ -119,98 +110,86 @@ public class JdbcDBCachedDataSource extends CachedDataSource // } dbUrl = jdbcConfig.getDbUrl(); - if(dbUrl == null){ - String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; - LOGGER.error(AS_CONF_ERROR + errorMsg); + if (dbUrl == null) { + String errorMsg = "Invalid XML contents: JDBCConnection missing dbUrl attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); throw new DBConfigException(errorMsg); } - try { - Class clazz = Class.forName(dbDriver) ; - - PoolProperties p = new PoolProperties(); - p.setDriverClassName(dbDriver); - p.setUrl(dbUrl); - p.setUsername(dbUserId); - p.setPassword(dbPasswd); - p.setJmxEnabled(true); - p.setTestWhileIdle(false); - p.setTestOnBorrow(true); - p.setValidationQuery("SELECT 1"); - p.setTestOnReturn(false); - p.setValidationInterval(30000); - p.setTimeBetweenEvictionRunsMillis(30000); - p.setInitialSize(initialLimit); - p.setMaxActive(maxLimit); - p.setMaxIdle(maxLimit); - p.setMaxWait(10000); - p.setRemoveAbandonedTimeout(60); - p.setMinEvictableIdleTimeMillis(30000); - p.setMinIdle(minLimit); - p.setLogAbandoned(true); - p.setRemoveAbandoned(true); - p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" - + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"); - - DataSource dataSource = new DataSource(p); - - synchronized(this) - { - this.ds = dataSource; - Connection con = null; - PreparedStatement st = null; - ResultSet rs = null; - - initialized = true; - LOGGER.info("JdbcDBCachedDataSource <"+dbConnectionName+"> configured successfully. Using URL: "+dbUrl); - } - } catch (Exception exc) { - initialized = false; - StringBuffer sb = new StringBuffer(); - sb.append("Failed to initialize MySQLCachedDataSource <"); - sb.append(dbConnectionName).append(">. Reason: "); - sb.append(exc.getMessage()); - LOGGER.error("AS_CONF_ERROR: " + sb.toString()); + try { + + PoolProperties p = new PoolProperties(); + p.setDriverClassName(dbDriver); + p.setUrl(dbUrl); + p.setUsername(dbUserId); + p.setPassword(dbPasswd); + p.setJmxEnabled(true); + p.setTestWhileIdle(false); + p.setTestOnBorrow(true); + p.setValidationQuery("SELECT 1"); + p.setTestOnReturn(false); + p.setValidationInterval(30000); + p.setTimeBetweenEvictionRunsMillis(30000); + p.setInitialSize(initialLimit); + p.setMaxActive(maxLimit); + p.setMaxIdle(maxLimit); + p.setMaxWait(10000); + p.setRemoveAbandonedTimeout(60); + p.setMinEvictableIdleTimeMillis(30000); + p.setMinIdle(minLimit); + p.setLogAbandoned(true); + p.setRemoveAbandoned(true); + p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" + + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"); + + DataSource dataSource = new DataSource(p); + + synchronized (this) { + this.ds = dataSource; + + initialized = true; + LOGGER.info(String.format("JdbcDBCachedDataSource <%s> configured successfully. Using URL: %s", + dbConnectionName, dbUrl)); + } + } catch (Exception exc) { + initialized = false; + LOGGER.error(String.format("AS_CONF_ERROR: Failed to initialize MySQLCachedDataSource <%s>. Reason: %s", + dbConnectionName, exc.getMessage())); // throw new DBConfigException(e.getMessage()); - } + } } - public final String getDbUrl() - { - return dbUrl; - } - - public final String getDbUserId() - { - return dbUserId; - } - - public final String getDbPasswd() - { - return dbPasswd; - } - - public static JdbcDBCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { - return new JdbcDBCachedDataSource(config); - } - - public String toString(){ - return getDbConnectionName(); - } - - public java.util.logging.Logger getParentLogger() - throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub - return null; - } - - public void cleanUp(){ - DataSource dataSource = (DataSource)ds; - dataSource.getPool().purge(); - int active = dataSource.getActive(); - int size = dataSource.getSize(); - dataSource.close(true); - super.cleanUp(); - } + public final String getDbUrl() { + return dbUrl; + } + + public final String getDbUserId() { + return dbUserId; + } + + public final String getDbPasswd() { + return dbPasswd; + } + + public static JdbcDBCachedDataSource createInstance(BaseDBConfiguration config) /*throws Exception*/ { + return new JdbcDBCachedDataSource(config); + } + + public String toString() { + return getDbConnectionName(); + } + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void cleanUp() { + DataSource dataSource = (DataSource) ds; + dataSource.getPool().purge(); + dataSource.close(true); + super.cleanUp(); + } } -- cgit 1.2.3-korg From 37d6468cc670045ab4ff1ee23315739a429aa5e3 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 21 Sep 2017 16:07:02 -0400 Subject: Install sdnc-core utils as karaf package New utils jar was added in another change, but wasn't bundled as a karaf feature and was not being installed in container. This broke odlsli docker container. This change wraps that util package as a new feature (sdnc-core-utils). Change-Id: Ie8c1d608e2c67aa1635837bc400cec942761c81c Issue-ID: CCSDK-54 Signed-off-by: Dan Timoney --- dblib/provider/pom.xml | 2 +- pom.xml | 2 +- utils/features/pom.xml | 138 +++++++++++++++++++++ utils/features/src/main/resources/features.xml | 16 +++ utils/installer/pom.xml | 138 +++++++++++++++++++++ .../src/assembly/assemble_installer_zip.xml | 39 ++++++ .../src/assembly/assemble_mvnrepo_zip.xml | 29 +++++ .../src/main/resources/scripts/install-feature.sh | 19 +++ utils/pom.xml | 105 ++++++++++------ utils/provider/pom.xml | 56 +++++++++ .../ccsdk/sli/core/utils/DefaultFileResolver.java | 61 +++++++++ .../ccsdk/sli/core/utils/EnvVarFileResolver.java | 70 +++++++++++ .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 74 +++++++++++ .../sli/core/utils/KarafRootFileResolver.java | 63 ++++++++++ .../sli/core/utils/PropertiesFileResolver.java | 45 +++++++ .../core/utils/dblib/DblibDefaultFileResolver.java | 17 +++ .../core/utils/dblib/DblibEnvVarFileResolver.java | 15 +++ .../ccsdk/sli/core/utils/JREFileResolverTest.java | 15 +++ .../sli/core/utils/KarafRootFileResolverTest.java | 14 +++ .../utils/dblib/DblibDefaultFileResolverTest.java | 25 ++++ .../utils/dblib/DblibEnvVarFileResolverTest.java | 24 ++++ .../ccsdk/sli/core/utils/DefaultFileResolver.java | 61 --------- .../ccsdk/sli/core/utils/EnvVarFileResolver.java | 70 ----------- .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 74 ----------- .../sli/core/utils/KarafRootFileResolver.java | 63 ---------- .../sli/core/utils/PropertiesFileResolver.java | 45 ------- .../core/utils/dblib/DblibDefaultFileResolver.java | 17 --- .../core/utils/dblib/DblibEnvVarFileResolver.java | 15 --- .../ccsdk/sli/core/utils/JREFileResolverTest.java | 15 --- .../sli/core/utils/KarafRootFileResolverTest.java | 14 --- .../utils/dblib/DblibDefaultFileResolverTest.java | 25 ---- .../utils/dblib/DblibEnvVarFileResolverTest.java | 24 ---- 32 files changed, 924 insertions(+), 466 deletions(-) create mode 100755 utils/features/pom.xml create mode 100755 utils/features/src/main/resources/features.xml create mode 100755 utils/installer/pom.xml create mode 100755 utils/installer/src/assembly/assemble_installer_zip.xml create mode 100755 utils/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 utils/installer/src/main/resources/scripts/install-feature.sh mode change 100644 => 100755 utils/pom.xml create mode 100644 utils/provider/pom.xml create mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java create mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java create mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java create mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java create mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java create mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java create mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java create mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java create mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java create mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java create mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java delete mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java delete mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java delete mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java delete mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java delete mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java delete mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java delete mode 100644 utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java delete mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java delete mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java delete mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java delete mode 100644 utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index ad1cc9d28..6d4d93239 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -58,7 +58,7 @@ org.onap.ccsdk.sli.core - utils + utils-provider ${project.version} diff --git a/pom.xml b/pom.xml index a36918109..efbe2738a 100755 --- a/pom.xml +++ b/pom.xml @@ -109,12 +109,12 @@ + utils dblib sli filters sliPluginUtils sliapi - utils ONAP diff --git a/utils/features/pom.xml b/utils/features/pom.xml new file mode 100755 index 000000000..6871d8eb9 --- /dev/null +++ b/utils/features/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + + utils + org.onap.ccsdk.sli.core + 0.1.2-SNAPSHOT + + utils-features + DBLIB Adaptor - Features + + jar + + + + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + + + + commons-lang + commons-lang + 2.6 + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + + + org.opendaylight.odlparent + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/utils/features/src/main/resources/features.xml b/utils/features/src/main/resources/features.xml new file mode 100755 index 000000000..409f8c485 --- /dev/null +++ b/utils/features/src/main/resources/features.xml @@ -0,0 +1,16 @@ + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + + odl-mdsal-broker + mvn:org.onap.ccsdk.sli.core/util-provider/${project.version} + + + diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml new file mode 100755 index 000000000..b6f7f825c --- /dev/null +++ b/utils/installer/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + + utils + org.onap.ccsdk.sli.core + 0.1.2-SNAPSHOT + + utils-installer + SLI core utils - Karaf Installer + pom + + + sdnc-core-utils + sdnc-core-utils + mvn:org.onap.ccsdk.sli.core/utils-features/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.core + utils-features + ${project.version} + features + xml + + + * + * + + + + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli,org.apache.tomcat + sli-common,sli-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/utils/installer/src/assembly/assemble_installer_zip.xml b/utils/installer/src/assembly/assemble_installer_zip.xml new file mode 100755 index 000000000..a6a22a9ba --- /dev/null +++ b/utils/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,39 @@ + + + + bin + + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/utils/installer/src/assembly/assemble_mvnrepo_zip.xml b/utils/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100755 index 000000000..d96c9f402 --- /dev/null +++ b/utils/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,29 @@ + + + + bin + + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/utils/installer/src/main/resources/scripts/install-feature.sh b/utils/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..16b5be8c4 --- /dev/null +++ b/utils/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/utils/pom.xml b/utils/pom.xml old mode 100644 new mode 100755 index 93326a9dc..cf7dbc50f --- a/utils/pom.xml +++ b/utils/pom.xml @@ -1,56 +1,79 @@ - - + org.onap.ccsdk.sli.core ccsdk-sli-core 0.1.2-SNAPSHOT + 4.0.0 - bundle + pom + org.onap.ccsdk.sli.core utils - SLI Core Utilities Package - - - The SLI Core Utilities Package provides common functionality for setting up SLI connectivity. - - - - - com.google.guava - guava - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - - - org.mockito - mockito-core - test - - - junit - junit - test - - + + + SLI Utils + Utilities used across sli-core + + 0.1.2-SNAPSHOT - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - - + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compile.plugin.version} + + ${java.version.source} + ${java.version.target} + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10 + + + + aggregate + + aggregate + + site + + + + + + maven-source-plugin + 2.1.1 + + + bundle-sources + package + + + jar-no-fork + + + test-jar-no-fork + + + + + + + - Inocybe Technologies and Others + AT&T + + provider + features + installer + diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml new file mode 100644 index 000000000..41527f0e4 --- /dev/null +++ b/utils/provider/pom.xml @@ -0,0 +1,56 @@ + + + + + org.onap.ccsdk.sli.core + ccsdk-sli-core + 0.1.2-SNAPSHOT + + + 4.0.0 + bundle + utils-provider + SLI Core Utilities Package + + + The SLI Core Utilities Package provides common functionality for setting up SLI connectivity. + + + + + com.google.guava + guava + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + + + org.mockito + mockito-core + test + + + junit + junit + test + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + + + + + Inocybe Technologies and Others + + diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java new file mode 100644 index 000000000..8938aa6e7 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; + +/** + * Resolves dblib properties files relative to the default file path. In Unix, this is represented by: + * /opt/sdnc/data/properties + */ +public abstract class DefaultFileResolver implements PropertiesFileResolver { + + private final String successMessage; + + private final Path propertyPath; + + public DefaultFileResolver(final String successMessage, final Path propertyPath) { + this.successMessage = successMessage; + this.propertyPath = propertyPath; + } + + /** + * Parse a properties file location based on the default properties location + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + final File fileFromDefaultDblibDir = propertyPath.resolve(filename).toFile(); + if (fileFromDefaultDblibDir.exists()) { + return Optional.of(fileFromDefaultDblibDir); + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java new file mode 100644 index 000000000..3e438d1a9 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import com.google.common.base.Strings; + +import java.io.File; +import java.nio.file.Paths; +import java.util.Optional; + +/** + * Resolves dblib properties files relative to the directory identified by the SDNC_CONFIG_DIR + * environment variable. + */ +public abstract class EnvVarFileResolver implements PropertiesFileResolver { + + /** + * Key for environment variable representing the configuration directory + */ + private final String propertyKey; + + private final String successMessage; + + public EnvVarFileResolver(final String successMessage, final String propertyKey) { + this.successMessage = successMessage; + this.propertyKey = propertyKey; + } + + /** + * Parse a properties file location based on System environment variable + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + // attempt to resolve the property directory from the corresponding environment variable + final String propDirectoryFromEnvVariable = System.getenv(propertyKey); + final File fileFromEnvVariable; + if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { + fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(filename).toFile(); + if(fileFromEnvVariable.exists()) { + return Optional.of(fileFromEnvVariable); + } + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} 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 new file mode 100644 index 000000000..5cd6c3606 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import java.io.File; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; +import org.osgi.framework.FrameworkUtil; + +/** + * Resolves dblib properties files relative to the directory identified by the JRE property + * dblib.properties. + */ +public class JREFileResolver implements PropertiesFileResolver { + + /** + * Key for JRE argument representing the configuration directory + */ + private static final String DBLIB_JRE_PROPERTY_KEY = "dblib.properties"; + + private final String successMessage; + private final Class clazz; + + public JREFileResolver(final String successMessage, final Class clazz) { + this.successMessage = successMessage; + this.clazz = clazz; + } + + /** + * Parse a properties file location based on JRE argument + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + final URL jreArgumentUrl = FrameworkUtil.getBundle(this.clazz) + .getResource(DBLIB_JRE_PROPERTY_KEY); + try { + if (jreArgumentUrl == null) { + return Optional.empty(); + } + final Path dblibPath = Paths.get(jreArgumentUrl.toURI()); + return Optional.of(dblibPath.resolve(filename).toFile()); + } catch(final URISyntaxException e) { + return Optional.empty(); + } + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java new file mode 100644 index 000000000..0cb754504 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import java.io.File; +import java.net.URL; +import java.util.Optional; + +/** + * Resolves dblib properties files relative to the karaf root directory. + */ +public class KarafRootFileResolver implements PropertiesFileResolver { + + final Object provider; + + private final String successMessage; + + public KarafRootFileResolver(final String successMessage, final Object provider) { + this.successMessage = successMessage; + this.provider = provider; + } + + /** + * Parse a properties file location relative to the karaf root + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + final URL fromKarafRoot = provider.getClass().getResource(filename); + if (fromKarafRoot != null) { + final File propertiesFile = new File(fromKarafRoot.getFile()); + if (propertiesFile.exists()) { + return Optional.of(propertiesFile); + } + return Optional.empty(); + } + return Optional.empty(); + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java new file mode 100644 index 000000000..bfb417dca --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils; + +import java.io.File; +import java.util.Optional; + +/** + * Strategy for resolving dblib properties. + */ +public interface PropertiesFileResolver { + + /** + * Resolve dblib properties file. + * + * @param filename the name of the file to look for at the specific location. + * @return An optional File or empty. + */ + Optional resolveFile(final String filename); + + /** + * A success message, used only for logging now. + * + * @return a success message, used only for logging now. + */ + String getSuccessfulResolutionMessage(); +} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java new file mode 100644 index 000000000..56b4ca1b6 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java @@ -0,0 +1,17 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import java.nio.file.Path; +import java.nio.file.Paths; +import org.onap.ccsdk.sli.core.utils.DefaultFileResolver; + +public class DblibDefaultFileResolver extends DefaultFileResolver { + + /** + * Default path to look for the configuration directory + */ + private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("opt", "sdnc", "data", "properties"); + + public DblibDefaultFileResolver(final String successMessage) { + super(successMessage, DEFAULT_DBLIB_PROP_DIR); + } +} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java new file mode 100644 index 000000000..9eef4cee2 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java @@ -0,0 +1,15 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import org.onap.ccsdk.sli.core.utils.EnvVarFileResolver; + +public class DblibEnvVarFileResolver extends EnvVarFileResolver { + + /** + * Key for environment variable representing the configuration directory + */ + private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; + + public DblibEnvVarFileResolver(final String successMessage) { + super(successMessage, SDNC_CONFIG_DIR_PROP_KEY); + } +} diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java new file mode 100644 index 000000000..e5051d65a --- /dev/null +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java @@ -0,0 +1,15 @@ +package org.onap.ccsdk.sli.core.utils; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class JREFileResolverTest { + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new JREFileResolver("success", JREFileResolverTest.class); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java new file mode 100644 index 000000000..5e407daf6 --- /dev/null +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.utils; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class KarafRootFileResolverTest { + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new KarafRootFileResolver("success", null); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java new file mode 100644 index 000000000..4b28d449d --- /dev/null +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java @@ -0,0 +1,25 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class DblibDefaultFileResolverTest { + + @Test + public void resolveFile() throws Exception { + final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java new file mode 100644 index 000000000..bae4168d8 --- /dev/null +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.sli.core.utils.dblib; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class DblibEnvVarFileResolverTest { + @Test + public void resolveFile() throws Exception { + final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java deleted file mode 100644 index 8938aa6e7..000000000 --- a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.utils; - -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; - -/** - * Resolves dblib properties files relative to the default file path. In Unix, this is represented by: - * /opt/sdnc/data/properties - */ -public abstract class DefaultFileResolver implements PropertiesFileResolver { - - private final String successMessage; - - private final Path propertyPath; - - public DefaultFileResolver(final String successMessage, final Path propertyPath) { - this.successMessage = successMessage; - this.propertyPath = propertyPath; - } - - /** - * Parse a properties file location based on the default properties location - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - final File fileFromDefaultDblibDir = propertyPath.resolve(filename).toFile(); - if (fileFromDefaultDblibDir.exists()) { - return Optional.of(fileFromDefaultDblibDir); - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java deleted file mode 100644 index 3e438d1a9..000000000 --- a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.utils; - -import com.google.common.base.Strings; - -import java.io.File; -import java.nio.file.Paths; -import java.util.Optional; - -/** - * Resolves dblib properties files relative to the directory identified by the SDNC_CONFIG_DIR - * environment variable. - */ -public abstract class EnvVarFileResolver implements PropertiesFileResolver { - - /** - * Key for environment variable representing the configuration directory - */ - private final String propertyKey; - - private final String successMessage; - - public EnvVarFileResolver(final String successMessage, final String propertyKey) { - this.successMessage = successMessage; - this.propertyKey = propertyKey; - } - - /** - * Parse a properties file location based on System environment variable - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - // attempt to resolve the property directory from the corresponding environment variable - final String propDirectoryFromEnvVariable = System.getenv(propertyKey); - final File fileFromEnvVariable; - if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { - fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(filename).toFile(); - if(fileFromEnvVariable.exists()) { - return Optional.of(fileFromEnvVariable); - } - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java deleted file mode 100644 index 5cd6c3606..000000000 --- a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.utils; - -import java.io.File; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; -import org.osgi.framework.FrameworkUtil; - -/** - * Resolves dblib properties files relative to the directory identified by the JRE property - * dblib.properties. - */ -public class JREFileResolver implements PropertiesFileResolver { - - /** - * Key for JRE argument representing the configuration directory - */ - private static final String DBLIB_JRE_PROPERTY_KEY = "dblib.properties"; - - private final String successMessage; - private final Class clazz; - - public JREFileResolver(final String successMessage, final Class clazz) { - this.successMessage = successMessage; - this.clazz = clazz; - } - - /** - * Parse a properties file location based on JRE argument - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - final URL jreArgumentUrl = FrameworkUtil.getBundle(this.clazz) - .getResource(DBLIB_JRE_PROPERTY_KEY); - try { - if (jreArgumentUrl == null) { - return Optional.empty(); - } - final Path dblibPath = Paths.get(jreArgumentUrl.toURI()); - return Optional.of(dblibPath.resolve(filename).toFile()); - } catch(final URISyntaxException e) { - return Optional.empty(); - } - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java deleted file mode 100644 index 0cb754504..000000000 --- a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.utils; - -import java.io.File; -import java.net.URL; -import java.util.Optional; - -/** - * Resolves dblib properties files relative to the karaf root directory. - */ -public class KarafRootFileResolver implements PropertiesFileResolver { - - final Object provider; - - private final String successMessage; - - public KarafRootFileResolver(final String successMessage, final Object provider) { - this.successMessage = successMessage; - this.provider = provider; - } - - /** - * Parse a properties file location relative to the karaf root - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - final URL fromKarafRoot = provider.getClass().getResource(filename); - if (fromKarafRoot != null) { - final File propertiesFile = new File(fromKarafRoot.getFile()); - if (propertiesFile.exists()) { - return Optional.of(propertiesFile); - } - return Optional.empty(); - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java deleted file mode 100644 index bfb417dca..000000000 --- a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.utils; - -import java.io.File; -import java.util.Optional; - -/** - * Strategy for resolving dblib properties. - */ -public interface PropertiesFileResolver { - - /** - * Resolve dblib properties file. - * - * @param filename the name of the file to look for at the specific location. - * @return An optional File or empty. - */ - Optional resolveFile(final String filename); - - /** - * A success message, used only for logging now. - * - * @return a success message, used only for logging now. - */ - String getSuccessfulResolutionMessage(); -} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java deleted file mode 100644 index 56b4ca1b6..000000000 --- a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.dblib; - -import java.nio.file.Path; -import java.nio.file.Paths; -import org.onap.ccsdk.sli.core.utils.DefaultFileResolver; - -public class DblibDefaultFileResolver extends DefaultFileResolver { - - /** - * Default path to look for the configuration directory - */ - private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("opt", "sdnc", "data", "properties"); - - public DblibDefaultFileResolver(final String successMessage) { - super(successMessage, DEFAULT_DBLIB_PROP_DIR); - } -} diff --git a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java b/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java deleted file mode 100644 index 9eef4cee2..000000000 --- a/utils/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.dblib; - -import org.onap.ccsdk.sli.core.utils.EnvVarFileResolver; - -public class DblibEnvVarFileResolver extends EnvVarFileResolver { - - /** - * Key for environment variable representing the configuration directory - */ - private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; - - public DblibEnvVarFileResolver(final String successMessage) { - super(successMessage, SDNC_CONFIG_DIR_PROP_KEY); - } -} diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java deleted file mode 100644 index e5051d65a..000000000 --- a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.onap.ccsdk.sli.core.utils; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class JREFileResolverTest { - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new JREFileResolver("success", JREFileResolverTest.class); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java deleted file mode 100644 index 5e407daf6..000000000 --- a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.onap.ccsdk.sli.core.utils; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class KarafRootFileResolverTest { - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new KarafRootFileResolver("success", null); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java deleted file mode 100644 index 4b28d449d..000000000 --- a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.dblib; - -import static org.junit.Assert.*; - -import java.io.File; -import java.util.Optional; -import org.junit.Test; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; - -public class DblibDefaultFileResolverTest { - - @Test - public void resolveFile() throws Exception { - final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java b/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java deleted file mode 100644 index bae4168d8..000000000 --- a/utils/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.dblib; - -import static org.junit.Assert.*; - -import java.io.File; -import java.util.Optional; -import org.junit.Test; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; - -public class DblibEnvVarFileResolverTest { - @Test - public void resolveFile() throws Exception { - final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file -- cgit 1.2.3-korg From b428ca0261f0333757d114680fb1efa0f424a781 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Fri, 22 Sep 2017 16:40:30 +0530 Subject: Add "@Override" annotation Added @Override annotation before method signature *This is to improve the readability of code Issue-Id: CCSDK-87 Change-Id: I979eb03ec81b9868012e5c16f48b595c8e53e26e Signed-off-by: surya-huawei --- .../main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java index 95172ad7a..b6664f3c3 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java @@ -55,6 +55,7 @@ public class SQLExecutionMonitor extends Observable { private final class MonitoringTask extends TimerTask { + @Override public void run() { try { TestObject testObj = new TestObject(); @@ -103,6 +104,7 @@ public class SQLExecutionMonitor extends Observable { startTime = newTime; } + @Override public int compareTo(TestObject o) { if (this == o) { return 0; -- cgit 1.2.3-korg From bac4dbe402cc81409d210a2dabd25847a12b6a36 Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Fri, 22 Sep 2017 09:41:20 -0700 Subject: Changes to fix failing utils feature Change-Id: I88d30aaf49da78008c62352d398323fbc0d4dd5b Signed-off-by: Patrick Brady Issue-id: CCSDK-102 --- utils/features/src/main/resources/features.xml | 2 +- utils/installer/pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/features/src/main/resources/features.xml b/utils/features/src/main/resources/features.xml index 409f8c485..547832ba6 100755 --- a/utils/features/src/main/resources/features.xml +++ b/utils/features/src/main/resources/features.xml @@ -10,7 +10,7 @@ odl-mdsal-broker - mvn:org.onap.ccsdk.sli.core/util-provider/${project.version} + mvn:org.onap.ccsdk.sli.core/utils-provider/${project.version} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index b6f7f825c..3af9a5866 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -11,8 +11,8 @@ pom - sdnc-core-utils - sdnc-core-utils + sdnc-slicore-utils + sdnc-slicore-utils mvn:org.onap.ccsdk.sli.core/utils-features/${project.version}/xml/features false -- cgit 1.2.3-korg From 025e0ac819afe9ab5e05c7c75420814ff881ad03 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Sat, 23 Sep 2017 22:28:03 +0530 Subject: Some minor refinements in CCSDK SLI Core module Fix few Critical/Major sonar issues in CCSDK SLI Core module * Define and throw a dedicated exception instead of using a generic one * Either log or rethrow the exception * Change "try" to a try-with-resources * Remove useless assignment to local variable * Use built-in logger method string formatting instead of string concatination * code indentation Change-Id: I83dc1fb931b8021118e259c722f7dfbc1621dce8 Issue-Id: CCSDK-67 Signed-off-by: Ramu N --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 356f5ee8b..d2331786e 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -7,9 +7,9 @@ * 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. @@ -33,7 +33,6 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Observer; import javax.sql.DataSource; @@ -109,7 +108,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito throw new SQLException("Connection invalid"); } if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Obtained connection <" + connectionName + ">: " + connection.toString()); + LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); } return executePreparedStatement(connection, statement, arguments, true); } finally { @@ -126,7 +125,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito throw new SQLException("Connection invalid"); } if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Obtained connection <" + connectionName + ">: " + connection.toString()); + LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); } return executeUpdatePreparedStatement(connection, statement, arguments, true); } finally { @@ -140,9 +139,9 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito CachedRowSet data = null; if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL Statement: " + statement); + LOGGER.debug("SQL Statement: {}", statement); if (arguments != null && !arguments.isEmpty()) { - LOGGER.debug("Argunments: " + Arrays.toString(arguments.toArray())); + LOGGER.debug("Argunments: {}", arguments); } } @@ -158,7 +157,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito data.populate(rs); // Point the rowset Cursor to the start if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL SUCCESS. rows returned: " + data.size() + ", time(ms): " + (System.currentTimeMillis() + LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), (System.currentTimeMillis() - time)); } } catch (SQLException exc) { @@ -182,7 +181,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } if (arguments != null && !arguments.isEmpty()) { LOGGER.error(String.format("<%s%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_ARGUMENTS, - arguments.toString()), exc); + arguments), exc); } else { LOGGER.error(String.format("<%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_NO_ARGUMENTS), exc); @@ -221,7 +220,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito ps.executeUpdate(); // Point the rowset Cursor to the start if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL SUCCESS. rows returned: " + data.size() + ", time(ms): " + (System.currentTimeMillis() + LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), (System.currentTimeMillis() - time)); } ps.close(); @@ -465,12 +464,12 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } protected boolean isSlave() throws PoolExhaustedException { - CachedRowSet rs = null; - boolean isSlave = true; + CachedRowSet rs; + boolean isSlave; String hostname = "UNDETERMINED"; try { boolean localSlave = true; - rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList()); + rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList<>()); while (rs.next()) { localSlave = rs.getBoolean(1); hostname = rs.getString(2); @@ -483,9 +482,9 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito isSlave = true; } if (isSlave) { - LOGGER.debug(String.format("SQL SLAVE : %s on server %s", connectionName, hostname)); + LOGGER.debug("SQL SLAVE : {} on server {}", connectionName, hostname); } else { - LOGGER.debug(String.format("SQL MASTER : %s on server %s", connectionName, hostname)); + LOGGER.debug("SQL MASTER : {} on server {}", connectionName, hostname); } return isSlave; } @@ -524,7 +523,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito boolean retValue; try (Statement lock = conn.createStatement()) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'UNLOCK TABLES' on connection " + conn.toString()); + LOGGER.debug("Executing 'UNLOCK TABLES' on connection {}", conn); } retValue = lock.execute("UNLOCK TABLES"); } catch (Exception exc) { -- cgit 1.2.3-korg From 0923423a42c94993d79d342c6679905e80346b29 Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Mon, 25 Sep 2017 12:58:52 +0530 Subject: Fixes for SvcLogicActivator 1. Convert tabs to 4 spaces. 2. Break lines to be less than 120 characters 3. Remove extraneous spaces/parenthesis & redundant assignments. 4. Use logger built-in string format. 5. Fix critical sonar issues. https://sonar.onap.org/component_issues/index?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#resolved=false|severities=CRITICAL Change-Id: Idb348f125e92f0e9be30847c41b385411220fd96 Issue-Id: CCSDK-67 Signed-off-by: Gaurav Agrawal --- .../sli/core/sli/provider/SvcLogicActivator.java | 291 ++++++++++----------- 1 file changed, 141 insertions(+), 150 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java index a578dc6ae..7c1fa8e44 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java @@ -3,7 +3,7 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import java.util.Hashtable; import java.util.LinkedList; import java.util.Map; import java.util.Properties; - import org.onap.ccsdk.sli.core.sli.ConfigurationException; import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -44,180 +43,172 @@ import org.slf4j.LoggerFactory; public class SvcLogicActivator implements BundleActivator { - private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - - private static final Map BUILTIN_NODES = new HashMap() { - { - put("block", new BlockNodeExecutor()); - put("call", new CallNodeExecutor()); - put("configure", new ConfigureNodeExecutor()); - put("delete", new DeleteNodeExecutor()); - put("execute", new ExecuteNodeExecutor()); - put("exists", new ExistsNodeExecutor()); - put("for", new ForNodeExecutor()); - put("get-resource", new GetResourceNodeExecutor()); - put("is-available", new IsAvailableNodeExecutor()); - put("notify", new NotifyNodeExecutor()); - put("record", new RecordNodeExecutor()); - put("release", new ReleaseNodeExecutor()); - put("reserve", new ReserveNodeExecutor()); - put("return", new ReturnNodeExecutor()); - put("save", new SaveNodeExecutor()); - put("set", new SetNodeExecutor()); - put("switch", new SwitchNodeExecutor()); - put("update", new UpdateNodeExecutor()); + private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); put("break", new BreakNodeExecutor()); - } - }; - - private static LinkedList registrations = new LinkedList(); - - private static HashMap adaptorMap = null; - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicActivator.class); - - private static Properties props = null; - - private static BundleContext bundleCtx = null; - - private static SvcLogicService svcLogicServiceImpl = null; - - @Override - public void start(BundleContext ctx) throws Exception { - - LOG.info("Activating SLI"); - - bundleCtx = ctx; - - // Read properties - props = new Properties(); - String propPath = System.getenv(SVCLOGIC_PROP_VAR); - - if (propPath == null) { - String propDir = System.getenv(SDNC_CONFIG_DIR); - if (propDir == null) { - - propDir = "/opt/sdnc/data/properties"; - } - propPath = propDir + "/svclogic.properties"; - LOG.warn("Environment variable "+SVCLOGIC_PROP_VAR+" unset - defaulting to "+propPath); - } - - File propFile = new File(propPath); - - if (!propFile.exists()) { - - throw new ConfigurationException( - "Missing configuration properties file : " - + propFile); - } - try { - - props.load(new FileInputStream(propFile)); - } catch (Exception e) { - throw new ConfigurationException( - "Could not load properties file " + propPath, e); + } + }; - } + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicActivator.class); + private static LinkedList registrations = new LinkedList<>(); - if (registrations == null) { + private static HashMap adaptorMap; - registrations = new LinkedList(); - } + private static Properties props; - // Advertise SvcLogicService - svcLogicServiceImpl = new SvcLogicServiceImpl(); + private static BundleContext bundleCtx; - LOG.info("SLI: Registering service " + SvcLogicService.NAME - + " in bundle " + ctx.getBundle().getSymbolicName()); - ServiceRegistration reg = ctx.registerService(SvcLogicService.NAME, - svcLogicServiceImpl, null); - registrations.add(reg); + private static SvcLogicService svcLogicServiceImpl; - // Initialize SvcLogicStore - try { - SvcLogicStore store = getStore(); - registerNodeTypes(store); - } catch (ConfigurationException e) { - LOG.warn("Could not initialize SvcLogicScore", e); - } + @Override + public void start(BundleContext ctx) throws Exception { - LOG.info("SLI - done registering services"); - } + LOG.info("Activating SLI"); - @Override - public void stop(BundleContext ctx) throws Exception { + synchronized (SvcLogicActivator.class) { + bundleCtx = ctx; + props = new Properties(); + } - if (registrations != null) { - for (ServiceRegistration reg : registrations) { - ServiceReference regRef = reg.getReference(); - /* Don't bother to remove node types from table - String nodeType = (String) regRef.getProperty("nodeType"); - if (nodeType != null) { - LOG.info("SLI - unregistering node type " + nodeType); - store.unregisterNodeType(nodeType); - } - */ - reg.unregister(); - } - registrations = null; - } - } + // Read properties + String propPath = System.getenv(SVCLOGIC_PROP_VAR); - public static SvcLogicStore getStore() throws SvcLogicException { - // Create and initialize SvcLogicStore object - used to access - // saved service logic. + if (propPath == null) { + String propDir = System.getenv(SDNC_CONFIG_DIR); + if (propDir == null) { - SvcLogicStore store = null; + propDir = "/opt/sdnc/data/properties"; + } + propPath = propDir + "/svclogic.properties"; + LOG.warn("Environment variable {} unset - defaulting to {}", SVCLOGIC_PROP_VAR, propPath); + } - try { - store = SvcLogicStoreFactory.getSvcLogicStore(props); - } catch (Exception e) { - throw new ConfigurationException( - "Could not get service logic store", e); + File propFile = new File(propPath); - } + if (!propFile.exists()) { + throw new ConfigurationException("Missing configuration properties file : " + propFile); + } - try { - store.init(props); - } catch (Exception e) { - throw new ConfigurationException( - "Could not get service logic store", e); - } + try { + props.load(new FileInputStream(propFile)); + } catch (Exception e) { + throw new ConfigurationException("Could not load properties file " + propPath, e); - return(store); - } + } - private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException { + synchronized (SvcLogicActivator.class) { + if (registrations == null) { + registrations = new LinkedList<>(); + } + // Advertise SvcLogicService + svcLogicServiceImpl = new SvcLogicServiceImpl(); + } - if (store == null) { - return; - } - // Advertise built-in node executors - LOG.info("SLI : Registering built-in node executors"); - Hashtable propTable = new Hashtable(); + LOG.info("SLI: Registering service {} in bundle {}", SvcLogicService.NAME, ctx.getBundle().getSymbolicName()); + ServiceRegistration reg = ctx.registerService(SvcLogicService.NAME, svcLogicServiceImpl, null); + registrations.add(reg); - for (String nodeType : BUILTIN_NODES.keySet()) { - LOG.info("SLI - registering node type " + nodeType); - propTable.clear(); - propTable.put("nodeType", nodeType); + // Initialize SvcLogicStore + try { + SvcLogicStore store = getStore(); + registerNodeTypes(store); + } catch (ConfigurationException e) { + LOG.warn("Could not initialize SvcLogicScore", e); + } - ServiceRegistration reg = bundleCtx.registerService(SvcLogicNodeExecutor.class.getName(), - BUILTIN_NODES.get(nodeType), propTable); - registrations.add(reg); + LOG.info("SLI - done registering services"); + } - store.registerNodeType(nodeType); + @Override + public void stop(BundleContext ctx) throws Exception { - LOG.info("SLI - registering node executor"); + if (registrations != null) { + for (ServiceRegistration reg : registrations) { + ServiceReference regRef = reg.getReference(); + /* Don't bother to remove node types from table + String nodeType = (String) regRef.getProperty("nodeType"); + if (nodeType != null) { + LOG.info("SLI - unregistering node type " + nodeType); + store.unregisterNodeType(nodeType); + } + */ + reg.unregister(); + } + synchronized (SvcLogicActivator.class) { + registrations = null; + } + } + } - ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + public static SvcLogicStore getStore() throws SvcLogicException { + // Create and initialize SvcLogicStore object - used to access + // saved service logic. - } + SvcLogicStore store; - } + try { + store = SvcLogicStoreFactory.getSvcLogicStore(props); + } catch (Exception e) { + throw new ConfigurationException("Could not get service logic store", e); + } + + try { + store.init(props); + } catch (Exception e) { + throw new ConfigurationException("Could not get service logic store", e); + } + + return(store); + } + + private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException { + + if (store == null) { + return; + } + // Advertise built-in node executors + LOG.info("SLI : Registering built-in node executors"); + Hashtable propTable = new Hashtable(); + + for (String nodeType : BUILTIN_NODES.keySet()) { + LOG.info("SLI - registering node type {}", nodeType); + propTable.clear(); + propTable.put("nodeType", nodeType); + + ServiceRegistration reg = bundleCtx.registerService(SvcLogicNodeExecutor.class.getName(), + BUILTIN_NODES.get(nodeType), propTable); + registrations.add(reg); + + store.registerNodeType(nodeType); + + LOG.info("SLI - registering node executor"); + + ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + + } + } } -- cgit 1.2.3-korg From a0ee49cbe032a205b5b9a3fe5536394ab3c6607c Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Mon, 25 Sep 2017 14:48:42 +0530 Subject: Remove hardcoded dependency versions Remove the hardcoded junit & common-lang version and rather take from parent pom. Change-Id: Ibc71ff4b86a2fefc89365017f06333776cb2fed3 Issue-Id: CCSDK-105 Signed-off-by: Gaurav Agrawal --- dblib/features/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- filters/provider/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/provider/pom.xml | 1 + 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 4053efaf9..e3356d8e0 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -23,7 +23,7 @@ commons-lang commons-lang - 2.6 + ${commons.lang.version} compile diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 6d4d93239..d0dc72933 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -18,7 +18,7 @@ junit junit - 4.11 + ${junit.version} test diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index e6d91c903..65f6e45a1 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -17,7 +17,7 @@ junit junit - 4.11 + ${junit.version} test diff --git a/sli/features/pom.xml b/sli/features/pom.xml index dc7a95dc1..11684bead 100755 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -27,7 +27,7 @@ commons-lang commons-lang - 2.6 + ${commons.lang.version} compile diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index f0bc09706..c2cfbee07 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -16,7 +16,7 @@ junit junit - 3.8.1 + ${junit.version} test @@ -44,7 +44,7 @@ commons-lang commons-lang - 2.6 + ${commons.lang.version} compile diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 41381b6f0..cfa86b3a4 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -22,7 +22,7 @@ commons-lang commons-lang - 2.6 + ${commons.lang.version} compile diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index d105036b3..3697b435f 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -22,7 +22,7 @@ junit junit - 4.11 + ${junit.version} test diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 6871d8eb9..dedb18e4a 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -23,7 +23,7 @@ commons-lang commons-lang - 2.6 + ${commons.lang.version} compile diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 41527f0e4..790f10105 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -37,6 +37,7 @@ junit junit + ${junit.version} test -- cgit 1.2.3-korg From 2a392e229f81a0a8228e6160ab4614a0fbc60621 Mon Sep 17 00:00:00 2001 From: "ramu.n" Date: Mon, 25 Sep 2017 16:52:45 +0530 Subject: Some minor refinements in CCSDK SLI Core module *Remove useless braces while logging exception stack trace *Register all DG nodes in SvcLogicParser Test file Change-Id: I7916bec20e36e1def15c24806da2f7e01e79bf4b Issue-Id: CCSDK-106 Signed-off-by: Ramu N --- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java | 4 ++-- .../java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index ee192d620..a33ba4767 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -385,7 +385,7 @@ public class SvcLogicParser { saxParser.parse(fileName, new SvcLogicHandler(graphs, store)); } catch (Exception e) { - LOGGER.error("Parsing failed {}", e); + LOGGER.error("Parsing failed ", e); String msg = e.getMessage(); if (msg != null) { throw new SvcLogicException("Compiler error: " + fileName + " @ " + msg); @@ -412,7 +412,7 @@ public class SvcLogicParser { try { SvcLogicParser.load(xmlfile, store); } catch (Exception e) { - LOGGER.error("Load failed {}", e); + LOGGER.error("Load failed ", e); } } else { SvcLogicParser.usage(); diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 8bf748aa4..7af4c1c5d 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -96,6 +96,13 @@ public class ITCaseSvcLogicParser { store.registerNodeType("release"); store.registerNodeType("for"); store.registerNodeType("set"); + store.registerNodeType("call"); + store.registerNodeType("delete"); + store.registerNodeType("execute"); + store.registerNodeType("notify"); + store.registerNodeType("save"); + store.registerNodeType("update"); + store.registerNodeType("break"); } @Before -- cgit 1.2.3-korg From ea256b21bd4f2565ca9ae30e737748e40aa21f23 Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Tue, 26 Sep 2017 17:19:32 +0000 Subject: Updated DBLIB svc definition Changes made: 1. updated DBLibService definition by adding javax.sql.DataSource Change-Id: I5dd63a81420f451b0ce9bbbc878d351d62ccd819 Issue-ID: CCSDK-102 Signed-off-by: Rich Tabedzki --- .../src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java index b31de3547..b30ad7bbf 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DbLibService.java @@ -24,9 +24,10 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; +import javax.sql.DataSource; import javax.sql.rowset.CachedRowSet; -public interface DbLibService { +public interface DbLibService extends DataSource { /* (non-Javadoc) * @see DataAccessor#getData(java.lang.String, java.util.ArrayList) -- cgit 1.2.3-korg From fde2515098be8db3eae61e1aa510a747dd660e10 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Mon, 25 Sep 2017 14:56:04 +0530 Subject: Use Long.toString instead Major sonar issue in sli/core module *Using static method to reduce memory and cycles Issue-Id: CCSDK-87 Change-Id: Iaf255892a4bd698934f865a707e54f8e740370ab Signed-off-by: surya-huawei --- sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 0d0faee8a..0f6ae673e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -209,7 +209,7 @@ public class MetricLogger { } private void setElapsedTime(long elapsedTime) { - MDC.put(ELAPSED_TIME, ""+elapsedTime); + MDC.put(ELAPSED_TIME, Long.toString(elapsedTime)); } public String getServer() { -- cgit 1.2.3-korg From bebf6ea5839c87799602da01b166000f8b746b86 Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Wed, 27 Sep 2017 16:13:04 +0530 Subject: Refinements to core Changes includes: 1. Simplifying the test cases. 2. Critical Sonar issue fix for MdsalHelper 3. Critical sonar issue fix for SvcLogicServiceImpl 4. Use logger in-built formatting. https://sonar.onap.org/component_issues/index?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#resolved=false|severities=CRITICAL Change-Id: Ib85637fcd2351970f8d96bf6b855db05cf7d9834 Issue-Id: CCSDK-67 Signed-off-by: Gaurav Agrawal --- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 191 ++++------ .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 2 +- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 64 +--- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 393 ++++++++++++--------- 4 files changed, 324 insertions(+), 326 deletions(-) diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 7af4c1c5d..0912ee9fb 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -28,6 +28,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; @@ -103,117 +104,81 @@ public class ITCaseSvcLogicParser { store.registerNodeType("save"); store.registerNodeType("update"); store.registerNodeType("break"); - } - - @Before - public void setUp() throws Exception { - LOG.info("before"); - } - - @After - public void tearDown() throws Exception { - LOG.info("after"); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - LOG.info("after class"); - } - - /** - * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}. - */ - @Test - public void testParseValidXml() { - - try - { - InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - String testCaseFile = null; - while ((testCaseFile = testsReader.readLine()) != null) { - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) - { - if (!testCaseFile.startsWith("/")) - { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) - { - fail("Could not resolve test case file "+testCaseFile); - } - - try { - SvcLogicParser.validate(testCaseUrl.getPath(), store); - } catch (Exception e) { - fail("Validation failure ["+e.getMessage()+"]"); - } - } - } - } - catch (SvcLogicParserException e) - { - fail("Parser error : "+e.getMessage()); - } - catch (Exception e) - { - LOG.error("", e); - fail("Caught exception processing test cases"); - } - } - - @Test - public void testParseInvalidXml() { - - try - { - InputStream testStr = getClass().getResourceAsStream("/parser-bad.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - String testCaseFile = null; - while ((testCaseFile = testsReader.readLine()) != null) { - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) - { - if (!testCaseFile.startsWith("/")) - { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) - { - fail("Could not resolve test case file "+testCaseFile); - } - - boolean valid = true; - try { - SvcLogicParser.load(testCaseUrl.getPath(), store); - } catch (Exception e) { - System.out.println(e.getMessage()); - valid = false; - } - - if (valid) { - fail("Expected compiler error on "+testCaseFile+", but got success"); - } - } - } - } - catch (SvcLogicParserException e) - { - fail("Parser error : "+e.getMessage()); - } - catch (Exception e) - { - LOG.error("", e); - fail("Caught exception processing test cases"); - } - - } - + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + LOG.info("after class"); + } + + @Before + public void setUp() throws Exception { + LOG.info("before"); + } + + @After + public void tearDown() throws Exception { + LOG.info("after"); + } + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}. + */ + @Test + public void testParseValidXml() { + + try { + InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + String testCaseFile = null; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) { + if (!testCaseFile.startsWith("/")) { + testCaseFile = "/" + testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) { + fail("Could not resolve test case file " + testCaseFile); + } + + try { + SvcLogicParser.validate(testCaseUrl.getPath(), store); + } catch (Exception e) { + fail("Validation failure [" + e.getMessage() + "]"); + } + } + } + } catch (SvcLogicParserException e) { + fail("Parser error : " + e.getMessage()); + } catch (Exception e) { + LOG.error("", e); + fail("Caught exception processing test cases"); + } + } + + @Test(expected = SvcLogicException.class) + public void testParseInvalidXml() throws SvcLogicException, IOException { + + InputStream testStr = getClass().getResourceAsStream("/parser-bad.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + String testCaseFile; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) { + if (!testCaseFile.startsWith("/")) { + testCaseFile = "/" + testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) { + fail("Could not resolve test case file " + testCaseFile); + } + SvcLogicParser.load(testCaseUrl.getPath(), store); + } + } + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 3eeb398f4..52c25b6b3 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -765,7 +765,7 @@ public class MdsalHelper { } catch (Exception gme) { LOG.info("Unable to find static method getDefaultInstance for " - + "class {}", paramClass.getSimpleName(), e); + + "class {}", paramClass.getSimpleName(), gme); } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 4bb460d78..5f4d3653e 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -59,12 +59,11 @@ public class SvcLogicServiceImpl implements SvcLogicService { } if (nodeExecutors == null) { - nodeExecutors = new HashMap(); + nodeExecutors = new HashMap<>(); } LOG.info("Opening service tracker"); - ServiceTracker tracker = new ServiceTracker(bctx, - SvcLogicNodeExecutor.class.getName(), null); + ServiceTracker tracker = new ServiceTracker(bctx, SvcLogicNodeExecutor.class.getName(), null); tracker.open(); @@ -90,14 +89,12 @@ public class SvcLogicServiceImpl implements SvcLogicService { + ")"; try { bctx.addServiceListener(listener, filter); - ServiceReference[] srl = bctx.getServiceReferences( - SvcLogicNodeExecutor.class.getName(), null); + ServiceReference[] srl = bctx.getServiceReferences(SvcLogicNodeExecutor.class.getName(), null); for (int i = 0; srl != null && i < srl.length; i++) { - listener.serviceChanged(new ServiceEvent( - ServiceEvent.REGISTERED, srl[i])); + listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, srl[i])); } } catch (InvalidSyntaxException e) { - e.printStackTrace(); + LOG.info("Invalid syntax", e); } LOG.info("Done registerExecutors"); } @@ -107,26 +104,24 @@ public class SvcLogicServiceImpl implements SvcLogicService { String nodeName = (String) sr.getProperty("nodeType"); if (nodeName != null) { - SvcLogicNodeExecutor executor = null; + SvcLogicNodeExecutor executor; try { executor = (SvcLogicNodeExecutor) bctx.getService(sr); } catch (Exception e) { - LOG.error("Cannot get service executor for " + nodeName); + LOG.error("Cannot get service executor for {}", nodeName, e); return; } - registerExecutor(nodeName, executor); - } } public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) { if (nodeExecutors == null) { - nodeExecutors = new HashMap(); + nodeExecutors = new HashMap<>(); } - LOG.info("SLI - registering executor for node type "+nodeName); + LOG.info("SLI - registering executor for node type {}", nodeName); nodeExecutors.put(nodeName, executor); } @@ -134,25 +129,16 @@ public class SvcLogicServiceImpl implements SvcLogicService { String nodeName = (String) sr.getProperty("nodeType"); if (nodeName != null) { - unregisterExecutor(nodeName); - } - } - public void unregisterExecutor(String nodeName) - { - - LOG.info("SLI - unregistering executor for node type "+nodeName); + public void unregisterExecutor(String nodeName) { + LOG.info("SLI - unregistering executor for node type {}", nodeName); nodeExecutors.remove(nodeName); } - - - - public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) - throws SvcLogicException { + public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException { if (nodeExecutors == null) { registerExecutors(); @@ -164,13 +150,11 @@ public class SvcLogicServiceImpl implements SvcLogicService { MDC.put("currentGraph", graph.toString()); SvcLogicNode curNode = graph.getRootNode(); - LOG.info("About to execute graph " + graph.toString()); - - + LOG.info("About to execute graph {}", graph.toString()); while (curNode != null) { MDC.put("nodeId", curNode.getNodeId()+" ("+curNode.getNodeType()+")"); - LOG.info("About to execute node # "+curNode.getNodeId()+" ("+curNode.getNodeType()+")"); + LOG.info("About to execute node # {} ({})", curNode.getNodeId(), curNode.getNodeType()); SvcLogicNode nextNode = executeNode(curNode, ctx); curNode = nextNode; @@ -181,25 +165,24 @@ public class SvcLogicServiceImpl implements SvcLogicService { return (ctx); } - - public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { + public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { if (node == null) { return (null); } if (LOG.isDebugEnabled()) { - LOG.debug("Executing node " + node.getNodeId()); + LOG.debug("Executing node {}", node.getNodeId()); } SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); if (executor != null) { - LOG.debug("Executing node executor for node type "+node.getNodeType()+" - "+executor.getClass().getName()); + LOG.debug("Executing node executor for node type {} - {}", + node.getNodeType(), executor.getClass().getName()); return (executor.execute(this, node, ctx)); } else { if (LOG.isDebugEnabled()) { - LOG.debug(node.getNodeType() + " node not implemented"); + LOG.debug("{} node not implemented", node.getNodeType()); } SvcLogicNode nextNode = node.getOutcomeValue("failure"); if (nextNode != null) { @@ -243,23 +226,18 @@ public class SvcLogicServiceImpl implements SvcLogicService { public Properties execute(String module, String rpc, String version, String mode, Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { - // See if there is a service logic defined - // SvcLogicStore store = SvcLogicActivator.getStore(); LOG.info("Fetching service logic from data store"); SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - - if (graph == null) { Properties retProps = new Properties(); retProps.setProperty("error-code", "401"); retProps.setProperty("error-message", "No service logic found for ["+module+","+rpc+","+version+","+mode+"]"); return(retProps); - } SvcLogicContext ctx = new SvcLogicContext(props); @@ -271,8 +249,4 @@ public class SvcLogicServiceImpl implements SvcLogicService { return(ctx.toProperties()); } - - - - } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index cdf837afe..0a0e28c4f 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -21,6 +21,11 @@ package org.onap.ccsdk.sli.core.sli.provider; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import ch.vorburger.mariadb4j.DB; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; @@ -30,7 +35,11 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Properties; - +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicParser; @@ -39,170 +48,220 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import ch.vorburger.mariadb4j.DB; -import ch.vorburger.mariadb4j.DBConfigurationBuilder; -import junit.framework.TestCase; - -public class ITCaseSvcLogicGraphExecutor extends TestCase { - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicGraph.class); - - private static final Map BUILTIN_NODES = new HashMap() { - { - put("block", new BlockNodeExecutor()); - put("call", new CallNodeExecutor()); - put("configure", new ConfigureNodeExecutor()); - put("delete", new DeleteNodeExecutor()); - put("execute", new ExecuteNodeExecutor()); - put("exists", new ExistsNodeExecutor()); - put("for", new ForNodeExecutor()); - put("get-resource", new GetResourceNodeExecutor()); - put("is-available", new IsAvailableNodeExecutor()); - put("notify", new NotifyNodeExecutor()); - put("record", new RecordNodeExecutor()); - put("release", new ReleaseNodeExecutor()); - put("reserve", new ReserveNodeExecutor()); - put("return", new ReturnNodeExecutor()); - put("save", new SaveNodeExecutor()); - put("set", new SetNodeExecutor()); - put("switch", new SwitchNodeExecutor()); - put("update", new UpdateNodeExecutor()); - - } - }; - - public void testExecute() { - - try { - InputStream testStr = getClass().getResourceAsStream("/executor.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - - InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - - Properties svcprops = new Properties(); - svcprops.load(propStr); - - // Start MariaDB4j database - DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); - config.setPort(0); // 0 => autom. detect free port - DB db = DB.newEmbeddedDB(config.build()); - db.start(); - - - - // Override jdbc URL and database name - svcprops.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); - svcprops.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); - - - - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); - - assertNotNull(store); - - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); - SvcLogicParser parser = new SvcLogicParser(store); - - // Loop through executor tests - - SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); - - for (String nodeType : BUILTIN_NODES.keySet()) { - - LOG.info("SLI - registering node executor for node type "+nodeType); - - svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); - - } - String testCaseLine = null; - while ((testCaseLine = testsReader.readLine()) != null) { - - String[] testCaseFields = testCaseLine.split(":"); - String testCaseFile = testCaseFields[0]; - String testCaseMethod = testCaseFields[1]; - String testCaseParameters = null; - - if (testCaseFields.length > 2) { - testCaseParameters = testCaseFields[2]; - } - - SvcLogicContext ctx = new SvcLogicContext(); - if (testCaseParameters != null) { - String[] testCaseParameterSettings = testCaseParameters.split(","); - - for (int i = 0 ; i < testCaseParameterSettings.length ; i++) { - String[] nameValue = testCaseParameterSettings[i].split("="); - if (nameValue != null) { - String name = nameValue[0]; - String value = ""; - if (nameValue.length > 1) { - value = nameValue[1]; - } - - ctx.setAttribute(name, value); - } - } - } - - testCaseFile = testCaseFile.trim(); - - if (testCaseFile.length() > 0) { - if (!testCaseFile.startsWith("/")) { - testCaseFile = "/"+testCaseFile; - } - URL testCaseUrl = getClass().getResource(testCaseFile); - if (testCaseUrl == null) { - fail("Could not resolve test case file "+testCaseFile); - } - - LinkedList graphs = parser.parse(testCaseUrl.getPath()); - - - assertNotNull(graphs); - - for (SvcLogicGraph graph: graphs) { - if (graph.getRpc().equals(testCaseMethod)) { - Properties props = ctx.toProperties(); - LOG.info("SvcLogicContext before executing "+testCaseMethod+":"); - for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements() ; ) { - String propName = (String) e1.nextElement(); - LOG.info(propName+" = "+props.getProperty(propName)); - } - - svc.execute(graph, ctx); - - props = ctx.toProperties(); - LOG.info("SvcLogicContext after executing "+testCaseMethod+":"); - for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements() ; ) { - String propName = (String) e2.nextElement(); - LOG.info(propName+" = "+props.getProperty(propName)); - } - } - } - - } - - - } - - - } catch (Exception e) { - LOG.error("Caught exception executing directed graphs", e); - fail("Exception executing graphs"); - } - } - - +public class ITCaseSvcLogicGraphExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicGraph.class); + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + + } + }; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + + LOG.info("before class"); + + InputStream propStr = ITCaseSvcLogicGraphExecutor.class.getResourceAsStream("/svclogic.properties"); + + Properties svcprops = new Properties(); + svcprops.load(propStr); + + // Start MariaDB4j database + DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); + config.setPort(0); // 0 => autom. detect free port + DB db = DB.newEmbeddedDB(config.build()); + db.start(); + + // Override jdbc URL and database name + svcprops.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + svcprops.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); + + assertNotNull(store); + + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + SvcLogicParser parser = new SvcLogicParser(store); + + // Loop through executor tests + + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); + + for (String nodeType : BUILTIN_NODES.keySet()) { + LOG.info("SLI - registering node executor for node type " + nodeType); + svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + } + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + LOG.info("after class"); + } + + @Before + public void setUp() throws Exception { + LOG.info("before"); + } + + @After + public void tearDown() throws Exception { + LOG.info("after"); + } + + @Test + public void testExecute() { + + try { + InputStream testStr = getClass().getResourceAsStream("/executor.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + + Properties svcprops = new Properties(); + svcprops.load(propStr); + + // Start MariaDB4j database + DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); + config.setPort(0); // 0 => autom. detect free port + DB db = DB.newEmbeddedDB(config.build()); + db.start(); + + // Override jdbc URL and database name + svcprops.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + svcprops.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); + + assertNotNull(store); + + store.registerNodeType("switch"); + store.registerNodeType("block"); + store.registerNodeType("get-resource"); + store.registerNodeType("reserve"); + store.registerNodeType("is-available"); + store.registerNodeType("exists"); + store.registerNodeType("configure"); + store.registerNodeType("return"); + store.registerNodeType("record"); + store.registerNodeType("allocate"); + store.registerNodeType("release"); + store.registerNodeType("for"); + store.registerNodeType("set"); + SvcLogicParser parser = new SvcLogicParser(store); + + // Loop through executor tests + + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); + + for (String nodeType : BUILTIN_NODES.keySet()) { + + LOG.info("SLI - registering node executor for node type {}", nodeType); + + svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + + } + String testCaseLine = null; + while ((testCaseLine = testsReader.readLine()) != null) { + + String[] testCaseFields = testCaseLine.split(":"); + String testCaseFile = testCaseFields[0]; + String testCaseMethod = testCaseFields[1]; + String testCaseParameters = null; + + if (testCaseFields.length > 2) { + testCaseParameters = testCaseFields[2]; + } + + SvcLogicContext ctx = new SvcLogicContext(); + if (testCaseParameters != null) { + String[] testCaseParameterSettings = testCaseParameters.split(","); + + for (int i = 0; i < testCaseParameterSettings.length; i++) { + String[] nameValue = testCaseParameterSettings[i].split("="); + if (nameValue != null) { + String name = nameValue[0]; + String value = ""; + if (nameValue.length > 1) { + value = nameValue[1]; + } + + ctx.setAttribute(name, value); + } + } + } + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) { + if (!testCaseFile.startsWith("/")) { + testCaseFile = "/" + testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) { + fail("Could not resolve test case file " + testCaseFile); + } + + LinkedList graphs = parser.parse(testCaseUrl.getPath()); + + assertNotNull(graphs); + + for (SvcLogicGraph graph : graphs) { + if (graph.getRpc().equals(testCaseMethod)) { + Properties props = ctx.toProperties(); + LOG.info("SvcLogicContext before executing {}:", testCaseMethod); + for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements(); ) { + String propName = (String) e1.nextElement(); + LOG.info(propName + " = " + props.getProperty(propName)); + } + + svc.execute(graph, ctx); + + props = ctx.toProperties(); + LOG.info("SvcLogicContext after executing {}:", testCaseMethod); + for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements(); ) { + String propName = (String) e2.nextElement(); + LOG.info(propName + " = " + props.getProperty(propName)); + } + } + } + + } + } + + } catch (Exception e) { + LOG.error("Caught exception executing directed graphs", e); + fail("Exception executing graphs"); + } + } } -- cgit 1.2.3-korg From 4749ba466f24e8e95e2538889f2f0e1d5f69f7b4 Mon Sep 17 00:00:00 2001 From: shashikanth Date: Wed, 27 Sep 2017 16:31:12 +0530 Subject: Fix major sonar issue Fix major sonar issues in ccsdk/sli/core module https://sonar.onap.org/component_issues?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#resolved=false|severities=MAJOR|rules=squid%3AS1161 Add the "@Override" annotation above this method signature. Issue-Id:CCSDK-67 Change-Id: Ie074574c7bbd2ca394d116e73aa6aab47ad5b8de Signed-off-by: shashikanth.vh --- .../java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 323758681..d24ae809a 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -651,6 +651,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { return 0; } + @Override public boolean equals(Object object) { if (this == object) { return true; @@ -676,6 +677,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { return true; } + @Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (child_elements != null ? child_elements.hashCode() : 0); -- cgit 1.2.3-korg From d8b7a6a745bf861c896360950a6e4d41742cb9b4 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 26 Sep 2017 13:01:50 +0530 Subject: Add unit test for SliStringUtils *Made quotedOrNull method public This is done for accessing this in ut *Added a unit test for the SliStringUtils.quotedOrNull() This is done for increasing code coverage Issue-Id: CCSDK-106 Change-Id: I9d74c6645256227b23beded5179fbb28ac3d3c04 Signed-off-by: surya-huawei --- .../java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java | 2 +- .../org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index 6048c66d6..0c43f6850 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -100,7 +100,7 @@ public class SliStringUtils implements SvcLogicJavaPlugin { } } - private static String quotedOrNULL( String str ) { + public static String quotedOrNULL( String str ) { return (str == null) ? "NULL" : '"' + str + '"'; } diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index 72b3264e9..96c6ae4ac 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -90,6 +90,12 @@ public class SliStringUtilsTest { assertThat(ctx.getAttribute("result_length"), equalTo("2")); } + @Test + public final void testQuotedOrNull() throws SvcLogicException { + //param.put("nullString",null); + assertEquals("NULL",SliStringUtils.quotedOrNULL(null)); + } + @Test public void equalsIgnoreCaseTrue() throws SvcLogicException { String sourceString = "HeLlOwORLD"; -- cgit 1.2.3-korg From 38f77425e9515b061f7eca1683fc85c42997619a Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Thu, 28 Sep 2017 03:00:10 +0000 Subject: Refined DBLIB blueprint configuration Changes made: 1. updated DBLibService definition by registering service on two interfaces: a) javax.sql.DataSource b) org.onap.ccsdk.sli.core.dblib.DbLibService Change-Id: If187b07db83ebca5428c809a83f546d9178a2b7f Issue-ID: CCSDK-102 Signed-off-by: Rich Tabedzki --- .../main/resources/org/opendaylight/blueprint/dblib-blueprint.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) mode change 100644 => 100755 dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml diff --git a/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml b/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml old mode 100644 new mode 100755 index ee3e0f033..f1d5166db --- a/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml +++ b/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml @@ -8,6 +8,11 @@ - + + + javax.sql.DataSource + org.onap.ccsdk.sli.core.dblib.DbLibService + + \ No newline at end of file -- cgit 1.2.3-korg From c7adf7195e50cf5af435d8c4e8ad143e90ea12c0 Mon Sep 17 00:00:00 2001 From: shashikanth Date: Wed, 27 Sep 2017 17:12:46 +0530 Subject: Added @Override annotation Fix major sonar issues in ccsdk/sli/core module https://sonar.onap.org/component_issues?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#resolved=false|severities=MAJOR|rules=squid%3AS1161 Add the "@Override" annotation above this method signature Issue-Id:CCSDK-67 Change-Id: I233be3f88547049a5f78c438e87f2f8c0129df78 Signed-off-by: shashikanth.vh --- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java index b089d60e3..4edf3ecbe 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicVariableTerm.java @@ -47,10 +47,10 @@ public class SvcLogicVariableTerm extends SvcLogicExpression { } } - + @Override public String toString() { - String retval = ""; + String retval; if (numOperands() > 0) { -- cgit 1.2.3-korg From a28fa047a9a304a40f5b26d9777cfc7cb9f9fe97 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 28 Sep 2017 11:31:42 +0530 Subject: Remove redundant casts *Remove unnecessary cast to "CachedDataSource" These unnecessary casting expressions maked the code harder to read and understand *Replace type specification with diamond operator This is to reduce the verbosity of generics code Issue-Id: CCSDK-87 Change-Id: I6cd2f7d16886ffa6cc26e5dd300b8376705d9366 Signed-off-by: surya-huawei --- .../ccsdk/sli/core/dblib/DBResourceManager.java | 62 +++++++++++----------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index e7a94e64c..61fb000fb 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -71,29 +71,29 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb protected final AtomicBoolean dsSelector = new AtomicBoolean(); // Queue dsQueue = new ConcurrentLinkedQueue(); - Queue dsQueue = new PriorityQueue(4, new Comparator() { - @Override - public int compare(CachedDataSource left, CachedDataSource right) { - try { - if(left == null){ - return 1; - } - if(right == null){ - return -1; - } + Queue dsQueue = new PriorityQueue<>(4, new Comparator() { + @Override + public int compare(CachedDataSource left, CachedDataSource right) { + try { + if (left == null) { + return 1; + } + if (right == null) { + return -1; + } - if(!left.isSlave()) { - return -1; - } - if (!right.isSlave()) { - return 1; - } - } catch (Throwable e) { - LOGGER.warn("", e); + if (!left.isSlave()) { + return -1; + } + if (!right.isSlave()) { + return 1; } - return 0; + } catch (Throwable e) { + LOGGER.warn("", e); } - }); + return 0; + } +}); protected final Set broken = Collections.synchronizedSet(new HashSet()); protected final Object monitor = new Object(); protected final Properties configProps; @@ -313,7 +313,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public void testForceRecovery() { - CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + CachedDataSource active = this.dsQueue.peek(); handleGetConnectionException(active, new Exception("test")); } @@ -461,7 +461,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); } - CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + CachedDataSource active = this.dsQueue.peek(); long time = System.currentTimeMillis(); try { if(!active.isFabric()) { @@ -533,7 +533,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb boolean initialRequest = true; boolean retryAllowed = true; - CachedDataSource active = (CachedDataSource) this.dsQueue.peek(); + CachedDataSource active = this.dsQueue.peek(); long time = System.currentTimeMillis(); while(initialRequest) { initialRequest = false; @@ -724,7 +724,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public void cleanUp() { for(Iterator it=dsQueue.iterator();it.hasNext();){ - CachedDataSource cds = (CachedDataSource)it.next(); + CachedDataSource cds = it.next(); it.remove(); cds.cleanUp(); } @@ -748,28 +748,28 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb @Override public PrintWriter getLogWriter() throws SQLException { - return ((CachedDataSource)this.dsQueue.peek()).getLogWriter(); + return this.dsQueue.peek().getLogWriter(); } @Override public int getLoginTimeout() throws SQLException { - return ((CachedDataSource)this.dsQueue.peek()).getLoginTimeout(); + return this.dsQueue.peek().getLoginTimeout(); } @Override public void setLogWriter(PrintWriter out) throws SQLException { - ((CachedDataSource)this.dsQueue.peek()).setLogWriter(out); + this.dsQueue.peek().setLogWriter(out); } @Override public void setLoginTimeout(int seconds) throws SQLException { - ((CachedDataSource)this.dsQueue.peek()).setLoginTimeout(seconds); + this.dsQueue.peek().setLoginTimeout(seconds); } public void displayState(){ if(LOGGER.isDebugEnabled()){ LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); - CachedDataSource current = (CachedDataSource)dsQueue.peek(); + CachedDataSource current = dsQueue.peek(); if(current != null) { LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); } @@ -800,7 +800,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb .append("Name:").append(""); for (int i = 0; i < list.size(); i++) { buffer.append(""); - buffer.append(((CachedDataSource) list.get(i)).getDbConnectionName()).append(""); + buffer.append(list.get(i).getDbConnectionName()).append(""); } buffer.append(""); @@ -820,7 +820,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } else { for (int i = 0; i < list.size(); i++) { - buffer.append("Name: ").append(((CachedDataSource) list.get(i)).getDbConnectionName()); + buffer.append("Name: ").append(list.get(i).getDbConnectionName()); buffer.append("\tState: "); if (broken.contains(list.get(i))) { buffer.append("in recovery"); -- cgit 1.2.3-korg From 51947ee9a2c3bce15ed16b7313bde7ad0a552764 Mon Sep 17 00:00:00 2001 From: Brian Freeman Date: Thu, 28 Sep 2017 12:01:42 +0000 Subject: Setup ReadTheDocs Issue-ID: CCSDK-107 Change-Id: I6f09524c02f899bd4e6df82e6eda8e94518fe8ec Signed-off-by: Brian Freeman --- docs/index.rst | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docs/index.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..833e1aa96 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,8 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. + +TODO Add files to toctree and delete this header +------------------------------------------------ +.. toctree:: + :maxdepth: 1 + + -- cgit 1.2.3-korg From b7128b31e2818b591ede570f187a3ecc38b06e3a Mon Sep 17 00:00:00 2001 From: Brian Freeman Date: Thu, 28 Sep 2017 20:31:06 +0000 Subject: SLI-API northbound add to docs Issue-ID: CCSDK-107 Change-Id: Ic4a41466288229140ae3cad79e650d14c7877cc9 Signed-off-by: Brian Freeman --- docs/index.rst | 11 +++++++++-- sliapi/model/src/main/resources/sli-api.20161110.json | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 sliapi/model/src/main/resources/sli-api.20161110.json diff --git a/docs/index.rst b/docs/index.rst index 833e1aa96..3a4849b2d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,8 +1,15 @@ .. This work is licensed under a Creative Commons Attribution 4.0 International License. -TODO Add files to toctree and delete this header ------------------------------------------------- +SDNC Service Logic Interpreter +------------------------------ .. toctree:: :maxdepth: 1 +Offered APIs +============ +List of Northbound APIs +SLI-API(2016-11-11) +================== + +.. swaggerv2doc:: https://gerrit.onap.org/r/gitweb?p=ccsdk/sli/core.git;a=blob_plain;f=sliapi/model/src/main/resources/ sli-api.20161110.json diff --git a/sliapi/model/src/main/resources/sli-api.20161110.json b/sliapi/model/src/main/resources/sli-api.20161110.json new file mode 100644 index 000000000..0cc53fe92 --- /dev/null +++ b/sliapi/model/src/main/resources/sli-api.20161110.json @@ -0,0 +1 @@ +{"apiVersion":"1.0.0","swaggerVersion":"1.2","basePath":"restconf","resourcePath":null,"produces":["application/json","application/xml"],"apis":[{"path":"/config","operations":[{"method":"POST","summary":null,"notes":"Defines API to service logic interpreter","type":"(config)SLI-API_modulePOST","nickname":"POST-SLI-API_module","consumes":["application/json","application/xml"],"parameters":[{"name":"**(config)test-results","description":null,"required":false,"type":"SLI-API(config)test-results-TOP","paramType":"body"}],"responseMessages":null}]},{"path":"/config/SLI-API:test-results","operations":[{"method":"GET","summary":null,"notes":"Test results","type":"(config)test-results","nickname":"GET-test-results","consumes":null,"parameters":[],"responseMessages":null},{"method":"PUT","summary":null,"notes":"Test results","type":"SLI-API(config)test-results-TOP","nickname":"PUT-test-results","consumes":["application/json","application/xml"],"parameters":[{"name":"(config)test-results","description":null,"required":false,"type":"SLI-API(config)test-results-TOP","paramType":"body"}],"responseMessages":null},{"method":"DELETE","summary":null,"notes":"Test results","type":null,"nickname":"DELETE-test-results","consumes":null,"parameters":[],"responseMessages":null},{"method":"POST","summary":null,"notes":"Test results","type":"(config)test-resultsPOST","nickname":"POST-test-results","consumes":["application/json","application/xml"],"parameters":[{"name":"**(config)test-result","description":null,"required":false,"type":"SLI-API/test-results(config)test-result-TOP","paramType":"body"}],"responseMessages":null}]},{"path":"/config/SLI-API:test-results/test-result/{test-identifier}","operations":[{"method":"GET","summary":null,"notes":null,"type":"(config)test-result","nickname":"GET-test-result","consumes":null,"parameters":[{"name":"test-identifier","description":null,"required":false,"type":"string","paramType":"path"}],"responseMessages":null},{"method":"PUT","summary":null,"notes":null,"type":"SLI-API/test-results(config)test-result-TOP","nickname":"PUT-test-result","consumes":["application/json","application/xml"],"parameters":[{"name":"test-identifier","description":null,"required":false,"type":"string","paramType":"path"},{"name":"(config)test-result","description":null,"required":false,"type":"SLI-API/test-results(config)test-result-TOP","paramType":"body"}],"responseMessages":null},{"method":"DELETE","summary":null,"notes":null,"type":null,"nickname":"DELETE-test-result","consumes":null,"parameters":[{"name":"test-identifier","description":null,"required":false,"type":"string","paramType":"path"}],"responseMessages":null}]},{"path":"/operational/SLI-API:test-results","operations":[{"method":"GET","summary":null,"notes":"Test results","type":"(operational)test-results","nickname":"GET-test-results","consumes":null,"parameters":[],"responseMessages":null}]},{"path":"/operations/SLI-API:healthcheck","operations":[{"method":"POST","summary":null,"notes":null,"type":"(healthcheck)output-TOP","nickname":"healthcheck","consumes":["application/json","application/xml"],"parameters":[{"name":null,"description":null,"required":false,"type":"(healthcheck)input-TOP","paramType":"body"}],"responseMessages":null}]},{"path":"/operations/SLI-API:execute-graph","operations":[{"method":"POST","summary":null,"notes":" Method to add a new parameter.","type":"(execute-graph)output-TOP","nickname":"execute-graph","consumes":["application/json","application/xml"],"parameters":[{"name":null,"description":null,"required":false,"type":"(execute-graph)input-TOP","paramType":"body"}],"responseMessages":null}]}],"models":{"(execute-graph)output":{"$schema":"http://json-schema.org/draft-04/schema","id":"(execute-graph)output","type":"object","properties":{"SLI-API:response-code":{"type":"Some response-code","required":false},"SLI-API:ack-final-indicator":{"type":"Some ack-final-indicator","required":false},"SLI-API:context-memory-json":{"type":"Some context-memory-json","required":false},"SLI-API:response-message":{"type":"Some response-message","required":false}}},"SLI-API(config)sli-parameter":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(config)sli-parameter","type":"object","properties":{"SLI-API:boolean-value":{"type":"true","required":false},"SLI-API:parameter-name":{"description":"Parameter name","type":"Some parameter-name","required":false},"SLI-API:int-value":{"type":"-2147483648","required":false},"SLI-API:string-value":{"type":"Some string-value","required":false}}},"SLI-API/test-results(config)test-result":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API/test-results(config)test-result","type":"object","properties":{"SLI-API:results":{"type":"array","items":{"type":"Some results"},"required":false},"SLI-API:test-identifier":{"type":"Some test-identifier","required":false}}},"(config)sli-parameterPOST":{"$schema":"http://json-schema.org/draft-04/schema","id":"(config)sli-parameterPOST","type":"object","properties":{"parameter-name":{"description":"Parameter name","type":"Some parameter-name","required":false},"boolean-value":{"type":"true","required":false},"string-value":{"type":"Some string-value","required":false},"int-value":{"type":"-2147483648","required":false}}},"SLI-API(config)test-results":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(config)test-results","type":"object","properties":{"SLI-API:test-result":{"type":"array","items":{"$ref":"SLI-API/test-results(config)test-result"}}}},"(healthcheck)input":{"$schema":"http://json-schema.org/draft-04/schema","id":"(healthcheck)input","type":"object","properties":{"SLI-API:dummy-leaf":{"type":"Some dummy-leaf","required":false}}},"(execute-graph)input":{"$schema":"http://json-schema.org/draft-04/schema","id":"(execute-graph)input","type":"object","properties":{"SLI-API:rpc-name":{"type":"Some rpc-name","required":false},"SLI-API:sli-parameter":{"type":"array","items":{"$ref":"SLI-API(config)sli-parameter"}},"SLI-API:module-name":{"type":"Some module-name","required":false},"SLI-API:mode":{"type":"sync","required":false,"enum":["sync","async"]}}},"(execute-graph)input-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"(execute-graph)input-TOP","type":"object","properties":{"SLI-API:input":{"type":"object","items":{"$ref":"(execute-graph)input"}}}},"unique_empty_identifier":{},"SLI-API/test-results(config)test-result-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API/test-results(config)test-result-TOP","type":"object","properties":{"SLI-API:test-result":{"type":"array","items":{"$ref":"SLI-API/test-results(config)test-result"}}}},"SLI-API(config)sli-parameter-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(config)sli-parameter-TOP","type":"object","properties":{"SLI-API:sli-parameter":{"type":"array","items":{"$ref":"SLI-API(config)sli-parameter"}}}},"SLI-API(operational)test-results":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(operational)test-results","type":"object","properties":{}},"(execute-graph)output-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"(execute-graph)output-TOP","type":"object","properties":{"SLI-API:output":{"type":"object","items":{"$ref":"(execute-graph)output"}}}},"(healthcheck)output":{"$schema":"http://json-schema.org/draft-04/schema","id":"(healthcheck)output","type":"object","properties":{"SLI-API:response-code":{"type":"Some response-code","required":false},"SLI-API:ack-final-indicator":{"type":"Some ack-final-indicator","required":false},"SLI-API:context-memory-json":{"type":"Some context-memory-json","required":false},"SLI-API:response-message":{"type":"Some response-message","required":false}}},"(config)SLI-API_modulePOST":{"$schema":"http://json-schema.org/draft-04/schema","id":"(config)SLI-API_modulePOST","type":"object","properties":{"test-results":{"type":"object","items":{"$ref":"SLI-API(config)test-results"}}}},"(config)test-resultsPOST":{"$schema":"http://json-schema.org/draft-04/schema","id":"(config)test-resultsPOST","type":"object","properties":{"test-result":{"type":"array","items":{"$ref":"SLI-API/test-results(config)test-result"}}}},"SLI-API(operational)test-results-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(operational)test-results-TOP","type":"object","properties":{"SLI-API:test-results":{"description":"Test results","type":"object","items":{"$ref":"SLI-API(operational)test-results"}}}},"SLI-API(config)test-results-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(config)test-results-TOP","type":"object","properties":{"SLI-API:test-results":{"description":"Test results","type":"object","items":{"$ref":"SLI-API(config)test-results"}}}},"(healthcheck)input-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"(healthcheck)input-TOP","type":"object","properties":{"SLI-API:input":{"type":"object","items":{"$ref":"(healthcheck)input"}}}},"(healthcheck)output-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"(healthcheck)output-TOP","type":"object","properties":{"SLI-API:output":{"type":"object","items":{"$ref":"(healthcheck)output"}}}},"(config)test-resultPOST":{"$schema":"http://json-schema.org/draft-04/schema","id":"(config)test-resultPOST","type":"object","properties":{"test-identifier":{"type":"Some test-identifier","required":false}}}}} \ No newline at end of file -- cgit 1.2.3-korg From 2a7f6affcecfcd2a7f9db3731884699f1bacff1c Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 2 Oct 2017 15:48:23 -0400 Subject: Add test cases for MdsalHelper Add test cases for MdsalHelper methods toBuilder() and toProperties(). This requires a Yang model, so added a copy of sliapi/model to sli, since could not use sliapi directly otherwise would create circular dependency (since sliapi depends on sli). Change-Id: I4824afe250f93428c73dbeec9f4a4c36ee4f76e6 Issue-ID: CCSDK-106 Signed-off-by: Dan Timoney --- sli/model/pom.xml | 82 +++++ .../rev161110/$YangModelBindingProvider.java | 8 + .../core/sliapi/rev161110/$YangModuleInfoImpl.java | 82 +++++ .../core/sliapi/rev161110/ExecuteGraphInput.java | 128 ++++++++ .../sliapi/rev161110/ExecuteGraphInputBuilder.java | 287 +++++++++++++++++ .../core/sliapi/rev161110/ExecuteGraphOutput.java | 46 +++ .../rev161110/ExecuteGraphOutputBuilder.java | 315 ++++++++++++++++++ .../core/sliapi/rev161110/HealthcheckOutput.java | 46 +++ .../sliapi/rev161110/HealthcheckOutputBuilder.java | 315 ++++++++++++++++++ .../core/sliapi/rev161110/ParameterSetting.java | 64 ++++ .../sli/core/sliapi/rev161110/ResponseFields.java | 58 ++++ .../sli/core/sliapi/rev161110/SLIAPIData.java | 147 +++++++++ .../sli/core/sliapi/rev161110/SLIAPIService.java | 93 ++++++ .../sli/core/sliapi/rev161110/TestResults.java | 49 +++ .../core/sliapi/rev161110/TestResultsBuilder.java | 202 ++++++++++++ .../execute/graph/input/SliParameter.java | 60 ++++ .../execute/graph/input/SliParameterBuilder.java | 357 +++++++++++++++++++++ .../execute/graph/input/SliParameterKey.java | 75 +++++ .../sliapi/rev161110/test/results/TestResult.java | 62 ++++ .../rev161110/test/results/TestResultBuilder.java | 271 ++++++++++++++++ .../rev161110/test/results/TestResultKey.java | 75 +++++ sli/model/src/main/yang/sliapi.yang | 111 +++++++ sli/pom.xml | 97 +++--- sli/provider/pom.xml | 6 + .../sli/core/sli/provider/MdsalHelperTest.java | 81 ++++- .../core/sli/provider/TestMdsalHelperUtils.java | 79 ----- 26 files changed, 3066 insertions(+), 130 deletions(-) create mode 100755 sli/model/pom.xml create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModelBindingProvider.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModuleInfoImpl.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInput.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInputBuilder.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutput.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutputBuilder.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutput.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutputBuilder.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ParameterSetting.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ResponseFields.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIData.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIService.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResults.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResultsBuilder.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameter.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterBuilder.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterKey.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResult.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultBuilder.java create mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultKey.java create mode 100755 sli/model/src/main/yang/sliapi.yang delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/TestMdsalHelperUtils.java diff --git a/sli/model/pom.xml b/sli/model/pom.xml new file mode 100755 index 000000000..18b56f46b --- /dev/null +++ b/sli/model/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + sli + org.onap.ccsdk.sli.core + 0.1.2-SNAPSHOT + + sli-model + bundle + SLI - Model + + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${odl.yangtools.yang.maven.plugin.version} + + + org.opendaylight.mdsal + maven-sal-api-gen-plugin + ${odl.sal.api.gen.plugin.version} + jar + + + + + + generate-sources + + + ${yang.file.directory} + + + + org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + + + + org.opendaylight.mdsal + yang-binding + ${odl.mdsal.yang.binding.version} + + + org.opendaylight.yangtools + yang-common + ${odl.yangtools.version} + + + org.opendaylight.mdsal.model + ietf-inet-types + ${odl.ietf-inet-types.version} + + + org.opendaylight.mdsal.model + ietf-yang-types + ${odl.ietf-yang-types.version} + + + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModelBindingProvider.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModelBindingProvider.java new file mode 100644 index 000000000..5195da540 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModelBindingProvider.java @@ -0,0 +1,8 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; + +public final class $YangModelBindingProvider implements org.opendaylight.yangtools.yang.binding.YangModelBindingProvider { + @Override + public org.opendaylight.yangtools.yang.binding.YangModuleInfo getModuleInfo() { + return $YangModuleInfoImpl.getInstance(); + } +} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModuleInfoImpl.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModuleInfoImpl.java new file mode 100644 index 000000000..e1cdacc54 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModuleInfoImpl.java @@ -0,0 +1,82 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110 ; +import org.opendaylight.yangtools.yang.binding.YangModuleInfo; +import java.util.Set; +import java.util.HashSet; +import com.google.common.collect.ImmutableSet; +import java.io.InputStream; +import java.io.IOException; +public final class $YangModuleInfoImpl implements YangModuleInfo { + + private static final YangModuleInfo INSTANCE = new $YangModuleInfoImpl(); + + private final java.lang.String name = "SLI-API"; + private final java.lang.String namespace = "org:onap:ccsdk:sli:core:sliapi"; + private final java.lang.String revision = "2016-11-10"; + private final java.lang.String resourcePath = "/META-INF/yang/sliapi.yang"; + + private final Set importedModules; + + public static YangModuleInfo getInstance() { + return INSTANCE; + } + + private $YangModuleInfoImpl() { + Set set = new HashSet<>(); + set.add(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.$YangModuleInfoImpl.getInstance()); + importedModules = ImmutableSet.copyOf(set); + + InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath); + if (stream == null) { + throw new IllegalStateException("Resource '" + resourcePath + "' is missing"); + } + try { + stream.close(); + } catch (IOException e) { + // Resource leak, but there is nothing we can do + } + } + + @Override + public java.lang.String getName() { + return name; + } + + @Override + public java.lang.String getRevision() { + return revision; + } + + @Override + public java.lang.String getNamespace() { + return namespace; + } + + @Override + public InputStream getModuleSourceStream() throws IOException { + InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath); + if (stream == null) { + throw new IOException("Resource " + resourcePath + " is missing"); + } + return stream; + } + + @Override + public Set getImportedModules() { + return importedModules; + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder sb = new java.lang.StringBuilder(this.getClass().getCanonicalName()); + sb.append("["); + sb.append("name = " + name); + sb.append(", namespace = " + namespace); + sb.append(", revision = " + revision); + sb.append(", resourcePath = " + resourcePath); + sb.append(", imports = " + importedModules); + sb.append("]"); + return sb.toString(); + } + + +} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInput.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInput.java new file mode 100644 index 000000000..4045483ec --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInput.java @@ -0,0 +1,128 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.QName; +import java.util.List; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yangtools.yang.binding.Augmentable; + +/** + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * container input {
    + *     leaf module-name {
    + *         type string;
    + *     }
    + *     leaf rpc-name {
    + *         type string;
    + *     }
    + *     leaf mode {
    + *         type enumeration;
    + *     }
    + *     list sli-parameter {
    + *         key "parameter-name"
    + *         leaf parameter-name {
    + *             type string;
    + *         }
    + *         leaf int-value {
    + *             type int32;
    + *         }
    + *         leaf string-value {
    + *             type string;
    + *         }
    + *         leaf boolean-value {
    + *             type boolean;
    + *         }
    + *         uses parameter-setting;
    + *     }
    + * }
    + * 
    + * The schema path to identify an instance is + * SLI-API/execute-graph/input + * + *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder}. + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder + * + */ +public interface ExecuteGraphInput + extends + DataObject, + Augmentable +{ + + + public enum Mode { + Sync(0, "sync"), + + Async(1, "async") + ; + + + java.lang.String name; + int value; + private static final java.util.Map VALUE_MAP; + + static { + final com.google.common.collect.ImmutableMap.Builder b = com.google.common.collect.ImmutableMap.builder(); + for (Mode enumItem : Mode.values()) + { + b.put(enumItem.value, enumItem); + } + + VALUE_MAP = b.build(); + } + + private Mode(int value, java.lang.String name) { + this.value = value; + this.name = name; + } + + /** + * Returns the name of the enumeration item as it is specified in the input yang. + * + * @return the name of the enumeration item as it is specified in the input yang + */ + public java.lang.String getName() { + return name; + } + + /** + * @return integer value + */ + public int getIntValue() { + return value; + } + + /** + * @param valueArg + * @return corresponding Mode item + */ + public static Mode forValue(int valueArg) { + return VALUE_MAP.get(valueArg); + } + } + + public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", + "2016-11-10", "input").intern(); + + /** + * @return java.lang.String moduleName, or null if not present + */ + java.lang.String getModuleName(); + + /** + * @return java.lang.String rpcName, or null if not present + */ + java.lang.String getRpcName(); + + /** + * @return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode mode, or null if not present + */ + Mode getMode(); + + /** + * @return java.util.List sliParameter, or null if not present + */ + List getSliParameter(); + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInputBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInputBuilder.java new file mode 100644 index 000000000..9f28ef27b --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInputBuilder.java @@ -0,0 +1,287 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.AugmentationHolder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import java.util.HashMap; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; +import java.util.Objects; +import java.util.List; +import java.util.Collections; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import java.util.Map; + +/** + * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput} instances. + * + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput + * + */ +public class ExecuteGraphInputBuilder implements Builder { + + private Mode _mode; + private java.lang.String _moduleName; + private java.lang.String _rpcName; + private List _sliParameter; + + Map>, Augmentation> augmentation = Collections.emptyMap(); + + public ExecuteGraphInputBuilder() { + } + + public ExecuteGraphInputBuilder(ExecuteGraphInput base) { + this._mode = base.getMode(); + this._moduleName = base.getModuleName(); + this._rpcName = base.getRpcName(); + this._sliParameter = base.getSliParameter(); + if (base instanceof ExecuteGraphInputImpl) { + ExecuteGraphInputImpl impl = (ExecuteGraphInputImpl) base; + if (!impl.augmentation.isEmpty()) { + this.augmentation = new HashMap<>(impl.augmentation); + } + } else if (base instanceof AugmentationHolder) { + @SuppressWarnings("unchecked") + AugmentationHolder casted =(AugmentationHolder) base; + if (!casted.augmentations().isEmpty()) { + this.augmentation = new HashMap<>(casted.augmentations()); + } + } + } + + + public Mode getMode() { + return _mode; + } + + public java.lang.String getModuleName() { + return _moduleName; + } + + public java.lang.String getRpcName() { + return _rpcName; + } + + public List getSliParameter() { + return _sliParameter; + } + + @SuppressWarnings("unchecked") + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + + public ExecuteGraphInputBuilder setMode(final Mode value) { + this._mode = value; + return this; + } + + + public ExecuteGraphInputBuilder setModuleName(final java.lang.String value) { + this._moduleName = value; + return this; + } + + + public ExecuteGraphInputBuilder setRpcName(final java.lang.String value) { + this._rpcName = value; + return this; + } + + + public ExecuteGraphInputBuilder setSliParameter(final List value) { + this._sliParameter = value; + return this; + } + + public ExecuteGraphInputBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { + if (augmentation == null) { + return removeAugmentation(augmentationType); + } + + if (!(this.augmentation instanceof HashMap)) { + this.augmentation = new HashMap<>(); + } + + this.augmentation.put(augmentationType, augmentation); + return this; + } + + public ExecuteGraphInputBuilder removeAugmentation(java.lang.Class> augmentationType) { + if (this.augmentation instanceof HashMap) { + this.augmentation.remove(augmentationType); + } + return this; + } + + @Override + public ExecuteGraphInput build() { + return new ExecuteGraphInputImpl(this); + } + + private static final class ExecuteGraphInputImpl implements ExecuteGraphInput { + + @Override + public java.lang.Class getImplementedInterface() { + return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.class; + } + + private final Mode _mode; + private final java.lang.String _moduleName; + private final java.lang.String _rpcName; + private final List _sliParameter; + + private Map>, Augmentation> augmentation = Collections.emptyMap(); + + private ExecuteGraphInputImpl(ExecuteGraphInputBuilder base) { + this._mode = base.getMode(); + this._moduleName = base.getModuleName(); + this._rpcName = base.getRpcName(); + this._sliParameter = base.getSliParameter(); + switch (base.augmentation.size()) { + case 0: + this.augmentation = Collections.emptyMap(); + break; + case 1: + final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); + this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); + break; + default : + this.augmentation = new HashMap<>(base.augmentation); + } + } + + @Override + public Mode getMode() { + return _mode; + } + + @Override + public java.lang.String getModuleName() { + return _moduleName; + } + + @Override + public java.lang.String getRpcName() { + return _rpcName; + } + + @Override + public List getSliParameter() { + return _sliParameter; + } + + @SuppressWarnings("unchecked") + @Override + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + private int hash = 0; + private volatile boolean hashValid = false; + + @Override + public int hashCode() { + if (hashValid) { + return hash; + } + + final int prime = 31; + int result = 1; + result = prime * result + Objects.hashCode(_mode); + result = prime * result + Objects.hashCode(_moduleName); + result = prime * result + Objects.hashCode(_rpcName); + result = prime * result + Objects.hashCode(_sliParameter); + result = prime * result + Objects.hashCode(augmentation); + + hash = result; + hashValid = true; + return result; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DataObject)) { + return false; + } + if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.class.equals(((DataObject)obj).getImplementedInterface())) { + return false; + } + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)obj; + if (!Objects.equals(_mode, other.getMode())) { + return false; + } + if (!Objects.equals(_moduleName, other.getModuleName())) { + return false; + } + if (!Objects.equals(_rpcName, other.getRpcName())) { + return false; + } + if (!Objects.equals(_sliParameter, other.getSliParameter())) { + return false; + } + if (getClass() == obj.getClass()) { + // Simple case: we are comparing against self + ExecuteGraphInputImpl otherImpl = (ExecuteGraphInputImpl) obj; + if (!Objects.equals(augmentation, otherImpl.augmentation)) { + return false; + } + } else { + // Hard case: compare our augments with presence there... + for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { + if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { + return false; + } + } + // .. and give the other one the chance to do the same + if (!obj.equals(this)) { + return false; + } + } + return true; + } + + @Override + public java.lang.String toString() { + java.lang.String name = "ExecuteGraphInput ["; + java.lang.StringBuilder builder = new java.lang.StringBuilder (name); + if (_mode != null) { + builder.append("_mode="); + builder.append(_mode); + builder.append(", "); + } + if (_moduleName != null) { + builder.append("_moduleName="); + builder.append(_moduleName); + builder.append(", "); + } + if (_rpcName != null) { + builder.append("_rpcName="); + builder.append(_rpcName); + builder.append(", "); + } + if (_sliParameter != null) { + builder.append("_sliParameter="); + builder.append(_sliParameter); + } + final int builderLength = builder.length(); + final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); + if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { + builder.append(", "); + } + builder.append("augmentation="); + builder.append(augmentation.values()); + return builder.append(']').toString(); + } + } + +} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutput.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutput.java new file mode 100644 index 000000000..08321c079 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutput.java @@ -0,0 +1,46 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.binding.Augmentable; + +/** + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * container output {
    + *     leaf response-code {
    + *         type string;
    + *     }
    + *     leaf ack-final-indicator {
    + *         type string;
    + *     }
    + *     leaf response-message {
    + *         type string;
    + *     }
    + *     leaf context-memory-json {
    + *         type string;
    + *     }
    + *     uses response-fields;
    + * }
    + * 
    + * The schema path to identify an instance is + * SLI-API/execute-graph/output + * + *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder}. + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder + * + */ +public interface ExecuteGraphOutput + extends + ResponseFields, + DataObject, + Augmentable +{ + + + + public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", + "2016-11-10", "output").intern(); + + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutputBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutputBuilder.java new file mode 100644 index 000000000..7b613bb41 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutputBuilder.java @@ -0,0 +1,315 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.AugmentationHolder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import java.util.HashMap; +import org.opendaylight.yangtools.concepts.Builder; +import java.util.Objects; +import java.util.Collections; +import java.util.Map; + +/** + * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput} instances. + * + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput + * + */ +public class ExecuteGraphOutputBuilder implements Builder { + + private java.lang.String _ackFinalIndicator; + private java.lang.String _contextMemoryJson; + private java.lang.String _responseCode; + private java.lang.String _responseMessage; + + Map>, Augmentation> augmentation = Collections.emptyMap(); + + public ExecuteGraphOutputBuilder() { + } + public ExecuteGraphOutputBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields arg) { + this._responseCode = arg.getResponseCode(); + this._ackFinalIndicator = arg.getAckFinalIndicator(); + this._responseMessage = arg.getResponseMessage(); + this._contextMemoryJson = arg.getContextMemoryJson(); + } + + public ExecuteGraphOutputBuilder(ExecuteGraphOutput base) { + this._ackFinalIndicator = base.getAckFinalIndicator(); + this._contextMemoryJson = base.getContextMemoryJson(); + this._responseCode = base.getResponseCode(); + this._responseMessage = base.getResponseMessage(); + if (base instanceof ExecuteGraphOutputImpl) { + ExecuteGraphOutputImpl impl = (ExecuteGraphOutputImpl) base; + if (!impl.augmentation.isEmpty()) { + this.augmentation = new HashMap<>(impl.augmentation); + } + } else if (base instanceof AugmentationHolder) { + @SuppressWarnings("unchecked") + AugmentationHolder casted =(AugmentationHolder) base; + if (!casted.augmentations().isEmpty()) { + this.augmentation = new HashMap<>(casted.augmentations()); + } + } + } + + /** + *Set fields from given grouping argument. Valid argument is instance of one of following types: + *

      + *
    • org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields
    • + *
    + * + * @param arg grouping object + * @throws IllegalArgumentException if given argument is none of valid types + */ + public void fieldsFrom(DataObject arg) { + boolean isValidArg = false; + if (arg instanceof org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields) { + this._responseCode = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getResponseCode(); + this._ackFinalIndicator = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getAckFinalIndicator(); + this._responseMessage = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getResponseMessage(); + this._contextMemoryJson = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getContextMemoryJson(); + isValidArg = true; + } + if (!isValidArg) { + throw new IllegalArgumentException( + "expected one of: [org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields] \n" + + "but was: " + arg + ); + } + } + + public java.lang.String getAckFinalIndicator() { + return _ackFinalIndicator; + } + + public java.lang.String getContextMemoryJson() { + return _contextMemoryJson; + } + + public java.lang.String getResponseCode() { + return _responseCode; + } + + public java.lang.String getResponseMessage() { + return _responseMessage; + } + + @SuppressWarnings("unchecked") + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + + public ExecuteGraphOutputBuilder setAckFinalIndicator(final java.lang.String value) { + this._ackFinalIndicator = value; + return this; + } + + + public ExecuteGraphOutputBuilder setContextMemoryJson(final java.lang.String value) { + this._contextMemoryJson = value; + return this; + } + + + public ExecuteGraphOutputBuilder setResponseCode(final java.lang.String value) { + this._responseCode = value; + return this; + } + + + public ExecuteGraphOutputBuilder setResponseMessage(final java.lang.String value) { + this._responseMessage = value; + return this; + } + + public ExecuteGraphOutputBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { + if (augmentation == null) { + return removeAugmentation(augmentationType); + } + + if (!(this.augmentation instanceof HashMap)) { + this.augmentation = new HashMap<>(); + } + + this.augmentation.put(augmentationType, augmentation); + return this; + } + + public ExecuteGraphOutputBuilder removeAugmentation(java.lang.Class> augmentationType) { + if (this.augmentation instanceof HashMap) { + this.augmentation.remove(augmentationType); + } + return this; + } + + @Override + public ExecuteGraphOutput build() { + return new ExecuteGraphOutputImpl(this); + } + + private static final class ExecuteGraphOutputImpl implements ExecuteGraphOutput { + + @Override + public java.lang.Class getImplementedInterface() { + return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput.class; + } + + private final java.lang.String _ackFinalIndicator; + private final java.lang.String _contextMemoryJson; + private final java.lang.String _responseCode; + private final java.lang.String _responseMessage; + + private Map>, Augmentation> augmentation = Collections.emptyMap(); + + private ExecuteGraphOutputImpl(ExecuteGraphOutputBuilder base) { + this._ackFinalIndicator = base.getAckFinalIndicator(); + this._contextMemoryJson = base.getContextMemoryJson(); + this._responseCode = base.getResponseCode(); + this._responseMessage = base.getResponseMessage(); + switch (base.augmentation.size()) { + case 0: + this.augmentation = Collections.emptyMap(); + break; + case 1: + final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); + this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); + break; + default : + this.augmentation = new HashMap<>(base.augmentation); + } + } + + @Override + public java.lang.String getAckFinalIndicator() { + return _ackFinalIndicator; + } + + @Override + public java.lang.String getContextMemoryJson() { + return _contextMemoryJson; + } + + @Override + public java.lang.String getResponseCode() { + return _responseCode; + } + + @Override + public java.lang.String getResponseMessage() { + return _responseMessage; + } + + @SuppressWarnings("unchecked") + @Override + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + private int hash = 0; + private volatile boolean hashValid = false; + + @Override + public int hashCode() { + if (hashValid) { + return hash; + } + + final int prime = 31; + int result = 1; + result = prime * result + Objects.hashCode(_ackFinalIndicator); + result = prime * result + Objects.hashCode(_contextMemoryJson); + result = prime * result + Objects.hashCode(_responseCode); + result = prime * result + Objects.hashCode(_responseMessage); + result = prime * result + Objects.hashCode(augmentation); + + hash = result; + hashValid = true; + return result; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DataObject)) { + return false; + } + if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput.class.equals(((DataObject)obj).getImplementedInterface())) { + return false; + } + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput)obj; + if (!Objects.equals(_ackFinalIndicator, other.getAckFinalIndicator())) { + return false; + } + if (!Objects.equals(_contextMemoryJson, other.getContextMemoryJson())) { + return false; + } + if (!Objects.equals(_responseCode, other.getResponseCode())) { + return false; + } + if (!Objects.equals(_responseMessage, other.getResponseMessage())) { + return false; + } + if (getClass() == obj.getClass()) { + // Simple case: we are comparing against self + ExecuteGraphOutputImpl otherImpl = (ExecuteGraphOutputImpl) obj; + if (!Objects.equals(augmentation, otherImpl.augmentation)) { + return false; + } + } else { + // Hard case: compare our augments with presence there... + for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { + if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { + return false; + } + } + // .. and give the other one the chance to do the same + if (!obj.equals(this)) { + return false; + } + } + return true; + } + + @Override + public java.lang.String toString() { + java.lang.String name = "ExecuteGraphOutput ["; + java.lang.StringBuilder builder = new java.lang.StringBuilder (name); + if (_ackFinalIndicator != null) { + builder.append("_ackFinalIndicator="); + builder.append(_ackFinalIndicator); + builder.append(", "); + } + if (_contextMemoryJson != null) { + builder.append("_contextMemoryJson="); + builder.append(_contextMemoryJson); + builder.append(", "); + } + if (_responseCode != null) { + builder.append("_responseCode="); + builder.append(_responseCode); + builder.append(", "); + } + if (_responseMessage != null) { + builder.append("_responseMessage="); + builder.append(_responseMessage); + } + final int builderLength = builder.length(); + final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); + if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { + builder.append(", "); + } + builder.append("augmentation="); + builder.append(augmentation.values()); + return builder.append(']').toString(); + } + } + +} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutput.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutput.java new file mode 100644 index 000000000..b0dd3b1be --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutput.java @@ -0,0 +1,46 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.binding.Augmentable; + +/** + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * container output {
    + *     leaf response-code {
    + *         type string;
    + *     }
    + *     leaf ack-final-indicator {
    + *         type string;
    + *     }
    + *     leaf response-message {
    + *         type string;
    + *     }
    + *     leaf context-memory-json {
    + *         type string;
    + *     }
    + *     uses response-fields;
    + * }
    + * 
    + * The schema path to identify an instance is + * SLI-API/healthcheck/output + * + *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder}. + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder + * + */ +public interface HealthcheckOutput + extends + ResponseFields, + DataObject, + Augmentable +{ + + + + public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", + "2016-11-10", "output").intern(); + + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutputBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutputBuilder.java new file mode 100644 index 000000000..de7840321 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutputBuilder.java @@ -0,0 +1,315 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.AugmentationHolder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import java.util.HashMap; +import org.opendaylight.yangtools.concepts.Builder; +import java.util.Objects; +import java.util.Collections; +import java.util.Map; + +/** + * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput} instances. + * + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput + * + */ +public class HealthcheckOutputBuilder implements Builder { + + private java.lang.String _ackFinalIndicator; + private java.lang.String _contextMemoryJson; + private java.lang.String _responseCode; + private java.lang.String _responseMessage; + + Map>, Augmentation> augmentation = Collections.emptyMap(); + + public HealthcheckOutputBuilder() { + } + public HealthcheckOutputBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields arg) { + this._responseCode = arg.getResponseCode(); + this._ackFinalIndicator = arg.getAckFinalIndicator(); + this._responseMessage = arg.getResponseMessage(); + this._contextMemoryJson = arg.getContextMemoryJson(); + } + + public HealthcheckOutputBuilder(HealthcheckOutput base) { + this._ackFinalIndicator = base.getAckFinalIndicator(); + this._contextMemoryJson = base.getContextMemoryJson(); + this._responseCode = base.getResponseCode(); + this._responseMessage = base.getResponseMessage(); + if (base instanceof HealthcheckOutputImpl) { + HealthcheckOutputImpl impl = (HealthcheckOutputImpl) base; + if (!impl.augmentation.isEmpty()) { + this.augmentation = new HashMap<>(impl.augmentation); + } + } else if (base instanceof AugmentationHolder) { + @SuppressWarnings("unchecked") + AugmentationHolder casted =(AugmentationHolder) base; + if (!casted.augmentations().isEmpty()) { + this.augmentation = new HashMap<>(casted.augmentations()); + } + } + } + + /** + *Set fields from given grouping argument. Valid argument is instance of one of following types: + *

      + *
    • org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields
    • + *
    + * + * @param arg grouping object + * @throws IllegalArgumentException if given argument is none of valid types + */ + public void fieldsFrom(DataObject arg) { + boolean isValidArg = false; + if (arg instanceof org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields) { + this._responseCode = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getResponseCode(); + this._ackFinalIndicator = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getAckFinalIndicator(); + this._responseMessage = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getResponseMessage(); + this._contextMemoryJson = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getContextMemoryJson(); + isValidArg = true; + } + if (!isValidArg) { + throw new IllegalArgumentException( + "expected one of: [org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields] \n" + + "but was: " + arg + ); + } + } + + public java.lang.String getAckFinalIndicator() { + return _ackFinalIndicator; + } + + public java.lang.String getContextMemoryJson() { + return _contextMemoryJson; + } + + public java.lang.String getResponseCode() { + return _responseCode; + } + + public java.lang.String getResponseMessage() { + return _responseMessage; + } + + @SuppressWarnings("unchecked") + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + + public HealthcheckOutputBuilder setAckFinalIndicator(final java.lang.String value) { + this._ackFinalIndicator = value; + return this; + } + + + public HealthcheckOutputBuilder setContextMemoryJson(final java.lang.String value) { + this._contextMemoryJson = value; + return this; + } + + + public HealthcheckOutputBuilder setResponseCode(final java.lang.String value) { + this._responseCode = value; + return this; + } + + + public HealthcheckOutputBuilder setResponseMessage(final java.lang.String value) { + this._responseMessage = value; + return this; + } + + public HealthcheckOutputBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { + if (augmentation == null) { + return removeAugmentation(augmentationType); + } + + if (!(this.augmentation instanceof HashMap)) { + this.augmentation = new HashMap<>(); + } + + this.augmentation.put(augmentationType, augmentation); + return this; + } + + public HealthcheckOutputBuilder removeAugmentation(java.lang.Class> augmentationType) { + if (this.augmentation instanceof HashMap) { + this.augmentation.remove(augmentationType); + } + return this; + } + + @Override + public HealthcheckOutput build() { + return new HealthcheckOutputImpl(this); + } + + private static final class HealthcheckOutputImpl implements HealthcheckOutput { + + @Override + public java.lang.Class getImplementedInterface() { + return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput.class; + } + + private final java.lang.String _ackFinalIndicator; + private final java.lang.String _contextMemoryJson; + private final java.lang.String _responseCode; + private final java.lang.String _responseMessage; + + private Map>, Augmentation> augmentation = Collections.emptyMap(); + + private HealthcheckOutputImpl(HealthcheckOutputBuilder base) { + this._ackFinalIndicator = base.getAckFinalIndicator(); + this._contextMemoryJson = base.getContextMemoryJson(); + this._responseCode = base.getResponseCode(); + this._responseMessage = base.getResponseMessage(); + switch (base.augmentation.size()) { + case 0: + this.augmentation = Collections.emptyMap(); + break; + case 1: + final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); + this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); + break; + default : + this.augmentation = new HashMap<>(base.augmentation); + } + } + + @Override + public java.lang.String getAckFinalIndicator() { + return _ackFinalIndicator; + } + + @Override + public java.lang.String getContextMemoryJson() { + return _contextMemoryJson; + } + + @Override + public java.lang.String getResponseCode() { + return _responseCode; + } + + @Override + public java.lang.String getResponseMessage() { + return _responseMessage; + } + + @SuppressWarnings("unchecked") + @Override + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + private int hash = 0; + private volatile boolean hashValid = false; + + @Override + public int hashCode() { + if (hashValid) { + return hash; + } + + final int prime = 31; + int result = 1; + result = prime * result + Objects.hashCode(_ackFinalIndicator); + result = prime * result + Objects.hashCode(_contextMemoryJson); + result = prime * result + Objects.hashCode(_responseCode); + result = prime * result + Objects.hashCode(_responseMessage); + result = prime * result + Objects.hashCode(augmentation); + + hash = result; + hashValid = true; + return result; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DataObject)) { + return false; + } + if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput.class.equals(((DataObject)obj).getImplementedInterface())) { + return false; + } + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput)obj; + if (!Objects.equals(_ackFinalIndicator, other.getAckFinalIndicator())) { + return false; + } + if (!Objects.equals(_contextMemoryJson, other.getContextMemoryJson())) { + return false; + } + if (!Objects.equals(_responseCode, other.getResponseCode())) { + return false; + } + if (!Objects.equals(_responseMessage, other.getResponseMessage())) { + return false; + } + if (getClass() == obj.getClass()) { + // Simple case: we are comparing against self + HealthcheckOutputImpl otherImpl = (HealthcheckOutputImpl) obj; + if (!Objects.equals(augmentation, otherImpl.augmentation)) { + return false; + } + } else { + // Hard case: compare our augments with presence there... + for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { + if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { + return false; + } + } + // .. and give the other one the chance to do the same + if (!obj.equals(this)) { + return false; + } + } + return true; + } + + @Override + public java.lang.String toString() { + java.lang.String name = "HealthcheckOutput ["; + java.lang.StringBuilder builder = new java.lang.StringBuilder (name); + if (_ackFinalIndicator != null) { + builder.append("_ackFinalIndicator="); + builder.append(_ackFinalIndicator); + builder.append(", "); + } + if (_contextMemoryJson != null) { + builder.append("_contextMemoryJson="); + builder.append(_contextMemoryJson); + builder.append(", "); + } + if (_responseCode != null) { + builder.append("_responseCode="); + builder.append(_responseCode); + builder.append(", "); + } + if (_responseMessage != null) { + builder.append("_responseMessage="); + builder.append(_responseMessage); + } + final int builderLength = builder.length(); + final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); + if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { + builder.append(", "); + } + builder.append("augmentation="); + builder.append(augmentation.values()); + return builder.append(']').toString(); + } + } + +} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ParameterSetting.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ParameterSetting.java new file mode 100644 index 000000000..e2d610b6b --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ParameterSetting.java @@ -0,0 +1,64 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.QName; + +/** + * Parameter setting + * + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * grouping parameter-setting {
    + *     leaf parameter-name {
    + *         type string;
    + *     }
    + *     leaf int-value {
    + *         type int32;
    + *     }
    + *     leaf string-value {
    + *         type string;
    + *     }
    + *     leaf boolean-value {
    + *         type boolean;
    + *     }
    + * }
    + * 
    + * The schema path to identify an instance is + * SLI-API/parameter-setting + * + */ +public interface ParameterSetting + extends + DataObject +{ + + + + public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", + "2016-11-10", "parameter-setting").intern(); + + /** + * Parameter name + * + * + * + * @return java.lang.String parameterName, or null if not present + */ + java.lang.String getParameterName(); + + /** + * @return java.lang.Integer intValue, or null if not present + */ + java.lang.Integer getIntValue(); + + /** + * @return java.lang.String stringValue, or null if not present + */ + java.lang.String getStringValue(); + + /** + * @return java.lang.Boolean booleanValue, or null if not present + */ + java.lang.Boolean isBooleanValue(); + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ResponseFields.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ResponseFields.java new file mode 100644 index 000000000..440beea03 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ResponseFields.java @@ -0,0 +1,58 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.QName; + +/** + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * grouping response-fields {
    + *     leaf response-code {
    + *         type string;
    + *     }
    + *     leaf ack-final-indicator {
    + *         type string;
    + *     }
    + *     leaf response-message {
    + *         type string;
    + *     }
    + *     leaf context-memory-json {
    + *         type string;
    + *     }
    + * }
    + * 
    + * The schema path to identify an instance is + * SLI-API/response-fields + * + */ +public interface ResponseFields + extends + DataObject +{ + + + + public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", + "2016-11-10", "response-fields").intern(); + + /** + * @return java.lang.String responseCode, or null if not present + */ + java.lang.String getResponseCode(); + + /** + * @return java.lang.String ackFinalIndicator, or null if not present + */ + java.lang.String getAckFinalIndicator(); + + /** + * @return java.lang.String responseMessage, or null if not present + */ + java.lang.String getResponseMessage(); + + /** + * @return java.lang.String contextMemoryJson, or null if not present + */ + java.lang.String getContextMemoryJson(); + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIData.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIData.java new file mode 100644 index 000000000..1917b475c --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIData.java @@ -0,0 +1,147 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.DataRoot; + +/** + * Defines API to service logic interpreter + * + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * module SLI-API {
    + *     yang-version 1;
    + *     namespace "org:onap:ccsdk:sli:core:sliapi";
    + *     prefix "sample";
    + *
    + *     import ietf-inet-types { prefix "inet"; }
    + *     revision 2016-11-10 {
    + *         description "Defines API to service logic interpreter
    + *         ";
    + *     }
    + *
    + *     container test-results {
    + *         list test-result {
    + *             key "test-identifier"
    + *             leaf test-identifier {
    + *                 type string;
    + *             }
    + *             leaf-list results {
    + *                 type string;
    + *             }
    + *         }
    + *     }
    + *
    + *     grouping response-fields {
    + *         leaf response-code {
    + *             type string;
    + *         }
    + *         leaf ack-final-indicator {
    + *             type string;
    + *         }
    + *         leaf response-message {
    + *             type string;
    + *         }
    + *         leaf context-memory-json {
    + *             type string;
    + *         }
    + *     }
    + *     grouping parameter-setting {
    + *         leaf parameter-name {
    + *             type string;
    + *         }
    + *         leaf int-value {
    + *             type int32;
    + *         }
    + *         leaf string-value {
    + *             type string;
    + *         }
    + *         leaf boolean-value {
    + *             type boolean;
    + *         }
    + *     }
    + *
    + *     rpc healthcheck {
    + *         input {
    + *         }
    + *         
    + *         output {
    + *             leaf response-code {
    + *                 type string;
    + *             }
    + *             leaf ack-final-indicator {
    + *                 type string;
    + *             }
    + *             leaf response-message {
    + *                 type string;
    + *             }
    + *             leaf context-memory-json {
    + *                 type string;
    + *             }
    + *         }
    + *     }
    + *     rpc execute-graph {
    + *         " Method to add a new parameter.";
    + *         input {
    + *             leaf module-name {
    + *                 type string;
    + *             }
    + *             leaf rpc-name {
    + *                 type string;
    + *             }
    + *             leaf mode {
    + *                 type enumeration;
    + *             }
    + *             list sli-parameter {
    + *                 key "parameter-name"
    + *                 leaf parameter-name {
    + *                     type string;
    + *                 }
    + *                 leaf int-value {
    + *                     type int32;
    + *                 }
    + *                 leaf string-value {
    + *                     type string;
    + *                 }
    + *                 leaf boolean-value {
    + *                     type boolean;
    + *                 }
    + *                 uses parameter-setting;
    + *             }
    + *         }
    + *         
    + *         output {
    + *             leaf response-code {
    + *                 type string;
    + *             }
    + *             leaf ack-final-indicator {
    + *                 type string;
    + *             }
    + *             leaf response-message {
    + *                 type string;
    + *             }
    + *             leaf context-memory-json {
    + *                 type string;
    + *             }
    + *         }
    + *     }
    + * }
    + * 
    + * + */ +public interface SLIAPIData + extends + DataRoot +{ + + + + + /** + * Test results + * + * + * + * @return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults testResults, or null if not present + */ + TestResults getTestResults(); + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIService.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIService.java new file mode 100644 index 000000000..3ad03f6fd --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIService.java @@ -0,0 +1,93 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.RpcService; +import org.opendaylight.yangtools.yang.common.RpcResult; +import java.util.concurrent.Future; + +/** + * Interface for implementing the following YANG RPCs defined in module SLI-API + *
    + * rpc healthcheck {
    + *     input {
    + *     }
    + *     
    + *     output {
    + *         leaf response-code {
    + *             type string;
    + *         }
    + *         leaf ack-final-indicator {
    + *             type string;
    + *         }
    + *         leaf response-message {
    + *             type string;
    + *         }
    + *         leaf context-memory-json {
    + *             type string;
    + *         }
    + *     }
    + * }
    + * rpc execute-graph {
    + *     " Method to add a new parameter.";
    + *     input {
    + *         leaf module-name {
    + *             type string;
    + *         }
    + *         leaf rpc-name {
    + *             type string;
    + *         }
    + *         leaf mode {
    + *             type enumeration;
    + *         }
    + *         list sli-parameter {
    + *             key "parameter-name"
    + *             leaf parameter-name {
    + *                 type string;
    + *             }
    + *             leaf int-value {
    + *                 type int32;
    + *             }
    + *             leaf string-value {
    + *                 type string;
    + *             }
    + *             leaf boolean-value {
    + *                 type boolean;
    + *             }
    + *             uses parameter-setting;
    + *         }
    + *     }
    + *     
    + *     output {
    + *         leaf response-code {
    + *             type string;
    + *         }
    + *         leaf ack-final-indicator {
    + *             type string;
    + *         }
    + *         leaf response-message {
    + *             type string;
    + *         }
    + *         leaf context-memory-json {
    + *             type string;
    + *         }
    + *     }
    + * }
    + * 
    + * + */ +public interface SLIAPIService + extends + RpcService +{ + + + + + Future> healthcheck(); + + /** + * Method to add a new parameter. + * + */ + Future> executeGraph(ExecuteGraphInput input); + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResults.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResults.java new file mode 100644 index 000000000..a1723d730 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResults.java @@ -0,0 +1,49 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.ChildOf; +import org.opendaylight.yangtools.yang.common.QName; +import java.util.List; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; +import org.opendaylight.yangtools.yang.binding.Augmentable; + +/** + * Test results + * + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * container test-results {
    + *     list test-result {
    + *         key "test-identifier"
    + *         leaf test-identifier {
    + *             type string;
    + *         }
    + *         leaf-list results {
    + *             type string;
    + *         }
    + *     }
    + * }
    + * 
    + * The schema path to identify an instance is + * SLI-API/test-results + * + *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResultsBuilder}. + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResultsBuilder + * + */ +public interface TestResults + extends + ChildOf, + Augmentable +{ + + + + public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", + "2016-11-10", "test-results").intern(); + + /** + * @return java.util.List testResult, or null if not present + */ + List getTestResult(); + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResultsBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResultsBuilder.java new file mode 100644 index 000000000..36da730ed --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResultsBuilder.java @@ -0,0 +1,202 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.AugmentationHolder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import java.util.HashMap; +import org.opendaylight.yangtools.concepts.Builder; +import java.util.Objects; +import java.util.List; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; +import java.util.Collections; +import java.util.Map; + +/** + * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults} instances. + * + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults + * + */ +public class TestResultsBuilder implements Builder { + + private List _testResult; + + Map>, Augmentation> augmentation = Collections.emptyMap(); + + public TestResultsBuilder() { + } + + public TestResultsBuilder(TestResults base) { + this._testResult = base.getTestResult(); + if (base instanceof TestResultsImpl) { + TestResultsImpl impl = (TestResultsImpl) base; + if (!impl.augmentation.isEmpty()) { + this.augmentation = new HashMap<>(impl.augmentation); + } + } else if (base instanceof AugmentationHolder) { + @SuppressWarnings("unchecked") + AugmentationHolder casted =(AugmentationHolder) base; + if (!casted.augmentations().isEmpty()) { + this.augmentation = new HashMap<>(casted.augmentations()); + } + } + } + + + public List getTestResult() { + return _testResult; + } + + @SuppressWarnings("unchecked") + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + + public TestResultsBuilder setTestResult(final List value) { + this._testResult = value; + return this; + } + + public TestResultsBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { + if (augmentation == null) { + return removeAugmentation(augmentationType); + } + + if (!(this.augmentation instanceof HashMap)) { + this.augmentation = new HashMap<>(); + } + + this.augmentation.put(augmentationType, augmentation); + return this; + } + + public TestResultsBuilder removeAugmentation(java.lang.Class> augmentationType) { + if (this.augmentation instanceof HashMap) { + this.augmentation.remove(augmentationType); + } + return this; + } + + @Override + public TestResults build() { + return new TestResultsImpl(this); + } + + private static final class TestResultsImpl implements TestResults { + + @Override + public java.lang.Class getImplementedInterface() { + return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults.class; + } + + private final List _testResult; + + private Map>, Augmentation> augmentation = Collections.emptyMap(); + + private TestResultsImpl(TestResultsBuilder base) { + this._testResult = base.getTestResult(); + switch (base.augmentation.size()) { + case 0: + this.augmentation = Collections.emptyMap(); + break; + case 1: + final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); + this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); + break; + default : + this.augmentation = new HashMap<>(base.augmentation); + } + } + + @Override + public List getTestResult() { + return _testResult; + } + + @SuppressWarnings("unchecked") + @Override + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + private int hash = 0; + private volatile boolean hashValid = false; + + @Override + public int hashCode() { + if (hashValid) { + return hash; + } + + final int prime = 31; + int result = 1; + result = prime * result + Objects.hashCode(_testResult); + result = prime * result + Objects.hashCode(augmentation); + + hash = result; + hashValid = true; + return result; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DataObject)) { + return false; + } + if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults.class.equals(((DataObject)obj).getImplementedInterface())) { + return false; + } + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults)obj; + if (!Objects.equals(_testResult, other.getTestResult())) { + return false; + } + if (getClass() == obj.getClass()) { + // Simple case: we are comparing against self + TestResultsImpl otherImpl = (TestResultsImpl) obj; + if (!Objects.equals(augmentation, otherImpl.augmentation)) { + return false; + } + } else { + // Hard case: compare our augments with presence there... + for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { + if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { + return false; + } + } + // .. and give the other one the chance to do the same + if (!obj.equals(this)) { + return false; + } + } + return true; + } + + @Override + public java.lang.String toString() { + java.lang.String name = "TestResults ["; + java.lang.StringBuilder builder = new java.lang.StringBuilder (name); + if (_testResult != null) { + builder.append("_testResult="); + builder.append(_testResult); + } + final int builderLength = builder.length(); + final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); + if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { + builder.append(", "); + } + builder.append("augmentation="); + builder.append(augmentation.values()); + return builder.append(']').toString(); + } + } + +} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameter.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameter.java new file mode 100644 index 000000000..e1cac53c5 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameter.java @@ -0,0 +1,60 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input; +import org.opendaylight.yangtools.yang.binding.ChildOf; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.binding.Augmentable; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; +import org.opendaylight.yangtools.yang.binding.Identifiable; + +/** + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * list sli-parameter {
    + *     key "parameter-name"
    + *     leaf parameter-name {
    + *         type string;
    + *     }
    + *     leaf int-value {
    + *         type int32;
    + *     }
    + *     leaf string-value {
    + *         type string;
    + *     }
    + *     leaf boolean-value {
    + *         type boolean;
    + *     }
    + *     uses parameter-setting;
    + * }
    + * 
    + * The schema path to identify an instance is + * SLI-API/execute-graph/input/sli-parameter + * + *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder}. + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterKey + * + */ +public interface SliParameter + extends + ChildOf, + Augmentable, + ParameterSetting, + Identifiable +{ + + + + public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", + "2016-11-10", "sli-parameter").intern(); + + /** + * Returns Primary Key of Yang List Type + * + * + * + * @return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterKey key, or null if not present + */ + SliParameterKey getKey(); + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterBuilder.java new file mode 100644 index 000000000..f28eb1a8b --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterBuilder.java @@ -0,0 +1,357 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.AugmentationHolder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import java.util.HashMap; +import org.opendaylight.yangtools.concepts.Builder; +import java.util.Objects; +import java.util.Collections; +import java.util.Map; + +/** + * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter} instances. + * + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter + * + */ +public class SliParameterBuilder implements Builder { + + private java.lang.Integer _intValue; + private SliParameterKey _key; + private java.lang.String _parameterName; + private java.lang.String _stringValue; + private java.lang.Boolean _booleanValue; + + Map>, Augmentation> augmentation = Collections.emptyMap(); + + public SliParameterBuilder() { + } + public SliParameterBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting arg) { + this._parameterName = arg.getParameterName(); + this._intValue = arg.getIntValue(); + this._stringValue = arg.getStringValue(); + this._booleanValue = arg.isBooleanValue(); + } + + public SliParameterBuilder(SliParameter base) { + if (base.getKey() == null) { + this._key = new SliParameterKey( + base.getParameterName() + ); + this._parameterName = base.getParameterName(); + } else { + this._key = base.getKey(); + this._parameterName = _key.getParameterName(); + } + this._intValue = base.getIntValue(); + this._stringValue = base.getStringValue(); + this._booleanValue = base.isBooleanValue(); + if (base instanceof SliParameterImpl) { + SliParameterImpl impl = (SliParameterImpl) base; + if (!impl.augmentation.isEmpty()) { + this.augmentation = new HashMap<>(impl.augmentation); + } + } else if (base instanceof AugmentationHolder) { + @SuppressWarnings("unchecked") + AugmentationHolder casted =(AugmentationHolder) base; + if (!casted.augmentations().isEmpty()) { + this.augmentation = new HashMap<>(casted.augmentations()); + } + } + } + + /** + *Set fields from given grouping argument. Valid argument is instance of one of following types: + *

      + *
    • org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting
    • + *
    + * + * @param arg grouping object + * @throws IllegalArgumentException if given argument is none of valid types + */ + public void fieldsFrom(DataObject arg) { + boolean isValidArg = false; + if (arg instanceof org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting) { + this._parameterName = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting)arg).getParameterName(); + this._intValue = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting)arg).getIntValue(); + this._stringValue = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting)arg).getStringValue(); + this._booleanValue = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting)arg).isBooleanValue(); + isValidArg = true; + } + if (!isValidArg) { + throw new IllegalArgumentException( + "expected one of: [org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting] \n" + + "but was: " + arg + ); + } + } + + public java.lang.Integer getIntValue() { + return _intValue; + } + + public SliParameterKey getKey() { + return _key; + } + + public java.lang.String getParameterName() { + return _parameterName; + } + + public java.lang.String getStringValue() { + return _stringValue; + } + + public java.lang.Boolean isBooleanValue() { + return _booleanValue; + } + + @SuppressWarnings("unchecked") + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + + public SliParameterBuilder setIntValue(final java.lang.Integer value) { + this._intValue = value; + return this; + } + + + public SliParameterBuilder setKey(final SliParameterKey value) { + this._key = value; + return this; + } + + + public SliParameterBuilder setParameterName(final java.lang.String value) { + this._parameterName = value; + return this; + } + + + public SliParameterBuilder setStringValue(final java.lang.String value) { + this._stringValue = value; + return this; + } + + + public SliParameterBuilder setBooleanValue(final java.lang.Boolean value) { + this._booleanValue = value; + return this; + } + + public SliParameterBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { + if (augmentation == null) { + return removeAugmentation(augmentationType); + } + + if (!(this.augmentation instanceof HashMap)) { + this.augmentation = new HashMap<>(); + } + + this.augmentation.put(augmentationType, augmentation); + return this; + } + + public SliParameterBuilder removeAugmentation(java.lang.Class> augmentationType) { + if (this.augmentation instanceof HashMap) { + this.augmentation.remove(augmentationType); + } + return this; + } + + @Override + public SliParameter build() { + return new SliParameterImpl(this); + } + + private static final class SliParameterImpl implements SliParameter { + + @Override + public java.lang.Class getImplementedInterface() { + return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter.class; + } + + private final java.lang.Integer _intValue; + private final SliParameterKey _key; + private final java.lang.String _parameterName; + private final java.lang.String _stringValue; + private final java.lang.Boolean _booleanValue; + + private Map>, Augmentation> augmentation = Collections.emptyMap(); + + private SliParameterImpl(SliParameterBuilder base) { + if (base.getKey() == null) { + this._key = new SliParameterKey( + base.getParameterName() + ); + this._parameterName = base.getParameterName(); + } else { + this._key = base.getKey(); + this._parameterName = _key.getParameterName(); + } + this._intValue = base.getIntValue(); + this._stringValue = base.getStringValue(); + this._booleanValue = base.isBooleanValue(); + switch (base.augmentation.size()) { + case 0: + this.augmentation = Collections.emptyMap(); + break; + case 1: + final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); + this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); + break; + default : + this.augmentation = new HashMap<>(base.augmentation); + } + } + + @Override + public java.lang.Integer getIntValue() { + return _intValue; + } + + @Override + public SliParameterKey getKey() { + return _key; + } + + @Override + public java.lang.String getParameterName() { + return _parameterName; + } + + @Override + public java.lang.String getStringValue() { + return _stringValue; + } + + @Override + public java.lang.Boolean isBooleanValue() { + return _booleanValue; + } + + @SuppressWarnings("unchecked") + @Override + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + private int hash = 0; + private volatile boolean hashValid = false; + + @Override + public int hashCode() { + if (hashValid) { + return hash; + } + + final int prime = 31; + int result = 1; + result = prime * result + Objects.hashCode(_intValue); + result = prime * result + Objects.hashCode(_key); + result = prime * result + Objects.hashCode(_parameterName); + result = prime * result + Objects.hashCode(_stringValue); + result = prime * result + Objects.hashCode(_booleanValue); + result = prime * result + Objects.hashCode(augmentation); + + hash = result; + hashValid = true; + return result; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DataObject)) { + return false; + } + if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter.class.equals(((DataObject)obj).getImplementedInterface())) { + return false; + } + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter)obj; + if (!Objects.equals(_intValue, other.getIntValue())) { + return false; + } + if (!Objects.equals(_key, other.getKey())) { + return false; + } + if (!Objects.equals(_parameterName, other.getParameterName())) { + return false; + } + if (!Objects.equals(_stringValue, other.getStringValue())) { + return false; + } + if (!Objects.equals(_booleanValue, other.isBooleanValue())) { + return false; + } + if (getClass() == obj.getClass()) { + // Simple case: we are comparing against self + SliParameterImpl otherImpl = (SliParameterImpl) obj; + if (!Objects.equals(augmentation, otherImpl.augmentation)) { + return false; + } + } else { + // Hard case: compare our augments with presence there... + for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { + if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { + return false; + } + } + // .. and give the other one the chance to do the same + if (!obj.equals(this)) { + return false; + } + } + return true; + } + + @Override + public java.lang.String toString() { + java.lang.String name = "SliParameter ["; + java.lang.StringBuilder builder = new java.lang.StringBuilder (name); + if (_intValue != null) { + builder.append("_intValue="); + builder.append(_intValue); + builder.append(", "); + } + if (_key != null) { + builder.append("_key="); + builder.append(_key); + builder.append(", "); + } + if (_parameterName != null) { + builder.append("_parameterName="); + builder.append(_parameterName); + builder.append(", "); + } + if (_stringValue != null) { + builder.append("_stringValue="); + builder.append(_stringValue); + builder.append(", "); + } + if (_booleanValue != null) { + builder.append("_booleanValue="); + builder.append(_booleanValue); + } + final int builderLength = builder.length(); + final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); + if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { + builder.append(", "); + } + builder.append("augmentation="); + builder.append(augmentation.values()); + return builder.append(']').toString(); + } + } + +} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterKey.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterKey.java new file mode 100644 index 000000000..6c19a877b --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterKey.java @@ -0,0 +1,75 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input; +import org.opendaylight.yangtools.yang.binding.Identifier; +import java.util.Objects; + +public class SliParameterKey + implements Identifier { + private static final long serialVersionUID = 8929025111457627032L; + private final java.lang.String _parameterName; + + + public SliParameterKey(java.lang.String _parameterName) { + + + this._parameterName = _parameterName; + } + + /** + * Creates a copy from Source Object. + * + * @param source Source object + */ + public SliParameterKey(SliParameterKey source) { + this._parameterName = source._parameterName; + } + + + public java.lang.String getParameterName() { + return _parameterName; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Objects.hashCode(_parameterName); + return result; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + SliParameterKey other = (SliParameterKey) obj; + if (!Objects.equals(_parameterName, other._parameterName)) { + return false; + } + return true; + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder builder = new java.lang.StringBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterKey.class.getSimpleName()).append(" ["); + boolean first = true; + + if (_parameterName != null) { + if (first) { + first = false; + } else { + builder.append(", "); + } + builder.append("_parameterName="); + builder.append(_parameterName); + } + return builder.append(']').toString(); + } +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResult.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResult.java new file mode 100644 index 000000000..d12faa445 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResult.java @@ -0,0 +1,62 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results; +import org.opendaylight.yangtools.yang.binding.ChildOf; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults; +import java.util.List; +import org.opendaylight.yangtools.yang.binding.Augmentable; +import org.opendaylight.yangtools.yang.binding.Identifiable; + +/** + *

    This class represents the following YANG schema fragment defined in module SLI-API + *

    + * list test-result {
    + *     key "test-identifier"
    + *     leaf test-identifier {
    + *         type string;
    + *     }
    + *     leaf-list results {
    + *         type string;
    + *     }
    + * }
    + * 
    + * The schema path to identify an instance is + * SLI-API/test-results/test-result + * + *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder}. + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultKey + * + */ +public interface TestResult + extends + ChildOf, + Augmentable, + Identifiable +{ + + + + public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", + "2016-11-10", "test-result").intern(); + + /** + * @return java.lang.String testIdentifier, or null if not present + */ + java.lang.String getTestIdentifier(); + + /** + * @return java.util.List results, or null if not present + */ + List getResults(); + + /** + * Returns Primary Key of Yang List Type + * + * + * + * @return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultKey key, or null if not present + */ + TestResultKey getKey(); + +} + diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultBuilder.java new file mode 100644 index 000000000..51e437222 --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultBuilder.java @@ -0,0 +1,271 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.AugmentationHolder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import java.util.HashMap; +import org.opendaylight.yangtools.concepts.Builder; +import java.util.Objects; +import java.util.List; +import java.util.Collections; +import java.util.Map; + +/** + * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult} instances. + * + * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult + * + */ +public class TestResultBuilder implements Builder { + + private TestResultKey _key; + private List _results; + private java.lang.String _testIdentifier; + + Map>, Augmentation> augmentation = Collections.emptyMap(); + + public TestResultBuilder() { + } + + public TestResultBuilder(TestResult base) { + if (base.getKey() == null) { + this._key = new TestResultKey( + base.getTestIdentifier() + ); + this._testIdentifier = base.getTestIdentifier(); + } else { + this._key = base.getKey(); + this._testIdentifier = _key.getTestIdentifier(); + } + this._results = base.getResults(); + if (base instanceof TestResultImpl) { + TestResultImpl impl = (TestResultImpl) base; + if (!impl.augmentation.isEmpty()) { + this.augmentation = new HashMap<>(impl.augmentation); + } + } else if (base instanceof AugmentationHolder) { + @SuppressWarnings("unchecked") + AugmentationHolder casted =(AugmentationHolder) base; + if (!casted.augmentations().isEmpty()) { + this.augmentation = new HashMap<>(casted.augmentations()); + } + } + } + + + public TestResultKey getKey() { + return _key; + } + + public List getResults() { + return _results; + } + + public java.lang.String getTestIdentifier() { + return _testIdentifier; + } + + @SuppressWarnings("unchecked") + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + + public TestResultBuilder setKey(final TestResultKey value) { + this._key = value; + return this; + } + + + public TestResultBuilder setResults(final List value) { + this._results = value; + return this; + } + + + public TestResultBuilder setTestIdentifier(final java.lang.String value) { + this._testIdentifier = value; + return this; + } + + public TestResultBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { + if (augmentation == null) { + return removeAugmentation(augmentationType); + } + + if (!(this.augmentation instanceof HashMap)) { + this.augmentation = new HashMap<>(); + } + + this.augmentation.put(augmentationType, augmentation); + return this; + } + + public TestResultBuilder removeAugmentation(java.lang.Class> augmentationType) { + if (this.augmentation instanceof HashMap) { + this.augmentation.remove(augmentationType); + } + return this; + } + + @Override + public TestResult build() { + return new TestResultImpl(this); + } + + private static final class TestResultImpl implements TestResult { + + @Override + public java.lang.Class getImplementedInterface() { + return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult.class; + } + + private final TestResultKey _key; + private final List _results; + private final java.lang.String _testIdentifier; + + private Map>, Augmentation> augmentation = Collections.emptyMap(); + + private TestResultImpl(TestResultBuilder base) { + if (base.getKey() == null) { + this._key = new TestResultKey( + base.getTestIdentifier() + ); + this._testIdentifier = base.getTestIdentifier(); + } else { + this._key = base.getKey(); + this._testIdentifier = _key.getTestIdentifier(); + } + this._results = base.getResults(); + switch (base.augmentation.size()) { + case 0: + this.augmentation = Collections.emptyMap(); + break; + case 1: + final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); + this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); + break; + default : + this.augmentation = new HashMap<>(base.augmentation); + } + } + + @Override + public TestResultKey getKey() { + return _key; + } + + @Override + public List getResults() { + return _results; + } + + @Override + public java.lang.String getTestIdentifier() { + return _testIdentifier; + } + + @SuppressWarnings("unchecked") + @Override + public > E getAugmentation(java.lang.Class augmentationType) { + if (augmentationType == null) { + throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); + } + return (E) augmentation.get(augmentationType); + } + + private int hash = 0; + private volatile boolean hashValid = false; + + @Override + public int hashCode() { + if (hashValid) { + return hash; + } + + final int prime = 31; + int result = 1; + result = prime * result + Objects.hashCode(_key); + result = prime * result + Objects.hashCode(_results); + result = prime * result + Objects.hashCode(_testIdentifier); + result = prime * result + Objects.hashCode(augmentation); + + hash = result; + hashValid = true; + return result; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DataObject)) { + return false; + } + if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult.class.equals(((DataObject)obj).getImplementedInterface())) { + return false; + } + org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult)obj; + if (!Objects.equals(_key, other.getKey())) { + return false; + } + if (!Objects.equals(_results, other.getResults())) { + return false; + } + if (!Objects.equals(_testIdentifier, other.getTestIdentifier())) { + return false; + } + if (getClass() == obj.getClass()) { + // Simple case: we are comparing against self + TestResultImpl otherImpl = (TestResultImpl) obj; + if (!Objects.equals(augmentation, otherImpl.augmentation)) { + return false; + } + } else { + // Hard case: compare our augments with presence there... + for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { + if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { + return false; + } + } + // .. and give the other one the chance to do the same + if (!obj.equals(this)) { + return false; + } + } + return true; + } + + @Override + public java.lang.String toString() { + java.lang.String name = "TestResult ["; + java.lang.StringBuilder builder = new java.lang.StringBuilder (name); + if (_key != null) { + builder.append("_key="); + builder.append(_key); + builder.append(", "); + } + if (_results != null) { + builder.append("_results="); + builder.append(_results); + builder.append(", "); + } + if (_testIdentifier != null) { + builder.append("_testIdentifier="); + builder.append(_testIdentifier); + } + final int builderLength = builder.length(); + final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); + if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { + builder.append(", "); + } + builder.append("augmentation="); + builder.append(augmentation.values()); + return builder.append(']').toString(); + } + } + +} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultKey.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultKey.java new file mode 100644 index 000000000..d867ca23b --- /dev/null +++ b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultKey.java @@ -0,0 +1,75 @@ +package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results; +import org.opendaylight.yangtools.yang.binding.Identifier; +import java.util.Objects; + +public class TestResultKey + implements Identifier { + private static final long serialVersionUID = 3857649555637491806L; + private final java.lang.String _testIdentifier; + + + public TestResultKey(java.lang.String _testIdentifier) { + + + this._testIdentifier = _testIdentifier; + } + + /** + * Creates a copy from Source Object. + * + * @param source Source object + */ + public TestResultKey(TestResultKey source) { + this._testIdentifier = source._testIdentifier; + } + + + public java.lang.String getTestIdentifier() { + return _testIdentifier; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Objects.hashCode(_testIdentifier); + return result; + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + TestResultKey other = (TestResultKey) obj; + if (!Objects.equals(_testIdentifier, other._testIdentifier)) { + return false; + } + return true; + } + + @Override + public java.lang.String toString() { + java.lang.StringBuilder builder = new java.lang.StringBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultKey.class.getSimpleName()).append(" ["); + boolean first = true; + + if (_testIdentifier != null) { + if (first) { + first = false; + } else { + builder.append(", "); + } + builder.append("_testIdentifier="); + builder.append(_testIdentifier); + } + return builder.append(']').toString(); + } +} + diff --git a/sli/model/src/main/yang/sliapi.yang b/sli/model/src/main/yang/sliapi.yang new file mode 100755 index 000000000..8deb8a10f --- /dev/null +++ b/sli/model/src/main/yang/sliapi.yang @@ -0,0 +1,111 @@ +module SLI-API { + + yang-version 1; + + namespace "org:onap:ccsdk:sli:core:sliapi"; + + prefix sample; + + import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; } + + organization "ONAP"; + + contact + "Dan Timoney"; + + description + "Defines API to service logic interpreter"; + + revision "2016-11-10" { + description + "REST API to Service Logic Interpreter"; + } + + grouping parameter-setting { + description + "Parameter setting"; + + leaf parameter-name { + type string; + description "Parameter name"; + } + + leaf int-value { + type int32; + } + leaf string-value { + type string; + } + leaf boolean-value { + type boolean; + } + } + + grouping response-fields { + leaf response-code { + type string; + } + leaf ack-final-indicator { + type string; + } + leaf response-message { + type string; + } + leaf context-memory-json { + type string; + } + } + + container test-results { + description "Test results"; + + list test-result { + key "test-identifier"; + + leaf test-identifier { + type string; + } + + leaf-list results { + type string; + } + } + } + + rpc execute-graph { + description " Method to add a new parameter."; + input { + + leaf module-name { + type string; + } + + leaf rpc-name { + type string; + } + + leaf mode { + type enumeration { + enum sync; + enum async; + } + } + + list sli-parameter { + key "parameter-name"; + uses parameter-setting; + } + } + + output { + uses response-fields; + } + } + + rpc healthcheck { + output { + uses response-fields; + } + } + +} diff --git a/sli/pom.xml b/sli/pom.xml index 7257e9ee4..de882159d 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -2,64 +2,65 @@ - - org.onap.ccsdk.sli.core - ccsdk-sli-core - 0.1.2-SNAPSHOT - - 4.0.0 - pom - org.onap.ccsdk.sli.core - sli + + org.onap.ccsdk.sli.core + ccsdk-sli-core + 0.1.2-SNAPSHOT + + 4.0.0 + pom + org.onap.ccsdk.sli.core + sli - + - - - org.onap.ccsdk.sli.core - sli-features - features - xml - ${project.version} - + + + org.onap.ccsdk.sli.core + sli-features + features + xml + ${project.version} + - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - + + org.onap.ccsdk.sli.core + sli-recording + ${project.version} + - + - + - Service Logic Interpreter - The Service Logic Interpreter (SLI) allows service planners to design the flow of logic within the SDN controller in an XML format, without a need for custom Java code. + Service Logic Interpreter + The Service Logic Interpreter (SLI) allows service planners to design the flow of logic within the SDN controller in an XML format, without a need for custom Java code. - - common - provider - recording - features - installer - - - ONAP - - 0.1.2-SNAPSHOT + + model + common + provider + recording + features + installer + + + ONAP + + 0.1.2-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 51db628c7..7514c74e4 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -26,6 +26,12 @@ 2.2.3 test + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + test + org.onap.ccsdk.sli.core sli-common diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index 3e8c57b01..5ba0eb968 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -8,9 +8,9 @@ * 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. @@ -21,10 +21,26 @@ package org.onap.ccsdk.sli.core.sli.provider; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; + +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import junit.framework.TestCase; -public class MdsalHelperTest extends TestCase { +public class MdsalHelperTest extends TestCase { + private static final Logger LOG = LoggerFactory + .getLogger(MdsalHelperTest.class); public static final String pathToSdnPropertiesFile = "./src/test/resources/l3sdn.properties"; public void testSdnProperties() { @@ -40,4 +56,63 @@ public class MdsalHelperTest extends TestCase { assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); } + public void testToProperties() { + + ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); + SliParameterBuilder parmBuilder = new SliParameterBuilder(); + List params = new LinkedList(); + + parmBuilder.setParameterName("boolean-parm"); + parmBuilder.setBooleanValue(Boolean.TRUE); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("int-parm"); + parmBuilder.setIntValue(1); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("str-parm"); + parmBuilder.setStringValue("hello"); + params.add(parmBuilder.build()); + + + execBuilder.setMode(Mode.Sync); + execBuilder.setModuleName("my-module"); + execBuilder.setRpcName("do-it-now"); + execBuilder.setSliParameter(params); + + + Properties props = new Properties(); + + MdsalHelperTesterUtil.toProperties(props, execBuilder); + + LOG.info("Converted to properties"); + for (Map.Entry e : props.entrySet()) { + LOG.info(e.getKey().toString() + " = "+e.getValue().toString()); + + } + + + } + + public void testToBuilder() { + + Properties props = new Properties(); + + props.setProperty("execute-graph-input.mode", "Sync"); + props.setProperty("execute-graph-input.module", "my-module"); + props.setProperty("execute-graph-input.rpc", "do-it-now"); + props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm"); + props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true"); + props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param"); + props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1"); + props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param"); + props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello"); + + ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); + + MdsalHelperTesterUtil.toBuilder(props, execBuilder); + + + + } } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/TestMdsalHelperUtils.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/TestMdsalHelperUtils.java deleted file mode 100644 index dca6b54c6..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/TestMdsalHelperUtils.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.onap.ccsdk.sli.core.sli.provider; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.L3vpnSvcBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.SvcId; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.l3vpn.svc.VpnServicesBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.l3vpn.svc.vpn.services.VpnSvc; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.l3vpn.svc.vpn.services.VpnSvcBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.part.rev170921.l3vpn.svc.vpn.services.VpnSvcKey; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestMdsalHelperUtils { - - private static final Logger log = LoggerFactory.getLogger(TestMdsalHelperUtils.class); - - @Test - public void testL3vpnSvcToBuilder() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("l3vpn-svc.vpn-services.vpn-svc[0].vpn-id", "1"); - - L3vpnSvcBuilder svcBuilder = new L3vpnSvcBuilder(); - - MdsalHelper.toBuilder(ctx.toProperties(), "", svcBuilder); - - assertThat(svcBuilder.getVpnServices().getVpnSvc().get(0).getKey().getVpnId().getValue(), is("1")); - log.info(svcBuilder.toString()); - } - - @Test - public void testL3vpnSvcToProperties() throws SvcLogicException { - VpnSvcBuilder vpnSvcBuilder = new VpnSvcBuilder(); - vpnSvcBuilder.setKey(new VpnSvcKey(new SvcId("1"))); - List vpnSvcList = new ArrayList<>(); - vpnSvcList.add(vpnSvcBuilder.build()); - VpnServicesBuilder vpnServicesBuilder = new VpnServicesBuilder(); - vpnServicesBuilder.setVpnSvc(vpnSvcList); - L3vpnSvcBuilder l3vpnSvcBuilder = new L3vpnSvcBuilder(); - l3vpnSvcBuilder.setVpnServices(vpnServicesBuilder.build()); - - Properties properties = new Properties(); - - MdsalHelper.toProperties(properties, "", l3vpnSvcBuilder.build()); - - assertThat(properties.getProperty("l3vpn-svc.vpn-services.vpn-svc[0].vpn-id"), is("1")); - log.info(properties.toString()); - } - - // TODO add more detailed testcases. -} -- cgit 1.2.3-korg From dd9e2cbc650434d7c0da1976f9eb1bfe161f721a Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 2 Oct 2017 17:17:10 -0400 Subject: Add test cases for MdsalHelper Fix test case for loadProperties, and added test cases for IpAddress types Change-Id: Iabf182d32ae3937871dc9656105fdda0c1a9411f Issue-ID: CCSDK-106 Signed-off-by: Dan Timoney --- .../rev161110/$YangModelBindingProvider.java | 8 - .../core/sliapi/rev161110/$YangModuleInfoImpl.java | 82 ----- .../core/sliapi/rev161110/ExecuteGraphInput.java | 128 -------- .../sliapi/rev161110/ExecuteGraphInputBuilder.java | 287 ----------------- .../core/sliapi/rev161110/ExecuteGraphOutput.java | 46 --- .../rev161110/ExecuteGraphOutputBuilder.java | 315 ------------------ .../core/sliapi/rev161110/HealthcheckOutput.java | 46 --- .../sliapi/rev161110/HealthcheckOutputBuilder.java | 315 ------------------ .../core/sliapi/rev161110/ParameterSetting.java | 64 ---- .../sli/core/sliapi/rev161110/ResponseFields.java | 58 ---- .../sli/core/sliapi/rev161110/SLIAPIData.java | 147 --------- .../sli/core/sliapi/rev161110/SLIAPIService.java | 93 ------ .../sli/core/sliapi/rev161110/TestResults.java | 49 --- .../core/sliapi/rev161110/TestResultsBuilder.java | 202 ------------ .../execute/graph/input/SliParameter.java | 60 ---- .../execute/graph/input/SliParameterBuilder.java | 357 --------------------- .../execute/graph/input/SliParameterKey.java | 75 ----- .../sliapi/rev161110/test/results/TestResult.java | 62 ---- .../rev161110/test/results/TestResultBuilder.java | 271 ---------------- .../rev161110/test/results/TestResultKey.java | 75 ----- sli/model/src/main/yang/sliapi.yang | 6 + .../sli/core/sli/provider/MdsalHelperTest.java | 21 +- sli/provider/src/test/resources/l3sdn.properties | 66 ++++ 23 files changed, 91 insertions(+), 2742 deletions(-) delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModelBindingProvider.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModuleInfoImpl.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInput.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInputBuilder.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutput.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutputBuilder.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutput.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutputBuilder.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ParameterSetting.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ResponseFields.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIData.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIService.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResults.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResultsBuilder.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameter.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterBuilder.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterKey.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResult.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultBuilder.java delete mode 100644 sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultKey.java create mode 100644 sli/provider/src/test/resources/l3sdn.properties diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModelBindingProvider.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModelBindingProvider.java deleted file mode 100644 index 5195da540..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModelBindingProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; - -public final class $YangModelBindingProvider implements org.opendaylight.yangtools.yang.binding.YangModelBindingProvider { - @Override - public org.opendaylight.yangtools.yang.binding.YangModuleInfo getModuleInfo() { - return $YangModuleInfoImpl.getInstance(); - } -} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModuleInfoImpl.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModuleInfoImpl.java deleted file mode 100644 index e1cdacc54..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/$YangModuleInfoImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110 ; -import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import java.util.Set; -import java.util.HashSet; -import com.google.common.collect.ImmutableSet; -import java.io.InputStream; -import java.io.IOException; -public final class $YangModuleInfoImpl implements YangModuleInfo { - - private static final YangModuleInfo INSTANCE = new $YangModuleInfoImpl(); - - private final java.lang.String name = "SLI-API"; - private final java.lang.String namespace = "org:onap:ccsdk:sli:core:sliapi"; - private final java.lang.String revision = "2016-11-10"; - private final java.lang.String resourcePath = "/META-INF/yang/sliapi.yang"; - - private final Set importedModules; - - public static YangModuleInfo getInstance() { - return INSTANCE; - } - - private $YangModuleInfoImpl() { - Set set = new HashSet<>(); - set.add(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.$YangModuleInfoImpl.getInstance()); - importedModules = ImmutableSet.copyOf(set); - - InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath); - if (stream == null) { - throw new IllegalStateException("Resource '" + resourcePath + "' is missing"); - } - try { - stream.close(); - } catch (IOException e) { - // Resource leak, but there is nothing we can do - } - } - - @Override - public java.lang.String getName() { - return name; - } - - @Override - public java.lang.String getRevision() { - return revision; - } - - @Override - public java.lang.String getNamespace() { - return namespace; - } - - @Override - public InputStream getModuleSourceStream() throws IOException { - InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath); - if (stream == null) { - throw new IOException("Resource " + resourcePath + " is missing"); - } - return stream; - } - - @Override - public Set getImportedModules() { - return importedModules; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder sb = new java.lang.StringBuilder(this.getClass().getCanonicalName()); - sb.append("["); - sb.append("name = " + name); - sb.append(", namespace = " + namespace); - sb.append(", revision = " + revision); - sb.append(", resourcePath = " + resourcePath); - sb.append(", imports = " + importedModules); - sb.append("]"); - return sb.toString(); - } - - -} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInput.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInput.java deleted file mode 100644 index 4045483ec..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInput.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.common.QName; -import java.util.List; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; -import org.opendaylight.yangtools.yang.binding.Augmentable; - -/** - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * container input {
    - *     leaf module-name {
    - *         type string;
    - *     }
    - *     leaf rpc-name {
    - *         type string;
    - *     }
    - *     leaf mode {
    - *         type enumeration;
    - *     }
    - *     list sli-parameter {
    - *         key "parameter-name"
    - *         leaf parameter-name {
    - *             type string;
    - *         }
    - *         leaf int-value {
    - *             type int32;
    - *         }
    - *         leaf string-value {
    - *             type string;
    - *         }
    - *         leaf boolean-value {
    - *             type boolean;
    - *         }
    - *         uses parameter-setting;
    - *     }
    - * }
    - * 
    - * The schema path to identify an instance is - * SLI-API/execute-graph/input - * - *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder}. - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder - * - */ -public interface ExecuteGraphInput - extends - DataObject, - Augmentable -{ - - - public enum Mode { - Sync(0, "sync"), - - Async(1, "async") - ; - - - java.lang.String name; - int value; - private static final java.util.Map VALUE_MAP; - - static { - final com.google.common.collect.ImmutableMap.Builder b = com.google.common.collect.ImmutableMap.builder(); - for (Mode enumItem : Mode.values()) - { - b.put(enumItem.value, enumItem); - } - - VALUE_MAP = b.build(); - } - - private Mode(int value, java.lang.String name) { - this.value = value; - this.name = name; - } - - /** - * Returns the name of the enumeration item as it is specified in the input yang. - * - * @return the name of the enumeration item as it is specified in the input yang - */ - public java.lang.String getName() { - return name; - } - - /** - * @return integer value - */ - public int getIntValue() { - return value; - } - - /** - * @param valueArg - * @return corresponding Mode item - */ - public static Mode forValue(int valueArg) { - return VALUE_MAP.get(valueArg); - } - } - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", - "2016-11-10", "input").intern(); - - /** - * @return java.lang.String moduleName, or null if not present - */ - java.lang.String getModuleName(); - - /** - * @return java.lang.String rpcName, or null if not present - */ - java.lang.String getRpcName(); - - /** - * @return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode mode, or null if not present - */ - Mode getMode(); - - /** - * @return java.util.List sliParameter, or null if not present - */ - List getSliParameter(); - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInputBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInputBuilder.java deleted file mode 100644 index 9f28ef27b..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphInputBuilder.java +++ /dev/null @@ -1,287 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; -import java.util.Objects; -import java.util.List; -import java.util.Collections; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; -import java.util.Map; - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput} instances. - * - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput - * - */ -public class ExecuteGraphInputBuilder implements Builder { - - private Mode _mode; - private java.lang.String _moduleName; - private java.lang.String _rpcName; - private List _sliParameter; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public ExecuteGraphInputBuilder() { - } - - public ExecuteGraphInputBuilder(ExecuteGraphInput base) { - this._mode = base.getMode(); - this._moduleName = base.getModuleName(); - this._rpcName = base.getRpcName(); - this._sliParameter = base.getSliParameter(); - if (base instanceof ExecuteGraphInputImpl) { - ExecuteGraphInputImpl impl = (ExecuteGraphInputImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - - public Mode getMode() { - return _mode; - } - - public java.lang.String getModuleName() { - return _moduleName; - } - - public java.lang.String getRpcName() { - return _rpcName; - } - - public List getSliParameter() { - return _sliParameter; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public ExecuteGraphInputBuilder setMode(final Mode value) { - this._mode = value; - return this; - } - - - public ExecuteGraphInputBuilder setModuleName(final java.lang.String value) { - this._moduleName = value; - return this; - } - - - public ExecuteGraphInputBuilder setRpcName(final java.lang.String value) { - this._rpcName = value; - return this; - } - - - public ExecuteGraphInputBuilder setSliParameter(final List value) { - this._sliParameter = value; - return this; - } - - public ExecuteGraphInputBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public ExecuteGraphInputBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - @Override - public ExecuteGraphInput build() { - return new ExecuteGraphInputImpl(this); - } - - private static final class ExecuteGraphInputImpl implements ExecuteGraphInput { - - @Override - public java.lang.Class getImplementedInterface() { - return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.class; - } - - private final Mode _mode; - private final java.lang.String _moduleName; - private final java.lang.String _rpcName; - private final List _sliParameter; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private ExecuteGraphInputImpl(ExecuteGraphInputBuilder base) { - this._mode = base.getMode(); - this._moduleName = base.getModuleName(); - this._rpcName = base.getRpcName(); - this._sliParameter = base.getSliParameter(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public Mode getMode() { - return _mode; - } - - @Override - public java.lang.String getModuleName() { - return _moduleName; - } - - @Override - public java.lang.String getRpcName() { - return _rpcName; - } - - @Override - public List getSliParameter() { - return _sliParameter; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_mode); - result = prime * result + Objects.hashCode(_moduleName); - result = prime * result + Objects.hashCode(_rpcName); - result = prime * result + Objects.hashCode(_sliParameter); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DataObject)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.class.equals(((DataObject)obj).getImplementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)obj; - if (!Objects.equals(_mode, other.getMode())) { - return false; - } - if (!Objects.equals(_moduleName, other.getModuleName())) { - return false; - } - if (!Objects.equals(_rpcName, other.getRpcName())) { - return false; - } - if (!Objects.equals(_sliParameter, other.getSliParameter())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - ExecuteGraphInputImpl otherImpl = (ExecuteGraphInputImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.String name = "ExecuteGraphInput ["; - java.lang.StringBuilder builder = new java.lang.StringBuilder (name); - if (_mode != null) { - builder.append("_mode="); - builder.append(_mode); - builder.append(", "); - } - if (_moduleName != null) { - builder.append("_moduleName="); - builder.append(_moduleName); - builder.append(", "); - } - if (_rpcName != null) { - builder.append("_rpcName="); - builder.append(_rpcName); - builder.append(", "); - } - if (_sliParameter != null) { - builder.append("_sliParameter="); - builder.append(_sliParameter); - } - final int builderLength = builder.length(); - final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); - if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutput.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutput.java deleted file mode 100644 index 08321c079..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutput.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.binding.Augmentable; - -/** - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * container output {
    - *     leaf response-code {
    - *         type string;
    - *     }
    - *     leaf ack-final-indicator {
    - *         type string;
    - *     }
    - *     leaf response-message {
    - *         type string;
    - *     }
    - *     leaf context-memory-json {
    - *         type string;
    - *     }
    - *     uses response-fields;
    - * }
    - * 
    - * The schema path to identify an instance is - * SLI-API/execute-graph/output - * - *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder}. - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder - * - */ -public interface ExecuteGraphOutput - extends - ResponseFields, - DataObject, - Augmentable -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", - "2016-11-10", "output").intern(); - - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutputBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutputBuilder.java deleted file mode 100644 index 7b613bb41..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ExecuteGraphOutputBuilder.java +++ /dev/null @@ -1,315 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput} instances. - * - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput - * - */ -public class ExecuteGraphOutputBuilder implements Builder { - - private java.lang.String _ackFinalIndicator; - private java.lang.String _contextMemoryJson; - private java.lang.String _responseCode; - private java.lang.String _responseMessage; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public ExecuteGraphOutputBuilder() { - } - public ExecuteGraphOutputBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields arg) { - this._responseCode = arg.getResponseCode(); - this._ackFinalIndicator = arg.getAckFinalIndicator(); - this._responseMessage = arg.getResponseMessage(); - this._contextMemoryJson = arg.getContextMemoryJson(); - } - - public ExecuteGraphOutputBuilder(ExecuteGraphOutput base) { - this._ackFinalIndicator = base.getAckFinalIndicator(); - this._contextMemoryJson = base.getContextMemoryJson(); - this._responseCode = base.getResponseCode(); - this._responseMessage = base.getResponseMessage(); - if (base instanceof ExecuteGraphOutputImpl) { - ExecuteGraphOutputImpl impl = (ExecuteGraphOutputImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - /** - *Set fields from given grouping argument. Valid argument is instance of one of following types: - *

      - *
    • org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields
    • - *
    - * - * @param arg grouping object - * @throws IllegalArgumentException if given argument is none of valid types - */ - public void fieldsFrom(DataObject arg) { - boolean isValidArg = false; - if (arg instanceof org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields) { - this._responseCode = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getResponseCode(); - this._ackFinalIndicator = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getAckFinalIndicator(); - this._responseMessage = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getResponseMessage(); - this._contextMemoryJson = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getContextMemoryJson(); - isValidArg = true; - } - if (!isValidArg) { - throw new IllegalArgumentException( - "expected one of: [org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields] \n" + - "but was: " + arg - ); - } - } - - public java.lang.String getAckFinalIndicator() { - return _ackFinalIndicator; - } - - public java.lang.String getContextMemoryJson() { - return _contextMemoryJson; - } - - public java.lang.String getResponseCode() { - return _responseCode; - } - - public java.lang.String getResponseMessage() { - return _responseMessage; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public ExecuteGraphOutputBuilder setAckFinalIndicator(final java.lang.String value) { - this._ackFinalIndicator = value; - return this; - } - - - public ExecuteGraphOutputBuilder setContextMemoryJson(final java.lang.String value) { - this._contextMemoryJson = value; - return this; - } - - - public ExecuteGraphOutputBuilder setResponseCode(final java.lang.String value) { - this._responseCode = value; - return this; - } - - - public ExecuteGraphOutputBuilder setResponseMessage(final java.lang.String value) { - this._responseMessage = value; - return this; - } - - public ExecuteGraphOutputBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public ExecuteGraphOutputBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - @Override - public ExecuteGraphOutput build() { - return new ExecuteGraphOutputImpl(this); - } - - private static final class ExecuteGraphOutputImpl implements ExecuteGraphOutput { - - @Override - public java.lang.Class getImplementedInterface() { - return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput.class; - } - - private final java.lang.String _ackFinalIndicator; - private final java.lang.String _contextMemoryJson; - private final java.lang.String _responseCode; - private final java.lang.String _responseMessage; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private ExecuteGraphOutputImpl(ExecuteGraphOutputBuilder base) { - this._ackFinalIndicator = base.getAckFinalIndicator(); - this._contextMemoryJson = base.getContextMemoryJson(); - this._responseCode = base.getResponseCode(); - this._responseMessage = base.getResponseMessage(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public java.lang.String getAckFinalIndicator() { - return _ackFinalIndicator; - } - - @Override - public java.lang.String getContextMemoryJson() { - return _contextMemoryJson; - } - - @Override - public java.lang.String getResponseCode() { - return _responseCode; - } - - @Override - public java.lang.String getResponseMessage() { - return _responseMessage; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_ackFinalIndicator); - result = prime * result + Objects.hashCode(_contextMemoryJson); - result = prime * result + Objects.hashCode(_responseCode); - result = prime * result + Objects.hashCode(_responseMessage); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DataObject)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput.class.equals(((DataObject)obj).getImplementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput)obj; - if (!Objects.equals(_ackFinalIndicator, other.getAckFinalIndicator())) { - return false; - } - if (!Objects.equals(_contextMemoryJson, other.getContextMemoryJson())) { - return false; - } - if (!Objects.equals(_responseCode, other.getResponseCode())) { - return false; - } - if (!Objects.equals(_responseMessage, other.getResponseMessage())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - ExecuteGraphOutputImpl otherImpl = (ExecuteGraphOutputImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.String name = "ExecuteGraphOutput ["; - java.lang.StringBuilder builder = new java.lang.StringBuilder (name); - if (_ackFinalIndicator != null) { - builder.append("_ackFinalIndicator="); - builder.append(_ackFinalIndicator); - builder.append(", "); - } - if (_contextMemoryJson != null) { - builder.append("_contextMemoryJson="); - builder.append(_contextMemoryJson); - builder.append(", "); - } - if (_responseCode != null) { - builder.append("_responseCode="); - builder.append(_responseCode); - builder.append(", "); - } - if (_responseMessage != null) { - builder.append("_responseMessage="); - builder.append(_responseMessage); - } - final int builderLength = builder.length(); - final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); - if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutput.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutput.java deleted file mode 100644 index b0dd3b1be..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutput.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.binding.Augmentable; - -/** - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * container output {
    - *     leaf response-code {
    - *         type string;
    - *     }
    - *     leaf ack-final-indicator {
    - *         type string;
    - *     }
    - *     leaf response-message {
    - *         type string;
    - *     }
    - *     leaf context-memory-json {
    - *         type string;
    - *     }
    - *     uses response-fields;
    - * }
    - * 
    - * The schema path to identify an instance is - * SLI-API/healthcheck/output - * - *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder}. - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder - * - */ -public interface HealthcheckOutput - extends - ResponseFields, - DataObject, - Augmentable -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", - "2016-11-10", "output").intern(); - - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutputBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutputBuilder.java deleted file mode 100644 index de7840321..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/HealthcheckOutputBuilder.java +++ /dev/null @@ -1,315 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput} instances. - * - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput - * - */ -public class HealthcheckOutputBuilder implements Builder { - - private java.lang.String _ackFinalIndicator; - private java.lang.String _contextMemoryJson; - private java.lang.String _responseCode; - private java.lang.String _responseMessage; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public HealthcheckOutputBuilder() { - } - public HealthcheckOutputBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields arg) { - this._responseCode = arg.getResponseCode(); - this._ackFinalIndicator = arg.getAckFinalIndicator(); - this._responseMessage = arg.getResponseMessage(); - this._contextMemoryJson = arg.getContextMemoryJson(); - } - - public HealthcheckOutputBuilder(HealthcheckOutput base) { - this._ackFinalIndicator = base.getAckFinalIndicator(); - this._contextMemoryJson = base.getContextMemoryJson(); - this._responseCode = base.getResponseCode(); - this._responseMessage = base.getResponseMessage(); - if (base instanceof HealthcheckOutputImpl) { - HealthcheckOutputImpl impl = (HealthcheckOutputImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - /** - *Set fields from given grouping argument. Valid argument is instance of one of following types: - *

      - *
    • org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields
    • - *
    - * - * @param arg grouping object - * @throws IllegalArgumentException if given argument is none of valid types - */ - public void fieldsFrom(DataObject arg) { - boolean isValidArg = false; - if (arg instanceof org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields) { - this._responseCode = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getResponseCode(); - this._ackFinalIndicator = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getAckFinalIndicator(); - this._responseMessage = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getResponseMessage(); - this._contextMemoryJson = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields)arg).getContextMemoryJson(); - isValidArg = true; - } - if (!isValidArg) { - throw new IllegalArgumentException( - "expected one of: [org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ResponseFields] \n" + - "but was: " + arg - ); - } - } - - public java.lang.String getAckFinalIndicator() { - return _ackFinalIndicator; - } - - public java.lang.String getContextMemoryJson() { - return _contextMemoryJson; - } - - public java.lang.String getResponseCode() { - return _responseCode; - } - - public java.lang.String getResponseMessage() { - return _responseMessage; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public HealthcheckOutputBuilder setAckFinalIndicator(final java.lang.String value) { - this._ackFinalIndicator = value; - return this; - } - - - public HealthcheckOutputBuilder setContextMemoryJson(final java.lang.String value) { - this._contextMemoryJson = value; - return this; - } - - - public HealthcheckOutputBuilder setResponseCode(final java.lang.String value) { - this._responseCode = value; - return this; - } - - - public HealthcheckOutputBuilder setResponseMessage(final java.lang.String value) { - this._responseMessage = value; - return this; - } - - public HealthcheckOutputBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public HealthcheckOutputBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - @Override - public HealthcheckOutput build() { - return new HealthcheckOutputImpl(this); - } - - private static final class HealthcheckOutputImpl implements HealthcheckOutput { - - @Override - public java.lang.Class getImplementedInterface() { - return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput.class; - } - - private final java.lang.String _ackFinalIndicator; - private final java.lang.String _contextMemoryJson; - private final java.lang.String _responseCode; - private final java.lang.String _responseMessage; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private HealthcheckOutputImpl(HealthcheckOutputBuilder base) { - this._ackFinalIndicator = base.getAckFinalIndicator(); - this._contextMemoryJson = base.getContextMemoryJson(); - this._responseCode = base.getResponseCode(); - this._responseMessage = base.getResponseMessage(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public java.lang.String getAckFinalIndicator() { - return _ackFinalIndicator; - } - - @Override - public java.lang.String getContextMemoryJson() { - return _contextMemoryJson; - } - - @Override - public java.lang.String getResponseCode() { - return _responseCode; - } - - @Override - public java.lang.String getResponseMessage() { - return _responseMessage; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_ackFinalIndicator); - result = prime * result + Objects.hashCode(_contextMemoryJson); - result = prime * result + Objects.hashCode(_responseCode); - result = prime * result + Objects.hashCode(_responseMessage); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DataObject)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput.class.equals(((DataObject)obj).getImplementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput)obj; - if (!Objects.equals(_ackFinalIndicator, other.getAckFinalIndicator())) { - return false; - } - if (!Objects.equals(_contextMemoryJson, other.getContextMemoryJson())) { - return false; - } - if (!Objects.equals(_responseCode, other.getResponseCode())) { - return false; - } - if (!Objects.equals(_responseMessage, other.getResponseMessage())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - HealthcheckOutputImpl otherImpl = (HealthcheckOutputImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.String name = "HealthcheckOutput ["; - java.lang.StringBuilder builder = new java.lang.StringBuilder (name); - if (_ackFinalIndicator != null) { - builder.append("_ackFinalIndicator="); - builder.append(_ackFinalIndicator); - builder.append(", "); - } - if (_contextMemoryJson != null) { - builder.append("_contextMemoryJson="); - builder.append(_contextMemoryJson); - builder.append(", "); - } - if (_responseCode != null) { - builder.append("_responseCode="); - builder.append(_responseCode); - builder.append(", "); - } - if (_responseMessage != null) { - builder.append("_responseMessage="); - builder.append(_responseMessage); - } - final int builderLength = builder.length(); - final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); - if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ParameterSetting.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ParameterSetting.java deleted file mode 100644 index e2d610b6b..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ParameterSetting.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.common.QName; - -/** - * Parameter setting - * - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * grouping parameter-setting {
    - *     leaf parameter-name {
    - *         type string;
    - *     }
    - *     leaf int-value {
    - *         type int32;
    - *     }
    - *     leaf string-value {
    - *         type string;
    - *     }
    - *     leaf boolean-value {
    - *         type boolean;
    - *     }
    - * }
    - * 
    - * The schema path to identify an instance is - * SLI-API/parameter-setting - * - */ -public interface ParameterSetting - extends - DataObject -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", - "2016-11-10", "parameter-setting").intern(); - - /** - * Parameter name - * - * - * - * @return java.lang.String parameterName, or null if not present - */ - java.lang.String getParameterName(); - - /** - * @return java.lang.Integer intValue, or null if not present - */ - java.lang.Integer getIntValue(); - - /** - * @return java.lang.String stringValue, or null if not present - */ - java.lang.String getStringValue(); - - /** - * @return java.lang.Boolean booleanValue, or null if not present - */ - java.lang.Boolean isBooleanValue(); - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ResponseFields.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ResponseFields.java deleted file mode 100644 index 440beea03..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/ResponseFields.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.common.QName; - -/** - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * grouping response-fields {
    - *     leaf response-code {
    - *         type string;
    - *     }
    - *     leaf ack-final-indicator {
    - *         type string;
    - *     }
    - *     leaf response-message {
    - *         type string;
    - *     }
    - *     leaf context-memory-json {
    - *         type string;
    - *     }
    - * }
    - * 
    - * The schema path to identify an instance is - * SLI-API/response-fields - * - */ -public interface ResponseFields - extends - DataObject -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", - "2016-11-10", "response-fields").intern(); - - /** - * @return java.lang.String responseCode, or null if not present - */ - java.lang.String getResponseCode(); - - /** - * @return java.lang.String ackFinalIndicator, or null if not present - */ - java.lang.String getAckFinalIndicator(); - - /** - * @return java.lang.String responseMessage, or null if not present - */ - java.lang.String getResponseMessage(); - - /** - * @return java.lang.String contextMemoryJson, or null if not present - */ - java.lang.String getContextMemoryJson(); - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIData.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIData.java deleted file mode 100644 index 1917b475c..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIData.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.DataRoot; - -/** - * Defines API to service logic interpreter - * - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * module SLI-API {
    - *     yang-version 1;
    - *     namespace "org:onap:ccsdk:sli:core:sliapi";
    - *     prefix "sample";
    - *
    - *     import ietf-inet-types { prefix "inet"; }
    - *     revision 2016-11-10 {
    - *         description "Defines API to service logic interpreter
    - *         ";
    - *     }
    - *
    - *     container test-results {
    - *         list test-result {
    - *             key "test-identifier"
    - *             leaf test-identifier {
    - *                 type string;
    - *             }
    - *             leaf-list results {
    - *                 type string;
    - *             }
    - *         }
    - *     }
    - *
    - *     grouping response-fields {
    - *         leaf response-code {
    - *             type string;
    - *         }
    - *         leaf ack-final-indicator {
    - *             type string;
    - *         }
    - *         leaf response-message {
    - *             type string;
    - *         }
    - *         leaf context-memory-json {
    - *             type string;
    - *         }
    - *     }
    - *     grouping parameter-setting {
    - *         leaf parameter-name {
    - *             type string;
    - *         }
    - *         leaf int-value {
    - *             type int32;
    - *         }
    - *         leaf string-value {
    - *             type string;
    - *         }
    - *         leaf boolean-value {
    - *             type boolean;
    - *         }
    - *     }
    - *
    - *     rpc healthcheck {
    - *         input {
    - *         }
    - *         
    - *         output {
    - *             leaf response-code {
    - *                 type string;
    - *             }
    - *             leaf ack-final-indicator {
    - *                 type string;
    - *             }
    - *             leaf response-message {
    - *                 type string;
    - *             }
    - *             leaf context-memory-json {
    - *                 type string;
    - *             }
    - *         }
    - *     }
    - *     rpc execute-graph {
    - *         " Method to add a new parameter.";
    - *         input {
    - *             leaf module-name {
    - *                 type string;
    - *             }
    - *             leaf rpc-name {
    - *                 type string;
    - *             }
    - *             leaf mode {
    - *                 type enumeration;
    - *             }
    - *             list sli-parameter {
    - *                 key "parameter-name"
    - *                 leaf parameter-name {
    - *                     type string;
    - *                 }
    - *                 leaf int-value {
    - *                     type int32;
    - *                 }
    - *                 leaf string-value {
    - *                     type string;
    - *                 }
    - *                 leaf boolean-value {
    - *                     type boolean;
    - *                 }
    - *                 uses parameter-setting;
    - *             }
    - *         }
    - *         
    - *         output {
    - *             leaf response-code {
    - *                 type string;
    - *             }
    - *             leaf ack-final-indicator {
    - *                 type string;
    - *             }
    - *             leaf response-message {
    - *                 type string;
    - *             }
    - *             leaf context-memory-json {
    - *                 type string;
    - *             }
    - *         }
    - *     }
    - * }
    - * 
    - * - */ -public interface SLIAPIData - extends - DataRoot -{ - - - - - /** - * Test results - * - * - * - * @return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults testResults, or null if not present - */ - TestResults getTestResults(); - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIService.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIService.java deleted file mode 100644 index 3ad03f6fd..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/SLIAPIService.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.opendaylight.yangtools.yang.common.RpcResult; -import java.util.concurrent.Future; - -/** - * Interface for implementing the following YANG RPCs defined in module SLI-API - *
    - * rpc healthcheck {
    - *     input {
    - *     }
    - *     
    - *     output {
    - *         leaf response-code {
    - *             type string;
    - *         }
    - *         leaf ack-final-indicator {
    - *             type string;
    - *         }
    - *         leaf response-message {
    - *             type string;
    - *         }
    - *         leaf context-memory-json {
    - *             type string;
    - *         }
    - *     }
    - * }
    - * rpc execute-graph {
    - *     " Method to add a new parameter.";
    - *     input {
    - *         leaf module-name {
    - *             type string;
    - *         }
    - *         leaf rpc-name {
    - *             type string;
    - *         }
    - *         leaf mode {
    - *             type enumeration;
    - *         }
    - *         list sli-parameter {
    - *             key "parameter-name"
    - *             leaf parameter-name {
    - *                 type string;
    - *             }
    - *             leaf int-value {
    - *                 type int32;
    - *             }
    - *             leaf string-value {
    - *                 type string;
    - *             }
    - *             leaf boolean-value {
    - *                 type boolean;
    - *             }
    - *             uses parameter-setting;
    - *         }
    - *     }
    - *     
    - *     output {
    - *         leaf response-code {
    - *             type string;
    - *         }
    - *         leaf ack-final-indicator {
    - *             type string;
    - *         }
    - *         leaf response-message {
    - *             type string;
    - *         }
    - *         leaf context-memory-json {
    - *             type string;
    - *         }
    - *     }
    - * }
    - * 
    - * - */ -public interface SLIAPIService - extends - RpcService -{ - - - - - Future> healthcheck(); - - /** - * Method to add a new parameter. - * - */ - Future> executeGraph(ExecuteGraphInput input); - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResults.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResults.java deleted file mode 100644 index a1723d730..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResults.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.ChildOf; -import org.opendaylight.yangtools.yang.common.QName; -import java.util.List; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; -import org.opendaylight.yangtools.yang.binding.Augmentable; - -/** - * Test results - * - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * container test-results {
    - *     list test-result {
    - *         key "test-identifier"
    - *         leaf test-identifier {
    - *             type string;
    - *         }
    - *         leaf-list results {
    - *             type string;
    - *         }
    - *     }
    - * }
    - * 
    - * The schema path to identify an instance is - * SLI-API/test-results - * - *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResultsBuilder}. - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResultsBuilder - * - */ -public interface TestResults - extends - ChildOf, - Augmentable -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", - "2016-11-10", "test-results").intern(); - - /** - * @return java.util.List testResult, or null if not present - */ - List getTestResult(); - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResultsBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResultsBuilder.java deleted file mode 100644 index 36da730ed..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/TestResultsBuilder.java +++ /dev/null @@ -1,202 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.List; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; -import java.util.Collections; -import java.util.Map; - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults} instances. - * - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults - * - */ -public class TestResultsBuilder implements Builder { - - private List _testResult; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public TestResultsBuilder() { - } - - public TestResultsBuilder(TestResults base) { - this._testResult = base.getTestResult(); - if (base instanceof TestResultsImpl) { - TestResultsImpl impl = (TestResultsImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - - public List getTestResult() { - return _testResult; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public TestResultsBuilder setTestResult(final List value) { - this._testResult = value; - return this; - } - - public TestResultsBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public TestResultsBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - @Override - public TestResults build() { - return new TestResultsImpl(this); - } - - private static final class TestResultsImpl implements TestResults { - - @Override - public java.lang.Class getImplementedInterface() { - return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults.class; - } - - private final List _testResult; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private TestResultsImpl(TestResultsBuilder base) { - this._testResult = base.getTestResult(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public List getTestResult() { - return _testResult; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_testResult); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DataObject)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults.class.equals(((DataObject)obj).getImplementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults)obj; - if (!Objects.equals(_testResult, other.getTestResult())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - TestResultsImpl otherImpl = (TestResultsImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.String name = "TestResults ["; - java.lang.StringBuilder builder = new java.lang.StringBuilder (name); - if (_testResult != null) { - builder.append("_testResult="); - builder.append(_testResult); - } - final int builderLength = builder.length(); - final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); - if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameter.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameter.java deleted file mode 100644 index e1cac53c5..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameter.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input; -import org.opendaylight.yangtools.yang.binding.ChildOf; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; -import org.opendaylight.yangtools.yang.binding.Identifiable; - -/** - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * list sli-parameter {
    - *     key "parameter-name"
    - *     leaf parameter-name {
    - *         type string;
    - *     }
    - *     leaf int-value {
    - *         type int32;
    - *     }
    - *     leaf string-value {
    - *         type string;
    - *     }
    - *     leaf boolean-value {
    - *         type boolean;
    - *     }
    - *     uses parameter-setting;
    - * }
    - * 
    - * The schema path to identify an instance is - * SLI-API/execute-graph/input/sli-parameter - * - *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder}. - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterKey - * - */ -public interface SliParameter - extends - ChildOf, - Augmentable, - ParameterSetting, - Identifiable -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", - "2016-11-10", "sli-parameter").intern(); - - /** - * Returns Primary Key of Yang List Type - * - * - * - * @return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterKey key, or null if not present - */ - SliParameterKey getKey(); - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterBuilder.java deleted file mode 100644 index f28eb1a8b..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterBuilder.java +++ /dev/null @@ -1,357 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.Collections; -import java.util.Map; - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter} instances. - * - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter - * - */ -public class SliParameterBuilder implements Builder { - - private java.lang.Integer _intValue; - private SliParameterKey _key; - private java.lang.String _parameterName; - private java.lang.String _stringValue; - private java.lang.Boolean _booleanValue; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public SliParameterBuilder() { - } - public SliParameterBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting arg) { - this._parameterName = arg.getParameterName(); - this._intValue = arg.getIntValue(); - this._stringValue = arg.getStringValue(); - this._booleanValue = arg.isBooleanValue(); - } - - public SliParameterBuilder(SliParameter base) { - if (base.getKey() == null) { - this._key = new SliParameterKey( - base.getParameterName() - ); - this._parameterName = base.getParameterName(); - } else { - this._key = base.getKey(); - this._parameterName = _key.getParameterName(); - } - this._intValue = base.getIntValue(); - this._stringValue = base.getStringValue(); - this._booleanValue = base.isBooleanValue(); - if (base instanceof SliParameterImpl) { - SliParameterImpl impl = (SliParameterImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - /** - *Set fields from given grouping argument. Valid argument is instance of one of following types: - *

      - *
    • org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting
    • - *
    - * - * @param arg grouping object - * @throws IllegalArgumentException if given argument is none of valid types - */ - public void fieldsFrom(DataObject arg) { - boolean isValidArg = false; - if (arg instanceof org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting) { - this._parameterName = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting)arg).getParameterName(); - this._intValue = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting)arg).getIntValue(); - this._stringValue = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting)arg).getStringValue(); - this._booleanValue = ((org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting)arg).isBooleanValue(); - isValidArg = true; - } - if (!isValidArg) { - throw new IllegalArgumentException( - "expected one of: [org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ParameterSetting] \n" + - "but was: " + arg - ); - } - } - - public java.lang.Integer getIntValue() { - return _intValue; - } - - public SliParameterKey getKey() { - return _key; - } - - public java.lang.String getParameterName() { - return _parameterName; - } - - public java.lang.String getStringValue() { - return _stringValue; - } - - public java.lang.Boolean isBooleanValue() { - return _booleanValue; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public SliParameterBuilder setIntValue(final java.lang.Integer value) { - this._intValue = value; - return this; - } - - - public SliParameterBuilder setKey(final SliParameterKey value) { - this._key = value; - return this; - } - - - public SliParameterBuilder setParameterName(final java.lang.String value) { - this._parameterName = value; - return this; - } - - - public SliParameterBuilder setStringValue(final java.lang.String value) { - this._stringValue = value; - return this; - } - - - public SliParameterBuilder setBooleanValue(final java.lang.Boolean value) { - this._booleanValue = value; - return this; - } - - public SliParameterBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public SliParameterBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - @Override - public SliParameter build() { - return new SliParameterImpl(this); - } - - private static final class SliParameterImpl implements SliParameter { - - @Override - public java.lang.Class getImplementedInterface() { - return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter.class; - } - - private final java.lang.Integer _intValue; - private final SliParameterKey _key; - private final java.lang.String _parameterName; - private final java.lang.String _stringValue; - private final java.lang.Boolean _booleanValue; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private SliParameterImpl(SliParameterBuilder base) { - if (base.getKey() == null) { - this._key = new SliParameterKey( - base.getParameterName() - ); - this._parameterName = base.getParameterName(); - } else { - this._key = base.getKey(); - this._parameterName = _key.getParameterName(); - } - this._intValue = base.getIntValue(); - this._stringValue = base.getStringValue(); - this._booleanValue = base.isBooleanValue(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public java.lang.Integer getIntValue() { - return _intValue; - } - - @Override - public SliParameterKey getKey() { - return _key; - } - - @Override - public java.lang.String getParameterName() { - return _parameterName; - } - - @Override - public java.lang.String getStringValue() { - return _stringValue; - } - - @Override - public java.lang.Boolean isBooleanValue() { - return _booleanValue; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_intValue); - result = prime * result + Objects.hashCode(_key); - result = prime * result + Objects.hashCode(_parameterName); - result = prime * result + Objects.hashCode(_stringValue); - result = prime * result + Objects.hashCode(_booleanValue); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DataObject)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter.class.equals(((DataObject)obj).getImplementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter)obj; - if (!Objects.equals(_intValue, other.getIntValue())) { - return false; - } - if (!Objects.equals(_key, other.getKey())) { - return false; - } - if (!Objects.equals(_parameterName, other.getParameterName())) { - return false; - } - if (!Objects.equals(_stringValue, other.getStringValue())) { - return false; - } - if (!Objects.equals(_booleanValue, other.isBooleanValue())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - SliParameterImpl otherImpl = (SliParameterImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.String name = "SliParameter ["; - java.lang.StringBuilder builder = new java.lang.StringBuilder (name); - if (_intValue != null) { - builder.append("_intValue="); - builder.append(_intValue); - builder.append(", "); - } - if (_key != null) { - builder.append("_key="); - builder.append(_key); - builder.append(", "); - } - if (_parameterName != null) { - builder.append("_parameterName="); - builder.append(_parameterName); - builder.append(", "); - } - if (_stringValue != null) { - builder.append("_stringValue="); - builder.append(_stringValue); - builder.append(", "); - } - if (_booleanValue != null) { - builder.append("_booleanValue="); - builder.append(_booleanValue); - } - final int builderLength = builder.length(); - final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); - if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterKey.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterKey.java deleted file mode 100644 index 6c19a877b..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/execute/graph/input/SliParameterKey.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input; -import org.opendaylight.yangtools.yang.binding.Identifier; -import java.util.Objects; - -public class SliParameterKey - implements Identifier { - private static final long serialVersionUID = 8929025111457627032L; - private final java.lang.String _parameterName; - - - public SliParameterKey(java.lang.String _parameterName) { - - - this._parameterName = _parameterName; - } - - /** - * Creates a copy from Source Object. - * - * @param source Source object - */ - public SliParameterKey(SliParameterKey source) { - this._parameterName = source._parameterName; - } - - - public java.lang.String getParameterName() { - return _parameterName; - } - - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_parameterName); - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SliParameterKey other = (SliParameterKey) obj; - if (!Objects.equals(_parameterName, other._parameterName)) { - return false; - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterKey.class.getSimpleName()).append(" ["); - boolean first = true; - - if (_parameterName != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_parameterName="); - builder.append(_parameterName); - } - return builder.append(']').toString(); - } -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResult.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResult.java deleted file mode 100644 index d12faa445..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResult.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results; -import org.opendaylight.yangtools.yang.binding.ChildOf; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults; -import java.util.List; -import org.opendaylight.yangtools.yang.binding.Augmentable; -import org.opendaylight.yangtools.yang.binding.Identifiable; - -/** - *

    This class represents the following YANG schema fragment defined in module SLI-API - *

    - * list test-result {
    - *     key "test-identifier"
    - *     leaf test-identifier {
    - *         type string;
    - *     }
    - *     leaf-list results {
    - *         type string;
    - *     }
    - * }
    - * 
    - * The schema path to identify an instance is - * SLI-API/test-results/test-result - * - *

    To create instances of this class use {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder}. - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultKey - * - */ -public interface TestResult - extends - ChildOf, - Augmentable, - Identifiable -{ - - - - public static final QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("org:onap:ccsdk:sli:core:sliapi", - "2016-11-10", "test-result").intern(); - - /** - * @return java.lang.String testIdentifier, or null if not present - */ - java.lang.String getTestIdentifier(); - - /** - * @return java.util.List results, or null if not present - */ - List getResults(); - - /** - * Returns Primary Key of Yang List Type - * - * - * - * @return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultKey key, or null if not present - */ - TestResultKey getKey(); - -} - diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultBuilder.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultBuilder.java deleted file mode 100644 index 51e437222..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultBuilder.java +++ /dev/null @@ -1,271 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.AugmentationHolder; -import org.opendaylight.yangtools.yang.binding.DataObject; -import java.util.HashMap; -import org.opendaylight.yangtools.concepts.Builder; -import java.util.Objects; -import java.util.List; -import java.util.Collections; -import java.util.Map; - -/** - * Class that builds {@link org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult} instances. - * - * @see org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult - * - */ -public class TestResultBuilder implements Builder { - - private TestResultKey _key; - private List _results; - private java.lang.String _testIdentifier; - - Map>, Augmentation> augmentation = Collections.emptyMap(); - - public TestResultBuilder() { - } - - public TestResultBuilder(TestResult base) { - if (base.getKey() == null) { - this._key = new TestResultKey( - base.getTestIdentifier() - ); - this._testIdentifier = base.getTestIdentifier(); - } else { - this._key = base.getKey(); - this._testIdentifier = _key.getTestIdentifier(); - } - this._results = base.getResults(); - if (base instanceof TestResultImpl) { - TestResultImpl impl = (TestResultImpl) base; - if (!impl.augmentation.isEmpty()) { - this.augmentation = new HashMap<>(impl.augmentation); - } - } else if (base instanceof AugmentationHolder) { - @SuppressWarnings("unchecked") - AugmentationHolder casted =(AugmentationHolder) base; - if (!casted.augmentations().isEmpty()) { - this.augmentation = new HashMap<>(casted.augmentations()); - } - } - } - - - public TestResultKey getKey() { - return _key; - } - - public List getResults() { - return _results; - } - - public java.lang.String getTestIdentifier() { - return _testIdentifier; - } - - @SuppressWarnings("unchecked") - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - - public TestResultBuilder setKey(final TestResultKey value) { - this._key = value; - return this; - } - - - public TestResultBuilder setResults(final List value) { - this._results = value; - return this; - } - - - public TestResultBuilder setTestIdentifier(final java.lang.String value) { - this._testIdentifier = value; - return this; - } - - public TestResultBuilder addAugmentation(java.lang.Class> augmentationType, Augmentation augmentation) { - if (augmentation == null) { - return removeAugmentation(augmentationType); - } - - if (!(this.augmentation instanceof HashMap)) { - this.augmentation = new HashMap<>(); - } - - this.augmentation.put(augmentationType, augmentation); - return this; - } - - public TestResultBuilder removeAugmentation(java.lang.Class> augmentationType) { - if (this.augmentation instanceof HashMap) { - this.augmentation.remove(augmentationType); - } - return this; - } - - @Override - public TestResult build() { - return new TestResultImpl(this); - } - - private static final class TestResultImpl implements TestResult { - - @Override - public java.lang.Class getImplementedInterface() { - return org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult.class; - } - - private final TestResultKey _key; - private final List _results; - private final java.lang.String _testIdentifier; - - private Map>, Augmentation> augmentation = Collections.emptyMap(); - - private TestResultImpl(TestResultBuilder base) { - if (base.getKey() == null) { - this._key = new TestResultKey( - base.getTestIdentifier() - ); - this._testIdentifier = base.getTestIdentifier(); - } else { - this._key = base.getKey(); - this._testIdentifier = _key.getTestIdentifier(); - } - this._results = base.getResults(); - switch (base.augmentation.size()) { - case 0: - this.augmentation = Collections.emptyMap(); - break; - case 1: - final Map.Entry>, Augmentation> e = base.augmentation.entrySet().iterator().next(); - this.augmentation = Collections.>, Augmentation>singletonMap(e.getKey(), e.getValue()); - break; - default : - this.augmentation = new HashMap<>(base.augmentation); - } - } - - @Override - public TestResultKey getKey() { - return _key; - } - - @Override - public List getResults() { - return _results; - } - - @Override - public java.lang.String getTestIdentifier() { - return _testIdentifier; - } - - @SuppressWarnings("unchecked") - @Override - public > E getAugmentation(java.lang.Class augmentationType) { - if (augmentationType == null) { - throw new IllegalArgumentException("Augmentation Type reference cannot be NULL!"); - } - return (E) augmentation.get(augmentationType); - } - - private int hash = 0; - private volatile boolean hashValid = false; - - @Override - public int hashCode() { - if (hashValid) { - return hash; - } - - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_key); - result = prime * result + Objects.hashCode(_results); - result = prime * result + Objects.hashCode(_testIdentifier); - result = prime * result + Objects.hashCode(augmentation); - - hash = result; - hashValid = true; - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof DataObject)) { - return false; - } - if (!org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult.class.equals(((DataObject)obj).getImplementedInterface())) { - return false; - } - org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult other = (org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult)obj; - if (!Objects.equals(_key, other.getKey())) { - return false; - } - if (!Objects.equals(_results, other.getResults())) { - return false; - } - if (!Objects.equals(_testIdentifier, other.getTestIdentifier())) { - return false; - } - if (getClass() == obj.getClass()) { - // Simple case: we are comparing against self - TestResultImpl otherImpl = (TestResultImpl) obj; - if (!Objects.equals(augmentation, otherImpl.augmentation)) { - return false; - } - } else { - // Hard case: compare our augments with presence there... - for (Map.Entry>, Augmentation> e : augmentation.entrySet()) { - if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { - return false; - } - } - // .. and give the other one the chance to do the same - if (!obj.equals(this)) { - return false; - } - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.String name = "TestResult ["; - java.lang.StringBuilder builder = new java.lang.StringBuilder (name); - if (_key != null) { - builder.append("_key="); - builder.append(_key); - builder.append(", "); - } - if (_results != null) { - builder.append("_results="); - builder.append(_results); - builder.append(", "); - } - if (_testIdentifier != null) { - builder.append("_testIdentifier="); - builder.append(_testIdentifier); - } - final int builderLength = builder.length(); - final int builderAdditionalLength = builder.substring(name.length(), builderLength).length(); - if (builderAdditionalLength > 2 && !builder.substring(builderLength - 2, builderLength).equals(", ")) { - builder.append(", "); - } - builder.append("augmentation="); - builder.append(augmentation.values()); - return builder.append(']').toString(); - } - } - -} diff --git a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultKey.java b/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultKey.java deleted file mode 100644 index d867ca23b..000000000 --- a/sli/model/src/main/yang-gen-sal/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/rev161110/test/results/TestResultKey.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results; -import org.opendaylight.yangtools.yang.binding.Identifier; -import java.util.Objects; - -public class TestResultKey - implements Identifier { - private static final long serialVersionUID = 3857649555637491806L; - private final java.lang.String _testIdentifier; - - - public TestResultKey(java.lang.String _testIdentifier) { - - - this._testIdentifier = _testIdentifier; - } - - /** - * Creates a copy from Source Object. - * - * @param source Source object - */ - public TestResultKey(TestResultKey source) { - this._testIdentifier = source._testIdentifier; - } - - - public java.lang.String getTestIdentifier() { - return _testIdentifier; - } - - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Objects.hashCode(_testIdentifier); - return result; - } - - @Override - public boolean equals(java.lang.Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - TestResultKey other = (TestResultKey) obj; - if (!Objects.equals(_testIdentifier, other._testIdentifier)) { - return false; - } - return true; - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder builder = new java.lang.StringBuilder(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultKey.class.getSimpleName()).append(" ["); - boolean first = true; - - if (_testIdentifier != null) { - if (first) { - first = false; - } else { - builder.append(", "); - } - builder.append("_testIdentifier="); - builder.append(_testIdentifier); - } - return builder.append(']').toString(); - } -} - diff --git a/sli/model/src/main/yang/sliapi.yang b/sli/model/src/main/yang/sliapi.yang index 8deb8a10f..5d91ba2d5 100755 --- a/sli/model/src/main/yang/sliapi.yang +++ b/sli/model/src/main/yang/sliapi.yang @@ -39,6 +39,12 @@ module SLI-API { leaf boolean-value { type boolean; } + leaf ipaddress-value { + type inet:ip-address; + } + leaf ipprefix-value { + type inet:ip-prefix; + } } grouping response-fields { diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index 5ba0eb968..c00da68c5 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider; +import java.io.File; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -32,6 +33,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,9 +43,10 @@ import junit.framework.TestCase; public class MdsalHelperTest extends TestCase { private static final Logger LOG = LoggerFactory .getLogger(MdsalHelperTest.class); - public static final String pathToSdnPropertiesFile = "./src/test/resources/l3sdn.properties"; + public static final String pathToSdnPropertiesFile = "src/test/resources/l3sdn.properties"; public void testSdnProperties() { + MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile); assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "synccomplete")); assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); @@ -67,13 +70,24 @@ public class MdsalHelperTest extends TestCase { params.add(parmBuilder.build()); parmBuilder.setParameterName("int-parm"); + parmBuilder.setBooleanValue(null); parmBuilder.setIntValue(1); params.add(parmBuilder.build()); parmBuilder.setParameterName("str-parm"); + parmBuilder.setIntValue(null); parmBuilder.setStringValue("hello"); params.add(parmBuilder.build()); + parmBuilder.setParameterName("ipaddress4-parm"); + parmBuilder.setStringValue(null); + parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("ipaddress6-parm"); + parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1")); + params.add(parmBuilder.build()); + execBuilder.setMode(Mode.Sync); execBuilder.setModuleName("my-module"); @@ -107,7 +121,10 @@ public class MdsalHelperTest extends TestCase { props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1"); props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param"); props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello"); - + props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param"); + props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1"); + props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param"); + props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1"); ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); MdsalHelperTesterUtil.toBuilder(props, execBuilder); diff --git a/sli/provider/src/test/resources/l3sdn.properties b/sli/provider/src/test/resources/l3sdn.properties new file mode 100644 index 000000000..6f40ebca0 --- /dev/null +++ b/sli/provider/src/test/resources/l3sdn.properties @@ -0,0 +1,66 @@ +# yang conversion properties +# used to convert Enum back to the original yang value +yang.request-status.Synccomplete=synccomplete +yang.request-status.Asynccomplete=asynccomplete +yang.request-status.Notifycomplete=notifycomplete +yang.rpc-name.ServiceConfigurationOperation=service-configuration-operation +yang.rpc-name.SvcTopologyOperation=svc-topology-operation +yang.rpc-name.ServiceConfigurationNotification=service-configuration-notification +yang.rpc-action.Reserve=reserve +yang.rpc-action.Activate=activate +yang.rpc-action.Assign=assign +yang.rpc-action.Turnup=turnup +yang.rpc-action.Delete=delete +yang.rpc-action.Changereserve=changereserve +yang.rpc-action.Changeactivate=changeactivate +yang.rpc-action.Changedelete=changedelete +yang.rpc-action.Changeassign=changeassign +yang.svc-vnf-type.Vce=vce +yang.vnf-type.Vce=vce +yang.vnf-status.PendingCreate=pending-create +yang.vnf-status.Created=created +yang.vnf-status.Active=active +yang.vnf-status.PendingDelete=pending-delete +yang.connection-type.Customer=customer +yang.connection-type.Internet=internet +yang.net-status.PendingCreate=pending-create +yang.net-status.Created=created +yang.net-status.Active=active +yang.net-status.PendingDelete=pending-delete +yang.svc-action.Reserve=reserve +yang.svc-action.Activate=activate +yang.svc-action.Assign=assign +yang.svc-action.Turnup=turnup +yang.svc-action.Delete=delete +yang.svc-action.Changereserve=changereserve +yang.svc-action.Changeactivate=changeactivate +yang.svc-action.Changedelete=changedelete +yang.svc-action.Changeassign=changeassign +yang.service-type.SDNETHERNETINTERNET=SDN-ETHERNET-INTERNET +yang.internet-evc-speed-value._2=2 +yang.internet-evc-speed-value._4=4 +yang.internet-evc-speed-value._5=5 +yang.internet-evc-speed-value._8=8 +yang.internet-evc-speed-value._10=10 +yang.internet-evc-speed-value._20=20 +yang.internet-evc-speed-value._50=50 +yang.internet-evc-speed-value._100=100 +yang.internet-evc-speed-value._150=150 +yang.internet-evc-speed-value._250=250 +yang.internet-evc-speed-value._400=400 +yang.internet-evc-speed-value._500=500 +yang.internet-evc-speed-value._600=600 +yang.internet-evc-speed-value._1000=1000 +yang.ip-version.Ds=ds +yang.ip-version.V6=v6 +yang.routing-protocol.None=none +yang.routing-protocol.Bgp=bgp +yang.routing-protocol.Ospf=ospf +yang.routing-protocol.Igrp=igrp +yang.routing-protocol.Eigrp=eigrp +yang.routing-protocol.Rip=rip +yang.routing-protocol.IsIs=is-is +yang.vr-designation.Primary=primary +yang.feature-type.FIREWALLLITE=FIREWALL-LITE +yang.equipment-role.VPLSPE=VPLS-PE +yang.interface-role.CUSTOMERUPLINK=CUSTOMER-UPLINK -- cgit 1.2.3-korg From 78af232946c8534fa154bd0b425daf2bcac73e00 Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Tue, 3 Oct 2017 16:09:04 +0530 Subject: Add unit test for ccsdk/core *Add a unit test for SliStringUtils This is to test substring method of SliStringUtils and improve code coverage Issue-Id: CCSDK-106 Change-Id: I73c5af3b036a92fdcb1d3d1be7eb0b3abc44fd5a Signed-off-by: surya-huawei --- .../ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index 96c6ae4ac..4fc8d1866 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -90,6 +90,18 @@ public class SliStringUtilsTest { assertThat(ctx.getAttribute("result_length"), equalTo("2")); } + @Test + public final void testSubString() throws SvcLogicException { + param.put("string","splitatgivenindex"); + param.put("begin-index","0"); + param.put("end-index","5"); + param.put("result","result"); + + stringUtils.substring(param, ctx); + + assertEquals("split", ctx.getAttribute("result")); + } + @Test public final void testQuotedOrNull() throws SvcLogicException { //param.put("nullString",null); -- cgit 1.2.3-korg From d73d257d76fa8211113fa3ef1a4e4058e67f4f2c Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 3 Oct 2017 08:17:38 -0400 Subject: Add unit tests for dblib Add unit test case for dblib/provider, using MariaDB4J as database. Change-Id: I18492595a9d54999c3d52b56ecfe33d0d2cae019 Issue-ID: CCSDK-106 Signed-off-by: Dan Timoney --- dblib/provider/pom.xml | 6 +++ .../sli/core/dblib/TestDBResourceManager.java | 55 ++++++++++++++++++++++ dblib/provider/src/test/resources/dblib.properties | 38 +++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java create mode 100644 dblib/provider/src/test/resources/dblib.properties diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index d0dc72933..730919de0 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -21,6 +21,12 @@ ${junit.version} test + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + equinoxSDK381 org.eclipse.osgi diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java new file mode 100644 index 000000000..dca07921b --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java @@ -0,0 +1,55 @@ +package org.onap.ccsdk.sli.core.dblib; + +import static org.junit.Assert.*; + +import java.io.InputStream; +import java.net.URL; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; + +import ch.vorburger.mariadb4j.DB; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; + +public class TestDBResourceManager { + + DbLibService dblibSvc; + + @Before + public void setUp() throws Exception { + URL propUrl = getClass().getResource("/dblib.properties"); + + InputStream propStr = getClass().getResourceAsStream("/dblib.properties"); + + Properties props = new Properties(); + + props.load(propStr); + + + // Start MariaDB4j database + DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); + config.setPort(0); // 0 => autom. detect free port + DB db = DB.newEmbeddedDB(config.build()); + db.start(); + + + // Override jdbc URL and database name + props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + + + dblibSvc = new DBResourceManager(props); + + dblibSvc.writeData("CREATE TABLE DBLIB_TEST (name varchar(20));", null, null); + dblibSvc.getData("SELECT * FROM DBLIB_TEST", null, null); + + } + + @Test + public void test() { + + + } + +} diff --git a/dblib/provider/src/test/resources/dblib.properties b/dblib/provider/src/test/resources/dblib.properties new file mode 100644 index 000000000..9506ac8d1 --- /dev/null +++ b/dblib/provider/src/test/resources/dblib.properties @@ -0,0 +1,38 @@ +### +# ============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========================================================= +### + +# dblib.properrties +org.onap.ccsdk.sli.dbtype=jdbc + +org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01 +org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl +org.onap.ccsdk.sli.jdbc.driver=org.mariadb.jdbc.Driver +org.onap.ccsdk.sli.jdbc.database=sdnctl +org.onap.ccsdk.sli.jdbc.user=sdnctl +org.onap.ccsdk.sli.jdbc.password=gamma +org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01 +org.onap.ccsdk.sli.jdbc.connection.timeout=50 +org.onap.ccsdk.sli.jdbc.request.timeout=100 +org.onap.ccsdk.sli.jdbc.limit.init=10 +org.onap.ccsdk.sli.jdbc.limit.min=10 +org.onap.ccsdk.sli.jdbc.limit.max=20 +org.onap.dblib.connection.recovery=false + -- cgit 1.2.3-korg From eb1a9209bb408256799869da53cffaf4d6751cfb Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 10 Oct 2017 16:59:25 -0400 Subject: Add readthedocs templates Add readthedocs templates for sli/core Change-Id: I2efaad7720997ef51c4dcb9036de5011bc6a1c4b Issue-ID: CCSDK-107 Signed-off-by: Dan Timoney --- .gitignore | 1 + docs/architecture.rst | 27 +++++++++++++++++++++++++++ docs/build.rst | 23 +++++++++++++++++++++++ docs/index.rst | 16 +++++++--------- docs/logging.rst | 22 ++++++++++++++++++++++ docs/offeredapis.rst | 16 ++++++++++++++++ docs/release-notes.rst | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 142 insertions(+), 9 deletions(-) create mode 100644 docs/architecture.rst create mode 100644 docs/build.rst create mode 100644 docs/logging.rst create mode 100644 docs/offeredapis.rst create mode 100644 docs/release-notes.rst diff --git a/.gitignore b/.gitignore index 319e695b1..a36bed326 100755 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ workspace target target-ide MANIFEST.MF +**/yang-gen-sal ## Misc Ignores (OS specific etc) ## bin/ diff --git a/docs/architecture.rst b/docs/architecture.rst new file mode 100644 index 000000000..a1956d59f --- /dev/null +++ b/docs/architecture.rst @@ -0,0 +1,27 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +Architecture +============ + +.. note:: + * This section is used to describe a software component from a high level + view of capability, common usage scenarios, and interactions with other + components required in the usage scenarios. + + * The architecture section is typically: provided in a platform-component + and sdk collections; and referenced from developer and user guides. + + * This note must be removed after content has been added. + + +Capabilities +------------ + + +Usage Scenarios +--------------- + + +Interactions +------------ diff --git a/docs/build.rst b/docs/build.rst new file mode 100644 index 000000000..99a061c24 --- /dev/null +++ b/docs/build.rst @@ -0,0 +1,23 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +Build +===== + +.. note:: + * This section is used to describe how a software component is built from source + into something ready for use either in a run-time environment or to build other + components. + + * This section is typically provided for a platform-component, application, and sdk; and + referenced in developer guides. + + * This note must be removed after content has been added. + + +Environment +----------- + + +Steps +----- diff --git a/docs/index.rst b/docs/index.rst index 3a4849b2d..2055f1780 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,15 +1,13 @@ .. This work is licensed under a Creative Commons Attribution 4.0 International License. -SDNC Service Logic Interpreter ------------------------------- +CCSDK Service Logic Interpreter +------------------------------- .. toctree:: :maxdepth: 1 -Offered APIs -============ -List of Northbound APIs + architecture.rst + offeredapis.rst + logging.rst + build.rst + release-notes.rst -SLI-API(2016-11-11) -================== - -.. swaggerv2doc:: https://gerrit.onap.org/r/gitweb?p=ccsdk/sli/core.git;a=blob_plain;f=sliapi/model/src/main/resources/ sli-api.20161110.json diff --git a/docs/logging.rst b/docs/logging.rst new file mode 100644 index 000000000..5662acb1f --- /dev/null +++ b/docs/logging.rst @@ -0,0 +1,22 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +Logging +======= + +.. note:: + * This section is used to describe the informational or diagnostic messages emitted from + a software component and the methods or collecting them. + + * This section is typically: provided for a platform-component and sdk; and + referenced in developer and user guides + + * This note must be removed after content has been added. + + +Where to Access Information +--------------------------- + + +Error / Warning Messages +------------------------ diff --git a/docs/offeredapis.rst b/docs/offeredapis.rst new file mode 100644 index 000000000..de686ad36 --- /dev/null +++ b/docs/offeredapis.rst @@ -0,0 +1,16 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +Offered APIs +============ + +.. toctree:: + :maxdepth: 1 + :titlesonly: + +SLI-API(2016-11-11) +=================== + +.. swaggerv2doc:: https://gerrit.onap.org/r/gitweb?p=ccsdk/sli/core.git;a=blob_plain;f=sliapi/model/src/main/resources/sli-api.20161110.json + + diff --git a/docs/release-notes.rst b/docs/release-notes.rst new file mode 100644 index 000000000..b45165706 --- /dev/null +++ b/docs/release-notes.rst @@ -0,0 +1,46 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. + +Release Notes +============= + +.. note:: + * This Release Notes must be updated each time the team decides to Release new artifacts. + * The scope of this Release Notes is for this particular component. In other words, each ONAP component has its Release Notes. + * This Release Notes is cumulative, the most recently Released artifact is made visible in the top of this Release Notes. + * Except the date and the version number, all the other sections are optional but there must be at least one section describing the purpose of this new release. + * This note must be removed after content has been added. + + +Version: x.y.z +-------------- + + +:Release Date: yyyy-mm-dd + + + +**New Features** + +One or two sentences explaining the purpose of this Release. + +**Bug Fixes** + - `CIMAN-65 `_ and a sentence explaining what this defect is addressing. +**Known Issues** + - `CIMAN-65 `_ and two, three sentences. + One sentences explaining what is the issue. + + Another sentence explaining the impact of the issue. + + And an optional sentence providing a workaround. + +**Security Issues** + You may want to include a reference to CVE (Common Vulnerabilities and Exposures) `CVE `_ + + +**Upgrade Notes** + +**Deprecation Notes** + +**Other** + +=========== \ No newline at end of file -- cgit 1.2.3-korg From 312f6a301ae62f121482df6cbf969d41a76ca131 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 11 Oct 2017 11:01:38 -0400 Subject: Add readthedocs info to sli/core Add additional information to sli/core readthedocs documentation. Change-Id: I9fe5e6185061ed6a05f373b6667f686e11d5f0aa Issue-ID: CCSDK-107 Signed-off-by: Dan Timoney --- docs/apis/sliapi.rst | 15 + docs/architecture.rst | 19 +- docs/build.rst | 17 +- docs/logging.rst | 16 +- docs/nodes.rst | 1031 ++++++++++++++++++++ docs/offeredapis.rst | 6 +- sliapi/model/pom.xml | 13 +- .../model/src/main/resources/sli-api.20161110.json | 514 +++++++++- 8 files changed, 1586 insertions(+), 45 deletions(-) create mode 100644 docs/apis/sliapi.rst create mode 100644 docs/nodes.rst diff --git a/docs/apis/sliapi.rst b/docs/apis/sliapi.rst new file mode 100644 index 000000000..13cdcbd54 --- /dev/null +++ b/docs/apis/sliapi.rst @@ -0,0 +1,15 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 + +SLI-API(2016-11-11) +=================== + +.. toctree:: + :maxdepth: 1 + :titlesonly: + + + +.. swaggerv2doc:: https://gerrit.onap.org/r/gitweb?p=ccsdk/sli/core.git;a=blob_plain;f=sliapi/model/src/main/resources/sli-api.20161110.json + + diff --git a/docs/architecture.rst b/docs/architecture.rst index a1956d59f..f6101a116 100644 --- a/docs/architecture.rst +++ b/docs/architecture.rst @@ -4,24 +4,17 @@ Architecture ============ -.. note:: - * This section is used to describe a software component from a high level - view of capability, common usage scenarios, and interactions with other - components required in the usage scenarios. - - * The architecture section is typically: provided in a platform-component - and sdk collections; and referenced from developer and user guides. - - * This note must be removed after content has been added. Capabilities ------------ +Provides the core Service Logic Interpreter (SLI) functionality, used to execute directed graphs (DGs). Directed graphs allow service designers to define the +logic to be executed within the SDN controller in a graphical format which can be +updated in real time, without a need to restart the controller. +.. toctree:: + :maxdepth: 1 -Usage Scenarios ---------------- + nodes.rst -Interactions ------------- diff --git a/docs/build.rst b/docs/build.rst index 99a061c24..0a4c308e6 100644 --- a/docs/build.rst +++ b/docs/build.rst @@ -4,20 +4,15 @@ Build ===== -.. note:: - * This section is used to describe how a software component is built from source - into something ready for use either in a run-time environment or to build other - components. - - * This section is typically provided for a platform-component, application, and sdk; and - referenced in developer guides. - - * This note must be removed after content has been added. - Environment ----------- - +Requires maven release 3.3 or greater Steps ----- +To compile this code: + +1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the ONAP repositories and OpenDaylight repositories. + +2. To compile, run "mvn clean install". \ No newline at end of file diff --git a/docs/logging.rst b/docs/logging.rst index 5662acb1f..187eb03b7 100644 --- a/docs/logging.rst +++ b/docs/logging.rst @@ -3,20 +3,12 @@ Logging ======= - -.. note:: - * This section is used to describe the informational or diagnostic messages emitted from - a software component and the methods or collecting them. - - * This section is typically: provided for a platform-component and sdk; and - referenced in developer and user guides - - * This note must be removed after content has been added. - +CCSDK uses slf4j to log messages to the standard OpenDaylight karaf.log +log file. Where to Access Information --------------------------- +Logs are found within the SDNC docker container, in the directory +/opt/opendaylight/current/data/logs. -Error / Warning Messages ------------------------- diff --git a/docs/nodes.rst b/docs/nodes.rst new file mode 100644 index 000000000..3bdeabcfa --- /dev/null +++ b/docs/nodes.rst @@ -0,0 +1,1031 @@ +--- Service Logic Interpreter --- Dan Timoney --- 2014-11-12 --- + +Supported node types +==================== + +The following built-in node types are currently supported: + +- Flow Control + + - `**block** <#Block_node>`__ + + - `**call** <#Call_node>`__ + + - `**for** <#For_node>`__ + + - `**return** <#Return_node>`__ + + - `**set** <#Set_node>`__ + + - `**switch** <#Switch_node>`__ + +- Device Management + + - `**configure** <#Configure_node>`__ + +- Java Plugin Support + + - `**execute** <#Execute_node>`__ + +- Recording + + - `**record** <#Record_node>`__ + +- Resource Management + + - `**delete** <#Delete_node>`__ + + - `**exists** <#Exists_node>`__ + + - `**get-resource** <#Get-resource_node>`__ + + - `**is-available** <#Is-available_node>`__ + + - `**notify** <#Notify_node>`__ + + - `**release** <#Release_node>`__ + + - `**reserve** <#Reserve_node>`__ + + - `**save** <#Save_node>`__ + + - `**update** <#Update_node>`__ + +Flow Control +------------ + +Block node +~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **block** node is used to executes a set of nodes. + +Attributes +^^^^^^^^^^ + ++--------------+-----------------------------------------------------------------------------------------------------------------------------------+ +| **atomic** | if *true*, then if a node returns failure, subsequent nodes will not be executed and nodes already executed will be backed out. | ++--------------+-----------------------------------------------------------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + +None + +Example +^^^^^^^ + +:: + + + + + + + + + + + + + +Call node +~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **call** node is used to call another graph + +Attributes +^^^^^^^^^^ + ++---------------+------------------------------------------------------------------------------------+ +| **module** | Module of directed graph to call. If unset, defaults to that of calling graph | ++---------------+------------------------------------------------------------------------------------+ +| **rpc** | rpc of directed graph to call. | ++---------------+------------------------------------------------------------------------------------+ +| **version** | version of graph to call, If unset, uses active version. | ++---------------+------------------------------------------------------------------------------------+ +| **mode** | mode (sync/async) of graph to call. If unset, defaults to that of calling graph. | ++---------------+------------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +Not applicable + +Outcomes +^^^^^^^^ + ++-----------------+------------------------------+ +| **success** | Sub graph returned success | ++-----------------+------------------------------+ +| **not-found** | Graph not found | ++-----------------+------------------------------+ +| **failure** | Subgraph returned success | ++-----------------+------------------------------+ + +Table: . + +Example +^^^^^^^ + +:: + + + +For node +~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **for** node provides a fixed iteration looping mechanism, similar to +the Java for loop + +Attributes +^^^^^^^^^^ + ++-------------+------------------+ +| **index** | index variable | ++-------------+------------------+ +| **start** | initial value | ++-------------+------------------+ +| **end** | maximum value | ++-------------+------------------+ + +Parameters +^^^^^^^^^^ + +Not applicable. + +Outcomes +^^^^^^^^ + +Not applicable. The **status** node has no outcomes. + +Example +^^^^^^^ + +:: + + + + + + + + + +Return node +~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **return** node is used to return a status to the invoking MD-SAL +application + +Attributes +^^^^^^^^^^ + ++--------------+---------------------------------------------------+ +| **status** | Status value to return (*success* or *failure*) | ++--------------+---------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +The following optional parameters may be passed to convey more detailed +status information. + ++---------------------+-----------------------------------------------------------------+ +| **error-code** | A brief, usually numeric, code indicating the error condition | ++---------------------+-----------------------------------------------------------------+ +| **error-message** | A more detailed error message | ++---------------------+-----------------------------------------------------------------+ + +Outcomes +^^^^^^^^ + +Not applicable. The **status** node has no outcomes. + +Example +^^^^^^^ + +:: + + + + + + +Set node +~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **set** node is used to set one or more values in the execution +context + +Attributes +^^^^^^^^^^ + ++---------------------+-------------------------------------------------------------------------------------+ +| **only-if-unset** | If true the set node will only execute if the current value of the target is null | ++---------------------+-------------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +Values to be set are passed as parameters + +Outcomes +^^^^^^^^ + +Not applicable. The **set** node has no outcomes. + +Example +^^^^^^^ + +:: + + + + + +Switch node +~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **switch** node is used to make a decision based on its **test** +attribute. + +Attributes +^^^^^^^^^^ + ++------------+---------------------+ +| **test** | Condition to test | ++------------+---------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + +Depends on the **test** condition + +Example +^^^^^^^ + +:: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Device Management +----------------- + +Configure node +~~~~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **configure** node is used to configure a device. + +Attributes +^^^^^^^^^^ + ++----------------+-----------------------------------------------------------------------------------+ +| **adaptor** | Fully qualified Java class of resource adaptor to be used | ++----------------+-----------------------------------------------------------------------------------+ +| **activate** | Activate device/interface, for devices that support a separate activation step. | ++----------------+-----------------------------------------------------------------------------------+ +| **key** | SQL-like string specifying criteria for item to configure | ++----------------+-----------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +Specific to device adaptor. + +Outcomes +^^^^^^^^ + ++----------------------+------------------------------------------------------------------+ +| **success** | Device successfully configured | ++----------------------+------------------------------------------------------------------+ +| **not-found** | Element to be configured does not exist. | ++----------------------+------------------------------------------------------------------+ +| **not-ready** | Element is not in a state where it can be configured/activated | ++----------------------+------------------------------------------------------------------+ +| **already-active** | Attempt to activate element that is already active | ++----------------------+------------------------------------------------------------------+ +| **failure** | Configure failed for some other reason | ++----------------------+------------------------------------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Java Plugin Support +------------------- + +Execute node +~~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +An **execute** node is used to execute Java code supplied as a plugin + +Attributes +^^^^^^^^^^ + ++--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of plugin to be used | ++--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| **method** | Name of method in the plugin class to execute. Method must return void, and take 2 arguments: a Map (for parameters) and a SvcLogicContext (to allow plugin read/write access to context memory) | ++--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +Specific to plugin / method + +Outcomes +^^^^^^^^ + ++--------------------------+-----------------------------------------------------------------+ +| **success** | Device successfully configured | ++--------------------------+-----------------------------------------------------------------+ +| **not-found** | Plugin class could not be loaded | ++--------------------------+-----------------------------------------------------------------+ +| **unsupported-method** | Named method taking (Map, SvcLogicContext) could not be found | ++--------------------------+-----------------------------------------------------------------+ +| **failure** | Configure failed for some other reason | ++--------------------------+-----------------------------------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + + + + + + + + + + + +Recording +--------- + +Record node +~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **record** node is used to record an event. For example, this might be +used to log provisioning events. + +Attributes +^^^^^^^^^^ + ++--------------+---------------------------------------------------+ +| **plugin** | Fully qualified Java class to handle recording. | ++--------------+---------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +Parameters will depend on the plugin being used. For the FileRecorder +class, the parameters are as follows + ++--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| **file** | The file to which the record should be written | ++--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| **field1** | First field to write. There will be **field** parameters for each field to write, from **field1** through **fieldN**. A special value \_\_TIMESTAMP\_\_ may be assigned to a field to insert the current timestamp | ++--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +Outcomes +^^^^^^^^ + ++---------------+--------------------------------------------+ +| **success** | Record successfully written | ++---------------+--------------------------------------------+ +| **failure** | Record could not be successfully written | ++---------------+--------------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + +Resource Management +------------------- + +Delete node +~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **delete** node is used to delete a resource from the local resource +inventory. + +Attributes +^^^^^^^^^^ + ++----------------+-------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+-------------------------------------------------------------+ +| **resource** | Type of resource to delete | ++----------------+-------------------------------------------------------------+ +| **key** | SQL-like string specifying key to delete | ++----------------+-------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + ++---------------+--------------------------------------------+ +| **success** | Resource specified deleted successfully. | ++---------------+--------------------------------------------+ +| *failure*> | Resource specified was not deleted | ++---------------+--------------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + +Exists node +~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +An **exists** node is used to determine whether a particular instance of +a resource exists. For example, this might be used to test whether a +particular switch CLLI is provisioned. + +Attributes +^^^^^^^^^^ + ++----------------+-------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+-------------------------------------------------------------+ +| **resource** | Type of resource to check | ++----------------+-------------------------------------------------------------+ +| **key** | SQL-like string specifying key to check for | ++----------------+-------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + ++-------------+---------------------------------+ +| **true** | Resource specified exists. | ++-------------+---------------------------------+ +| **false** | Resource specified is unknown | ++-------------+---------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + +Get-resource node +~~~~~~~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **get-resource** node is used to retrieve information about a +particular resource and make it available to other nodes in the service +logic tree. For example, this might be used to retrieve information +about a particular uni-port. + +Attributes +^^^^^^^^^^ + ++----------------+------------------------------------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+------------------------------------------------------------------------------------------+ +| **resource** | Type of resource to retrieve | ++----------------+------------------------------------------------------------------------------------------+ +| **key** | SQL-like string specifying criteria for retrieval | ++----------------+------------------------------------------------------------------------------------------+ +| **pfx** | Prefix to add to context variable names set for data retrieved | ++----------------+------------------------------------------------------------------------------------------+ +| **select** | String to specify, if key matches multiple entries, which entry should take precedence | ++----------------+------------------------------------------------------------------------------------------+ +| **order-by** | Prefix to add to context variable names set for data retrieved | ++----------------+------------------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + ++-----------------+--------------------------------------------------+ +| **success** | Resource successfully retrieved | ++-----------------+--------------------------------------------------+ +| **not-found** | Resource referenced does not exist | ++-----------------+--------------------------------------------------+ +| **failure** | Resource retrieve failed for some other reason | ++-----------------+--------------------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + + + + +Is-available node +~~~~~~~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +An **is-available** node is used to determine whether a particular type +of resource is available. For example, this might be used to test +whether any ports are available for assignment on a particular switch. + +Attributes +^^^^^^^^^^ + ++----------------+------------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+------------------------------------------------------------------+ +| **resource** | Type of resource to check | ++----------------+------------------------------------------------------------------+ +| **key** | SQL-like string specifying key to check for | ++----------------+------------------------------------------------------------------+ +| **pfx** | Prefix to add to context variable names set for data retrieved | ++----------------+------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + ++-------------+---------------------------------------+ +| **true** | Resource requested is available | ++-------------+---------------------------------------+ +| **false** | Resource requested is not available | ++-------------+---------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + +Notify node +~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **notify** node is used to inform an external application (e.g. A&AI) +that a resource was updated. + +Attributes +^^^^^^^^^^ + ++----------------+---------------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+---------------------------------------------------------------------+ +| **resource** | Identifies resource that was updated | ++----------------+---------------------------------------------------------------------+ +| **action** | Action that triggered notification to be sent (ADD/UPDATE/DELETE) | ++----------------+---------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + ++---------------+----------------------------------------+ +| **success** | Notification was successful | ++---------------+----------------------------------------+ +| **failure** | Notification failed is not available | ++---------------+----------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + +Release node +~~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **release** node is used to mark a resource as no longer in use, and +thus available for assignment. + +Attributes +^^^^^^^^^^ + ++----------------+------------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+------------------------------------------------------------------+ +| **resource** | Type of resource to release | ++----------------+------------------------------------------------------------------+ +| **key** | SQL-like string specifying key to check of resource to release | ++----------------+------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + ++-----------------+-------------------------------------------------+ +| **success** | Resource successfully released | ++-----------------+-------------------------------------------------+ +| **not-found** | Resource referenced does not exist | ++-----------------+-------------------------------------------------+ +| **failure** | Resource release failed for some other reason | ++-----------------+-------------------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + + + + +Reserve node +~~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **reserve** node is used to reserve a particular type of resource.. +For example, this might be used to reserve a port on a particular +switch. + +Attributes +^^^^^^^^^^ + ++----------------+----------------------------------------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+----------------------------------------------------------------------------------------------+ +| **resource** | Type of resource to reserve | ++----------------+----------------------------------------------------------------------------------------------+ +| **key** | SQL-like string specifying criteria for reservation | ++----------------+----------------------------------------------------------------------------------------------+ +| **select** | String to specify, if **key** matches multiple entries, which entry should take precedence | ++----------------+----------------------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +None + +Outcomes +^^^^^^^^ + ++---------------+----------------------------------------------------+ +| **success** | Resource requested was successfully reserved | ++---------------+----------------------------------------------------+ +| **failure** | Resource requested was not successfully reserved | ++---------------+----------------------------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + +Save node +~~~~~~~~~ + +Description +^^^^^^^^^^^ + +A **save** node is used to save information about a particular resource +to persistent storage. For example, this might be used to save +information about a particular uni-port. + +Attributes +^^^^^^^^^^ + ++----------------+------------------------------------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+------------------------------------------------------------------------------------------+ +| **resource** | Type of resource to save | ++----------------+------------------------------------------------------------------------------------------+ +| **key** | SQL-like string specifying criteria for retrieval | ++----------------+------------------------------------------------------------------------------------------+ +| **force** | If "true", save resource even if this resource is already stored in persistent storage | ++----------------+------------------------------------------------------------------------------------------+ +| **pfx** | Prefix to be prepended to variable names, when attributes are set in SvcLogicContext | ++----------------+------------------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +Values to save (columns) are specified as parameters, with each name +corresponding to a column name and each value corresponding to the value +to set. + +Outcomes +^^^^^^^^ + ++---------------+-------------------------------+ +| **success** | Resource successfully saved | ++---------------+-------------------------------+ +| **failure** | Resource save failed | ++---------------+-------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + + +Update node +~~~~~~~~~~~ + +Description +^^^^^^^^^^^ + +An **update** node is used to update information about a particular +resource to persistent storage. + +Attributes +^^^^^^^^^^ + ++----------------+----------------------------------------------------------------------------------------+ +| **plugin** | Fully qualified Java class of resource adaptor to be used | ++----------------+----------------------------------------------------------------------------------------+ +| **resource** | Type of resource to update | ++----------------+----------------------------------------------------------------------------------------+ +| **key** | SQL-like string specifying criteria for retrieval | ++----------------+----------------------------------------------------------------------------------------+ +| **pfx** | Prefix to be prepended to variable names, when attributes are set in SvcLogicContext | ++----------------+----------------------------------------------------------------------------------------+ + +Parameters +^^^^^^^^^^ + +Values to save (columns) are specified as parameters, with each name +corresponding to a column name and each value corresponding to the value +to set. + +Outcomes +^^^^^^^^ + ++---------------+-------------------------------+ +| **success** | Resource successfully saved | ++---------------+-------------------------------+ +| **failure** | Resource save failed | ++---------------+-------------------------------+ + +Example +^^^^^^^ + +:: + + + + + + + + + diff --git a/docs/offeredapis.rst b/docs/offeredapis.rst index de686ad36..42eafdd41 100644 --- a/docs/offeredapis.rst +++ b/docs/offeredapis.rst @@ -8,9 +8,5 @@ Offered APIs :maxdepth: 1 :titlesonly: -SLI-API(2016-11-11) -=================== - -.. swaggerv2doc:: https://gerrit.onap.org/r/gitweb?p=ccsdk/sli/core.git;a=blob_plain;f=sliapi/model/src/main/resources/sli-api.20161110.json - + apis/sliapi.rst diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index fc9b76377..d36aaa131 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -33,6 +33,12 @@ ${odl.sal.api.gen.plugin.version} jar + + org.opendaylight.netconf + sal-rest-docgen-maven + ${odl.restconf.version} + jar + @@ -43,12 +49,13 @@ ${yang.file.directory} - org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl ${salGeneratorPath} + + org.opendaylight.netconf.sal.rest.doc.maven.StaticDocGenerator + target/swagger + true diff --git a/sliapi/model/src/main/resources/sli-api.20161110.json b/sliapi/model/src/main/resources/sli-api.20161110.json index 0cc53fe92..da966e1e7 100644 --- a/sliapi/model/src/main/resources/sli-api.20161110.json +++ b/sliapi/model/src/main/resources/sli-api.20161110.json @@ -1 +1,513 @@ -{"apiVersion":"1.0.0","swaggerVersion":"1.2","basePath":"restconf","resourcePath":null,"produces":["application/json","application/xml"],"apis":[{"path":"/config","operations":[{"method":"POST","summary":null,"notes":"Defines API to service logic interpreter","type":"(config)SLI-API_modulePOST","nickname":"POST-SLI-API_module","consumes":["application/json","application/xml"],"parameters":[{"name":"**(config)test-results","description":null,"required":false,"type":"SLI-API(config)test-results-TOP","paramType":"body"}],"responseMessages":null}]},{"path":"/config/SLI-API:test-results","operations":[{"method":"GET","summary":null,"notes":"Test results","type":"(config)test-results","nickname":"GET-test-results","consumes":null,"parameters":[],"responseMessages":null},{"method":"PUT","summary":null,"notes":"Test results","type":"SLI-API(config)test-results-TOP","nickname":"PUT-test-results","consumes":["application/json","application/xml"],"parameters":[{"name":"(config)test-results","description":null,"required":false,"type":"SLI-API(config)test-results-TOP","paramType":"body"}],"responseMessages":null},{"method":"DELETE","summary":null,"notes":"Test results","type":null,"nickname":"DELETE-test-results","consumes":null,"parameters":[],"responseMessages":null},{"method":"POST","summary":null,"notes":"Test results","type":"(config)test-resultsPOST","nickname":"POST-test-results","consumes":["application/json","application/xml"],"parameters":[{"name":"**(config)test-result","description":null,"required":false,"type":"SLI-API/test-results(config)test-result-TOP","paramType":"body"}],"responseMessages":null}]},{"path":"/config/SLI-API:test-results/test-result/{test-identifier}","operations":[{"method":"GET","summary":null,"notes":null,"type":"(config)test-result","nickname":"GET-test-result","consumes":null,"parameters":[{"name":"test-identifier","description":null,"required":false,"type":"string","paramType":"path"}],"responseMessages":null},{"method":"PUT","summary":null,"notes":null,"type":"SLI-API/test-results(config)test-result-TOP","nickname":"PUT-test-result","consumes":["application/json","application/xml"],"parameters":[{"name":"test-identifier","description":null,"required":false,"type":"string","paramType":"path"},{"name":"(config)test-result","description":null,"required":false,"type":"SLI-API/test-results(config)test-result-TOP","paramType":"body"}],"responseMessages":null},{"method":"DELETE","summary":null,"notes":null,"type":null,"nickname":"DELETE-test-result","consumes":null,"parameters":[{"name":"test-identifier","description":null,"required":false,"type":"string","paramType":"path"}],"responseMessages":null}]},{"path":"/operational/SLI-API:test-results","operations":[{"method":"GET","summary":null,"notes":"Test results","type":"(operational)test-results","nickname":"GET-test-results","consumes":null,"parameters":[],"responseMessages":null}]},{"path":"/operations/SLI-API:healthcheck","operations":[{"method":"POST","summary":null,"notes":null,"type":"(healthcheck)output-TOP","nickname":"healthcheck","consumes":["application/json","application/xml"],"parameters":[{"name":null,"description":null,"required":false,"type":"(healthcheck)input-TOP","paramType":"body"}],"responseMessages":null}]},{"path":"/operations/SLI-API:execute-graph","operations":[{"method":"POST","summary":null,"notes":" Method to add a new parameter.","type":"(execute-graph)output-TOP","nickname":"execute-graph","consumes":["application/json","application/xml"],"parameters":[{"name":null,"description":null,"required":false,"type":"(execute-graph)input-TOP","paramType":"body"}],"responseMessages":null}]}],"models":{"(execute-graph)output":{"$schema":"http://json-schema.org/draft-04/schema","id":"(execute-graph)output","type":"object","properties":{"SLI-API:response-code":{"type":"Some response-code","required":false},"SLI-API:ack-final-indicator":{"type":"Some ack-final-indicator","required":false},"SLI-API:context-memory-json":{"type":"Some context-memory-json","required":false},"SLI-API:response-message":{"type":"Some response-message","required":false}}},"SLI-API(config)sli-parameter":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(config)sli-parameter","type":"object","properties":{"SLI-API:boolean-value":{"type":"true","required":false},"SLI-API:parameter-name":{"description":"Parameter name","type":"Some parameter-name","required":false},"SLI-API:int-value":{"type":"-2147483648","required":false},"SLI-API:string-value":{"type":"Some string-value","required":false}}},"SLI-API/test-results(config)test-result":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API/test-results(config)test-result","type":"object","properties":{"SLI-API:results":{"type":"array","items":{"type":"Some results"},"required":false},"SLI-API:test-identifier":{"type":"Some test-identifier","required":false}}},"(config)sli-parameterPOST":{"$schema":"http://json-schema.org/draft-04/schema","id":"(config)sli-parameterPOST","type":"object","properties":{"parameter-name":{"description":"Parameter name","type":"Some parameter-name","required":false},"boolean-value":{"type":"true","required":false},"string-value":{"type":"Some string-value","required":false},"int-value":{"type":"-2147483648","required":false}}},"SLI-API(config)test-results":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(config)test-results","type":"object","properties":{"SLI-API:test-result":{"type":"array","items":{"$ref":"SLI-API/test-results(config)test-result"}}}},"(healthcheck)input":{"$schema":"http://json-schema.org/draft-04/schema","id":"(healthcheck)input","type":"object","properties":{"SLI-API:dummy-leaf":{"type":"Some dummy-leaf","required":false}}},"(execute-graph)input":{"$schema":"http://json-schema.org/draft-04/schema","id":"(execute-graph)input","type":"object","properties":{"SLI-API:rpc-name":{"type":"Some rpc-name","required":false},"SLI-API:sli-parameter":{"type":"array","items":{"$ref":"SLI-API(config)sli-parameter"}},"SLI-API:module-name":{"type":"Some module-name","required":false},"SLI-API:mode":{"type":"sync","required":false,"enum":["sync","async"]}}},"(execute-graph)input-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"(execute-graph)input-TOP","type":"object","properties":{"SLI-API:input":{"type":"object","items":{"$ref":"(execute-graph)input"}}}},"unique_empty_identifier":{},"SLI-API/test-results(config)test-result-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API/test-results(config)test-result-TOP","type":"object","properties":{"SLI-API:test-result":{"type":"array","items":{"$ref":"SLI-API/test-results(config)test-result"}}}},"SLI-API(config)sli-parameter-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(config)sli-parameter-TOP","type":"object","properties":{"SLI-API:sli-parameter":{"type":"array","items":{"$ref":"SLI-API(config)sli-parameter"}}}},"SLI-API(operational)test-results":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(operational)test-results","type":"object","properties":{}},"(execute-graph)output-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"(execute-graph)output-TOP","type":"object","properties":{"SLI-API:output":{"type":"object","items":{"$ref":"(execute-graph)output"}}}},"(healthcheck)output":{"$schema":"http://json-schema.org/draft-04/schema","id":"(healthcheck)output","type":"object","properties":{"SLI-API:response-code":{"type":"Some response-code","required":false},"SLI-API:ack-final-indicator":{"type":"Some ack-final-indicator","required":false},"SLI-API:context-memory-json":{"type":"Some context-memory-json","required":false},"SLI-API:response-message":{"type":"Some response-message","required":false}}},"(config)SLI-API_modulePOST":{"$schema":"http://json-schema.org/draft-04/schema","id":"(config)SLI-API_modulePOST","type":"object","properties":{"test-results":{"type":"object","items":{"$ref":"SLI-API(config)test-results"}}}},"(config)test-resultsPOST":{"$schema":"http://json-schema.org/draft-04/schema","id":"(config)test-resultsPOST","type":"object","properties":{"test-result":{"type":"array","items":{"$ref":"SLI-API/test-results(config)test-result"}}}},"SLI-API(operational)test-results-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(operational)test-results-TOP","type":"object","properties":{"SLI-API:test-results":{"description":"Test results","type":"object","items":{"$ref":"SLI-API(operational)test-results"}}}},"SLI-API(config)test-results-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"SLI-API(config)test-results-TOP","type":"object","properties":{"SLI-API:test-results":{"description":"Test results","type":"object","items":{"$ref":"SLI-API(config)test-results"}}}},"(healthcheck)input-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"(healthcheck)input-TOP","type":"object","properties":{"SLI-API:input":{"type":"object","items":{"$ref":"(healthcheck)input"}}}},"(healthcheck)output-TOP":{"$schema":"http://json-schema.org/draft-04/schema","id":"(healthcheck)output-TOP","type":"object","properties":{"SLI-API:output":{"type":"object","items":{"$ref":"(healthcheck)output"}}}},"(config)test-resultPOST":{"$schema":"http://json-schema.org/draft-04/schema","id":"(config)test-resultPOST","type":"object","properties":{"test-identifier":{"type":"Some test-identifier","required":false}}}}} \ No newline at end of file +{ + "swagger": "2.0", + "info": { + "version": "1.0.0" + }, + "basePath": "/restconf", + "paths": { + "/config": { + "post": { + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "**(config)test-results", + "required": false, + "schema": { + "$ref": "#/definitions/SLI-API(config)test-results-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(config)SLI-API_modulePOST" + } + } + }, + "description": "Defines API to service logic interpreter", + "operationId": "POST-SLI-API_module" + } + }, + "/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/(config)test-results" + } + } + }, + "description": "Test results", + "operationId": "GET-test-results" + }, + "post": { + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "**(config)test-result", + "required": false, + "schema": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(config)test-resultsPOST" + } + } + }, + "description": "Test results", + "operationId": "POST-test-results" + }, + "put": { + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "(config)test-results", + "required": false, + "schema": { + "$ref": "#/definitions/SLI-API(config)test-results-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/SLI-API(config)test-results-TOP" + } + } + }, + "description": "Test results", + "operationId": "PUT-test-results" + } + }, + "/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/(config)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": "(config)test-result", + "required": false, + "schema": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" + } + } + }, + "operationId": "PUT-test-result" + } + }, + "/operational/SLI-API:test-results": { + "get": { + "produces": [ + "application/json", + "application/xml" + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(operational)test-results" + } + } + }, + "description": "Test results", + "operationId": "GET-test-results" + } + }, + "/operations/SLI-API:execute-graph": { + "post": { + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "$ref": "#/definitions/(execute-graph)input-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(execute-graph)output-TOP" + } + } + }, + "description": " Method to add a new parameter.", + "operationId": "execute-graph" + } + }, + "/operations/SLI-API:healthcheck": { + "post": { + "produces": [ + "application/json", + "application/xml" + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(healthcheck)output-TOP" + } + } + }, + "operationId": "healthcheck" + } + } + }, + "definitions": { + "(config)SLI-API_modulePOST": { + "properties": { + "test-results": { + "items": { + "$ref": "#/definitions/SLI-API(config)test-results" + }, + "type": "object" + } + }, + "type": "object" + }, + "(config)sli-parameterPOST": { + "properties": { + "boolean-value": { + "$ref": "#/definitions/true" + }, + "int-value": { + "$ref": "#/definitions/-2147483648" + }, + "parameter-name": { + "$ref": "#/definitions/Some parameter-name", + "description": "Parameter name" + }, + "string-value": { + "$ref": "#/definitions/Some string-value" + } + }, + "type": "object" + }, + "(config)test-resultPOST": { + "properties": { + "test-identifier": { + "$ref": "#/definitions/Some test-identifier" + } + }, + "type": "object" + }, + "(config)test-resultsPOST": { + "properties": { + "test-result": { + "items": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result" + }, + "type": "array" + } + }, + "type": "object" + }, + "(execute-graph)input": { + "properties": { + "SLI-API:mode": { + "$ref": "#/definitions/sync", + "enum": [ + "sync", + "async" + ] + }, + "SLI-API:module-name": { + "$ref": "#/definitions/Some module-name" + }, + "SLI-API:rpc-name": { + "$ref": "#/definitions/Some rpc-name" + }, + "SLI-API:sli-parameter": { + "items": { + "$ref": "#/definitions/SLI-API(config)sli-parameter" + }, + "type": "array" + } + }, + "type": "object" + }, + "(execute-graph)input-TOP": { + "properties": { + "SLI-API:input": { + "items": { + "$ref": "#/definitions/(execute-graph)input" + }, + "type": "object" + } + }, + "type": "object" + }, + "(execute-graph)output": { + "properties": { + "SLI-API:ack-final-indicator": { + "$ref": "#/definitions/Some ack-final-indicator" + }, + "SLI-API:context-memory-json": { + "$ref": "#/definitions/Some context-memory-json" + }, + "SLI-API:response-code": { + "$ref": "#/definitions/Some response-code" + }, + "SLI-API:response-message": { + "$ref": "#/definitions/Some response-message" + } + }, + "type": "object" + }, + "(execute-graph)output-TOP": { + "properties": { + "SLI-API:output": { + "items": { + "$ref": "#/definitions/(execute-graph)output" + }, + "type": "object" + } + }, + "type": "object" + }, + "(healthcheck)output": { + "properties": { + "SLI-API:ack-final-indicator": { + "$ref": "#/definitions/Some ack-final-indicator" + }, + "SLI-API:context-memory-json": { + "$ref": "#/definitions/Some context-memory-json" + }, + "SLI-API:response-code": { + "$ref": "#/definitions/Some response-code" + }, + "SLI-API:response-message": { + "$ref": "#/definitions/Some response-message" + } + }, + "type": "object" + }, + "(healthcheck)output-TOP": { + "properties": { + "SLI-API:output": { + "items": { + "$ref": "#/definitions/(healthcheck)output" + }, + "type": "object" + } + }, + "type": "object" + }, + "SLI-API(config)sli-parameter": { + "properties": { + "SLI-API:boolean-value": { + "$ref": "#/definitions/true" + }, + "SLI-API:int-value": { + "$ref": "#/definitions/-2147483648" + }, + "SLI-API:parameter-name": { + "$ref": "#/definitions/Some parameter-name", + "description": "Parameter name" + }, + "SLI-API:string-value": { + "$ref": "#/definitions/Some string-value" + } + }, + "type": "object" + }, + "SLI-API(config)sli-parameter-TOP": { + "properties": { + "SLI-API:sli-parameter": { + "items": { + "$ref": "#/definitions/SLI-API(config)sli-parameter" + }, + "type": "array" + } + }, + "type": "object" + }, + "SLI-API(config)test-results": { + "properties": { + "SLI-API:test-result": { + "items": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result" + }, + "type": "array" + } + }, + "type": "object" + }, + "SLI-API(config)test-results-TOP": { + "properties": { + "SLI-API:test-results": { + "description": "Test results", + "items": { + "$ref": "#/definitions/SLI-API(config)test-results" + }, + "type": "object" + } + }, + "type": "object" + }, + "SLI-API(operational)test-results": { + "type": "object" + }, + "SLI-API(operational)test-results-TOP": { + "properties": { + "SLI-API:test-results": { + "description": "Test results", + "items": { + "$ref": "#/definitions/SLI-API(operational)test-results" + }, + "type": "object" + } + }, + "type": "object" + }, + "SLI-API/test-results(config)test-result": { + "properties": { + "SLI-API:results": { + "items": { + "$ref": "#/definitions/Some results" + }, + "type": "array" + }, + "SLI-API:test-identifier": { + "$ref": "#/definitions/Some test-identifier" + } + }, + "type": "object" + }, + "SLI-API/test-results(config)test-result-TOP": { + "properties": { + "SLI-API:test-result": { + "items": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result" + }, + "type": "array" + } + }, + "type": "object" + }, + "unique_empty_identifier": {} + } +} -- cgit 1.2.3-korg From e940e23cd0b574f8239cdd24fc3b1e590326361e Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 12 Oct 2017 11:48:42 +0530 Subject: Add @Override annotation *This is improve readability of source code Issue-Id: CCSDK-117 Change-Id: I4bb73a6e4b440ae861045c7548a7e985d1fbf02c Signed-off-by: surya-huawei --- .../src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java index b670a832d..4bfa058a8 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java @@ -102,6 +102,7 @@ public class PollingWorker implements Runnable { tasks.remove(object); } + @Override public void run() { for(;;){ Set data = new TreeSet(); @@ -150,6 +151,7 @@ public class PollingWorker implements Runnable { class MyTimerTask extends TimerTask{ + @Override public void run() { clearReqister(); @@ -198,6 +200,7 @@ public class PollingWorker implements Runnable { return endtime - starttime; } + @Override public int compareTo(Object o) { if(o instanceof TestSample){ TestSample x = (TestSample)o; -- cgit 1.2.3-korg From 1e1e9ffde7143ff18ff893f2ad5cb371dde139d1 Mon Sep 17 00:00:00 2001 From: Sheshi Chinthakayala Date: Wed, 18 Oct 2017 15:55:47 -0500 Subject: added code to convert yang to properties this code is used by dgbuilder to convert the yang to context property names Change-Id: Ib53f57df6e8bd32a3a1b7ba6fa7854497c1f5c6c Issue-ID: SDNC-81 Signed-off-by: Sheshi Chinthakayala --- .../onap/ccsdk/sli/core/sli/PrintYangToProp.java | 1367 ++++++++++++++++++++ 1 file changed, 1367 insertions(+) create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java new file mode 100644 index 000000000..bcbe42a60 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java @@ -0,0 +1,1367 @@ +/*- + * ============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; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.FileDescriptor; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; +import java.util.Arrays; +import java.util.ArrayList; +import java.io.*; +import org.opendaylight.yangtools.yang.binding.Identifier; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.CaseFormat; + +public class PrintYangToProp { + + private static final Logger LOG = LoggerFactory.getLogger(PrintYangToProp.class); + public static final String PROPERTIES_FILE=""; + private static Properties properties; + + public static Properties prop = new Properties(); + public static ArrayList propList = new ArrayList(); + + + public static Properties toProperties(Properties props, Object fromObj) { + Class fromClass = null; + + if (fromObj != null) + { + fromClass = fromObj.getClass(); + } + return (toProperties(props, "", fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj) + { + Class fromClass = null; + + if (fromObj != null) + { + fromClass = fromObj.getClass(); + } + + return(toProperties(props, pfx, fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, + Object fromObj, Class fromClass) { + + if (fromObj == null) { + return (props); + } + + + String simpleName = fromClass.getSimpleName(); + + //LOG.debug("Extracting properties from " + fromClass.getName() + // + " class"); + if (fromObj instanceof List) { + + // Class is a List. List should contain yang-generated classes. + //LOG.debug(fromClass.getName() + " is a List"); + + List fromList = (List) fromObj; + + for (int i = 0; i < fromList.size(); i++) { + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); + } + props.setProperty(pfx + "_length", "" + fromList.size()); + + } else if (isYangGenerated(fromClass)) { + // Class is yang generated. + //LOG.debug(fromClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + + // If called from a list (so prefix ends in ']'), don't + // add class name again + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx ; + } else { + propNamePfx = toLowerHyphen(fromClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // save from + + for (Method m : fromClass.getMethods()) { + // LOG.debug("Checking " + m.getName() + " method"); + if (isGetter(m)) { + // LOG.debug(m.getName() + " is a getter"); + Class returnType = m.getReturnType(); + String fieldName = toLowerHyphen(m.getName().substring(3)); + if(m != null && m.getName().matches("^is[A-Z].*")){ + fieldName = toLowerHyphen(m.getName().substring(2)); + } + + fieldName = fieldName.substring(0, 1).toLowerCase() + + fieldName.substring(1); + + // Is the return type a yang generated class? + if (isYangGenerated(returnType)) { + //System.out.println("returnType:" +returnType); + // Is it an enum? + if (returnType.isEnum()) { + // Return type is a typedef. Save its value. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + Object retValue = m.invoke(fromObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + String propName = propNamePfx + "." + + fieldName; + String propVal = retValue.toString(); + String yangProp = "yang." + fieldName + "." + propVal; + if ( properties.containsKey(yangProp)) { + propVal = properties.getProperty(yangProp); + //LOG.debug("Adjusting property " + yangProp + " " + propVal); + } + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated enum returned by " + + fromClass.getName() + "." + + m.getName() + + "() to Properties entry", e); + } + } else if (isIpv4Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue().toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + + fromClass.getName() + "." + + m.getName() + + "() to Properties entry", e); + } + } else if (isIpv6Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue().toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + + fromClass.getName() + "." + + m.getName() + + "() to Properties entry", e); + } + } else if (isIpv4Prefix(returnType)) { + //System.out.println("isIpv4Prefix"); + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Prefix retValue = (Ipv4Prefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue().toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + + fromClass.getName() + "." + + m.getName() + + "() to Properties entry", e); + } + } else if (isIpv6Prefix(returnType)) { + //System.out.println("isIpv6Prefix"); + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Prefix retValue = (Ipv6Prefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue().toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + + fromClass.getName() + "." + + m.getName() + + "() to Properties entry", e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated class returned by" + + fromClass.getName() + "." + + m.getName() + + "() to Properties entry", e); + } + } + } else if (returnType.equals(Class.class)) { + + //LOG.debug(m.getName() + // + " returns a Class object - not interested"); + + } else if (List.class.isAssignableFrom(returnType)) { + + // This getter method returns a list. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retList = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + // Figure out what type of elements are stored in this array. + Type paramType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) paramType) + .getActualTypeArguments()[0]; + toProperties(props, propNamePfx + "." + fieldName, + retList, (Class)elementType); + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert List returned by " + + fromClass.getName() + "." + + m.getName() + + "() to Properties entry", e); + } + + } else { + + // Method returns something that is not a List and not + // yang-generated. + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object propValObj = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (propValObj != null) { + String propVal = propValObj.toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by " + + fromClass.getName() + "." + + m.getName() + + "() to Properties entry", e); + } + } + + } + } + + } else { + // Class is not yang generated and not a list + // Do nothing. + + } + + return (props); + } + + public static Object toBuilder(Properties props, Object toObj) { + + return (toBuilder(props, "", toObj)); + } + + public static List toList(Properties props, String pfx, List toObj, + Class elemType) { + + int maxIdx = -1; + boolean foundValue = false; + + //LOG.debug("Saving properties to List<" + elemType.getName() + // + "> from " + pfx); + + // Figure out array size + for (Object pNameObj : props.keySet()) { + String key = (String) pNameObj; + + if (key.startsWith(pfx + "[")) { + String idxStr = key.substring(pfx.length() + 1); + int endloc = idxStr.indexOf("]"); + if (endloc != -1) { + idxStr = idxStr.substring(0, endloc); + } + + try { + int curIdx = Integer.parseInt(idxStr); + if (curIdx > maxIdx) { + maxIdx = curIdx; + } + } catch (Exception e) { + LOG.error("Illegal subscript in property " + key); + } + + } + } + + //LOG.debug(pfx + " has max index of " + maxIdx); + for (int i = 0; i <= maxIdx; i++) { + + String curBase = pfx + "[" + i + "]"; + + if (isYangGenerated(elemType)) { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + //LOG.debug("Calling " + builderObj.getClass().getName() + // + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class " + builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from " + + pfx); + } + } + + } + + if (foundValue) { + return (toObj); + } else { + return (null); + } + + } + + public static Object toBuilder(Properties props, String pfx, Object toObj) { + return(toBuilder(props, pfx, toObj, false)); + } + + public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { + Class toClass = toObj.getClass(); + boolean foundValue = false; + + //LOG.debug("Saving properties to " + toClass.getName() + " class from " + // + pfx); + + Ipv4Address addr; + + if (isYangGenerated(toClass)) { + // Class is yang generated. + //LOG.debug(toClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + if (preservePfx) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - "-impl".length()); + } + } + + if (toObj instanceof Identifier) { + //LOG.debug(toClass.getName() + " is a Key - skipping"); + return (toObj); + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + // LOG.debug("Is " + m.getName() + " method a setter?"); + if (isSetter(m)) { + // LOG.debug(m.getName() + " is a setter"); + Class paramTypes[] = m.getParameterTypes(); + Class paramClass = paramTypes[0]; + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + String paramValue = props.getProperty(propName); + if (paramValue == null) { + //LOG.debug(propName + " is unset"); + } else { + //LOG.debug(propName + " = " + paramValue); + } + + // Is the return type a yang generated class? + if (isYangGenerated(paramClass)) { + // Is it an enum? + if (paramClass.isEnum()) { + + //LOG.debug(m.getName() + " expects an Enum"); + // Param type is a typedef. + if (paramValue != null) { + Object paramObj = null; + + try { + paramObj = Enum.valueOf(paramClass, + toUpperCamelCase(paramValue)); + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert field " + + propName + " to enum " + + paramClass.getName(), e); + } + + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + //LOG.debug("Calling " + // + toObj.getClass().getName() + "." + // + m.getName() + "(" + paramValue + // + ")"); + m.invoke(toObj, paramObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to create Yang-generated enum expected by" + + toClass.getName() + + "." + + m.getName() + + "() from Properties entry", + e); + } + } + } else { + + String simpleName = paramClass.getSimpleName(); + LOG.info("simpleName:" + simpleName); + + if ("Ipv4Address".equals(simpleName) + || "Ipv6Address".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName)) { + + if (paramValue != null) { + if("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName)){ + try { + IpAddress ipAddr = IpAddressBuilder + .getDefaultInstance(paramValue); + + + if ("Ipv4Address".equals(simpleName)) + { + m.invoke(toObj, ipAddr.getIpv4Address()); + } + else + { + m.invoke(toObj, ipAddr.getIpv6Address()); + + } + foundValue = true; + } catch (Exception e) { + LOG.error( + "Caught exception calling " + + toClass.getName() + "." + + m.getName() + "(" + + paramValue + ")", e); + + } + }else if("Ipv4Prefix".equals(simpleName)|| "Ipv6Prefix".equals(simpleName)){ + try { + IpPrefix ipPrefix = IpPrefixBuilder + .getDefaultInstance(paramValue); + + + if ("Ipv4Prefix".equals(simpleName)) + { + m.invoke(toObj, ipPrefix.getIpv4Prefix()); + } + else + { + m.invoke(toObj, ipPrefix.getIpv6Prefix()); + + } + foundValue = true; + } catch (Exception e) { + LOG.error( + "Caught exception calling " + + toClass.getName() + "." + + m.getName() + "(" + + paramValue + ")", e); + + } + } + } + + } else { + // setter expects a yang-generated class. Need + // to + // create a builder to set it. + + String builderName = paramClass.getName() + + "Builder"; + Class builderClass = null; + Object builderObj = null; + Object paramObj = null; + + //LOG.debug(m.getName() + // + " expects a yang-generated class - looking for builder " + // + builderName); + try { + builderClass = Class.forName(builderName); + builderObj = builderClass.newInstance(); + paramObj = toBuilder(props, propNamePfx, + builderObj); + } catch (ClassNotFoundException e) { + Object constObj = null; + try { + // See if I can find a constructor I can + // use + Constructor[] constructors = paramClass + .getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (String.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (Long.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(Long + .parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error( + "Caught exception trying to call " + + m.getName(), + e2); + } + } + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + + paramClass.getName(), + e1); + } + + if (paramObj == null) { + LOG.warn("Could not find builder class " + + builderName + + " and could not find a String or Long constructor - trying just to set passing paramValue"); + + } + + } catch (Exception e) { + LOG.error( + "Caught exception trying to create builder " + + builderName, e); + } + + if (paramObj != null) { + + try { + + Method buildMethod = builderClass + .getMethod("build"); + //LOG.debug("Calling " + // + paramObj.getClass().getName() + // + "." + buildMethod.getName() + // + "()"); + Object builtObj = buildMethod + .invoke(paramObj); + + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + //LOG.debug("Calling " + // + toObj.getClass().getName() + // + "." + m.getName() + "()"); + m.invoke(toObj, builtObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to set Yang-generated class expected by" + + toClass.getName() + + "." + + m.getName() + + "() from Properties entry", + e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass().getName() + // + "." + m.getName() + "(" + // + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by" + + toClass.getName() + + "." + + m.getName() + + "() to Properties entry", + e); + } + } + } + } + }else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(paramClass)) { + + //LOG.debug("Parameter class " + paramClass.getName() + // + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type paramType = m.getGenericParameterTypes()[0]; + Type elementType = ((ParameterizedType) paramType) + .getActualTypeArguments()[0]; + Object paramObj = new LinkedList(); + try { + paramObj = toList(props, propName, + (List) paramObj, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to create list expected as argument to " + + toClass.getName() + "." + m.getName()); + } + + if (paramObj != null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass().getName() + "." + // + m.getName() + "(" + paramValue + // + ")"); + m.invoke(toObj, paramObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert List returned by" + + toClass.getName() + "." + + m.getName() + + "() to Properties entry", + e); + } + } + } else { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + //LOG.debug("Parameter class " + // + paramClass.getName() + // + " is not a yang-generated class or a List"); + + if (paramValue != null) { + + Object constObj = null; + + try { + // See if I can find a constructor I can use + Constructor[] constructors = paramClass + .getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (String.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (Long.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(Long + .parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + //LOG.debug("Calling " + // + toObj.getClass() + // .getName() + "." + // + m.getName() + "(" + // + constObj + ")"); + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error( + "Caught exception trying to call " + + m.getName(), e2); + } + } else { + try { + boolean isAccessible = m + .isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass() + // .getName() + "." + // + m.getName() + "(" + // + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by" + + toClass.getName() + + "." + + m.getName() + + "() to Properties entry", + e); + } + } + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + + paramClass.getName(), e1); + } + + /* + * try { boolean isAccessible = + * m.isAccessible(); if (!isAccessible) { + * m.setAccessible(true); } LOG.debug("Calling " + * + toObj.getClass().getName() + "." + + * m.getName() + "(" + paramValue + ")"); + * m.invoke(toObj, paramValue); if + * (!isAccessible) { + * m.setAccessible(isAccessible); } foundValue = + * true; + * + * } catch (Exception e) { LOG.error( + * "Caught exception trying to convert value returned by" + * + toClass.getName() + "." + m.getName() + + * "() to Properties entry", e); } + */ + } + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + if (foundValue) { + return (toObj); + } else { + return (null); + } + } + + public static Properties getProperties(PrintStream pstr, String pfx, + Class toClass) { + boolean foundValue = false; + + //LOG.debug("Analyzing " + toClass.getName() + " class : pfx " + pfx); + + if (isYangGenerated(toClass) + && (!Identifier.class.isAssignableFrom(toClass))) { + // Class is yang generated. + //LOG.debug(toClass.getName() + " is a Yang-generated class"); + + if (toClass.getName().endsWith("Key")) { + if (Identifier.class.isAssignableFrom(toClass)) { + //LOG.debug(Identifier.class.getName() + // + " is assignable from " + toClass.getName()); + } else { + + //LOG.debug(Identifier.class.getName() + // + " is NOT assignable from " + toClass.getName()); + } + } + + String propNamePfx = null; + if (pfx.endsWith("]")) { + propNamePfx = pfx; + }else if(pfx.indexOf(".CLASS_FOUND") != -1){ + pfx = pfx.replace(".CLASS_FOUND",""); + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + //LOG.debug("Is " + m.getName() + " method a getter?"); + if (isGetter(m)) { + // LOG.debug(m.getName() + " is a getter"); + Class returnClass = m.getReturnType(); + + String fieldName = toLowerHyphen(m.getName().substring(3)); + if(m != null && m.getName().matches("^is[A-Z].*")){ + fieldName = toLowerHyphen(m.getName().substring(2)); + } + fieldName = fieldName.substring(0, 1).toLowerCase() + + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + //System.out.println("****" + propName); + + // Is the return type a yang generated class? + if (isYangGenerated(returnClass)) { + // Is it an enum? + if (returnClass.isEnum()) { + + //LOG.debug(m.getName() + " is an Enum"); + //pstr.print("\n" + propName); + //pstr.print("\n" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\n"); + pstr.print("\"" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\","); + prop.setProperty(propName,""); + propList.add(propName); + + } else { + + String simpleName = returnClass.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName) || "IpPrefix".equals(simpleName)) { + //LOG.debug(m.getName()+" is an "+simpleName); + //pstr.print("\n" + propName); + //pstr.print("\n" + propName + ":" + simpleName + "\n"); + pstr.print("\"" + propName + ":" + simpleName + "\","); + prop.setProperty(propName,""); + propList.add(propName); + } else { + boolean isString = false; + boolean isNumber = false; + boolean isBoolean = false; + boolean isIdentifier = false; + //System.out.println("simpleName:" + simpleName); + //System.out.println("propName:" + propName); + for(Method mthd : returnClass.getMethods()){ + String methodName = mthd.getName(); + //System.out.println("methodName:" + methodName); + if(methodName.equals("getValue")){ + Class retType = mthd.getReturnType(); + //System.out.println("retType:" + retType); + isString = String.class.isAssignableFrom(retType); + isNumber = Number.class.isAssignableFrom(retType); + isBoolean = Boolean.class.isAssignableFrom(retType); + isIdentifier = Identifier.class.isAssignableFrom(retType); + //System.out.println("isString:" + isString); + //System.out.println("isNumber:" + isNumber); + //System.out.println("isNumber:" + isNumber); + break; + } + } + + if(isString){ + pstr.print("\"" + propName + ":String\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isNumber){ + pstr.print("\"" + propName + ":Number\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isBoolean){ + pstr.print("\"" + propName + ":Boolean\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isIdentifier){ + //System.out.println("isIdentifier"); + //isIdentifer so skipping + continue; + }else{ + /* + System.out.println("fieldName:" + fieldName); + System.out.println("simpleName:" + simpleName); + System.out.println("returnClass:" + returnClass); + System.out.println("pstr:" + pstr); + System.out.println("propNamePfx:" + propNamePfx); + */ + getProperties(pstr, propNamePfx + ".CLASS_FOUND", returnClass); + } + } + + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(returnClass)) { + + //LOG.debug("Parameter class " + // + returnClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type returnType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) returnType) + .getActualTypeArguments()[0]; + Class elementClass = (Class) elementType; + //LOG.debug("Calling printPropertyList on list type (" + //+ elementClass.getName() + // + "), pfx is (" + // + pfx + // + "), toClass is (" + // + toClass.getName() + ")"); + //System.out.println("List propNamePfx:" + propNamePfx+ "." + toLowerHyphen(elementClass.getSimpleName()) + "[]"); + if(String.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[String,String,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Number.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[Number,Number,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Boolean.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[Boolean,Boolean,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Identifier.class.isAssignableFrom(elementClass)){ + continue; + }else{ + getProperties( + pstr, + propNamePfx + + "." + + toLowerHyphen(elementClass + .getSimpleName()) + "[]", + elementClass); + } + + } else if (!returnClass.equals(Class.class)) { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + //LOG.debug("Parameter class " + // + returnClass.getName() + // + " is not a yang-generated class or a List"); + + //pstr.print("\n" + propName); + String className=returnClass.getName(); + int nClassNameIndex = className.lastIndexOf('.'); + String nClassName = className; + if(nClassNameIndex != -1){ + nClassName=className.substring(nClassNameIndex+1); + } + boolean isString = String.class.isAssignableFrom(returnClass); + boolean isNumber = Number.class.isAssignableFrom(returnClass); + boolean isBoolean = Boolean.class.isAssignableFrom(returnClass); + //pstr.print("\n" + propName +":" + nClassName +"\n"); + boolean isIdentifier = Identifier.class.isAssignableFrom(returnClass); + if(!isIdentifier && !nClassName.equals("[C")){ + if(isNumber){ + pstr.print("\"" + propName +":Number\","); + }else if(isBoolean){ + pstr.print("\"" + propName +":Boolean\","); + }else{ + if(nClassName.equals("[B")){ + pstr.print("\"" + propName +":Binary\","); + }else{ + pstr.print("\"" + propName +":" + nClassName +"\","); + } + } + prop.setProperty(propName,""); + propList.add(propName); + } + + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + return prop; + } + + public static boolean isYangGenerated(Class c) { + if (c == null) { + return (false); + } else { + //System.out.println(c.getName()); + return (c.getName().startsWith("org.opendaylight.yang.gen.")); + } + } + + public static boolean isIpv4Address(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv4Address".equals(simpleName)) ; + } + + public static boolean isIpv6Address(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv6Address".equals(simpleName)) ; + } + public static boolean isIpv4Prefix(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + return ("Ipv4Prefix".equals(simpleName)) ; + } + + public static boolean isIpv6Prefix(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + return ("Ipv6Prefix".equals(simpleName)) ; + } + + public static String toLowerHyphen(String inStr) { + if (inStr == null) { + return (null); + } + + String str = inStr.substring(0, 1).toLowerCase(); + if (inStr.length() > 1) { + str = str + inStr.substring(1); + } + + String regex = "(([a-z0-9])([A-Z]))"; + String replacement = "$2-$3"; + + String retval = str.replaceAll(regex, replacement).toLowerCase(); + + //LOG.debug("Converting " + inStr + " => " + str + " => " + retval); + return (retval); + } + + public static String toUpperCamelCase(String inStr) { + if (inStr == null) { + return (null); + } + + String[] terms = inStr.split("-"); + StringBuffer sbuff = new StringBuffer(); + // Check if string begins with a digit + if (Character.isDigit(inStr.charAt(0))) { + sbuff.append('_'); + } + for (String term : terms) { + sbuff.append(term.substring(0, 1).toUpperCase()); + if (term.length() > 1) { + sbuff.append(term.substring(1)); + } + } + return (sbuff.toString()); + + } + + public static boolean isGetter(Method m) { + //System.out.println(m); + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) + && (m.getParameterTypes().length == 0)) { + if ((m.getName().matches("^is[A-Z].*") || m.getName().matches("^get[A-Z].*")) + && m.getReturnType().equals(Boolean.class)) { + return (true); + } + if (m.getName().matches("^get[A-Z].*") + && !m.getReturnType().equals(void.class)) { + return (true); + } + + } + + return (false); + } + + public static boolean isSetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) + && (m.getParameterTypes().length == 1)) { + if (m.getName().matches("^set[A-Z].*")) { + Class[] paramTypes = m.getParameterTypes(); + if (paramTypes[0].isAssignableFrom(Identifier.class) + || Identifier.class.isAssignableFrom(paramTypes[0])) { + return (false); + } else { + return (true); + } + } + + } + + return (false); + } + + public static void main(String[] args){ + try{ + PrintStream ps = new PrintStream(new FileOutputStream(FileDescriptor.out)); + PrintYangToProp printYangToProp = new PrintYangToProp(); + String className = args[0]; + //ClassLoader classLoader = PrintYangToProp.class.getClassLoader(); + //Class aClass = classLoader.loadClass(className); + Class cl = Class.forName(className); + //printPropertyList(ps,"",cl); + //JsonObject jsonObj = Json.createObjectBuilder().build(); + Properties p = getProperties(ps,"",cl); + //System.out.println(p); + + }catch(Exception e){ + e.printStackTrace(); + } + } + + +} -- cgit 1.2.3-korg From 93a12ba2afdb13b202d461501f2605d52d80e4e6 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 24 Oct 2017 20:19:45 -0400 Subject: Fix release version version.properties contains wrong setting for release version Change-Id: Id76da3e2ad9009845e99ac1442cb66514733461c Issue-ID: CCSDK-80 Signed-off-by: Dan Timoney --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 45771401d..bd6c0d921 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=1 -feature_revision=1 +feature_revision=2 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 26f3062b282aff2f33d5c364a9e3e343c569ca0a Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 25 Oct 2017 12:04:26 -0400 Subject: Fix parent tag in utils/provider utils/provider parent should be utils, not ccsdk-sli-core. This was breaking release build. Change-Id: I3910189f9a989f93a0a8af4cb5a8512f0e9aca7a Issue-ID: CCSDK-80 Signed-off-by: Dan Timoney --- utils/provider/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 790f10105..7cfc66468 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core - ccsdk-sli-core + utils 0.1.2-SNAPSHOT -- cgit 1.2.3-korg From d621496c524846c1d0375926cafefdbf7bdd1d93 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 25 Oct 2017 14:08:31 -0400 Subject: Add unit test case for PrintYangToProp Add junit testing for PrintYangToProp Change-Id: I8c377bb51c812ea9ead32d8e9d5ef871157162a8 Issue-ID: CCSDK-129 Signed-off-by: Dan Timoney --- sli/common/pom.xml | 6 ++ .../ccsdk/sli/core/sli/PrintYangToPropTest.java | 69 ++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java diff --git a/sli/common/pom.xml b/sli/common/pom.xml index bd9ec696a..23f2df873 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -95,6 +95,12 @@ dblib-provider ${sdnctl.dblib.version} + + org.onap.ccsdk.sli.core + sliapi-model + ${project.version} + test + diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java new file mode 100644 index 000000000..21d3e59c3 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java @@ -0,0 +1,69 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.*; + +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.junit.Test; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author dt5972 + * + */ +public class PrintYangToPropTest { + + private static final Logger LOG = LoggerFactory.getLogger(PrintYangToPropTest.class); + @Test + public void test() { + + Properties props = new Properties(); + + // Set up a builder with data + ExecuteGraphInputBuilder egBuilder = new ExecuteGraphInputBuilder(); + egBuilder.setMode(Mode.Sync); + egBuilder.setModuleName("my-module"); + egBuilder.setRpcName("my-rpc"); + + List pList = new LinkedList<>(); + + SliParameterBuilder pBuilder = new SliParameterBuilder(); + pBuilder.setParameterName("string-param"); + pBuilder.setStringValue("hi"); + pList.add(pBuilder.build()); + pBuilder.setParameterName("int-param"); + pBuilder.setIntValue(1); + pBuilder.setStringValue(null); + pList.add(pBuilder.build()); + pBuilder.setParameterName("bool-param"); + pBuilder.setIntValue(null); + pBuilder.setBooleanValue(true); + pList.add(pBuilder.build()); + + egBuilder.setSliParameter(pList); + + + // Generate properties + props = PrintYangToProp.toProperties(props, egBuilder); + + Enumeration propNames = props.propertyNames(); + + while (propNames.hasMoreElements()) { + String propName = (String) propNames.nextElement(); + LOG.info("Property {} = {}", propName, props.getProperty(propName)); + } + + } + +} -- cgit 1.2.3-korg From bf966e65057f8239a8110025af33c1f6775529be Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 25 Oct 2017 15:21:43 -0400 Subject: Use version 0.1.0 of parent Update to use version 0.1.0 (released version) of parent pom Change-Id: I3b62a0cab11425ae9eb7e074aa1c23585aede1c4 Issue-ID: CCSDK-80 Signed-off-by: Dan Timoney --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index efbe2738a..e4586222c 100755 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.parent odlparent-carbon-sr1 - 0.0.2-SNAPSHOT + 0.1.0 -- cgit 1.2.3-korg From d2d0a06cd7a24dc47cc77c575bf77c5fd68a84c6 Mon Sep 17 00:00:00 2001 From: Morgan Richomme Date: Wed, 8 Nov 2017 08:53:23 +0100 Subject: Fix Doc8 errors JIRA: CCSDK-139 Change-Id: I5b48d4189ae9fdd72bb85a4d98be7798452249df Signed-off-by: Morgan Richomme --- docs/release-notes.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index b45165706..dd01fc7e4 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -42,5 +42,3 @@ One or two sentences explaining the purpose of this Release. **Deprecation Notes** **Other** - -=========== \ No newline at end of file -- cgit 1.2.3-korg From 0dcd7f08365a87947a18dee0f617cf8586f4b287 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 8 Nov 2017 17:10:13 -0500 Subject: Roll version to 0.1.3-SNAPSHOT Roll to next snapshot version to prepare for release cut Change-Id: I2a4c8395630b461314291bc8e0f83bf114a21f61 Issue-ID: CCSDK-141 Signed-off-by: Dan Timoney --- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 2 +- 29 files changed, 36 insertions(+), 36 deletions(-) diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index e3356d8e0..bde897906 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT dblib-features DBLIB Adaptor - Features diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index a2d7362a9..a1106e4d3 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT dblib-installer DBLIB Adaptor - Karaf Installer diff --git a/dblib/pom.xml b/dblib/pom.xml index 8e7afabb5..2b016e8d9 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT @@ -16,7 +16,7 @@ DBLIB Adaptor The DBLIB adaptor allows service logic to access persistent data in a local sql database - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 730919de0..a0e3d3c7f 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -4,10 +4,10 @@ org.onap.ccsdk.sli.core dblib - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT dblib-provider - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT bundle DBLIB Adaptor - Provider http://maven.apache.org diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 95ccdfcd3..a68da7d6b 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -4,7 +4,7 @@ filters org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT filters-features Filters - Features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index e2eb43060..f33b73452 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT filters-installer Filters - Karaf Installer diff --git a/filters/pom.xml b/filters/pom.xml index f79787ea4..896ecda29 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT 4.0.0 @@ -16,7 +16,7 @@ Filters Servlet filter to implement ECOMP logging spec - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 65f6e45a1..3d35b96dc 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT filters-provider bundle diff --git a/pom.xml b/pom.xml index e4586222c..e11499aea 100755 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ ONAP - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 23f2df873..cec0fc5cd 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sli-common bundle diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 11684bead..a442a5255 100755 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sli-features SLI - Features diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 0eec3324a..6e5a2efab 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sli-installer SLI - Karaf Installer diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 18b56f46b..4cdb69a4a 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sli-model bundle diff --git a/sli/pom.xml b/sli/pom.xml index de882159d..5875d6fff 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT 4.0.0 pom @@ -60,7 +60,7 @@ ONAP - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 7514c74e4..9dc74cc2b 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core sli - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sli-provider bundle diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index c2cfbee07..251d225c5 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sli-recording bundle diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index cfa86b3a4..e74d31d3e 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -8,7 +8,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT SliPluginUtils Plugin - Features diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index dd904e40d..57e5b4e1c 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -4,7 +4,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sliPluginUtils-installer SLI Plugin Utilities - Karaf Installer diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 3d80b7231..2817fa52d 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT pom 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT Service Logic Interface Plugin Utilities A package of static utility functions to be used when developing SLI plugins diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 3697b435f..9e070aa44 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -8,7 +8,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT SliPluginUtils Plugin - Provider diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index caa6a8b39..34c75ddb6 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sliapi-features diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index dff580b62..b3287b78e 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sliapi-installer pom diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index d36aaa131..ed6cb56f8 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sliapi-model bundle diff --git a/sliapi/pom.xml b/sliapi/pom.xml index a58596a93..db005176d 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT pom org.onap.ccsdk.sli.core sliapi - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 7e0bd2642..2bfd4e988 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT sliapi-provider bundle diff --git a/utils/features/pom.xml b/utils/features/pom.xml index dedb18e4a..29c023b4b 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -4,7 +4,7 @@ utils org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT utils-features DBLIB Adaptor - Features diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 3af9a5866..5361dafc9 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -4,7 +4,7 @@ utils org.onap.ccsdk.sli.core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT utils-installer SLI core utils - Karaf Installer diff --git a/utils/pom.xml b/utils/pom.xml index cf7dbc50f..aad7e625a 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT @@ -16,7 +16,7 @@ SLI Utils Utilities used across sli-core - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 7cfc66468..c0ffbe26c 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core utils - 0.1.2-SNAPSHOT + 0.1.3-SNAPSHOT 4.0.0 -- cgit 1.2.3-korg From a751721b05b266243aac6b592ddff149319ef751 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 9 Nov 2017 07:30:49 -0500 Subject: Update version.properties Change version.properties to next release Change-Id: I99fc70938511254d126a9220f4cef71fce551efe Issue-ID: CCSDK-141 Signed-off-by: Dan Timoney --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index bd6c0d921..5b017c6a6 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=1 -feature_revision=2 +feature_revision=3 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 7390e8a7e253ed120832f08605e8d13bcc92314f Mon Sep 17 00:00:00 2001 From: Rich Bennett Date: Wed, 15 Nov 2017 06:50:18 -0500 Subject: Rm docs in repo consolidated w/ ccsdk/distribution Change-Id: I573779aa46dfbf9f1c7956ecf0e4eedf16184417 Issue-ID: DOC-130 Signed-off-by: Rich Bennett --- docs/apis/sliapi.rst | 15 - docs/architecture.rst | 20 - docs/build.rst | 18 - docs/index.rst | 13 - docs/logging.rst | 14 - docs/nodes.rst | 1031 ------------------------------------------------ docs/offeredapis.rst | 12 - docs/release-notes.rst | 44 --- 8 files changed, 1167 deletions(-) delete mode 100644 docs/apis/sliapi.rst delete mode 100644 docs/architecture.rst delete mode 100644 docs/build.rst delete mode 100644 docs/index.rst delete mode 100644 docs/logging.rst delete mode 100644 docs/nodes.rst delete mode 100644 docs/offeredapis.rst delete mode 100644 docs/release-notes.rst diff --git a/docs/apis/sliapi.rst b/docs/apis/sliapi.rst deleted file mode 100644 index 13cdcbd54..000000000 --- a/docs/apis/sliapi.rst +++ /dev/null @@ -1,15 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -SLI-API(2016-11-11) -=================== - -.. toctree:: - :maxdepth: 1 - :titlesonly: - - - -.. swaggerv2doc:: https://gerrit.onap.org/r/gitweb?p=ccsdk/sli/core.git;a=blob_plain;f=sliapi/model/src/main/resources/sli-api.20161110.json - - diff --git a/docs/architecture.rst b/docs/architecture.rst deleted file mode 100644 index f6101a116..000000000 --- a/docs/architecture.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -Architecture -============ - - - -Capabilities ------------- -Provides the core Service Logic Interpreter (SLI) functionality, used to execute directed graphs (DGs). Directed graphs allow service designers to define the -logic to be executed within the SDN controller in a graphical format which can be -updated in real time, without a need to restart the controller. - -.. toctree:: - :maxdepth: 1 - - nodes.rst - - diff --git a/docs/build.rst b/docs/build.rst deleted file mode 100644 index 0a4c308e6..000000000 --- a/docs/build.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -Build -===== - - -Environment ------------ -Requires maven release 3.3 or greater - -Steps ------ -To compile this code: - -1. Make sure your local Maven settings file ($HOME/.m2/settings.xml) contains references to the ONAP repositories and OpenDaylight repositories. - -2. To compile, run "mvn clean install". \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 2055f1780..000000000 --- a/docs/index.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. - -CCSDK Service Logic Interpreter -------------------------------- -.. toctree:: - :maxdepth: 1 - - architecture.rst - offeredapis.rst - logging.rst - build.rst - release-notes.rst - diff --git a/docs/logging.rst b/docs/logging.rst deleted file mode 100644 index 187eb03b7..000000000 --- a/docs/logging.rst +++ /dev/null @@ -1,14 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -Logging -======= -CCSDK uses slf4j to log messages to the standard OpenDaylight karaf.log -log file. - -Where to Access Information ---------------------------- -Logs are found within the SDNC docker container, in the directory -/opt/opendaylight/current/data/logs. - - diff --git a/docs/nodes.rst b/docs/nodes.rst deleted file mode 100644 index 3bdeabcfa..000000000 --- a/docs/nodes.rst +++ /dev/null @@ -1,1031 +0,0 @@ ---- Service Logic Interpreter --- Dan Timoney --- 2014-11-12 --- - -Supported node types -==================== - -The following built-in node types are currently supported: - -- Flow Control - - - `**block** <#Block_node>`__ - - - `**call** <#Call_node>`__ - - - `**for** <#For_node>`__ - - - `**return** <#Return_node>`__ - - - `**set** <#Set_node>`__ - - - `**switch** <#Switch_node>`__ - -- Device Management - - - `**configure** <#Configure_node>`__ - -- Java Plugin Support - - - `**execute** <#Execute_node>`__ - -- Recording - - - `**record** <#Record_node>`__ - -- Resource Management - - - `**delete** <#Delete_node>`__ - - - `**exists** <#Exists_node>`__ - - - `**get-resource** <#Get-resource_node>`__ - - - `**is-available** <#Is-available_node>`__ - - - `**notify** <#Notify_node>`__ - - - `**release** <#Release_node>`__ - - - `**reserve** <#Reserve_node>`__ - - - `**save** <#Save_node>`__ - - - `**update** <#Update_node>`__ - -Flow Control ------------- - -Block node -~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **block** node is used to executes a set of nodes. - -Attributes -^^^^^^^^^^ - -+--------------+-----------------------------------------------------------------------------------------------------------------------------------+ -| **atomic** | if *true*, then if a node returns failure, subsequent nodes will not be executed and nodes already executed will be backed out. | -+--------------+-----------------------------------------------------------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -None - -Example -^^^^^^^ - -:: - - - - - - - - - - - - - -Call node -~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **call** node is used to call another graph - -Attributes -^^^^^^^^^^ - -+---------------+------------------------------------------------------------------------------------+ -| **module** | Module of directed graph to call. If unset, defaults to that of calling graph | -+---------------+------------------------------------------------------------------------------------+ -| **rpc** | rpc of directed graph to call. | -+---------------+------------------------------------------------------------------------------------+ -| **version** | version of graph to call, If unset, uses active version. | -+---------------+------------------------------------------------------------------------------------+ -| **mode** | mode (sync/async) of graph to call. If unset, defaults to that of calling graph. | -+---------------+------------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -Not applicable - -Outcomes -^^^^^^^^ - -+-----------------+------------------------------+ -| **success** | Sub graph returned success | -+-----------------+------------------------------+ -| **not-found** | Graph not found | -+-----------------+------------------------------+ -| **failure** | Subgraph returned success | -+-----------------+------------------------------+ - -Table: . - -Example -^^^^^^^ - -:: - - - -For node -~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **for** node provides a fixed iteration looping mechanism, similar to -the Java for loop - -Attributes -^^^^^^^^^^ - -+-------------+------------------+ -| **index** | index variable | -+-------------+------------------+ -| **start** | initial value | -+-------------+------------------+ -| **end** | maximum value | -+-------------+------------------+ - -Parameters -^^^^^^^^^^ - -Not applicable. - -Outcomes -^^^^^^^^ - -Not applicable. The **status** node has no outcomes. - -Example -^^^^^^^ - -:: - - - - - - - - - -Return node -~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **return** node is used to return a status to the invoking MD-SAL -application - -Attributes -^^^^^^^^^^ - -+--------------+---------------------------------------------------+ -| **status** | Status value to return (*success* or *failure*) | -+--------------+---------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -The following optional parameters may be passed to convey more detailed -status information. - -+---------------------+-----------------------------------------------------------------+ -| **error-code** | A brief, usually numeric, code indicating the error condition | -+---------------------+-----------------------------------------------------------------+ -| **error-message** | A more detailed error message | -+---------------------+-----------------------------------------------------------------+ - -Outcomes -^^^^^^^^ - -Not applicable. The **status** node has no outcomes. - -Example -^^^^^^^ - -:: - - - - - - -Set node -~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **set** node is used to set one or more values in the execution -context - -Attributes -^^^^^^^^^^ - -+---------------------+-------------------------------------------------------------------------------------+ -| **only-if-unset** | If true the set node will only execute if the current value of the target is null | -+---------------------+-------------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -Values to be set are passed as parameters - -Outcomes -^^^^^^^^ - -Not applicable. The **set** node has no outcomes. - -Example -^^^^^^^ - -:: - - - - - -Switch node -~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **switch** node is used to make a decision based on its **test** -attribute. - -Attributes -^^^^^^^^^^ - -+------------+---------------------+ -| **test** | Condition to test | -+------------+---------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -Depends on the **test** condition - -Example -^^^^^^^ - -:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Device Management ------------------ - -Configure node -~~~~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **configure** node is used to configure a device. - -Attributes -^^^^^^^^^^ - -+----------------+-----------------------------------------------------------------------------------+ -| **adaptor** | Fully qualified Java class of resource adaptor to be used | -+----------------+-----------------------------------------------------------------------------------+ -| **activate** | Activate device/interface, for devices that support a separate activation step. | -+----------------+-----------------------------------------------------------------------------------+ -| **key** | SQL-like string specifying criteria for item to configure | -+----------------+-----------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -Specific to device adaptor. - -Outcomes -^^^^^^^^ - -+----------------------+------------------------------------------------------------------+ -| **success** | Device successfully configured | -+----------------------+------------------------------------------------------------------+ -| **not-found** | Element to be configured does not exist. | -+----------------------+------------------------------------------------------------------+ -| **not-ready** | Element is not in a state where it can be configured/activated | -+----------------------+------------------------------------------------------------------+ -| **already-active** | Attempt to activate element that is already active | -+----------------------+------------------------------------------------------------------+ -| **failure** | Configure failed for some other reason | -+----------------------+------------------------------------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Java Plugin Support -------------------- - -Execute node -~~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -An **execute** node is used to execute Java code supplied as a plugin - -Attributes -^^^^^^^^^^ - -+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of plugin to be used | -+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| **method** | Name of method in the plugin class to execute. Method must return void, and take 2 arguments: a Map (for parameters) and a SvcLogicContext (to allow plugin read/write access to context memory) | -+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -Specific to plugin / method - -Outcomes -^^^^^^^^ - -+--------------------------+-----------------------------------------------------------------+ -| **success** | Device successfully configured | -+--------------------------+-----------------------------------------------------------------+ -| **not-found** | Plugin class could not be loaded | -+--------------------------+-----------------------------------------------------------------+ -| **unsupported-method** | Named method taking (Map, SvcLogicContext) could not be found | -+--------------------------+-----------------------------------------------------------------+ -| **failure** | Configure failed for some other reason | -+--------------------------+-----------------------------------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - - - - - - - - - - - -Recording ---------- - -Record node -~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **record** node is used to record an event. For example, this might be -used to log provisioning events. - -Attributes -^^^^^^^^^^ - -+--------------+---------------------------------------------------+ -| **plugin** | Fully qualified Java class to handle recording. | -+--------------+---------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -Parameters will depend on the plugin being used. For the FileRecorder -class, the parameters are as follows - -+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| **file** | The file to which the record should be written | -+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| **field1** | First field to write. There will be **field** parameters for each field to write, from **field1** through **fieldN**. A special value \_\_TIMESTAMP\_\_ may be assigned to a field to insert the current timestamp | -+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - -Outcomes -^^^^^^^^ - -+---------------+--------------------------------------------+ -| **success** | Record successfully written | -+---------------+--------------------------------------------+ -| **failure** | Record could not be successfully written | -+---------------+--------------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - -Resource Management -------------------- - -Delete node -~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **delete** node is used to delete a resource from the local resource -inventory. - -Attributes -^^^^^^^^^^ - -+----------------+-------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+-------------------------------------------------------------+ -| **resource** | Type of resource to delete | -+----------------+-------------------------------------------------------------+ -| **key** | SQL-like string specifying key to delete | -+----------------+-------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -+---------------+--------------------------------------------+ -| **success** | Resource specified deleted successfully. | -+---------------+--------------------------------------------+ -| *failure*> | Resource specified was not deleted | -+---------------+--------------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - -Exists node -~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -An **exists** node is used to determine whether a particular instance of -a resource exists. For example, this might be used to test whether a -particular switch CLLI is provisioned. - -Attributes -^^^^^^^^^^ - -+----------------+-------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+-------------------------------------------------------------+ -| **resource** | Type of resource to check | -+----------------+-------------------------------------------------------------+ -| **key** | SQL-like string specifying key to check for | -+----------------+-------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -+-------------+---------------------------------+ -| **true** | Resource specified exists. | -+-------------+---------------------------------+ -| **false** | Resource specified is unknown | -+-------------+---------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - -Get-resource node -~~~~~~~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **get-resource** node is used to retrieve information about a -particular resource and make it available to other nodes in the service -logic tree. For example, this might be used to retrieve information -about a particular uni-port. - -Attributes -^^^^^^^^^^ - -+----------------+------------------------------------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+------------------------------------------------------------------------------------------+ -| **resource** | Type of resource to retrieve | -+----------------+------------------------------------------------------------------------------------------+ -| **key** | SQL-like string specifying criteria for retrieval | -+----------------+------------------------------------------------------------------------------------------+ -| **pfx** | Prefix to add to context variable names set for data retrieved | -+----------------+------------------------------------------------------------------------------------------+ -| **select** | String to specify, if key matches multiple entries, which entry should take precedence | -+----------------+------------------------------------------------------------------------------------------+ -| **order-by** | Prefix to add to context variable names set for data retrieved | -+----------------+------------------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -+-----------------+--------------------------------------------------+ -| **success** | Resource successfully retrieved | -+-----------------+--------------------------------------------------+ -| **not-found** | Resource referenced does not exist | -+-----------------+--------------------------------------------------+ -| **failure** | Resource retrieve failed for some other reason | -+-----------------+--------------------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - - - - -Is-available node -~~~~~~~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -An **is-available** node is used to determine whether a particular type -of resource is available. For example, this might be used to test -whether any ports are available for assignment on a particular switch. - -Attributes -^^^^^^^^^^ - -+----------------+------------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+------------------------------------------------------------------+ -| **resource** | Type of resource to check | -+----------------+------------------------------------------------------------------+ -| **key** | SQL-like string specifying key to check for | -+----------------+------------------------------------------------------------------+ -| **pfx** | Prefix to add to context variable names set for data retrieved | -+----------------+------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -+-------------+---------------------------------------+ -| **true** | Resource requested is available | -+-------------+---------------------------------------+ -| **false** | Resource requested is not available | -+-------------+---------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - -Notify node -~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **notify** node is used to inform an external application (e.g. A&AI) -that a resource was updated. - -Attributes -^^^^^^^^^^ - -+----------------+---------------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+---------------------------------------------------------------------+ -| **resource** | Identifies resource that was updated | -+----------------+---------------------------------------------------------------------+ -| **action** | Action that triggered notification to be sent (ADD/UPDATE/DELETE) | -+----------------+---------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -+---------------+----------------------------------------+ -| **success** | Notification was successful | -+---------------+----------------------------------------+ -| **failure** | Notification failed is not available | -+---------------+----------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - -Release node -~~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **release** node is used to mark a resource as no longer in use, and -thus available for assignment. - -Attributes -^^^^^^^^^^ - -+----------------+------------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+------------------------------------------------------------------+ -| **resource** | Type of resource to release | -+----------------+------------------------------------------------------------------+ -| **key** | SQL-like string specifying key to check of resource to release | -+----------------+------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -+-----------------+-------------------------------------------------+ -| **success** | Resource successfully released | -+-----------------+-------------------------------------------------+ -| **not-found** | Resource referenced does not exist | -+-----------------+-------------------------------------------------+ -| **failure** | Resource release failed for some other reason | -+-----------------+-------------------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - - - - -Reserve node -~~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **reserve** node is used to reserve a particular type of resource.. -For example, this might be used to reserve a port on a particular -switch. - -Attributes -^^^^^^^^^^ - -+----------------+----------------------------------------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+----------------------------------------------------------------------------------------------+ -| **resource** | Type of resource to reserve | -+----------------+----------------------------------------------------------------------------------------------+ -| **key** | SQL-like string specifying criteria for reservation | -+----------------+----------------------------------------------------------------------------------------------+ -| **select** | String to specify, if **key** matches multiple entries, which entry should take precedence | -+----------------+----------------------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -None - -Outcomes -^^^^^^^^ - -+---------------+----------------------------------------------------+ -| **success** | Resource requested was successfully reserved | -+---------------+----------------------------------------------------+ -| **failure** | Resource requested was not successfully reserved | -+---------------+----------------------------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - -Save node -~~~~~~~~~ - -Description -^^^^^^^^^^^ - -A **save** node is used to save information about a particular resource -to persistent storage. For example, this might be used to save -information about a particular uni-port. - -Attributes -^^^^^^^^^^ - -+----------------+------------------------------------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+------------------------------------------------------------------------------------------+ -| **resource** | Type of resource to save | -+----------------+------------------------------------------------------------------------------------------+ -| **key** | SQL-like string specifying criteria for retrieval | -+----------------+------------------------------------------------------------------------------------------+ -| **force** | If "true", save resource even if this resource is already stored in persistent storage | -+----------------+------------------------------------------------------------------------------------------+ -| **pfx** | Prefix to be prepended to variable names, when attributes are set in SvcLogicContext | -+----------------+------------------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -Values to save (columns) are specified as parameters, with each name -corresponding to a column name and each value corresponding to the value -to set. - -Outcomes -^^^^^^^^ - -+---------------+-------------------------------+ -| **success** | Resource successfully saved | -+---------------+-------------------------------+ -| **failure** | Resource save failed | -+---------------+-------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - - -Update node -~~~~~~~~~~~ - -Description -^^^^^^^^^^^ - -An **update** node is used to update information about a particular -resource to persistent storage. - -Attributes -^^^^^^^^^^ - -+----------------+----------------------------------------------------------------------------------------+ -| **plugin** | Fully qualified Java class of resource adaptor to be used | -+----------------+----------------------------------------------------------------------------------------+ -| **resource** | Type of resource to update | -+----------------+----------------------------------------------------------------------------------------+ -| **key** | SQL-like string specifying criteria for retrieval | -+----------------+----------------------------------------------------------------------------------------+ -| **pfx** | Prefix to be prepended to variable names, when attributes are set in SvcLogicContext | -+----------------+----------------------------------------------------------------------------------------+ - -Parameters -^^^^^^^^^^ - -Values to save (columns) are specified as parameters, with each name -corresponding to a column name and each value corresponding to the value -to set. - -Outcomes -^^^^^^^^ - -+---------------+-------------------------------+ -| **success** | Resource successfully saved | -+---------------+-------------------------------+ -| **failure** | Resource save failed | -+---------------+-------------------------------+ - -Example -^^^^^^^ - -:: - - - - - - - - - diff --git a/docs/offeredapis.rst b/docs/offeredapis.rst deleted file mode 100644 index 42eafdd41..000000000 --- a/docs/offeredapis.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 - -Offered APIs -============ - -.. toctree:: - :maxdepth: 1 - :titlesonly: - - apis/sliapi.rst - diff --git a/docs/release-notes.rst b/docs/release-notes.rst deleted file mode 100644 index dd01fc7e4..000000000 --- a/docs/release-notes.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. - -Release Notes -============= - -.. note:: - * This Release Notes must be updated each time the team decides to Release new artifacts. - * The scope of this Release Notes is for this particular component. In other words, each ONAP component has its Release Notes. - * This Release Notes is cumulative, the most recently Released artifact is made visible in the top of this Release Notes. - * Except the date and the version number, all the other sections are optional but there must be at least one section describing the purpose of this new release. - * This note must be removed after content has been added. - - -Version: x.y.z --------------- - - -:Release Date: yyyy-mm-dd - - - -**New Features** - -One or two sentences explaining the purpose of this Release. - -**Bug Fixes** - - `CIMAN-65 `_ and a sentence explaining what this defect is addressing. -**Known Issues** - - `CIMAN-65 `_ and two, three sentences. - One sentences explaining what is the issue. - - Another sentence explaining the impact of the issue. - - And an optional sentence providing a workaround. - -**Security Issues** - You may want to include a reference to CVE (Common Vulnerabilities and Exposures) `CVE `_ - - -**Upgrade Notes** - -**Deprecation Notes** - -**Other** -- cgit 1.2.3-korg From 636c3a7d71ff65ef314d62dde67be8fda7d6a240 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Thu, 16 Nov 2017 23:48:25 -0800 Subject: Bump minor version Bump minor version in preparation for Amsterdam branching. Change-Id: Ifa47aa1d818d4a632afb02ec342124678ad855e1 Issue-ID: CIMAN-120 Signed-off-by: Jessica Wagantall --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 5b017c6a6..1abffd200 100644 --- a/version.properties +++ b/version.properties @@ -5,7 +5,7 @@ release_name=0 -sprint_number=1 +sprint_number=2 feature_revision=3 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 9cf0a1e191259f19cc7cbffdf57a96cd4e06ee1f Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Fri, 17 Nov 2017 16:51:44 -0800 Subject: Bump minor version Bump minor version in preparation for Amsterdam branching. (part 2) Change-Id: Ib9f7cf7f98feb159ce1b136a3cd792820c99e659 Issue-ID: CIMAN-120 Signed-off-by: Jessica Wagantall --- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 2 +- pom.xml | 4 ++-- sli/common/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 2 +- 29 files changed, 37 insertions(+), 37 deletions(-) diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index bde897906..e9cb6dd0b 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT dblib-features DBLIB Adaptor - Features diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index a1106e4d3..bff158011 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -4,7 +4,7 @@ dblib org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT dblib-installer DBLIB Adaptor - Karaf Installer diff --git a/dblib/pom.xml b/dblib/pom.xml index 2b016e8d9..e7743d81c 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT @@ -16,7 +16,7 @@ DBLIB Adaptor The DBLIB adaptor allows service logic to access persistent data in a local sql database - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index a0e3d3c7f..3bdd7e67b 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -4,10 +4,10 @@ org.onap.ccsdk.sli.core dblib - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT dblib-provider - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT bundle DBLIB Adaptor - Provider http://maven.apache.org diff --git a/filters/features/pom.xml b/filters/features/pom.xml index a68da7d6b..3662f3368 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -4,7 +4,7 @@ filters org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT filters-features Filters - Features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index f33b73452..a22e9ab72 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT filters-installer Filters - Karaf Installer diff --git a/filters/pom.xml b/filters/pom.xml index 896ecda29..7780dcecb 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT 4.0.0 @@ -16,7 +16,7 @@ Filters Servlet filter to implement ECOMP logging spec - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 3d35b96dc..51d0c63aa 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core filters - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT filters-provider bundle diff --git a/pom.xml b/pom.xml index e11499aea..0e9b1735e 100755 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.parent odlparent-carbon-sr1 - 0.1.0 + 0.2.1-SNAPSHOT @@ -119,7 +119,7 @@ ONAP - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/sli/common/pom.xml b/sli/common/pom.xml index cec0fc5cd..4c7daa395 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sli-common bundle diff --git a/sli/features/pom.xml b/sli/features/pom.xml index a442a5255..4630b7833 100755 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sli-features SLI - Features diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 6e5a2efab..23b747130 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sli-installer SLI - Karaf Installer diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 4cdb69a4a..59658a3e1 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -4,7 +4,7 @@ sli org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sli-model bundle diff --git a/sli/pom.xml b/sli/pom.xml index 5875d6fff..95417c3c8 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT 4.0.0 pom @@ -60,7 +60,7 @@ ONAP - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 9dc74cc2b..4f410ab01 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core sli - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sli-provider bundle diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 251d225c5..b571cfbb9 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sli-recording bundle diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index e74d31d3e..19d32f7a2 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -8,7 +8,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT SliPluginUtils Plugin - Features diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 57e5b4e1c..736d22202 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -4,7 +4,7 @@ sliPluginUtils org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sliPluginUtils-installer SLI Plugin Utilities - Karaf Installer diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 2817fa52d..21efb170b 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT pom 4.0.0 @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT Service Logic Interface Plugin Utilities A package of static utility functions to be used when developing SLI plugins diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 9e070aa44..a950939ef 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -8,7 +8,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT SliPluginUtils Plugin - Provider diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 34c75ddb6..78bfb89a4 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sliapi-features diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index b3287b78e..cddcf6dd7 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sliapi-installer pom diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index ed6cb56f8..4ea88516a 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sliapi-model bundle diff --git a/sliapi/pom.xml b/sliapi/pom.xml index db005176d..a08d8fcb8 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT pom org.onap.ccsdk.sli.core sliapi - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 2bfd4e988..5db9671d6 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -4,7 +4,7 @@ sliapi org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT sliapi-provider bundle diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 29c023b4b..be6227d7e 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -4,7 +4,7 @@ utils org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT utils-features DBLIB Adaptor - Features diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 5361dafc9..df7fc0de8 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -4,7 +4,7 @@ utils org.onap.ccsdk.sli.core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT utils-installer SLI core utils - Karaf Installer diff --git a/utils/pom.xml b/utils/pom.xml index aad7e625a..17a0f6b6e 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -3,7 +3,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT @@ -16,7 +16,7 @@ SLI Utils Utilities used across sli-core - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index c0ffbe26c..b0adc7d46 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.sli.core utils - 0.1.3-SNAPSHOT + 0.2.0-SNAPSHOT 4.0.0 -- cgit 1.2.3-korg From 226929e3c0d175ebe074765111dba7a81756b6af Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 20 Nov 2017 15:10:26 -0500 Subject: Update parent version Parent version should be 1.2.0, not 1.2.1-SNAPSHOT Change-Id: I678f264135223d45bb632df86d2854bbb51307e3 Issue-ID: CIMAN-120 Signed-off-by: Dan Timoney --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0e9b1735e..c7885a9b6 100755 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.parent odlparent-carbon-sr1 - 0.2.1-SNAPSHOT + 0.2.0-SNAPSHOT -- cgit 1.2.3-korg From 7cb74a4e851ae85ffa8c7cd1ebe94007418b816c Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 21 Nov 2017 15:29:19 -0500 Subject: Fix version.properties Reset patch version in version.properties to zero Change-Id: If331cd45026f27b1232621535b2d7facf3bbd387 Issue-ID: CIMAN-120 Signed-off-by: Dan Timoney --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 1abffd200..bf303c1bf 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=2 -feature_revision=3 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 13cbc4e6633e4cef9cc33d10c11b9b177213acd9 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 5 Dec 2017 11:50:42 -0500 Subject: SLI parser improvements Update SLI parser to remove validation based on NODE_TYPE table, which is no longer needed (was introduced prior to use of XSD schema validation). Also, use checksums to avoid needless recompilation if version being loaded already exists in database. Change-Id: Idfcba94de8fb71b17d5e0c5e69e04dee266988b1 Issue-ID: CCSDK-152 Signed-off-by: Dan Timoney --- .../onap/ccsdk/sli/core/sli/ActivationEntry.java | 41 + .../onap/ccsdk/sli/core/sli/CheckSumHelper.java | 45 + .../org/onap/ccsdk/sli/core/sli/MetricLogger.java | 8 +- .../onap/ccsdk/sli/core/sli/SvcLogicCrawler.java | 90 ++ .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 101 +- .../org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java | 16 +- .../onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 1280 ++++++++------------ .../onap/ccsdk/sli/core/sli/SvcLogicLoader.java | 168 +++ .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 516 ++++---- .../org/onap/ccsdk/sli/core/sli/SvcLogicStore.java | 5 +- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 25 - .../sli/core/sli/provider/SvcLogicActivator.java | 33 - .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 31 +- 13 files changed, 1170 insertions(+), 1189 deletions(-) create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ActivationEntry.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ActivationEntry.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ActivationEntry.java new file mode 100644 index 000000000..a1c0eafe8 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ActivationEntry.java @@ -0,0 +1,41 @@ +/*- + * ============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========================================================= + */ + +package org.onap.ccsdk.sli.core.sli; + +public class ActivationEntry { + String module; + String rpc; + String version; + String mode; + + public ActivationEntry(String module, String rpc, String version, String mode) { + this.module = module; + this.rpc = rpc; + this.version = version; + this.mode = mode; + } + + @Override + public String toString() { + return "ActivationEntry [module=" + module + ", rpc=" + rpc + ", version=" + version + ", mode=" + mode + "]"; + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java new file mode 100644 index 000000000..d6ad07424 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java @@ -0,0 +1,45 @@ +/*- + * ============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========================================================= + */ + +package org.onap.ccsdk.sli.core.sli; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import javax.xml.bind.DatatypeConverter; + +public class CheckSumHelper { + + public static String md5SumFromFile(String pathToFile) throws NoSuchAlgorithmException, IOException { + byte[] b = Files.readAllBytes(Paths.get(pathToFile)); + return md5SumFromByteArray(b); + } + + private static String md5SumFromByteArray(byte[] input) throws NoSuchAlgorithmException { + byte[] hash = MessageDigest.getInstance("MD5").digest(input); + String hexString = DatatypeConverter.printHexBinary(hash); + return hexString.toLowerCase(); + } + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 0f6ae673e..79989b514 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -295,7 +295,13 @@ public class MetricLogger { setResponseCode(responseCode); setResponseDescription(responseDescription); - METRIC.info(lastMsg); + METRIC.info(formatString(lastMsg)); } + + protected String formatString(String str) { + str = str.replaceAll("\\R",""); // this will strip all new line characters + str = str.replaceAll("\\|","%7C"); //log records should not contain a pipe, encode the pipe character + return str; + } } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java new file mode 100644 index 000000000..5ee138a3e --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java @@ -0,0 +1,90 @@ +/*- + * ============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========================================================= + */ + +package org.onap.ccsdk.sli.core.sli; + +import static java.nio.file.FileVisitResult.CONTINUE; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.List; + +public class SvcLogicCrawler extends SimpleFileVisitor { + + private List xmlGraphPathList; + private List activationFilePathList; + + public SvcLogicCrawler() { + xmlGraphPathList = new ArrayList(); + activationFilePathList = new ArrayList(); + } + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attr) { + if (attr.isRegularFile()) { + String fileName = file.getFileName().toString(); + if (!file.toString().contains(".git") && !fileName.equals("pom.xml") && !fileName.equals("assemble_zip.xml") && !fileName.equals("assemble_zip_less_config.xml") && !fileName.equals("descriptor.xml")) { + if (fileName.endsWith(".xml")) { + xmlGraphPathList.add(file); + } + else if (fileName.endsWith(".versions")) { + activationFilePathList.add(file); + } + } + } + return CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) { + return CONTINUE; + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) { + System.err.println("Couldn't visitFile"); + System.err.println(exc.getMessage()); + return CONTINUE; + } + + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + String[] skipDirectories = {".git"}; + for (String str : skipDirectories) { + if (dir.endsWith(str)) { + return FileVisitResult.SKIP_SUBTREE; + } + } + return CONTINUE; + } + + public List getGraphPaths() { + return this.xmlGraphPathList; + } + + public List getActivationPaths() { + return this.activationFilePathList; + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index ab5773c06..74fa1dd66 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -326,80 +326,6 @@ public class SvcLogicDblibStore implements SvcLogicStore { } } - @Override - public void registerNodeType(String nodeType) throws SvcLogicException { - - String registerNodeSql = "INSERT INTO NODE_TYPES (nodetype) VALUES(?)"; - - if (isValidNodeType(nodeType)) { - return; - } - - DbLibService dbSvc = getDbLibService(); - ArrayList args = new ArrayList<>(); - - args.add(nodeType); - - try { - dbSvc.writeData(registerNodeSql, args, null); - } catch (Exception e) { - throw new SvcLogicException("Could not add node type to database", e); - } - - } - - @Override - public void unregisterNodeType(String nodeType) throws SvcLogicException { - - if (!isValidNodeType(nodeType)) { - return; - } - - String unregisterNodeSql = "DELETE FROM NODE_TYPES WHERE nodetype = ?"; - - DbLibService dbSvc = getDbLibService(); - ArrayList args = new ArrayList<>(); - - args.add(nodeType); - - try { - dbSvc.writeData(unregisterNodeSql, args, null); - } catch (Exception e) { - throw new SvcLogicException( - "Could not delete node type from database", e); - } - - } - - @Override - public boolean isValidNodeType(String nodeType) throws SvcLogicException { - - String validateNodeSql = "SELECT count(*) FROM NODE_TYPES WHERE nodetype = ?"; - - DbLibService dbSvc = getDbLibService(); - - ArrayList args = new ArrayList<>(); - - args.add(nodeType); - - boolean isValid = false; - - try (CachedRowSet results = dbSvc.getData(validateNodeSql, args, null)) { - - if (results != null && results.next()) { - int cnt = results.getInt(1); - - if (cnt > 0) { - isValid = true; - } - } - } catch (Exception e) { - throw new SvcLogicException("Cannot select node type from database", e); - } - - return isValid; - } - private DbLibService getDbLibService() { // Get DbLibService interface object. @@ -490,4 +416,31 @@ public class SvcLogicDblibStore implements SvcLogicStore { INSTANCE = dbresource; } } + + @Override + public void activate(String module, String rpc, String version, String mode) throws SvcLogicException { + DbLibService dbSvc = getDbLibService(); + + String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; + + String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; + + ArrayList args = new ArrayList(); + + args.add(module); + args.add(rpc); + args.add(mode); + + try { + + dbSvc.writeData(deactivateSql, args, null); + + args.add(version); + dbSvc.writeData(activateSql, args, null); + + } catch (Exception e) { + throw new SvcLogicException("Could not activate graph", e); + } + } + } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java index 35486eba8..cbac15442 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java @@ -37,7 +37,9 @@ public class SvcLogicGraph implements Serializable { private String rpc = null; private String mode = null; private String version = null; - + + private String md5sum = null; + private Map attributes; private Map namedNodes; private SvcLogicNode rootNode; @@ -48,6 +50,16 @@ public class SvcLogicGraph implements Serializable { namedNodes = new HashMap(); rootNode = null; } + + public String getMd5sum() { + return md5sum; + } + + + public void setMd5sum(String md5sum) { + this.md5sum = md5sum; + } + public String getModule() { @@ -178,7 +190,7 @@ public class SvcLogicGraph implements Serializable { @Override public String toString() { - return "SvcLogicGraph [module=" + module + ", rpc=" + rpc + ", mode=" + mode + ", version=" + version + "]"; + return "SvcLogicGraph [module=" + module + ", rpc=" + rpc + ", mode=" + mode + ", version=" + version + ", md5sum=" + md5sum + "]"; } } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index 1e4b71cd8..e2fbdf726 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -35,109 +35,90 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SvcLogicJdbcStore implements SvcLogicStore { - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicJdbcStore.class); - - private String dbUrl = null; - private String dbName = null; - private String dbUser = null; - private String dbPasswd = null; - private String dbDriver = null; - - private Connection dbConn; - private PreparedStatement hasActiveGraphStmt = null; - private PreparedStatement hasVersionGraphStmt = null; - private PreparedStatement fetchActiveGraphStmt = null; - private PreparedStatement fetchVersionGraphStmt = null; - private PreparedStatement storeGraphStmt = null; - private PreparedStatement deleteGraphStmt = null; - - private PreparedStatement deactivateStmt = null; - private PreparedStatement activateStmt = null; - - private PreparedStatement registerNodeStmt = null; - private PreparedStatement unregisterNodeStmt = null; - private PreparedStatement validateNodeStmt = null; - - private void getConnection() throws ConfigurationException - { - - Properties jdbcProps = new Properties(); - - jdbcProps.setProperty("user", dbUser); - jdbcProps.setProperty("password", dbPasswd); - - try { - Driver dvr = new org.mariadb.jdbc.Driver(); - if (dvr.acceptsURL(dbUrl)) - { - LOG.debug("Driver com.mysql.jdbc.Driver accepts {}", dbUrl); - } - else - { - LOG.warn("Driver com.mysql.jdbc.Driver does not accept {}", dbUrl); - } - } catch (SQLException e1) { - LOG.error("Caught exception trying to load com.mysql.jdbc.Driver", e1); - } - - try - { - this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps); - } - catch (Exception e) - { - throw new ConfigurationException("failed to get database connection ["+dbUrl+"]", e); - } - - } - - private void createTable() throws ConfigurationException - { - - DatabaseMetaData dbm; - - try { - dbm = dbConn.getMetaData(); - } catch (SQLException e) { - - throw new ConfigurationException("could not get databse metadata", e); - } - - // See if table SVC_LOGIC exists. If not, create it. + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicJdbcStore.class); + + private String dbUrl = null; + private String dbName = null; + private String dbUser = null; + private String dbPasswd = null; + private String dbDriver = null; + + private Connection dbConn; + private PreparedStatement hasActiveGraphStmt = null; + private PreparedStatement hasVersionGraphStmt = null; + private PreparedStatement fetchActiveGraphStmt = null; + private PreparedStatement fetchVersionGraphStmt = null; + private PreparedStatement storeGraphStmt = null; + private PreparedStatement deleteGraphStmt = null; + + private PreparedStatement deactivateStmt = null; + private PreparedStatement activateStmt = null; + + private PreparedStatement registerNodeStmt = null; + private PreparedStatement unregisterNodeStmt = null; + private PreparedStatement validateNodeStmt = null; + + private void getConnection() throws ConfigurationException { + + Properties jdbcProps = new Properties(); + + jdbcProps.setProperty("user", dbUser); + jdbcProps.setProperty("password", dbPasswd); + + try { + Driver dvr = new org.mariadb.jdbc.Driver(); + if (dvr.acceptsURL(dbUrl)) { + LOG.debug("Driver com.mysql.jdbc.Driver accepts {}", dbUrl); + } else { + LOG.warn("Driver com.mysql.jdbc.Driver does not accept {}", dbUrl); + } + } catch (SQLException e1) { + LOG.error("Caught exception trying to load com.mysql.jdbc.Driver", e1); + } + + try { + this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps); + } catch (Exception e) { + throw new ConfigurationException("failed to get database connection [" + dbUrl + "]", e); + } + + } + + private void createTable() throws ConfigurationException { + + DatabaseMetaData dbm; + + try { + dbm = dbConn.getMetaData(); + } catch (SQLException e) { + + throw new ConfigurationException("could not get databse metadata", e); + } + + // See if table SVC_LOGIC exists. If not, create it. Statement stmt = null; - try - { + try { - ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null); - if (tables.next()) { + ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null); + if (tables.next()) { LOG.debug("SVC_LOGIC table already exists"); - } - else { - String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC (" - + "module varchar(80) NOT NULL," - + "rpc varchar(80) NOT NULL," - + "version varchar(40) NOT NULL," - + "mode varchar(5) NOT NULL," - + "active varchar(1) NOT NULL," - + "graph BLOB," - + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; + } else { + String crTableCmd = "CREATE TABLE " + dbName + ".SVC_LOGIC (" + "module varchar(80) NOT NULL," + + "rpc varchar(80) NOT NULL," + "version varchar(40) NOT NULL," + "mode varchar(5) NOT NULL," + + "active varchar(1) NOT NULL," + "graph BLOB," + + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; stmt = dbConn.createStatement(); stmt.executeUpdate(crTableCmd); - } - } - catch (Exception e) - { - throw new ConfigurationException("could not create SVC_LOGIC table", e); - } - finally - { + } + } catch (Exception e) { + throw new ConfigurationException("could not create SVC_LOGIC table", e); + } finally { if (stmt != null) { try { stmt.close(); @@ -147,31 +128,24 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } } - // See if NODE_TYPES table exists and, if not, create it + // See if NODE_TYPES table exists and, if not, create it stmt = null; - try - { + try { - ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null); - if (tables.next()) { + ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null); + if (tables.next()) { LOG.debug("NODE_TYPES table already exists"); - } - else { - String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES (" - + "nodetype varchar(80) NOT NULL," - + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))"; + } else { + String crTableCmd = "CREATE TABLE " + dbName + ".NODE_TYPES (" + "nodetype varchar(80) NOT NULL," + + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))"; stmt = dbConn.createStatement(); stmt.executeUpdate(crTableCmd); - } - } - catch (Exception e) - { - throw new ConfigurationException("could not create SVC_LOGIC table", e); - } - finally - { + } + } catch (Exception e) { + throw new ConfigurationException("could not create SVC_LOGIC table", e); + } finally { if (stmt != null) { try { stmt.close(); @@ -180,652 +154,444 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } } } - } - - private void prepStatements() throws ConfigurationException - { - - // Prepare statements - String hasVersionGraphSql = CommonConstants.JDBC_SELECT_COUNT + dbName + CommonConstants.SVCLOGIC_TABLE - + CommonConstants.JDBC_GRAPH_QUERY; - - try - { - hasVersionGraphStmt = dbConn.prepareStatement(hasVersionGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + hasVersionGraphSql, e); - - } - - String hasActiveGraphSql = CommonConstants.JDBC_SELECT_COUNT + dbName + CommonConstants.SVCLOGIC_TABLE - + CommonConstants.JDBC_ACTIVE_GRAPH_QUERY; - - try - { - hasActiveGraphStmt = dbConn.prepareStatement(hasActiveGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + hasVersionGraphSql, e); - - } - - String fetchVersionGraphSql = CommonConstants.JDBC_SELECT_GRAPGH + dbName+CommonConstants.SVCLOGIC_TABLE - + CommonConstants.JDBC_GRAPH_QUERY; - - try - { - fetchVersionGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + fetchVersionGraphSql, e); - - } - - String fetchActiveGraphSql = CommonConstants.JDBC_SELECT_GRAPGH + dbName + CommonConstants.SVCLOGIC_TABLE - + CommonConstants.JDBC_ACTIVE_GRAPH_QUERY; - - try - { - fetchActiveGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + fetchVersionGraphSql, e); - - } - - String storeGraphSql = CommonConstants.JDBC_INSERT+dbName - + ".SVC_LOGIC (module, rpc, version, mode, active, graph) VALUES(?, ?, ?, ?, ?, ?)"; - - try - { - storeGraphStmt = dbConn.prepareStatement(storeGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + storeGraphSql, e); - } - - String deleteGraphSql = CommonConstants.JDBC_DELETE+dbName - + ".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - - try - { - deleteGraphStmt = dbConn.prepareStatement(deleteGraphSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + deleteGraphSql, e); - } - - String deactivateSql = CommonConstants.JDBC_UPDATE + dbName - +".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; - - try - { - deactivateStmt = dbConn.prepareStatement(deactivateSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + deactivateSql, e); - } - - String activateSql = CommonConstants.JDBC_UPDATE + dbName - +".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - - try - { - activateStmt = dbConn.prepareStatement(activateSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + activateSql, e); - } - - String registerNodeSql = CommonConstants.JDBC_INSERT + dbName + ".NODE_TYPES (nodetype) VALUES(?)"; - try - { - registerNodeStmt = dbConn.prepareStatement(registerNodeSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + registerNodeSql, e); - } - - String unregisterNodeSql = CommonConstants.JDBC_DELETE + dbName + ".NODE_TYPES WHERE nodetype = ?"; - try - { - unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + unregisterNodeSql, e); - } - - String validateNodeSql = CommonConstants.JDBC_SELECT_COUNT + dbName + ".NODE_TYPES WHERE nodetype = ?"; - try - { - validateNodeStmt = dbConn.prepareStatement(validateNodeSql); - } - catch (Exception e) - { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + validateNodeSql, e); - } - } - - private void initDbResources() throws ConfigurationException - { - if ((dbDriver != null) && (dbDriver.length() > 0)) - { - - try - { - Class.forName(dbDriver); - } - catch (Exception e) - { - throw new ConfigurationException("could not load driver class "+dbDriver, e); - } - } - getConnection(); - createTable(); - prepStatements(); - } - - - @Override - public void init(Properties props) throws ConfigurationException { - - - dbUrl = props.getProperty("org.onap.ccsdk.sli.jdbc.url"); - if ((dbUrl == null) || (dbUrl.length() == 0)) - { - throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.url unset"); - } - - dbName = props.getProperty("org.onap.ccsdk.sli.jdbc.database"); - if ((dbName == null) || (dbName.length() == 0)) - { - throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.database unset"); - } - - dbUser = props.getProperty("org.onap.ccsdk.sli.jdbc.user"); - if ((dbUser == null) || (dbUser.length() == 0)) - { - throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.user unset"); - } - - - dbPasswd = props.getProperty("org.onap.ccsdk.sli.jdbc.password"); - if ((dbPasswd == null) || (dbPasswd.length() == 0)) - { - throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.password unset"); - } - - dbDriver = props.getProperty("org.onap.ccsdk.sli.jdbc.driver"); - - - initDbResources(); - - } - - private boolean isDbConnValid() - { - - boolean isValid = false; - - try - { - if (dbConn != null) - { - isValid = dbConn.isValid(1); - } - } - catch (SQLException e) - { - LOG.error("Not a valid db connection: ", e); - } - - return isValid; - } - - @Override - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); - } - } - - boolean retval = false; - ResultSet results = null; - - PreparedStatement hasGraphStmt; - if (version == null) - { - hasGraphStmt = hasActiveGraphStmt; - } - else - { - hasGraphStmt = hasVersionGraphStmt; - } - - try - { - hasGraphStmt.setString(1, module); - hasGraphStmt.setString(2, rpc); - hasGraphStmt.setString(3, mode); - - - if (version != null) - { - hasGraphStmt.setString(4, version); - } - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - results = hasGraphStmt.executeQuery(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - - if (results.next()) - { - int cnt = results.getInt(1); - - if (cnt > 0) - { - retval = true; - } - - } - } - catch (Exception e) - { - throw new ConfigurationException("SQL query failed", e); - } - finally - { - if (results != null) - { - try - { - results.close(); - } - catch (SQLException x) - { - LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x); - } - } - - } - - return retval; - - } - - @Override - public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { - - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); - } - } - - SvcLogicGraph retval = null; - ResultSet results = null; - - PreparedStatement fetchGraphStmt; - if (version == null) - { - fetchGraphStmt = fetchActiveGraphStmt; - } - else - { - fetchGraphStmt = fetchVersionGraphStmt; - } - try - { - fetchGraphStmt.setString(1, module); - fetchGraphStmt.setString(2, rpc); - fetchGraphStmt.setString(3, mode); - - - if (version != null) - { - fetchGraphStmt.setString(4, version); - } - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - results = fetchGraphStmt.executeQuery(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - - if (results.next()) - { - Blob graphBlob = results.getBlob("graph"); - - ObjectInputStream gStream = new ObjectInputStream(graphBlob.getBinaryStream()); - - Object graphObj = gStream.readObject(); - gStream.close(); - - if (graphObj instanceof SvcLogicGraph) - { - retval = (SvcLogicGraph) graphObj; - } - else - { - throw new ConfigurationException("invalid type for graph ("+graphObj.getClass().getName()); - - } - } - - } - catch (Exception e) - { - throw new ConfigurationException("SQL query failed", e); - } - finally - { - if (results != null) - { - try - { - results.close(); - } - catch (SQLException x) - { - LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x); - } - } - - } - - return retval; - } - - public void store(SvcLogicGraph graph) throws SvcLogicException { - - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); - } - } - - if (graph == null) - { - throw new SvcLogicException("graph cannot be null"); - } - - byte[] graphBytes; - - try (ByteArrayOutputStream byteStr = new ByteArrayOutputStream(); - ObjectOutputStream goutStr = new ObjectOutputStream(byteStr)) - { - - goutStr.writeObject(graph); - - graphBytes = byteStr.toByteArray(); - - } - catch (Exception e) - { - throw new SvcLogicException("could not serialize graph", e); - } - - // If object already stored in database, delete it - if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode())) - { - delete(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode()); - } - - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - storeGraphStmt.setString(1, graph.getModule()); - storeGraphStmt.setString(2, graph.getRpc()); - storeGraphStmt.setString(3, graph.getVersion()); - storeGraphStmt.setString(4, graph.getMode()); - storeGraphStmt.setString(5, "N"); - storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); - - storeGraphStmt.executeUpdate(); - dbConn.commit(); - - dbConn.setAutoCommit(oldAutoCommit); - } - catch (Exception e) - { - throw new SvcLogicException("Could not write object to database", e); - } - } - - @Override - public void delete(String module, String rpc, String version, String mode) throws SvcLogicException - { - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); - } - } - - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - deleteGraphStmt.setString(1, module); - deleteGraphStmt.setString(2, rpc); - deleteGraphStmt.setString(3, version); - deleteGraphStmt.setString(4, mode); - - - deleteGraphStmt.executeUpdate(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - } - catch (Exception e) - { - throw new SvcLogicException("Could not delete object from database", e); - } - } - - @Override - public void activate(SvcLogicGraph graph) throws SvcLogicException - { - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - - dbConn.setAutoCommit(false); - - // Deactivate any current active version - deactivateStmt.setString(1, graph.getModule()); - deactivateStmt.setString(2, graph.getRpc()); - deactivateStmt.setString(3, graph.getMode()); - deactivateStmt.executeUpdate(); - - // Activate this version - activateStmt.setString(1, graph.getModule()); - activateStmt.setString(2, graph.getRpc()); - activateStmt.setString(3, graph.getVersion()); - activateStmt.setString(4, graph.getMode()); - activateStmt.executeUpdate(); - - dbConn.commit(); - - dbConn.setAutoCommit(oldAutoCommit); - - } - catch (Exception e) - { - throw new SvcLogicException("Could not activate graph", e); - } - } - - @Override - public void registerNodeType(String nodeType) throws SvcLogicException { - - if (isValidNodeType(nodeType)) - { - return; - } - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); - } - } - - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - registerNodeStmt.setString(1, nodeType); - registerNodeStmt.executeUpdate(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - } - catch (Exception e) - { - throw new SvcLogicException("Could not add node type to database", e); - } - - } - - @Override - public void unregisterNodeType(String nodeType) throws SvcLogicException { - - if (!isValidNodeType(nodeType)) - { - return; - } - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); - } - } - - try - { - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - unregisterNodeStmt.setString(1, nodeType); - unregisterNodeStmt.executeUpdate(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - } - catch (Exception e) - { - throw new SvcLogicException("Could not delete node type from database", e); - } - - } - - @Override - public boolean isValidNodeType(String nodeType) throws SvcLogicException { - - boolean isValid = false; - - if (!isDbConnValid()) - { - - // Try reinitializing - initDbResources(); - - if (!isDbConnValid()) - { - throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); - } - } - - ResultSet results = null; - try - { - validateNodeStmt.setString(1, nodeType); - - boolean oldAutoCommit = dbConn.getAutoCommit(); - dbConn.setAutoCommit(false); - results = validateNodeStmt.executeQuery(); - dbConn.commit(); - dbConn.setAutoCommit(oldAutoCommit); - - if (results.next()) - { - int cnt = results.getInt(1); - - if (cnt > 0) - { - isValid = true; - } - } - - } - catch (Exception e) - { - throw new SvcLogicException("Cannot select node type from database", e); - } - finally - { - if (results != null) - { - try - { - results.close(); - } - catch (SQLException x) - { - LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x); - } - } - - } - - return(isValid); - } + } + + private void prepStatements() throws ConfigurationException { + + // Prepare statements + String hasVersionGraphSql = CommonConstants.JDBC_SELECT_COUNT + dbName + CommonConstants.SVCLOGIC_TABLE + + CommonConstants.JDBC_GRAPH_QUERY; + + try { + hasVersionGraphStmt = dbConn.prepareStatement(hasVersionGraphSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + hasVersionGraphSql, e); + + } + + String hasActiveGraphSql = CommonConstants.JDBC_SELECT_COUNT + dbName + CommonConstants.SVCLOGIC_TABLE + + CommonConstants.JDBC_ACTIVE_GRAPH_QUERY; + + try { + hasActiveGraphStmt = dbConn.prepareStatement(hasActiveGraphSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + hasVersionGraphSql, e); + + } + + String fetchVersionGraphSql = CommonConstants.JDBC_SELECT_GRAPGH + dbName + CommonConstants.SVCLOGIC_TABLE + + CommonConstants.JDBC_GRAPH_QUERY; + + try { + fetchVersionGraphStmt = dbConn.prepareStatement(fetchVersionGraphSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + fetchVersionGraphSql, e); + + } + + String fetchActiveGraphSql = CommonConstants.JDBC_SELECT_GRAPGH + dbName + CommonConstants.SVCLOGIC_TABLE + + CommonConstants.JDBC_ACTIVE_GRAPH_QUERY; + + try { + fetchActiveGraphStmt = dbConn.prepareStatement(fetchActiveGraphSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + fetchVersionGraphSql, e); + + } + + String storeGraphSql = CommonConstants.JDBC_INSERT + dbName + + ".SVC_LOGIC (module, rpc, version, mode, active, graph) VALUES(?, ?, ?, ?, ?, ?)"; + + try { + storeGraphStmt = dbConn.prepareStatement(storeGraphSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + storeGraphSql, e); + } + + String deleteGraphSql = CommonConstants.JDBC_DELETE + dbName + + ".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + + try { + deleteGraphStmt = dbConn.prepareStatement(deleteGraphSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + deleteGraphSql, e); + } + + String deactivateSql = CommonConstants.JDBC_UPDATE + dbName + + ".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; + + try { + deactivateStmt = dbConn.prepareStatement(deactivateSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + deactivateSql, e); + } + + String activateSql = CommonConstants.JDBC_UPDATE + dbName + + ".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; + + try { + activateStmt = dbConn.prepareStatement(activateSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + activateSql, e); + } + + String registerNodeSql = CommonConstants.JDBC_INSERT + dbName + ".NODE_TYPES (nodetype) VALUES(?)"; + try { + registerNodeStmt = dbConn.prepareStatement(registerNodeSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + registerNodeSql, e); + } + + String unregisterNodeSql = CommonConstants.JDBC_DELETE + dbName + ".NODE_TYPES WHERE nodetype = ?"; + try { + unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + unregisterNodeSql, e); + } + + String validateNodeSql = CommonConstants.JDBC_SELECT_COUNT + dbName + ".NODE_TYPES WHERE nodetype = ?"; + try { + validateNodeStmt = dbConn.prepareStatement(validateNodeSql); + } catch (Exception e) { + throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + validateNodeSql, e); + } + } + + private void initDbResources() throws ConfigurationException { + if ((dbDriver != null) && (dbDriver.length() > 0)) { + + try { + Class.forName(dbDriver); + } catch (Exception e) { + throw new ConfigurationException("could not load driver class " + dbDriver, e); + } + } + getConnection(); + createTable(); + prepStatements(); + } + + + @Override + public void init(Properties props) throws ConfigurationException { + + + dbUrl = props.getProperty("org.onap.ccsdk.sli.jdbc.url"); + if ((dbUrl == null) || (dbUrl.length() == 0)) { + throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.url unset"); + } + + dbName = props.getProperty("org.onap.ccsdk.sli.jdbc.database"); + if ((dbName == null) || (dbName.length() == 0)) { + throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.database unset"); + } + + dbUser = props.getProperty("org.onap.ccsdk.sli.jdbc.user"); + if ((dbUser == null) || (dbUser.length() == 0)) { + throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.user unset"); + } + + + dbPasswd = props.getProperty("org.onap.ccsdk.sli.jdbc.password"); + if ((dbPasswd == null) || (dbPasswd.length() == 0)) { + throw new ConfigurationException("property org.onap.ccsdk.sli.jdbc.password unset"); + } + + dbDriver = props.getProperty("org.onap.ccsdk.sli.jdbc.driver"); + + + initDbResources(); + + } + + private boolean isDbConnValid() { + + boolean isValid = false; + + try { + if (dbConn != null) { + isValid = dbConn.isValid(1); + } + } catch (SQLException e) { + LOG.error("Not a valid db connection: ", e); + } + + return isValid; + } + + @Override + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { + + if (!isDbConnValid()) { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) { + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); + } + } + + boolean retval = false; + ResultSet results = null; + + PreparedStatement hasGraphStmt; + if (version == null) { + hasGraphStmt = hasActiveGraphStmt; + } else { + hasGraphStmt = hasVersionGraphStmt; + } + + try { + hasGraphStmt.setString(1, module); + hasGraphStmt.setString(2, rpc); + hasGraphStmt.setString(3, mode); + + + if (version != null) { + hasGraphStmt.setString(4, version); + } + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + results = hasGraphStmt.executeQuery(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + + if (results.next()) { + int cnt = results.getInt(1); + + if (cnt > 0) { + retval = true; + } + + } + } catch (Exception e) { + throw new ConfigurationException("SQL query failed", e); + } finally { + if (results != null) { + try { + results.close(); + } catch (SQLException x) { + LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x); + } + } + + } + + return retval; + + } + + @Override + public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { + + + if (!isDbConnValid()) { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) { + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); + } + } + + SvcLogicGraph retval = null; + ResultSet results = null; + + PreparedStatement fetchGraphStmt; + if (version == null) { + fetchGraphStmt = fetchActiveGraphStmt; + } else { + fetchGraphStmt = fetchVersionGraphStmt; + } + try { + fetchGraphStmt.setString(1, module); + fetchGraphStmt.setString(2, rpc); + fetchGraphStmt.setString(3, mode); + + + if (version != null) { + fetchGraphStmt.setString(4, version); + } + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + results = fetchGraphStmt.executeQuery(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + + if (results.next()) { + Blob graphBlob = results.getBlob("graph"); + + ObjectInputStream gStream = new ObjectInputStream(graphBlob.getBinaryStream()); + + Object graphObj = gStream.readObject(); + gStream.close(); + + if (graphObj instanceof SvcLogicGraph) { + retval = (SvcLogicGraph) graphObj; + } else { + throw new ConfigurationException("invalid type for graph (" + graphObj.getClass().getName()); + + } + } + + } catch (Exception e) { + throw new ConfigurationException("SQL query failed", e); + } finally { + if (results != null) { + try { + results.close(); + } catch (SQLException x) { + LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x); + } + } + + } + + return retval; + } + + public void store(SvcLogicGraph graph) throws SvcLogicException { + + + if (!isDbConnValid()) { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) { + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); + } + } + + if (graph == null) { + throw new SvcLogicException("graph cannot be null"); + } + + byte[] graphBytes; + + try (ByteArrayOutputStream byteStr = new ByteArrayOutputStream(); + ObjectOutputStream goutStr = new ObjectOutputStream(byteStr)) { + + goutStr.writeObject(graph); + + graphBytes = byteStr.toByteArray(); + + } catch (Exception e) { + throw new SvcLogicException("could not serialize graph", e); + } + + // If object already stored in database, delete it + if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode())) { + delete(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode()); + } + + try { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + storeGraphStmt.setString(1, graph.getModule()); + storeGraphStmt.setString(2, graph.getRpc()); + storeGraphStmt.setString(3, graph.getVersion()); + storeGraphStmt.setString(4, graph.getMode()); + storeGraphStmt.setString(5, "N"); + storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); + + storeGraphStmt.executeUpdate(); + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + } catch (Exception e) { + throw new SvcLogicException("Could not write object to database", e); + } + } + + @Override + public void delete(String module, String rpc, String version, String mode) throws SvcLogicException { + if (!isDbConnValid()) { + + // Try reinitializing + initDbResources(); + + if (!isDbConnValid()) { + throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR); + } + } + + try { + boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn.setAutoCommit(false); + deleteGraphStmt.setString(1, module); + deleteGraphStmt.setString(2, rpc); + deleteGraphStmt.setString(3, version); + deleteGraphStmt.setString(4, mode); + + + deleteGraphStmt.executeUpdate(); + dbConn.commit(); + dbConn.setAutoCommit(oldAutoCommit); + } catch (Exception e) { + throw new SvcLogicException("Could not delete object from database", e); + } + } + + @Override + public void activate(SvcLogicGraph graph) throws SvcLogicException { + try { + boolean oldAutoCommit = dbConn.getAutoCommit(); + + dbConn.setAutoCommit(false); + + // Deactivate any current active version + deactivateStmt.setString(1, graph.getModule()); + deactivateStmt.setString(2, graph.getRpc()); + deactivateStmt.setString(3, graph.getMode()); + deactivateStmt.executeUpdate(); + + // Activate this version + activateStmt.setString(1, graph.getModule()); + activateStmt.setString(2, graph.getRpc()); + activateStmt.setString(3, graph.getVersion()); + activateStmt.setString(4, graph.getMode()); + activateStmt.executeUpdate(); + + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + + } catch (Exception e) { + throw new SvcLogicException("Could not activate graph", e); + } + } + + @Override + public void activate(String module, String rpc, String version, String mode) throws SvcLogicException { + try { + boolean oldAutoCommit = dbConn.getAutoCommit(); + + dbConn.setAutoCommit(false); + + // Deactivate any current active version + deactivateStmt.setString(1, module); + deactivateStmt.setString(2, rpc); + deactivateStmt.setString(3, mode); + deactivateStmt.executeUpdate(); + + // Activate this version + activateStmt.setString(1, module); + activateStmt.setString(2, rpc); + activateStmt.setString(3, version); + activateStmt.setString(4, mode); + activateStmt.executeUpdate(); + + dbConn.commit(); + + dbConn.setAutoCommit(oldAutoCommit); + + } catch (Exception e) { + throw new SvcLogicException("Could not activate graph", e); + } + } + } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java new file mode 100644 index 000000000..bc8c1bdf3 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java @@ -0,0 +1,168 @@ +/*- + * ============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========================================================= + */ + +package org.onap.ccsdk.sli.core.sli; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicLoader { + private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicLoader.class); + SvcLogicStore store; + String directoryRoot; + String propFile; + + public SvcLogicLoader(String directoryRoot, String propFile) { + store = SvcLogicParser.getStore(propFile); + this.directoryRoot = directoryRoot; + this.propFile = propFile; + } + + public void loadAndActivate() throws IOException { + SvcLogicCrawler slc = new SvcLogicCrawler(); + Files.walkFileTree(Paths.get(this.directoryRoot), slc); + + loadGraphs(slc.getGraphPaths(), directoryRoot); + + List activationEntries = processActivationFiles(slc.getActivationPaths()); + activateGraphs(activationEntries); + } + + private List processActivationFiles(List activationPaths) { + List activationEntries = new ArrayList(); + for (Path activationFile : activationPaths) { + activationEntries.addAll(getActivationEntries(activationFile)); + } + return activationEntries; + + } + + private void activateGraphs(List activationEntries) { + for (ActivationEntry entry : activationEntries) { + try { + if (store.hasGraph(entry.module, entry.rpc, entry.version, entry.mode)) { + store.activate(entry.module, entry.rpc, entry.version, entry.mode); + } else { + LOGGER.error("hasGraph returned false for " + entry.toString()); + } + } catch (SvcLogicException e) { + LOGGER.error("Failed to call hasGraph for " + entry.toString(), e); + } + } + } + + protected List getActivationEntries(Path activationFilePath) { + List activationEntries = new ArrayList<>(); + int lineNumber = 1; + try (BufferedReader br = Files.newBufferedReader(activationFilePath, StandardCharsets.US_ASCII)) { + String fileRead = br.readLine(); + while (fileRead != null) { + String[] fields = fileRead.split("\\s"); + if (fields.length == 4) { + activationEntries.add(parseActivationEntry(fields)); + } else { + LOGGER.error("Activation entry [" + fileRead + "] is declared at line number " + lineNumber + " in the file " + activationFilePath + " and is invalid."); + } + fileRead = br.readLine(); + lineNumber++; + } + return activationEntries; + } catch (IOException ioe) { + LOGGER.error("Couldn't read the activation file at " + activationFilePath, ioe); + return null; + } + } + + protected void loadGraphs(List graphPaths, String directoryRoot) { + for (Path graphPath : graphPaths) { + try { + saveGraph(graphPath.toString()); + } catch (Exception e) { + LOGGER.error("Couldn't load graph at " + graphPath, e); + } + } + } + + private void saveGraph(String xmlFile) throws SvcLogicException { + File f = new File(xmlFile); + if (!f.canRead()) { + throw new ConfigurationException("Cannot read xml file (" + xmlFile + ")"); + } + + SvcLogicParser parser = new SvcLogicParser(); + LinkedList graphs = null; + + try { + graphs = parser.parse(xmlFile); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + if (graphs == null) { + throw new SvcLogicException("Could not parse " + xmlFile); + } + + for (Iterator iter = graphs.iterator(); iter.hasNext();) { + + SvcLogicGraph graph = iter.next(); + + try { + LOGGER.info("Saving " + graph.toString() + " to database"); + store.store(graph); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + + } + } + + protected ActivationEntry parseActivationEntry(String[] fileInput) { + return new ActivationEntry(fileInput[0], fileInput[1], fileInput[2], fileInput[3]); + } + + protected String getValue(String raw, String attributeName) { + raw = raw.substring(attributeName.length() + 1); + if (raw.contains(">")) { + raw = raw.substring(0, raw.lastIndexOf('>')); + } + if (raw.endsWith("'")) { + raw = raw.substring(0, raw.lastIndexOf('\'')); + } + if (raw.endsWith("\"")) { + raw = raw.substring(0, raw.lastIndexOf('"')); + } + return raw; + } + + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index a33ba4767..ee260433a 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -21,32 +21,29 @@ package org.onap.ccsdk.sli.core.sli; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.LinkedList; +import javax.xml.XMLConstants; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; -import javax.xml.XMLConstants; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.util.LinkedList; - /** * @author dt5972 * */ public class SvcLogicParser { - private SvcLogicStore store = null; static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; @@ -64,282 +61,247 @@ public class SvcLogicParser { private static final String SVCLOGIC_XSD = "/svclogic.xsd"; private class SvcLogicHandler extends DefaultHandler { - private Locator locator = null; - private String module = null; - private String version = null; - private LinkedList graphs = null; - private SvcLogicGraph curGraph = null; - private SvcLogicNode curNode = null; - private LinkedList nodeStack = null; - private int curNodeId = 0; - private String outcomeValue = null; - private LinkedList outcomeStack = null; - private SvcLogicStore svcLogicStore = null; - - public SvcLogicHandler(LinkedList graphs, SvcLogicStore store) { - this.graphs = graphs; - this.curNode = null; - this.nodeStack = new LinkedList<>(); - this.outcomeStack = new LinkedList<>(); - this.curNodeId = 1; - this.outcomeValue = null; - this.svcLogicStore = store; + private Locator locator = null; + private String module = null; + private String version = null; + private LinkedList graphs = null; + private SvcLogicGraph curGraph = null; + private SvcLogicNode curNode = null; + private LinkedList nodeStack = null; + private int curNodeId = 0; + private String outcomeValue = null; + private LinkedList outcomeStack = null; + + public SvcLogicHandler(LinkedList graphs) { + this.graphs = graphs; + this.curNode = null; + this.nodeStack = new LinkedList<>(); + this.outcomeStack = new LinkedList<>(); + this.curNodeId = 1; + this.outcomeValue = null; + } - } + @Override + public void setDocumentLocator(Locator locator) { + this.locator = locator; + } - @Override - public void setDocumentLocator(Locator locator) { - this.locator = locator; - } + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) + throws SAXException { - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + // Handle service-logic (graph) tag + if ("service-logic".equalsIgnoreCase(qName)) { - // Handle service-logic (graph) tag - if ("service-logic".equalsIgnoreCase(qName)) { + module = attributes.getValue("module"); + if (module == null || module.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Missing 'module' attribute from service-logic tag"); + } - module = attributes.getValue("module"); - if (module == null || module.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "Missing 'module' attribute from service-logic tag"); - } + version = attributes.getValue("version"); + if (version == null || version.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Missing 'version' attribute from service-logic tag"); + } - version = attributes.getValue("version"); - if (version == null || version.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "Missing 'version' attribute from service-logic tag"); + return; } - return; - } + if ("method".equalsIgnoreCase(qName)) { - if ("method".equalsIgnoreCase(qName)) { + if (curGraph != null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Cannot nest module tags"); + } - if (curGraph != null) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "Cannot nest module tags"); - } + curGraph = new SvcLogicGraph(); + curGraph.setModule(module); + curGraph.setVersion(version); + this.curNodeId = 1; - curGraph = new SvcLogicGraph(); - curGraph.setModule(module); - curGraph.setVersion(version); - this.curNodeId = 1; + String attrValue = attributes.getValue("rpc"); + if (attrValue == null || attrValue.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Missing 'rpc' attribute for method tag"); + } + curGraph.setRpc(attrValue); - String attrValue = attributes.getValue("rpc"); - if (attrValue == null || attrValue.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "Missing 'rpc' attribute for method tag"); - } - curGraph.setRpc(attrValue); + attrValue = attributes.getValue("mode"); + if (attrValue == null || attrValue.length() == 0) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Missing 'mode' attribute for method tag"); + } + curGraph.setMode(attrValue); - attrValue = attributes.getValue("mode"); - if (attrValue == null || attrValue.length() == 0) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "Missing 'mode' attribute for method tag"); + return; } - curGraph.setMode(attrValue); - return; - } + // Handle outcome (edge) tag + if ("outcome".equalsIgnoreCase(qName)) { + String refValue = attributes.getValue("ref"); + + if (refValue != null) { + SvcLogicNode refNode = curGraph.getNamedNode(refValue); + + if (refNode != null) { + try { + curNode.addOutcome(attributes.getValue("value"), refNode); + } catch (SvcLogicException e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + + " " + "Cannot add outcome", e); + } + } else { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "ref to unknown node " + refValue); + } + return; + } + + if (outcomeValue != null) { + outcomeStack.push(outcomeValue); + } + outcomeValue = attributes.getValue("value"); - // Handle outcome (edge) tag - if ("outcome".equalsIgnoreCase(qName)) { - String refValue = attributes.getValue("ref"); + return; + } - if (refValue != null) { - SvcLogicNode refNode = curGraph.getNamedNode(refValue); + // Handle parameter tag + if ("parameter".equalsIgnoreCase(qName)) { + String parmName = attributes.getValue("name"); + String parmValue = attributes.getValue("value"); - if (refNode != null) { + if (parmName != null && parmName.length() > 0 && parmValue != null) { try { - curNode.addOutcome(attributes.getValue("value"), refNode); - } catch (SvcLogicException e) { + + curNode.mapParameter(parmName, parmValue); + } catch (Exception e) { throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "Cannot add outcome", e); + + " cannot set parameter " + parmName + " to " + parmValue + " [" + e.getMessage() + + "]"); } - } else { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "ref to unknown node " + refValue); } - return; - } - if (outcomeValue != null) { - outcomeStack.push(outcomeValue); + return; } - outcomeValue = attributes.getValue("value"); - return; - } + // Handle node tags + String nodeName = attributes.getValue("name"); + SvcLogicNode thisNode; - // Handle parameter tag - if ("parameter".equalsIgnoreCase(qName)) { - String parmName = attributes.getValue("name"); - String parmValue = attributes.getValue("value"); - if (parmName != null && parmName.length() > 0 && parmValue != null) { - try { + try { + if (nodeName != null && nodeName.length() > 0) { + thisNode = new SvcLogicNode(curNodeId++, qName, nodeName, curGraph); + } else { + thisNode = new SvcLogicNode(curNodeId++, qName, curGraph); + } - curNode.mapParameter(parmName, parmValue); - } catch (Exception e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + " cannot set parameter " + parmName + " to " + parmValue + " [" + e.getMessage() + "]"); + if (curGraph.getRootNode() == null) { + curGraph.setRootNode(thisNode); } - } + } catch (SvcLogicException e) { + throw new SAXException( + "line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); - return; - } + } - // Handle node tags - String nodeName = attributes.getValue("name"); - SvcLogicNode thisNode; + int numAttributes = attributes.getLength(); - try { - if (!svcLogicStore.isValidNodeType(qName)) { - throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() - + " " + "Unknown tag " + qName); - } - } catch (Exception e) { - throw new SAXNotRecognizedException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() - + " " + "Cannot validate node type " + qName); - } + for (int i = 0; i < numAttributes; i++) { + String attrName = attributes.getQName(i); + if (!"name".equalsIgnoreCase(attrName)) { + try { - try { - if (nodeName != null && nodeName.length() > 0) { - thisNode = new SvcLogicNode(curNodeId++, qName, nodeName, curGraph); - } else { - thisNode = new SvcLogicNode(curNodeId++, qName, curGraph); + String attrValueStr = attributes.getValue(i); + SvcLogicExpression attrValue; + if (attrValueStr.trim().startsWith("`")) { + int lastParen = attrValueStr.lastIndexOf('`'); + String evalExpr = attrValueStr.trim().substring(1, lastParen); + attrValue = SvcLogicExpressionFactory.parse(evalExpr); + + } else { + if (Character.isDigit(attrValueStr.charAt(0))) { + attrValue = new SvcLogicAtom("NUMBER", attrValueStr); + } else { + attrValue = new SvcLogicAtom("STRING", attrValueStr); + } + } + thisNode.setAttribute(attrName, attrValue); + } catch (Exception e) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + + "Cannot set attribute " + attrName, e); + } + } } - if (curGraph.getRootNode() == null) { - curGraph.setRootNode(thisNode); + if (curNode != null) { + try { + if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) + || "while".equalsIgnoreCase(curNode.getNodeType())) { + curNode.addOutcome(Integer.toString(curNode.getNumOutcomes() + 1), thisNode); + } else { + if (outcomeValue == null) { + throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + + " " + curNode.getNodeType() + " node expects outcome, instead found " + + thisNode.getNodeType()); + } + curNode.addOutcome(outcomeValue, thisNode); + } + } catch (SvcLogicException e) { + throw new SAXException( + "line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + e.getMessage()); + } + nodeStack.push(curNode); } - } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + e.getMessage()); + curNode = thisNode; } - int numAttributes = attributes.getLength(); - - for (int i = 0; i < numAttributes; i++) { - String attrName = attributes.getQName(i); - if (!"name".equalsIgnoreCase(attrName)) { - try { - - String attrValueStr = attributes.getValue(i); - SvcLogicExpression attrValue; - if (attrValueStr.trim().startsWith("`")) { - int lastParen = attrValueStr.lastIndexOf('`'); - String evalExpr = attrValueStr.trim().substring(1, lastParen); - attrValue = SvcLogicExpressionFactory.parse(evalExpr); + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { - } else { - if (Character.isDigit(attrValueStr.charAt(0))) { - attrValue = new SvcLogicAtom("NUMBER", attrValueStr); - } else { - attrValue = new SvcLogicAtom("STRING", attrValueStr); - } + // Handle close of service-logic tag + if ("service-logic".equalsIgnoreCase(qName)) { + // Nothing more to do + return; } - thisNode.setAttribute(attrName, attrValue); - } catch (Exception e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + "Cannot set attribute " + attrName, e); + + // Handle close of method tag + if ("method".equalsIgnoreCase(qName)) { + graphs.add(curGraph); + curGraph = null; + return; } - } - } - if (curNode != null) { - try { - if ("block".equalsIgnoreCase(curNode.getNodeType()) || "for".equalsIgnoreCase(curNode.getNodeType()) - || "while".equalsIgnoreCase(curNode.getNodeType())) { - curNode.addOutcome(Integer.toString(curNode.getNumOutcomes() + 1), thisNode); + // Handle close of outcome tag + if ("outcome".equalsIgnoreCase(qName)) { + // Finished this outcome - pop the outcome stack + if (outcomeStack.isEmpty()) { + outcomeValue = null; } else { - if (outcomeValue == null) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + curNode.getNodeType() + " node expects outcome, instead found " + thisNode.getNodeType()); - } - curNode.addOutcome(outcomeValue, thisNode); + outcomeValue = outcomeStack.pop(); } - } catch (SvcLogicException e) { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + e.getMessage()); + return; } - nodeStack.push(curNode); - } - curNode = thisNode; - - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - // Handle close of service-logic tag - if ("service-logic".equalsIgnoreCase(qName)) { - // Nothing more to do - return; - } - - // Handle close of method tag - if ("method".equalsIgnoreCase(qName)) { - graphs.add(curGraph); - curGraph = null; - return; - } + // Handle close of parameter tag - do nothing + if ("parameter".equalsIgnoreCase(qName)) { + return; + } - // Handle close of outcome tag - if ("outcome".equalsIgnoreCase(qName)) { - // Finished this outcome - pop the outcome stack - if (outcomeStack.isEmpty()) { - outcomeValue = null; + // Handle close of a node tag + if (nodeStack.isEmpty()) { + curNode = null; } else { - outcomeValue = outcomeStack.pop(); + curNode = nodeStack.pop(); } - return; - } - - // Handle close of parameter tag - do nothing - if ("parameter".equalsIgnoreCase(qName)) { - return; - } - - // Handle close of a node tag - if (nodeStack.isEmpty()) { - curNode = null; - } else { - curNode = nodeStack.pop(); - } - } - - @Override - public void error(SAXParseException arg0) throws SAXException { - throw new SAXException("line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " - + arg0.getMessage()); - } - - } - - public SvcLogicParser(SvcLogicStore store) { - this.store = store; - } - - public SvcLogicParser(String propFile) { - - try { - this.store = SvcLogicStoreFactory.getSvcLogicStore(propFile); - } catch (Exception e) { - LOGGER.error(SVC_LOGIC_STORE_ERROR, e); - } - } - - public SvcLogicParser(InputStream propStr) { - - try { - this.store = SvcLogicStoreFactory.getSvcLogicStore(propStr); - } catch (Exception e) { - LOGGER.error(SVC_LOGIC_STORE_ERROR, e); - + @Override + public void error(SAXParseException arg0) throws SAXException { + throw new SAXException( + "line " + locator.getLineNumber() + ":" + locator.getColumnNumber() + " " + arg0.getMessage()); } } @@ -382,7 +344,15 @@ public class SvcLogicParser { graphs = new LinkedList<>(); - saxParser.parse(fileName, new SvcLogicHandler(graphs, store)); + saxParser.parse(fileName, new SvcLogicHandler(graphs)); + + try { + for (SvcLogicGraph graph : graphs) { + graph.setMd5sum(CheckSumHelper.md5SumFromFile(fileName)); + } + } catch (Exception exc) { + LOGGER.error("Couldn't set md5sum on graphs", exc); + } } catch (Exception e) { LOGGER.error("Parsing failed ", e); @@ -422,18 +392,18 @@ public class SvcLogicParser { String propfile = null; switch (argv.length) { - case 6: - version = argv[4]; - propfile = argv[5]; - case 5: - if (propfile == null) { - propfile = argv[4]; - } - SvcLogicStore store = SvcLogicParser.getStore(propfile); - SvcLogicParser.print(argv[1], argv[2], argv[3], version, store); - break; - default: - SvcLogicParser.usage(); + case 6: + version = argv[4]; + propfile = argv[5]; + case 5: + if (propfile == null) { + propfile = argv[4]; + } + SvcLogicStore store = SvcLogicParser.getStore(propfile); + SvcLogicParser.print(argv[1], argv[2], argv[3], version, store); + break; + default: + SvcLogicParser.usage(); } } else if ("get-source".equalsIgnoreCase(argv[0])) { @@ -445,32 +415,43 @@ public class SvcLogicParser { } } else if ("activate".equalsIgnoreCase(argv[0])) { if (argv.length == 6) { - SvcLogicStore store = SvcLogicParser.getStore(argv[5]); - SvcLogicParser.activate(argv[1], argv[2], argv[3], argv[4], store); + SvcLogicStore store = SvcLogicParser.getStore(argv[5]); + SvcLogicParser.activate(argv[1], argv[2], argv[3], argv[4], store); } else { - SvcLogicParser.usage(); + SvcLogicParser.usage(); } } else if ("validate".equalsIgnoreCase(argv[0])) { if (argv.length == 3) { - String xmlfile = argv[1]; - String propfile = argv[2]; + String xmlfile = argv[1]; + String propfile = argv[2]; - System.setProperty(SLI_VALIDATING_PARSER, "true"); - SvcLogicStore store = SvcLogicParser.getStore(propfile); - try { - SvcLogicParser.validate(xmlfile, store); - } catch (Exception e) { - LOGGER.error("Validate failed", e); + System.setProperty(SLI_VALIDATING_PARSER, "true"); + SvcLogicStore store = SvcLogicParser.getStore(propfile); + try { + SvcLogicParser.validate(xmlfile, store); + } catch (Exception e) { + LOGGER.error("Validate failed", e); + } + } else { + SvcLogicParser.usage(); } + } else if ("install".equalsIgnoreCase(argv[0])) { + if (argv.length == 3) { + SvcLogicLoader loader = new SvcLogicLoader(argv[1], argv[2]); + try { + loader.loadAndActivate(); + } catch (IOException e) { + LOGGER.error(e.getMessage(), e); + } } else { - SvcLogicParser.usage(); + SvcLogicParser.usage(); } } System.exit(0); } - private static SvcLogicStore getStore(String propfile) { + protected static SvcLogicStore getStore(String propfile) { SvcLogicStore store = null; @@ -491,7 +472,7 @@ public class SvcLogicParser { throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); } - SvcLogicParser parser = new SvcLogicParser(store); + SvcLogicParser parser = new SvcLogicParser(); LinkedList graphs; try { LOGGER.info("Loading {}", xmlfile); @@ -511,8 +492,8 @@ public class SvcLogicParser { String version = graph.getVersion(); String mode = graph.getMode(); try { - LOGGER.info("Saving SvcLogicGraph to database (module:{},rpc:{},mode:{},version:{})", module, rpc, - mode, version); + LOGGER.info("Saving SvcLogicGraph to database (module:{},rpc:{},mode:{},version:{})", module, rpc, mode, + version); store.store(graph); } catch (Exception e) { throw new SvcLogicException(e.getMessage(), e); @@ -528,7 +509,7 @@ public class SvcLogicParser { throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); } - SvcLogicParser parser = new SvcLogicParser(store); + SvcLogicParser parser = new SvcLogicParser(); LinkedList graphs; try { LOGGER.info("Validating {}", xmlfile); @@ -607,6 +588,9 @@ public class SvcLogicParser { System.err.println(" OR SvcLogicParser print [] "); System.err.println(" OR SvcLogicParser get-source "); System.err.println(" OR SvcLogicParser activate "); + System.err.println(" OR SvcLogicParser validate "); + System.err.println(" OR SvcLogicParser install "); + System.exit(1); } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java index 3a3f9288a..2eda67f11 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStore.java @@ -26,12 +26,11 @@ import java.util.Properties; public interface SvcLogicStore { public void init(Properties props) throws SvcLogicException; - public void registerNodeType(String nodeType) throws SvcLogicException; - public void unregisterNodeType(String nodeType) throws SvcLogicException; - public boolean isValidNodeType(String nodeType) throws SvcLogicException; public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException; public void store(SvcLogicGraph graph) throws SvcLogicException; public void delete(String module, String rpc, String version, String mode) throws SvcLogicException; public void activate(SvcLogicGraph graph) throws SvcLogicException; + public void activate(String module, String rpc, String version, String mode) throws SvcLogicException; + } diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 0912ee9fb..368d9f95d 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -79,31 +79,6 @@ public class ITCaseSvcLogicParser { props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); - - store = SvcLogicStoreFactory.getSvcLogicStore(props); - - assertNotNull(store); - - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); - store.registerNodeType("call"); - store.registerNodeType("delete"); - store.registerNodeType("execute"); - store.registerNodeType("notify"); - store.registerNodeType("save"); - store.registerNodeType("update"); - store.registerNodeType("break"); } @AfterClass diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java index 7c1fa8e44..cbde44d60 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java @@ -134,7 +134,6 @@ public class SvcLogicActivator implements BundleActivator { // Initialize SvcLogicStore try { SvcLogicStore store = getStore(); - registerNodeTypes(store); } catch (ConfigurationException e) { LOG.warn("Could not initialize SvcLogicScore", e); } @@ -148,13 +147,6 @@ public class SvcLogicActivator implements BundleActivator { if (registrations != null) { for (ServiceRegistration reg : registrations) { ServiceReference regRef = reg.getReference(); - /* Don't bother to remove node types from table - String nodeType = (String) regRef.getProperty("nodeType"); - if (nodeType != null) { - LOG.info("SLI - unregistering node type " + nodeType); - store.unregisterNodeType(nodeType); - } - */ reg.unregister(); } synchronized (SvcLogicActivator.class) { @@ -185,30 +177,5 @@ public class SvcLogicActivator implements BundleActivator { return(store); } - private static void registerNodeTypes(SvcLogicStore store) throws SvcLogicException { - if (store == null) { - return; - } - // Advertise built-in node executors - LOG.info("SLI : Registering built-in node executors"); - Hashtable propTable = new Hashtable(); - - for (String nodeType : BUILTIN_NODES.keySet()) { - LOG.info("SLI - registering node type {}", nodeType); - propTable.clear(); - propTable.put("nodeType", nodeType); - - ServiceRegistration reg = bundleCtx.registerService(SvcLogicNodeExecutor.class.getName(), - BUILTIN_NODES.get(nodeType), propTable); - registrations.add(reg); - - store.registerNodeType(nodeType); - - LOG.info("SLI - registering node executor"); - - ((SvcLogicServiceImpl)svcLogicServiceImpl).registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); - - } - } } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 0a0e28c4f..724e946d5 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -99,20 +99,7 @@ public class ITCaseSvcLogicGraphExecutor { assertNotNull(store); - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); - SvcLogicParser parser = new SvcLogicParser(store); + SvcLogicParser parser = new SvcLogicParser(); // Loop through executor tests @@ -165,20 +152,8 @@ public class ITCaseSvcLogicGraphExecutor { assertNotNull(store); - store.registerNodeType("switch"); - store.registerNodeType("block"); - store.registerNodeType("get-resource"); - store.registerNodeType("reserve"); - store.registerNodeType("is-available"); - store.registerNodeType("exists"); - store.registerNodeType("configure"); - store.registerNodeType("return"); - store.registerNodeType("record"); - store.registerNodeType("allocate"); - store.registerNodeType("release"); - store.registerNodeType("for"); - store.registerNodeType("set"); - SvcLogicParser parser = new SvcLogicParser(store); + + SvcLogicParser parser = new SvcLogicParser(); // Loop through executor tests -- cgit 1.2.3-korg From 849f77fba3188261f817279ee1a3aed98de5f4e5 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 18 Dec 2017 11:58:35 -0500 Subject: Service logic logging fixes Update MetricLogger class to properly escape characters within body of response. Also, used SvcLogicGraph.toString method to simplify logging call. Change-Id: I6bcaaf3c67032df041c6d37372016990ff0199d3 Issue-ID: CCSDK-152 Signed-off-by: Dan Timoney --- .../src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java | 2 +- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 79989b514..e70d08a5f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -169,7 +169,7 @@ public class MetricLogger { } private void setResponseDescription(String responseDesc) { - MDC.put(RESPONSE_DESCRIPTION, responseDesc); + MDC.put(RESPONSE_DESCRIPTION, formatString(responseDesc)); } public String getInstanceUUID() { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index ee260433a..51eb18e44 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -487,13 +487,8 @@ public class SvcLogicParser { for (SvcLogicGraph graph : graphs) { - String module = graph.getModule(); - String rpc = graph.getRpc(); - String version = graph.getVersion(); - String mode = graph.getMode(); try { - LOGGER.info("Saving SvcLogicGraph to database (module:{},rpc:{},mode:{},version:{})", module, rpc, mode, - version); + LOGGER.info("Saving " + graph.toString() + " to database."); store.store(graph); } catch (Exception e) { throw new SvcLogicException(e.getMessage(), e); -- cgit 1.2.3-korg From 8baaa038d6465a94aef0baf6b1cddca414a5505a Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 18 Dec 2017 15:01:10 -0500 Subject: Support additional IETF types Support additional IETF types in MdsalHelper. Change-Id: I1d0b4ab28645435d1ef72bc30a053d796aea44c8 Issue-ID: CCSDK-155 Signed-off-by: Dan Timoney --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 314 ++++++++++++++------- .../sli/core/sli/provider/SetNodeExecutor.java | 8 + .../sli/core/sli/provider/SvcLogicActivator.java | 2 +- 3 files changed, 222 insertions(+), 102 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 52c25b6b3..39a87a91d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -8,9 +8,9 @@ * 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. @@ -23,6 +23,7 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.io.File; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.lang.reflect.Constructor; @@ -33,12 +34,14 @@ import java.lang.reflect.Type; import java.util.LinkedList; import java.util.List; import java.util.Properties; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; import org.opendaylight.yangtools.yang.binding.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -188,8 +191,9 @@ public class MdsalHelper { } } catch (Exception e) { LOG.error( - "Caught exception trying to convert Yang-generated enum returned by " + fromClass - .getName() + "." + m.getName() + "() to Properties entry", e); + "Caught exception trying to convert Yang-generated enum returned by " + + fromClass.getName() + "." + m.getName() + "() to Properties entry", + e); } } else if (isIpv4Address(returnType)) { // Save its value @@ -211,9 +215,8 @@ public class MdsalHelper { } } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by " + fromClass.getName() + "." - + m.getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); } } else if (isIpv6Address(returnType)) { // Save its value @@ -235,9 +238,8 @@ public class MdsalHelper { } } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by " + fromClass.getName() + "." - + m.getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); } } else if (isIpAddress(returnType)) { // Save its value @@ -259,9 +261,8 @@ public class MdsalHelper { } } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by " + fromClass.getName() + "." - + m.getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); } } else if (isIpPrefix(returnType)) { // Save its value @@ -283,10 +284,55 @@ public class MdsalHelper { } } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by " + fromClass.getName() + "." - + m.getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); } + } else if (isPortNumber(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + PortNumber retValue = (PortNumber) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = "" + retValue.getValue(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } + } else if (isDscp(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Dscp retValue = (Dscp) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = "" + retValue.getValue(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } } else { try { boolean isAccessible = m.isAccessible(); @@ -299,7 +345,7 @@ public class MdsalHelper { LOG.trace(m.getName() + " returns a byte[]"); retValue = new String((byte[]) retValue, "UTF-8"); LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " - + retValue); + + retValue); } if (!isAccessible) { m.setAccessible(isAccessible); @@ -311,10 +357,10 @@ public class MdsalHelper { if (m.getName().equals("getKey")) { LOG.trace("Caught " + e.getClass().getName() - + " exception trying to convert results from getKey() - ignoring"); + + " exception trying to convert results from getKey() - ignoring"); } else { LOG.error("Caught exception trying to convert Yang-generated class returned by" - + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); } } } @@ -340,9 +386,8 @@ public class MdsalHelper { Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType); } catch (Exception e) { - LOG.error( - "Caught exception trying to convert List returned by " + fromClass.getName() + "." + m - .getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." + + m.getName() + "() to Properties entry", e); } } else { @@ -366,7 +411,7 @@ public class MdsalHelper { LOG.trace(m.getName() + " returns a byte[]"); propVal = new String((byte[]) propValObj, "UTF-8"); LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " - + propVal); + + propVal); } else { propVal = propValObj.toString(); @@ -378,11 +423,10 @@ public class MdsalHelper { } catch (Exception e) { if (m.getName().equals("getKey")) { LOG.trace("Caught " + e.getClass().getName() - + " exception trying to convert results from getKey() - ignoring"); + + " exception trying to convert results from getKey() - ignoring"); } else { - LOG.error( - "Caught exception trying to convert value returned by" + fromClass.getName() + "." - + m.getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); } } } @@ -394,13 +438,12 @@ public class MdsalHelper { // "getValue", then // set value identified by "prefix" to that one value. if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { - LOG.trace( - "getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + " = " - + propVal); + LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + + " = " + propVal); props.setProperty(propNamePfx, propVal); } else { LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " - + lastGetterName); + + lastGetterName); } @@ -578,6 +621,9 @@ public class MdsalHelper { String paramValue = props.getProperty(propName); if (paramValue == null) { LOG.trace(propName + " is unset"); + } else if ("".equals(paramValue)) { + LOG.trace(propName + " was set to the empty string, setting it to null"); + paramValue = null; } else { LOG.trace(propName + " = " + paramValue); } @@ -596,7 +642,7 @@ public class MdsalHelper { paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); } catch (Exception e) { LOG.error("Caught exception trying to convert field " + propName + " to enum " - + paramClass.getName(), e); + + paramClass.getName(), e); } try { @@ -605,9 +651,8 @@ public class MdsalHelper { m.setAccessible(true); } - LOG.trace( - "Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue - + ")"); + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); m.invoke(toObj, paramObj); if (!isAccessible) { @@ -616,17 +661,16 @@ public class MdsalHelper { foundValue = true; } catch (Exception e) { - LOG.error( - "Caught exception trying to create Yang-generated enum expected by" + toClass - .getName() + "." + m.getName() + "() from Properties entry", e); + LOG.error("Caught exception trying to create Yang-generated enum expected by" + + toClass.getName() + "." + m.getName() + "() from Properties entry", e); } } } else { String simpleName = paramClass.getSimpleName(); - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress" - .equals(simpleName)) { + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) + || "IpAddress".equals(simpleName)) { if ((paramValue != null) && (paramValue.length() > 0)) { try { @@ -642,9 +686,8 @@ public class MdsalHelper { } foundValue = true; } catch (Exception e) { - LOG.error( - "Caught exception calling " + toClass.getName() + "." + m.getName() + "(" - + paramValue + ")", e); + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); } } else { @@ -654,7 +697,7 @@ public class MdsalHelper { m.setAccessible(true); } LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); + + paramValue + ")"); m.invoke(toObj, paramValue); if (!isAccessible) { m.setAccessible(isAccessible); @@ -662,9 +705,8 @@ public class MdsalHelper { foundValue = true; } catch (Exception e) { - LOG.error( - "Caught exception trying to call " + toClass.getName() + "." + m.getName() - + "() with Properties entry", e); + LOG.error("Caught exception trying to call " + toClass.getName() + "." + + m.getName() + "() with Properties entry", e); } } } else if ("IpPrefix".equals(simpleName)) { @@ -674,11 +716,32 @@ public class MdsalHelper { m.invoke(toObj, ipPrefix); foundValue = true; } catch (Exception e) { - LOG.error( - "Caught exception calling " + toClass.getName() + "." + m.getName() + "(" - + paramValue + ")", e); + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); } } + } else if ("PortNumber".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + PortNumber portNumber = PortNumber.getDefaultInstance(paramValue); + m.invoke(toObj, portNumber); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } else if ("Dscp".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + Dscp dscp = Dscp.getDefaultInstance(paramValue); + m.invoke(toObj, dscp); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } } else { // setter expects a yang-generated class. Need // to @@ -692,7 +755,7 @@ public class MdsalHelper { Object constObj = null; LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " - + builderName); + + builderName); try { builderClass = Class.forName(builderName); builderObj = builderClass.newInstance(); @@ -705,17 +768,17 @@ public class MdsalHelper { if (!isAccessible) { m.setAccessible(true); } - LOG.trace( - "Calling " + toObj.getClass().getName() + "." + m.getName() + "(null)"); - m.invoke(toObj, new Object[]{null}); + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + + "(null)"); + m.invoke(toObj, new Object[] {null}); if (!isAccessible) { m.setAccessible(isAccessible); } foundValue = true; } catch (Exception e1) { - LOG.error("Caught exception trying to cally" + toClass.getName() + "." + m - .getName() + "() with Properties entry", e1); + LOG.error("Caught exception trying to cally" + toClass.getName() + "." + + m.getName() + "() with Properties entry", e1); } } else { try { @@ -753,8 +816,8 @@ public class MdsalHelper { // method // getDefaultInstance(String) try { - Method gm = paramClass - .getMethod("getDefaultInstance", String.class); + Method gm = + paramClass.getMethod("getDefaultInstance", String.class); int gmodifier = gm.getModifiers(); if (Modifier.isStatic(gmodifier)) { @@ -765,20 +828,20 @@ public class MdsalHelper { } catch (Exception gme) { LOG.info("Unable to find static method getDefaultInstance for " - + "class {}", paramClass.getSimpleName(), gme); + + "class {}", paramClass.getSimpleName(), gme); } } } catch (Exception e1) { LOG.warn( - "Could not find a suitable constructor for " + paramClass.getName(), - e1); + "Could not find a suitable constructor for " + paramClass.getName(), + e1); } if (constObj == null) { LOG.warn("Could not find builder class " + builderName - + " and could not find a String or Long constructor or static " - + "getDefaultInstance(String) - trying just to set passing paramValue"); + + " and could not find a String or Long constructor or static " + + "getDefaultInstance(String) - trying just to set passing paramValue"); } } @@ -790,9 +853,8 @@ public class MdsalHelper { try { Method buildMethod = builderClass.getMethod("build"); - LOG.trace( - "Calling " + paramObj.getClass().getName() + "." + buildMethod.getName() - + "()"); + LOG.trace("Calling " + paramObj.getClass().getName() + "." + + buildMethod.getName() + "()"); Object builtObj = buildMethod.invoke(paramObj); boolean isAccessible = m.isAccessible(); @@ -808,9 +870,9 @@ public class MdsalHelper { foundValue = true; } catch (Exception e) { - LOG.error( - "Caught exception trying to set Yang-generated class expected by" + toClass - .getName() + "." + m.getName() + "() from Properties entry", e); + LOG.error("Caught exception trying to set Yang-generated class expected by" + + toClass.getName() + "." + m.getName() + "() from Properties entry", + e); } } else { try { @@ -822,11 +884,11 @@ public class MdsalHelper { if (constObj != null) { LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + constObj.toString() + ")"); + + constObj.toString() + ")"); m.invoke(toObj, constObj); } else { LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); + + paramValue + ")"); m.invoke(toObj, paramValue); } @@ -836,9 +898,8 @@ public class MdsalHelper { foundValue = true; } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by" + toClass.getName() - + "." + m.getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert value returned by" + + toClass.getName() + "." + m.getName() + "() to Properties entry", e); } } } @@ -862,7 +923,7 @@ public class MdsalHelper { paramObj = toList(props, propName, (List) paramObj, (Class) elementType); } catch (Exception e) { LOG.error("Caught exception trying to create list expected as argument to {}.{}", - toClass.getName(), m.getName(), e); + toClass.getName(), m.getName(), e); } if (paramObj != null) { @@ -871,9 +932,8 @@ public class MdsalHelper { if (!isAccessible) { m.setAccessible(true); } - LOG.trace( - "Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + paramValue - + ")"); + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); m.invoke(toObj, paramObj); if (!isAccessible) { m.setAccessible(isAccessible); @@ -881,9 +941,8 @@ public class MdsalHelper { foundValue = true; } catch (Exception e) { - LOG.error( - "Caught exception trying to convert List returned by" + toClass.getName() + "." - + m.getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert List returned by" + toClass.getName() + + "." + m.getName() + "() to Properties entry", e); } } } else { @@ -891,8 +950,8 @@ public class MdsalHelper { // Setter expects something that is not a List and // not yang-generated. Just pass the parameter value - LOG.trace( - "Parameter class " + paramClass.getName() + " is not a yang-generated class or a List"); + LOG.trace("Parameter class " + paramClass.getName() + + " is not a yang-generated class or a List"); if ((paramValue != null) && (paramValue.length() > 0)) { @@ -927,7 +986,7 @@ public class MdsalHelper { if (constObj != null) { try { LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + constObj + ")"); + + constObj + ")"); m.invoke(toObj, constObj); foundValue = true; } catch (Exception e2) { @@ -940,7 +999,7 @@ public class MdsalHelper { m.setAccessible(true); } LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); + + paramValue + ")"); m.invoke(toObj, paramValue); if (!isAccessible) { m.setAccessible(isAccessible); @@ -948,8 +1007,9 @@ public class MdsalHelper { foundValue = true; } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" + toClass - .getName() + "." + m.getName() + "() to Properties entry", e); + LOG.error("Caught exception trying to convert value returned by" + + toClass.getName() + "." + m.getName() + "() to Properties entry", + e); } } } catch (Exception e1) { @@ -1034,8 +1094,9 @@ public class MdsalHelper { String simpleName = returnClass.getSimpleName(); - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress" - .equals(simpleName) || "IpPrefix".equals(simpleName)) { + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) + || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName) + || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { LOG.trace(m.getName() + " is an " + simpleName); pstr.print("\n\n * " + propName); } else { @@ -1058,11 +1119,11 @@ public class MdsalHelper { Type returnType = m.getGenericReturnType(); Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; Class elementClass = (Class) elementType; - LOG.trace( - "Calling printPropertyList on list type (" + elementClass.getName() + "), pfx is (" - + pfx + "), toClass is (" + toClass.getName() + ")"); + LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() + + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); printPropertyList(pstr, - propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", elementClass); + propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", + elementClass); } else if (!returnClass.equals(Class.class)) { @@ -1070,7 +1131,7 @@ public class MdsalHelper { // not yang-generated. Just pass the parameter value LOG.trace("Parameter class " + returnClass.getName() - + " is not a yang-generated class or a List"); + + " is not a yang-generated class or a List"); pstr.print("\n\n * " + propName); } @@ -1094,6 +1155,9 @@ public class MdsalHelper { if (c == null) { return (false); } + if (!isIetfInet(c)) { + return (false); + } String simpleName = c.getSimpleName(); return ("IpPrefix".equals(simpleName)); } @@ -1103,6 +1167,9 @@ public class MdsalHelper { if (c == null) { return (false); } + if (!isIetfInet(c)) { + return (false); + } String simpleName = c.getSimpleName(); return ("Ipv4Address".equals(simpleName)); } @@ -1112,6 +1179,9 @@ public class MdsalHelper { if (c == null) { return (false); } + if (!isIetfInet(c)) { + return (false); + } String simpleName = c.getSimpleName(); return ("Ipv6Address".equals(simpleName)); } @@ -1121,10 +1191,52 @@ public class MdsalHelper { if (c == null) { return (false); } + if (!isIetfInet(c)) { + return (false); + } String simpleName = c.getSimpleName(); return ("IpAddress".equals(simpleName)); } + public static boolean isPortNumber(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + + String simpleName = c.getSimpleName(); + return ("PortNumber".equals(simpleName)); + } + + public static boolean isDscp(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Dscp".equals(simpleName)); + } + + public static boolean isIetfInet(Class c) { + + Package p = c.getPackage(); + if (p != null) { + String pkgName = p.getName(); + + if ((pkgName != null) && (pkgName.indexOf("yang.ietf.inet.types") > -1)) { + return (true); + } + } + + return (false); + } + public static String toLowerHyphen(String inStr) { if (inStr == null) { return (null); @@ -1144,7 +1256,7 @@ public class MdsalHelper { return (retval); } - //This is called when mapping the yang value back to a valid java enumeration + // This is called when mapping the yang value back to a valid java enumeration public static String toJavaEnum(String inStr) { if (inStr == null) { return (null); @@ -1152,17 +1264,17 @@ public class MdsalHelper { return (inStr); } - //This will strip out all periods, which cannot be in a java enum + // This will strip out all periods, which cannot be in a java enum inStr = inStr.replaceAll("\\.", ""); String[] terms = inStr.split("-"); StringBuffer sbuff = new StringBuffer(); - //appends an _ if the string starts with a digit to make it a valid java enum + // appends an _ if the string starts with a digit to make it a valid java enum if (Character.isDigit(inStr.charAt(0))) { sbuff.append('_'); } - //If the string contains hyphens it will convert the string to upperCamelCase without hyphens + // If the string contains hyphens it will convert the string to upperCamelCase without hyphens for (String term : terms) { sbuff.append(term.substring(0, 1).toUpperCase()); if (term.length() > 1) { @@ -1205,8 +1317,8 @@ public class MdsalHelper { if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { if (m.getName().matches("^set[A-Z].*")) { Class[] paramTypes = m.getParameterTypes(); - if (paramTypes[0].isAssignableFrom(Identifier.class) || Identifier.class - .isAssignableFrom(paramTypes[0])) { + if (paramTypes[0].isAssignableFrom(Identifier.class) + || Identifier.class.isAssignableFrom(paramTypes[0])) { return (false); } else { return (true); @@ -1222,7 +1334,7 @@ public class MdsalHelper { return "/opt/bvc/controller/configuration/" + propertiesFileName; } - //This is called when mapping a valid java enumeration back to the yang model value + // This is called when mapping a valid java enumeration back to the yang model value public static String mapEnumeratedValue(String propertyName, String propertyValue) { LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); String mappingKey = "yang." + propertyName + "." + propertyValue; diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java index 502c1a422..d0c052a16 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java @@ -60,8 +60,16 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { // Resolve LHS of assignment (could contain index variables) try { + //Backticks symbolize the variable should be handled as an expression instead of as a variable + if (curName.trim().startsWith("`")) { + int lastParen = curName.lastIndexOf("`"); + String evalExpr = curName.trim().substring(1, lastParen); + SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(evalExpr); + lhsVarName = SvcLogicExpressionResolver.evaluate(lhsExpr, node, ctx); + } else { SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); + } } catch (Exception e) { LOG.warn("Caught exception trying to resolve variable name ("+curName+")", e); } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java index cbde44d60..95dfb2b88 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java @@ -67,7 +67,7 @@ public class SvcLogicActivator implements BundleActivator { put("switch", new SwitchNodeExecutor()); put("update", new UpdateNodeExecutor()); put("break", new BreakNodeExecutor()); - + put("while", new WhileNodeExecutor()); } }; -- cgit 1.2.3-korg From 5dcba2269e3a9a0be39f0093194ddeb0c70c20aa Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 19 Dec 2017 12:30:19 -0500 Subject: Fix logging filters Update logging filters package to handle X-Forwarded-For header and to correct timestamp format. Change-Id: I6b4dba94cc93d0936598a9b8cd568b6386a447a5 Issue-ID: CCSDK-155 Signed-off-by: Dan Timoney --- .../src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java index abbb7c66e..d7a599cb3 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java @@ -194,7 +194,13 @@ public class LogFilter implements Filter { //MDC.put(SERVER_IP,""); //by chef MDC.put(ELAPSED_TIME,Long.toString(System.currentTimeMillis() - startTime)); //MDC.put(SERVER_HOST,""); //by chef + String forwardedHost = request.getHeader("X-Forwarded-For"); + if (forwardedHost != null) { + MDC.put(CLIENT_IP, forwardedHost); + } + else{ MDC.put(CLIENT_IP,request.getRemoteHost()); + } MDC.put(CLASS,""); MDC.put(UNUSED,""); MDC.put(PROCESS_KEY,""); @@ -209,7 +215,7 @@ public class LogFilter implements Filter { private String asIso8601(Date date) { TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'hh:mm:ss:SS'+00:00'"); + DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss.SS'+00:00'"); df.setTimeZone(tz); return df.format(date); } -- cgit 1.2.3-korg From a2a1997c4976499912dae2aadef52a73c764840b Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 19 Dec 2017 13:13:36 -0500 Subject: Enhance health check In HA environment, different types of health check are needed for load balancers (which care about state of each node in cluster) vs external applications (which case about state of entire cluster). So, separate APIs are needed for these 2 types of needs. Change-Id: I99cd21cef7a7e2b4b8c96c1f22c0d6210bb91e96 Issue-ID: CCSDK-157 Signed-off-by: Dan Timoney --- sliapi/model/src/main/yang/sliapi.yang | 6 ++ .../onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 64 ++++++++++++++++++++-- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/sliapi/model/src/main/yang/sliapi.yang b/sliapi/model/src/main/yang/sliapi.yang index 8deb8a10f..f0e79c068 100755 --- a/sliapi/model/src/main/yang/sliapi.yang +++ b/sliapi/model/src/main/yang/sliapi.yang @@ -108,4 +108,10 @@ module SLI-API { } } + rpc vlbcheck { + output { + uses response-fields; + } + } + } diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index 88c475174..82e660083 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -8,9 +8,9 @@ * 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. @@ -21,11 +21,14 @@ package org.onap.ccsdk.sli.core.sliapi; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; import java.util.Enumeration; import java.util.LinkedList; import java.util.Properties; import java.util.concurrent.Future; - import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; @@ -47,11 +50,14 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.Hea import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -69,7 +75,6 @@ import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import com.google.common.util.concurrent.Futures; @@ -120,6 +125,8 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ private static String SLIAPI_NAMESPACE = "org:onap:ccsdk:sli:core:sliapi"; private static String SLIAPI_REVISION = "2016-11-10"; + private static String SDNC_STATUS_FILE = "SDNC_STATUS_FILE"; + private static String sdncStatusFile = null; private static QName TEST_RESULTS_QNAME = null; private static QName TEST_RESULT_QNAME = null; @@ -142,7 +149,8 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ public void initialize(){ LOG.info( "Initializing provider for " + appName ); //initialization code goes here. - + sdncStatusFile = System.getenv(SDNC_STATUS_FILE); + LOG.info( "SDNC STATUS FILE = " + sdncStatusFile ); rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); LOG.info( "Initialization complete for " + appName ); } @@ -554,4 +562,50 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } + @Override + public Future> vlbcheck() { + RpcResult rpcResult = null; + VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder(); + boolean suspended = false; + BufferedReader br = null; + String line = ""; + + // check the state based on the config file + + if (sdncStatusFile != null) { + try { + br = new BufferedReader(new FileReader(sdncStatusFile)); + while((line = br.readLine()) != null) + { + if ("ODL_STATE=SUSPENDED".equals(line)) { + suspended = true; + LOG.debug("vlbcheck: server is suspended"); + } + } + br.close(); + } catch (FileNotFoundException e) { + LOG.trace("Caught File not found exception " + sdncStatusFile +"\n",e); + } catch (Exception e) { + LOG.trace("Failed to read status file " + sdncStatusFile +"\n",e); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + LOG.warn("Failed to close status file " + sdncStatusFile +"\n",e); + } + } + } + } + + if (suspended) { + rpcResult = RpcResultBuilder.failed().withError(ErrorType.APPLICATION, + "resource-denied", "Server Suspended").build(); + } else { + respBuilder.setResponseMessage("server is normal"); + rpcResult = RpcResultBuilder. status(true) + .withResult(respBuilder.build()).build(); + } + return (Futures.immediateFuture(rpcResult)); + } } -- cgit 1.2.3-korg From 50e04450a21eb584fb843fbe009b29798b94a413 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 19 Dec 2017 14:36:21 -0500 Subject: New sliPluginUtils methods Add new sliPluginUtils methods to faciliate accessing data in context memory (SvcLogicContext). Change-Id: I70fe00fd60ac6da4804a41df0a2ef7c51e80f4a0 Issue-ID: CCSDK-158 Signed-off-by: Dan Timoney --- sliPluginUtils/provider/pom.xml | 10 + .../sli/core/slipluginutils/SliPluginUtils.java | 326 ++++++++++++++++++++- .../sli/core/slipluginutils/SliStringUtils.java | 26 +- 3 files changed, 356 insertions(+), 6 deletions(-) diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index a950939ef..61b5e958f 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -57,6 +57,16 @@ 1.3 test + + com.google.code.gson + gson + 2.6.2 + + + org.apache.commons + commons-text + 1.1 + diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index d24ae809a..0eb53199c 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -8,9 +8,9 @@ * 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. @@ -30,18 +30,24 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.UUID; - +import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; /** * A utility class used to streamline the interface between Java plugins, @@ -61,6 +67,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { public SliPluginUtils() {} + public SliPluginUtils( Properties props ) {} // ========== CONTEXT MEMORY FUNCTIONS ========== @@ -785,4 +792,317 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { throw new SvcLogicException("problem with setTime", ex); } } + + /** + * jsonStringToCtx takes a json string stored as a single property in context memory and breaks it into individual properties + * @param parameters - requires source, outputPath and isEscaped to not be null. + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public static void jsonStringToCtx(Map parameters, SvcLogicContext ctx) throws SvcLogicException + { + checkParameters(parameters, new String[] { "source","outputPath","isEscaped" }, LOG); + try { + String source = ctx.getAttribute(parameters.get("source")); + if("true".equals(parameters.get("isEscaped"))){ + source = StringEscapeUtils.unescapeJson(source); + } + writeJsonToCtx(source, ctx,parameters.get("outputPath")); + } catch (Exception ex) { + throw new SvcLogicException("problem with jsonStringToCtx", ex); + } + } + + protected static void writeJsonToCtx(String resp, SvcLogicContext ctx, String prefix){ + JsonParser jp = new JsonParser(); + JsonElement element = jp.parse(resp); + writeJsonObject(element.getAsJsonObject(), ctx, prefix + "."); + } + + protected static void writeJsonObject(JsonObject obj, SvcLogicContext 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.setAttribute(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 + "]."); + } else if (element.isJsonPrimitive()) { + ctx.setAttribute(root + entry.getKey() + "[" + arrayIdx + "]", element.getAsString()); + } + arrayIdx++; + } + } else { + //Handles when a JSON obj is nested within a JSON obj + if(!root.endsWith(".")){ + root = root + "."; + } + ctx.setAttribute(root + entry.getKey(), entry.getValue().getAsString()); + } + } + } + + /** + * getAttributeValue takes a ctx memory path as a string, gets the value stored at this path and set this value in context memory at + * outputPath + * @param parameters - requires source and outputPath + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public static void getAttributeValue(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + checkParameters(parameters, new String[] { "source", "outputPath" }, LOG); + String source = ctx.getAttribute(parameters.get("source")); + ctx.setAttribute(parameters.get("outputPath"), source); + } + + /** + * ctxListContains provides a way to see if a context memory list contains a key value + * @param parameters - requires list, keyName, keyValue, outputPath to all not be null. + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public static String ctxListContains(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + checkParameters(parameters, new String[]{"list", "keyName", "keyValue"}, LOG); + + try { + String ctxList = parameters.get("list"); + ctxList = (ctxList.endsWith("_length")) ? ctxList : ctxList + "_length"; + int listLength = getArrayLength(ctx, ctxList); + + if (listLength == 0) { + LOG.debug("List is not in context memory"); + return "false"; + } else { + Set keys = new HashSet(); + + String listPrefix = ctxList.substring(0, ctxList.lastIndexOf("_")) + "["; + String listSuffix = "]." + parameters.get("keyName"); + + for (int i = 0; i < listLength; i++) { + String keyLocation = listPrefix + i + listSuffix; + keys.add(ctx.getAttribute(keyLocation)); + } + + if (keys.contains(parameters.get("keyValue"))) { + LOG.debug("List " + parameters.get("list") + " contains " + parameters.get("keyValue")); + return "true"; + } else { + LOG.debug("List " + parameters.get("list") + " do not contains " + parameters.get("keyValue")); + return "false"; + } + } + } catch (Exception ex) { + throw new SvcLogicException("ctxListContains failed", ex); + } + } + + /** + * set properties in context memory for a container
    + * parameters with a null or empty key or value are ignored
    + * required parameter root - root + "." + parameters.key + * is the key to set the value too value in context memory
    + * optional parameter valueRoot - if set: valueRoot + "." + parameters.value + * is the key to get the value from context memory + * + * @param parameters - root (required), valueRoot (optional), properties names and values to be set + * @param ctx Reference to context memory + * @return success or failure of operation + */ + public static String setPropertiesForRoot(Map parameters, SvcLogicContext ctx) { + LOG.debug("Execute Node \"setPropertiesForRoot\""); + try { + checkParameters(parameters, new String[]{"root"}, LOG); + } catch (Exception ex) { + return "failure"; + } + + String root = parameters.get("root"); + + if (StringUtils.isEmpty(root)) { + return "failure"; + } + + // set context memory to the the properties passed with root as prefix + setParameterValuesToRoot(parameters, ctx, root); + + return "success"; + } + + private static boolean setParameterValuesToRoot(Map parameters, SvcLogicContext ctx, String root) { + boolean changeFlag = false; + String valueRoot = parameters.get("valueRoot"); + + for (Map.Entry entry : parameters.entrySet()) { + // ignore if it's the root parameter + if (!entry.getKey().equals("root")) { + String keyToBeSet = root + "." + entry.getKey(); + String valueToBeSet = ""; + + if (StringUtils.isEmpty(valueRoot)) { + valueToBeSet = entry.getValue(); + } else { + valueToBeSet = ctx.getAttribute(valueRoot + "." + entry.getValue()); + } + + LOG.debug("Setting context memory: " + keyToBeSet + " = " + valueToBeSet); + + if (!StringUtils.isEmpty(entry.getKey()) && !StringUtils.isEmpty(valueToBeSet)) { + ctxSetAttribute(ctx, keyToBeSet, valueToBeSet); + changeFlag = true; + } + } + } + + return changeFlag; + } + + /** + * takes container list and set the properties with the value provided
    + * parameters with a null or empty key or value are ignored
    + * required parameters
    + * prefixKey + "." + parameters.key is the key to set the value too value in context memory
    + * prefixKey + "[index]." + keyName is the key of the entry in the list in context memory
    + * keyValue is the value of the key of the list entry in context memory (must be actual value)
    + * optional parameter valuePrefixKey - if set: valuePrefixKey + "." + parameters.value + * is the key to get the value from context memory + * + * @param parameters
    + * - prefixKey e.g "service-data.universal-cpe-ft.l2-switch-interfaces"
    + * - keyName e.g "name"
    + * - keyValue e.g "WAN1" (must be actual value and not use the prefixKey as root)
    + * - valuePrefixKey (optional) e.g "input.universal-cpe-ft.l2-switch-interfaces[1]
    + * - properties to be set, values for the properties
    + * @param ctx reference to context memory + * @return success or failure of operation + */ + public static String setPropertiesForList(Map parameters, SvcLogicContext ctx) { + LOG.debug("Execute Node \"setPropertiesForList\""); + try { + checkParameters(parameters, new String[]{"prefixKey", "keyName", "keyValue"}, LOG); + } catch (Exception e) { + LOG.error("a required parameter is missing"); + return "failure"; + } + + String prefixKey = parameters.get("prefixKey"); + String keyName = parameters.get("keyName"); + String keyValue = parameters.get("keyValue"); + + if (StringUtils.isEmpty(keyName) || StringUtils.isEmpty(keyValue) || StringUtils.isEmpty(prefixKey)) { + LOG.error("a required parameters value is empty or null"); + return "failure"; + } + + int listLength = getArrayLength(ctx, prefixKey); + + Map containParams = new HashMap<>(); + containParams.put("list", prefixKey); + containParams.put("keyName", keyName); + containParams.put("keyValue", keyValue); + + String valuePrefixKey = parameters.get("valuePrefixKey"); + + try { + // create new list in context memory + if (listLength == 0) { + // since there's no length found make sure there's no current data at prefixKey in context memory + Map map = ctxGetBeginsWith(ctx, prefixKey); + + if (map.size() == 0) { + setNewEntryInList(parameters, ctx, keyName, keyValue, prefixKey, valuePrefixKey, listLength); + } else { + LOG.error("there was no length for the list parameter set in context memory " + + "but " + map.size() + " entries were found in context memory " + + "where the key begins with: " + prefixKey); + + return "failure"; + } + } else if (ctxListContains(containParams, ctx) == "false") { + setNewEntryInList(parameters, ctx, keyName, keyValue, prefixKey, valuePrefixKey, listLength); + } else if (ctxListContains(containParams, ctx) == "true") { + // else update the context memory with the properties passed in at the right index level + String listPrefix = prefixKey + "["; + String listSuffix = "]."; + + for (int i = 0; i < listLength; i++) { + String listRootWithIndex = listPrefix + i + listSuffix; + String listKeyName = listRootWithIndex + keyName; + String valueAtListIndexKey = ctx.getAttribute(listKeyName); + + if (valueAtListIndexKey.equals(keyValue)) { + setParametersToCtxList(parameters, ctx, listRootWithIndex, valuePrefixKey); + } + } + } + } catch (SvcLogicException e) { + LOG.error("Call to ctxListContains failed: " + e.getMessage()); + + return "failure"; + } + + return "success"; + } + + private static void setNewEntryInList(Map parameters, SvcLogicContext ctx, String keyName, + String keyValue, String prefixKey, String valuePrefixKey, int listLength) { + String prefixKeyWithIndex = prefixKey + "[" + listLength + "]."; + String listKeyName = prefixKeyWithIndex + keyName; + + // set list key + LOG.debug("Setting context memory, new list entry with key: " + listKeyName + " = " + keyValue); + ctxSetAttribute(ctx, listKeyName, keyValue); + + // set the other parameters + setParametersToCtxList(parameters, ctx, prefixKeyWithIndex, valuePrefixKey); + + // set length of list + String ListLengthKeyName = prefixKey + "_length"; + + ctxSetAttribute(ctx, prefixKey + "_length", listLength + 1); + LOG.debug("Updated _length: " + prefixKey + "_length is now " + ctx.getAttribute(ListLengthKeyName)); + } + + /** + * helper function to set the parameter properties for list at the provided prefix key + * + * @param parameters + * @param ctx + * @param prefixKey + * @return true if any new context memory was added and or modified + */ + private static boolean setParametersToCtxList(Map parameters, SvcLogicContext ctx, String prefixKeyWithIndex, + String valuePrefixKey) { + boolean changeFlag = false; + + for (Map.Entry entry : parameters.entrySet()) { + if (! (entry.getKey().equals("prefixKey") || + entry.getKey().equals("keyName") || + entry.getKey().equals("keyValue")) || + entry.getKey().equals("valuePrefixKey")) { + + String keyToBeSet = prefixKeyWithIndex + entry.getKey(); + String valueToBeSet = ""; + + if (StringUtils.isEmpty(valuePrefixKey)) { + valueToBeSet = entry.getValue(); + } else { + valueToBeSet = ctx.getAttribute(valuePrefixKey + "." + entry.getValue()); + } + + LOG.debug("Setting context memory: " + keyToBeSet + " = " + valueToBeSet); + + // only set context memory if properties key and value are not empty or null + if (!StringUtils.isEmpty(entry.getKey()) && !StringUtils.isEmpty(valueToBeSet)) { + ctxSetAttribute(ctx, keyToBeSet, valueToBeSet); + changeFlag = true; + } + } + } + + return changeFlag; + } + } diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index 0c43f6850..6402abd68 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -8,9 +8,9 @@ * 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. @@ -24,7 +24,7 @@ package org.onap.ccsdk.sli.core.slipluginutils; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Map; - +import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -38,6 +38,9 @@ import org.slf4j.LoggerFactory; public class SliStringUtils implements SvcLogicJavaPlugin { private static final Logger LOG = LoggerFactory.getLogger(SliStringUtils.class); + public static String INPUT_PARAM_SOURCE = "source"; + public static String INPUT_PARAM_TARGET = "target"; + public SliStringUtils() {} /** @@ -393,4 +396,21 @@ public class SliStringUtils implements SvcLogicJavaPlugin { } } + /** + * xmlEscapeText() will be used to format input xml with text. + * + * @param inParams + * accepts the instance of {@link Map} holds the input xml in string + * format. + * @param ctx + * accepts the instance of {@link SvcLogicContext} holds the service + * logic context. + * + */ + public static void xmlEscapeText(Map inParams, SvcLogicContext ctx) { + String source = inParams.get(INPUT_PARAM_SOURCE); + String target = inParams.get(INPUT_PARAM_TARGET); + source = StringEscapeUtils.escapeXml(source); + ctx.setAttribute(target, source); + } } -- cgit 1.2.3-korg From d3cd4dd5d5f300684be256eb1bf70d750a9a957e Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Fri, 5 Jan 2018 20:26:58 +0000 Subject: Generalization of CCSDK core/utils framework Changes made: * Created generalized version of core/utils/dblib as core/utils/common * Deprecated core/utils/dblib package Change-Id: I0992c43910278fbe254674d1e39d7e4fcad0a592 Issue-ID: CCSDK-168 Signed-off-by: Rich Tabedzki --- .../sli/core/dblib/DBLIBResourceProvider.java | 18 +- .../ccsdk/sli/core/dblib/DBResourceManager.java | 1759 ++++++++++---------- .../ccsdk/sli/core/utils/EnvVarFileResolver.java | 2 +- .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 10 +- .../utils/common/BundleContextFileResolver.java | 80 + .../core/utils/common/CoreDefaultFileResolver.java | 41 + .../utils/common/SdncConfigEnvVarFileResolver.java | 38 + .../core/utils/dblib/DblibDefaultFileResolver.java | 10 +- .../core/utils/dblib/DblibEnvVarFileResolver.java | 8 + .../utils/common/BundleContexFileResolverTest.java | 16 + .../utils/common/CoreDefaultFileResolverTest.java | 25 + .../common/SdncConfigEnvVarFileResolverTest.java | 24 + 12 files changed, 1137 insertions(+), 894 deletions(-) mode change 100644 => 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java mode change 100644 => 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java create mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java create mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolver.java create mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolver.java mode change 100644 => 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java create mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java create mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java create mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java index 411f04705..ddfb73316 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java @@ -7,9 +7,9 @@ * 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. @@ -27,11 +27,11 @@ import java.util.Optional; import java.util.Properties; import java.util.Vector; -import org.onap.ccsdk.sli.core.utils.dblib.DblibDefaultFileResolver; -import org.onap.ccsdk.sli.core.utils.dblib.DblibEnvVarFileResolver; import org.onap.ccsdk.sli.core.utils.JREFileResolver; import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; +import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +58,7 @@ public class DBLIBResourceProvider { /** * A prioritized list of strategies for resolving dblib properties files. */ - private Vector dblibPropertiesFileResolvers = new Vector(); + private Vector dblibPropertiesFileResolvers = new Vector<>(); /** * The configuration properties for the db connection. @@ -69,14 +69,14 @@ public class DBLIBResourceProvider { * Set up the prioritized list of strategies for resolving dblib properties files. */ public DBLIBResourceProvider() { - dblibPropertiesFileResolvers.add(new DblibEnvVarFileResolver( + dblibPropertiesFileResolvers.add(new SdncConfigEnvVarFileResolver( "Using property file (1) from environment variable" )); - dblibPropertiesFileResolvers.add(new DblibDefaultFileResolver( - "Using property file (1) from default directory" + dblibPropertiesFileResolvers.add(new CoreDefaultFileResolver( + "Using property file (2) from default directory" )); dblibPropertiesFileResolvers.add(new JREFileResolver( - "Using property file (2) from JRE argument", DBLIBResourceProvider.class + "Using property file (3) from JRE argument", DBLIBResourceProvider.class )); dblibPropertiesFileResolvers.add(new KarafRootFileResolver( "Using property file (4) from karaf root", this)); diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 61fb000fb..b31645d41 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -62,891 +62,892 @@ import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; * Rich Tabedzki */ public class DBResourceManager implements DataSource, DataAccessor, DBResourceObserver, DbLibService { - private static Logger LOGGER = LoggerFactory.getLogger(DBResourceManager.class); - - transient boolean terminating = false; - transient protected long retryInterval = 10000L; - transient boolean recoveryMode = true; - - protected final AtomicBoolean dsSelector = new AtomicBoolean(); - -// Queue dsQueue = new ConcurrentLinkedQueue(); - Queue dsQueue = new PriorityQueue<>(4, new Comparator() { - @Override - public int compare(CachedDataSource left, CachedDataSource right) { - try { - if (left == null) { - return 1; - } - if (right == null) { - return -1; - } - - if (!left.isSlave()) { - return -1; - } - if (!right.isSlave()) { - return 1; - } - } catch (Throwable e) { - LOGGER.warn("", e); - } - return 0; - } + private static Logger LOGGER = LoggerFactory.getLogger(DBResourceManager.class); + + transient boolean terminating = false; + transient protected long retryInterval = 10000L; + transient boolean recoveryMode = true; + + protected final AtomicBoolean dsSelector = new AtomicBoolean(); + + Queue dsQueue = new PriorityQueue<>(4, new Comparator() { + @Override + public int compare(CachedDataSource left, CachedDataSource right) { + try { + if (left == null) { + return 1; + } + if (right == null) { + return -1; + } + + if (!left.isSlave()) { + return -1; + } + if (!right.isSlave()) { + return 1; + } + } catch (Throwable e) { + LOGGER.warn("", e); + } + return 0; + } }); - protected final Set broken = Collections.synchronizedSet(new HashSet()); - protected final Object monitor = new Object(); - protected final Properties configProps; - protected final Thread worker; - - protected final long terminationTimeOut; - protected final boolean monitorDbResponse; - protected final long monitoringInterval; - protected final long monitoringInitialDelay; - protected final long expectedCompletionTime; - protected final long unprocessedFailoverThreshold; - - public DBResourceManager(final DBLIBResourceProvider configuration) { - this(configuration.getProperties()); - } - - public DBResourceManager(final Properties properties) { - this.configProps = properties; - - // get retry interval value - retryInterval = getLongFromProperties(properties, "org.onap.dblib.connection.retry", 10000L); - - // get recovery mode flag - recoveryMode = getBooleanFromProperties(properties, "org.onap.dblib.connection.recovery", true); - if(!recoveryMode) - { - recoveryMode = false; - LOGGER.info("Recovery Mode disabled"); - } - // get time out value for thread cleanup - terminationTimeOut = getLongFromProperties(properties, "org.onap.dblib.termination.timeout", 300000L); - // get properties for monitoring - monitorDbResponse = getBooleanFromProperties(properties, "org.onap.dblib.connection.monitor", false); - monitoringInterval = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.interval", 1000L); - monitoringInitialDelay = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.startdelay", 5000L); - expectedCompletionTime = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); - unprocessedFailoverThreshold = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); - - // initialize performance monitor - PollingWorker.createInistance(properties); - - // initialize recovery thread - worker = new RecoveryMgr(); - worker.setName("DBResourcemanagerWatchThread"); - worker.setDaemon(true); - worker.start(); - - try { - this.config(properties); - } catch (final Exception e) { - // TODO: config throws Exception which is poor practice. Eliminate this in a separate patch. - LOGGER.error("Fatal Exception encountered while configuring DBResourceManager", e); - } - } - - private void config(Properties configProps) throws Exception { - final ConcurrentLinkedQueue semaphore = new ConcurrentLinkedQueue<>(); - final DbConfigPool dbConfig = DBConfigFactory.createConfig(configProps); - - long startTime = System.currentTimeMillis(); - - try { - JDBCConfiguration[] config = dbConfig.getJDBCbSourceArray(); - CachedDataSource[] cachedDS = new CachedDataSource[config.length]; - if (cachedDS == null || cachedDS.length == 0) { - LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); - throw new Exception("Failed to initialize DB Library. No data source was created."); - } - - for(int i = 0; i < config.length; i++) { - cachedDS[i] = CachedDataSourceFactory.createDataSource(config[i]); - if(cachedDS[i] == null) - continue; - semaphore.add(cachedDS[i]); - cachedDS[i].setInterval(monitoringInterval); - cachedDS[i].setInitialDelay(monitoringInitialDelay); - cachedDS[i].setExpectedCompletionTime(expectedCompletionTime); - cachedDS[i].setUnprocessedFailoverThreshold(unprocessedFailoverThreshold); - cachedDS[i].addObserver(DBResourceManager.this); - } - -// CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, DBResourceManager.this, semaphore); - DataSourceTester[] tester = new DataSourceTester[config.length]; - - for(int i=0; i semaphoreQ; - - public DataSourceTester(CachedDataSource ds, DBResourceManager manager, ConcurrentLinkedQueue semaphore) { - this.ds = ds; - this.manager = manager; - this.semaphoreQ = semaphore; - } - - @Override - public void run() { - manager.setDataSource(ds); - boolean slave = true; - if(ds != null) { - try { - slave = ds.isSlave(); - } catch (Exception exc) { - LOGGER.warn("", exc); - } - } - if(!slave) { - LOGGER.info(String.format("Adding MASTER (%s) to active queue", ds.getDbConnectionName())); - try { - synchronized (semaphoreQ) { - semaphoreQ.notifyAll(); - } - } catch(Exception exc) { - LOGGER.warn("", exc); - } - } - try { - synchronized (semaphoreQ) { - semaphoreQ.remove(ds); - } - if(semaphoreQ.isEmpty()) { - synchronized (semaphoreQ) { - semaphoreQ.notifyAll(); - } - } - } catch(Exception exc) { - LOGGER.warn("", exc); - } - LOGGER.info(String.format("Thread DataSourceTester terminated %s for %s", this.getName(), ds.getDbConnectionName())); - } - - } - - - private long getLongFromProperties(Properties props, String property, long defaultValue) - { - String value = null; - long tmpLongValue = defaultValue; - try { - value = props.getProperty(property); - if(value != null) - tmpLongValue = Long.parseLong(value); - - } catch(NumberFormatException exc) { - if(LOGGER.isWarnEnabled()){ - LOGGER.warn("'"+property+"'=" + value+" is invalid. It should be a numeric value"); - } - } catch(Exception exc) { - } - return tmpLongValue; - - } - - private boolean getBooleanFromProperties(Properties props, String property, boolean defaultValue) - { - boolean tmpValue = defaultValue; - String value = null; - - try { - value = props.getProperty(property); - if(value != null) - tmpValue = Boolean.parseBoolean(value); - - } catch(NumberFormatException exc) { - if(LOGGER.isWarnEnabled()){ - LOGGER.warn("'"+property+"'=" + value+" is invalid. It should be a boolean value"); - } - } catch(Exception exc) { - } - return tmpValue; - - } - - - @Override - public void update(Observable observable, Object data) { - // if observable is active and there is a standby available, switch - if(observable instanceof SQLExecutionMonitor) - { - SQLExecutionMonitor monitor = (SQLExecutionMonitor)observable; - if(monitor.getParent() instanceof CachedDataSource) - { - CachedDataSource dataSource = (CachedDataSource)monitor.getParent(); - if(dataSource == dsQueue.peek()) - { - if(recoveryMode && dsQueue.size() > 1){ - handleGetConnectionException(dataSource, new Exception(data.toString())); - } - } - } - } - } - - public void testForceRecovery() - { - CachedDataSource active = this.dsQueue.peek(); - handleGetConnectionException(active, new Exception("test")); - } - - class RecoveryMgr extends Thread { - - @Override - public void run() { - while(!terminating) - { - try { - Thread.sleep(retryInterval); - } catch (InterruptedException e1) { } - CachedDataSource brokenSource = null; - try { - if (!broken.isEmpty()) { - CachedDataSource[] sourceArray = broken.toArray(new CachedDataSource[0]); - for (int i = 0; i < sourceArray.length; i++) - { - brokenSource = sourceArray[i]; - if (brokenSource instanceof TerminatingCachedDataSource) - break; - if (resetConnectionPool(brokenSource)) { - broken.remove(brokenSource); - brokenSource.blockImmediateOffLine(); - dsQueue.add(brokenSource); - LOGGER.info("DataSource <" - + brokenSource.getDbConnectionName() - + "> recovered."); - } - brokenSource = null; - } - } - } catch (Exception exc) { - LOGGER.warn(exc.getMessage()); - if(brokenSource != null){ - try { - if(!broken.contains(brokenSource)) - broken.add(brokenSource); - brokenSource = null; - } catch (Exception e1) { } - } - } - } - LOGGER.info("DBResourceManager.RecoveryMgr <"+this.toString() +"> terminated." ); - } - - private boolean resetConnectionPool(CachedDataSource dataSource){ - try { - return dataSource.testConnection(); - } catch (Exception exc) { - LOGGER.info("DataSource <" + dataSource.getDbConnectionName() + "> resetCache failed with error: "+ exc.getMessage()); - return false; - } - } - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#getData(java.lang.String, java.util.ArrayList, java.lang.String) - */ - @Override - public CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) throws SQLException { - ArrayList newList= new ArrayList<>(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - if(recoveryMode) - return requestDataWithRecovery(statement, newList, preferredDS); - else - return requestDataNoRecovery(statement, newList, preferredDS); - } - - private CachedRowSet requestDataWithRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { - Throwable lastException = null; - CachedDataSource active = null; - - // test if there are any connection pools available - LinkedList sources = new LinkedList<>(this.dsQueue); - if(sources.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); - throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); - } - if(preferredDS != null && !sources.peek().getDbConnectionName().equals(preferredDS)) { - Collections.reverse(sources); - } - - - // loop through available data sources to retrieve data. - while(!sources.isEmpty()) - { - active = sources.peek(); - - long time = System.currentTimeMillis(); - try { - if(!active.isFabric()) { - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - master = null; - } - } - sources.remove(active); - return active.getData(statement, arguments); - } catch(SQLDataException | SQLSyntaxErrorException | SQLIntegrityConstraintViolationException exc){ - throw exc; - } catch(Throwable exc){ - lastException = exc; - String message = exc.getMessage(); - if(message == null) { - if(exc.getCause() != null) { - message = exc.getCause().getMessage(); - } - if(message == null) - message = exc.getClass().getName(); - } - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); - handleGetConnectionException(active, exc); - } finally { - if(LOGGER.isDebugEnabled()){ - time = System.currentTimeMillis() - time; - LOGGER.debug("getData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); - } - } - } - if(lastException instanceof SQLException){ - throw (SQLException)lastException; - } - // repackage the exception - // you are here because either you run out of available data sources - // or the last exception was not of SQLException type. - // repackage the exception - if(lastException == null) { - throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); - } else { - SQLException exception = new DBLibException(lastException.getMessage()); - exception.setStackTrace(lastException.getStackTrace()); - if(lastException.getCause() instanceof SQLException) { - throw (SQLException)lastException.getCause(); - } - throw exception; - } - } - - private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { - if(dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); - throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); - } - CachedDataSource active = this.dsQueue.peek(); - long time = System.currentTimeMillis(); - try { - if(!active.isFabric()) { - CachedDataSource master = findMaster(); - if(master != null) - active = master; - } - return active.getData(statement, arguments); -// } catch(SQLDataException exc){ -// throw exc; - } catch(Throwable exc){ - String message = exc.getMessage(); - if(message == null) - message = exc.getClass().getName(); - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); - if(exc instanceof SQLException) - throw (SQLException)exc; - else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } finally { - if(LOGGER.isDebugEnabled()){ - time = System.currentTimeMillis() - time; - LOGGER.debug(">> getData : "+ active.getDbConnectionName()+" "+time+" miliseconds."); - } - } - } - - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#writeData(java.lang.String, java.util.ArrayList, java.lang.String) - */ - @Override - public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException + protected final Set broken = Collections.synchronizedSet(new HashSet()); + protected final Object monitor = new Object(); + protected final Properties configProps; + protected final Thread worker; + + protected final long terminationTimeOut; + protected final boolean monitorDbResponse; + protected final long monitoringInterval; + protected final long monitoringInitialDelay; + protected final long expectedCompletionTime; + protected final long unprocessedFailoverThreshold; + + public DBResourceManager(final DBLIBResourceProvider configuration) { + this(configuration.getProperties()); + } + + public DBResourceManager(final Properties properties) { + this.configProps = properties; + + // get retry interval value + retryInterval = getLongFromProperties(properties, "org.onap.dblib.connection.retry", 10000L); + + // get recovery mode flag + recoveryMode = getBooleanFromProperties(properties, "org.onap.dblib.connection.recovery", true); + if(!recoveryMode) + { + recoveryMode = false; + LOGGER.info("Recovery Mode disabled"); + } + // get time out value for thread cleanup + terminationTimeOut = getLongFromProperties(properties, "org.onap.dblib.termination.timeout", 300000L); + // get properties for monitoring + monitorDbResponse = getBooleanFromProperties(properties, "org.onap.dblib.connection.monitor", false); + monitoringInterval = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.interval", 1000L); + monitoringInitialDelay = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.startdelay", 5000L); + expectedCompletionTime = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); + unprocessedFailoverThreshold = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); + + // initialize performance monitor + PollingWorker.createInistance(properties); + + // initialize recovery thread + worker = new RecoveryMgr(); + worker.setName("DBResourcemanagerWatchThread"); + worker.setDaemon(true); + worker.start(); + + try { + this.config(properties); + } catch (final Exception e) { + // TODO: config throws Exception which is poor practice. Eliminate this in a separate patch. + LOGGER.error("Fatal Exception encountered while configuring DBResourceManager", e); + } + } + + private void config(Properties configProps) throws Exception { + final ConcurrentLinkedQueue semaphore = new ConcurrentLinkedQueue<>(); + final DbConfigPool dbConfig = DBConfigFactory.createConfig(configProps); + + long startTime = System.currentTimeMillis(); + + try { + JDBCConfiguration[] config = dbConfig.getJDBCbSourceArray(); + CachedDataSource[] cachedDS = new CachedDataSource[config.length]; + if (cachedDS == null || cachedDS.length == 0) { + LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); + throw new Exception("Failed to initialize DB Library. No data source was created."); + } + + for(int i = 0; i < config.length; i++) { + cachedDS[i] = CachedDataSourceFactory.createDataSource(config[i]); + if(cachedDS[i] == null) + continue; + semaphore.add(cachedDS[i]); + cachedDS[i].setInterval(monitoringInterval); + cachedDS[i].setInitialDelay(monitoringInitialDelay); + cachedDS[i].setExpectedCompletionTime(expectedCompletionTime); + cachedDS[i].setUnprocessedFailoverThreshold(unprocessedFailoverThreshold); + cachedDS[i].addObserver(DBResourceManager.this); + } + +// CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, DBResourceManager.this, semaphore); + DataSourceTester[] tester = new DataSourceTester[config.length]; + + for(int i=0; i semaphoreQ; + + public DataSourceTester(CachedDataSource ds, DBResourceManager manager, ConcurrentLinkedQueue semaphore) { + this.ds = ds; + this.manager = manager; + this.semaphoreQ = semaphore; + } + + @Override + public void run() { + manager.setDataSource(ds); + boolean slave = true; + if(ds != null) { + try { + slave = ds.isSlave(); + } catch (Exception exc) { + LOGGER.warn("", exc); + } + } + if(!slave) { + LOGGER.info(String.format("Adding MASTER (%s) to active queue", ds.getDbConnectionName())); + try { + synchronized (semaphoreQ) { + semaphoreQ.notifyAll(); + } + } catch(Exception exc) { + LOGGER.warn("", exc); + } + } + try { + synchronized (semaphoreQ) { + semaphoreQ.remove(ds); + } + if(semaphoreQ.isEmpty()) { + synchronized (semaphoreQ) { + semaphoreQ.notifyAll(); + } + } + } catch(Exception exc) { + LOGGER.warn("", exc); + } + LOGGER.info(String.format("Thread DataSourceTester terminated %s for %s", this.getName(), ds.getDbConnectionName())); + } + + } + + + private long getLongFromProperties(Properties props, String property, long defaultValue) + { + String value = null; + long tmpLongValue = defaultValue; + try { + value = props.getProperty(property); + if(value != null) + tmpLongValue = Long.parseLong(value); + + } catch(NumberFormatException exc) { + if(LOGGER.isWarnEnabled()){ + LOGGER.warn("'"+property+"'=" + value+" is invalid. It should be a numeric value"); + } + } catch(Exception exc) { + } + return tmpLongValue; + + } + + private boolean getBooleanFromProperties(Properties props, String property, boolean defaultValue) + { + boolean tmpValue = defaultValue; + String value = null; + + try { + value = props.getProperty(property); + if(value != null) + tmpValue = Boolean.parseBoolean(value); + + } catch(NumberFormatException exc) { + if(LOGGER.isWarnEnabled()){ + LOGGER.warn("'"+property+"'=" + value+" is invalid. It should be a boolean value"); + } + } catch(Exception exc) { + } + return tmpValue; + + } + + + @Override + public void update(Observable observable, Object data) { + // if observable is active and there is a standby available, switch + if(observable instanceof SQLExecutionMonitor) { - ArrayList newList= new ArrayList<>(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - - return writeDataNoRecovery(statement, newList, preferredDS); - } - - CachedDataSource findMaster() throws PoolExhaustedException { - CachedDataSource master = null; - CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); - for(int i=0; i arguments, String preferredDS) throws SQLException { - if(dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); - throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); - } - - boolean initialRequest = true; - boolean retryAllowed = true; - CachedDataSource active = this.dsQueue.peek(); - long time = System.currentTimeMillis(); - while(initialRequest) { - initialRequest = false; - try { - if(!active.isFabric()) { - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - } - } - - return active.writeData(statement, arguments); - } catch(Throwable exc){ - String message = exc.getMessage(); - if(message == null) - message = exc.getClass().getName(); - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); - if(exc instanceof SQLException) { - SQLException sqlExc = SQLException.class.cast(exc); - // handle read-only exception - if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { - LOGGER.warn("retrying due to: " + sqlExc.getMessage()); - dsQueue.remove(active); - dsQueue.add(active); - if(retryAllowed){ - retryAllowed = false; - initialRequest = true; - continue; - } - } - throw (SQLException)exc; - } else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } finally { - if(LOGGER.isDebugEnabled()){ - time = System.currentTimeMillis() - time; - LOGGER.debug("writeData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); - } - } - } - return true; - } - - public void setDataSource(CachedDataSource dataSource) { - if(this.dsQueue.contains(dataSource)) - return; - if(this.broken.contains(dataSource)) - return; - - if(dataSource.testConnection(true)){ - this.dsQueue.add(dataSource); - } else { - this.broken.add(dataSource); - } - } - - @Override - public Connection getConnection() throws SQLException { - Throwable lastException = null; - CachedDataSource active = null; - - if(dsQueue.isEmpty()){ - throw new DBLibException("No active DB connection pools are available in GetConnection call."); - } - - try { - active = dsQueue.peek(); - CachedDataSource tmpActive = findMaster(); - if(tmpActive != null) { - active = tmpActive; - } - return new DBLibConnection(active.getConnection(), active); - } catch(javax.sql.rowset.spi.SyncFactoryException exc){ - LOGGER.debug("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); - LOGGER.warn("CLASSPATH issue. Allowing retry", exc); - lastException = exc; - } catch(PoolExhaustedException exc) { - throw new NoAvailableConnectionsException(exc); - } catch(Exception exc){ - lastException = exc; - if(recoveryMode){ - handleGetConnectionException(active, exc); - } else { - if(exc instanceof SQLException) { - throw (SQLException)exc; - } else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } - } catch (Throwable trwb) { - DBLibException excptn = new DBLibException(trwb.getMessage()); - excptn.setStackTrace(trwb.getStackTrace()); - throw excptn; - } finally { - if(LOGGER.isDebugEnabled()){ - displayState(); - } - } - - if(lastException instanceof SQLException){ - throw (SQLException)lastException; - } - // repackage the exception - if(lastException == null) { - throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); - } else { - SQLException exception = new DBLibException(lastException.getMessage()); - exception.setStackTrace(lastException.getStackTrace()); - if(lastException.getCause() instanceof SQLException) { -// exception.setNextException((SQLException)lastException.getCause()); - throw (SQLException)lastException.getCause(); - } - throw exception; - } - } - - @Override - public Connection getConnection(String username, String password) - throws SQLException { - CachedDataSource active = null; - - if(dsQueue.isEmpty()){ - throw new DBLibException("No active DB connection pools are available in GetConnection call."); - } - - - try { - active = dsQueue.peek(); - CachedDataSource tmpActive = findMaster(); - if(tmpActive != null) { - active = tmpActive; - } - return active.getConnection(username, password); - } catch(Throwable exc){ - if(recoveryMode){ - handleGetConnectionException(active, exc); - } else { - if(exc instanceof SQLException) - throw (SQLException)exc; - else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } - - } - - throw new DBLibException("No connections available in DBResourceManager in GetConnection call."); - } - - private void handleGetConnectionException(CachedDataSource source, Throwable exc) { - try { - if(!source.canTakeOffLine()) - { - LOGGER.error("Could not switch due to blocking"); - return; - } - - boolean removed = dsQueue.remove(source); - if(!broken.contains(source)) - { - if(broken.add(source)) - { - LOGGER.warn("DB Recovery: DataSource <" + source.getDbConnectionName() + "> put in the recovery mode. Reason : " + exc.getMessage()); - } else { - LOGGER.warn("Error putting DataSource <" +source.getDbConnectionName()+ "> in recovery mode."); - } - } else { - LOGGER.info("DB Recovery: DataSource <" + source.getDbConnectionName() + "> already in recovery queue"); - } - if(removed) - { - if(!dsQueue.isEmpty()) - { - LOGGER.warn("DB DataSource <" + dsQueue.peek().getDbConnectionName() + "> became active"); - } - } - } catch (Exception e) { - LOGGER.error("", e); - } - } - - public void cleanUp() { - for(Iterator it=dsQueue.iterator();it.hasNext();){ - CachedDataSource cds = it.next(); - it.remove(); - cds.cleanUp(); - } - - try { - this.terminating = true; - if(broken != null) - { - try { - broken.add( new TerminatingCachedDataSource(null)); - } catch(Exception exc){ - LOGGER.error("Waiting for Worker to stop", exc); - } - } - worker.join(terminationTimeOut); - LOGGER.info("DBResourceManager.RecoveryMgr <"+worker.toString() +"> termination was successful: " + worker.getState()); - } catch(Exception exc){ - LOGGER.error("Waiting for Worker thread to terminate ", exc); - } - } - - @Override - public PrintWriter getLogWriter() throws SQLException { - return this.dsQueue.peek().getLogWriter(); - } - - @Override - public int getLoginTimeout() throws SQLException { - return this.dsQueue.peek().getLoginTimeout(); - } - - @Override - public void setLogWriter(PrintWriter out) throws SQLException { - this.dsQueue.peek().setLogWriter(out); - } - - @Override - public void setLoginTimeout(int seconds) throws SQLException { - this.dsQueue.peek().setLoginTimeout(seconds); - } - - public void displayState(){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); - CachedDataSource current = dsQueue.peek(); - if(current != null) { - LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); - } - } - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#isActive() - */ - @Override - public boolean isActive() { - return this.dsQueue.size()>0; - } - - public String getActiveStatus(){ - return "Connected: " + dsQueue.size()+"\tIn-recovery: "+broken.size(); - } - - public String getDBStatus(boolean htmlFormat) { - StringBuilder buffer = new StringBuilder(); - - ArrayList list = new ArrayList<>(); - list.addAll(dsQueue); - list.addAll(broken); - if (htmlFormat) - { - buffer.append("") - .append("Name:").append(""); - for (int i = 0; i < list.size(); i++) { - buffer.append(""); - buffer.append(list.get(i).getDbConnectionName()).append(""); - } - buffer.append(""); - - buffer.append("State:"); - for (int i = 0; i < list.size(); i++) { - if (broken.contains(list.get(i))) { - buffer.append("in recovery"); - } - if (dsQueue.contains(list.get(i))) { - if (dsQueue.peek() == list.get(i)) - buffer.append("active"); - else - buffer.append("standby"); - } - } - buffer.append(""); - - } else { - for (int i = 0; i < list.size(); i++) { - buffer.append("Name: ").append(list.get(i).getDbConnectionName()); - buffer.append("\tState: "); - if (broken.contains(list.get(i))) { - buffer.append("in recovery"); - } else - if (dsQueue.contains(list.get(i))) { - if (dsQueue.peek() == list.get(i)) - buffer.append("active"); - else - buffer.append("standby"); - } - - buffer.append("\n"); - - } - } - return buffer.toString(); - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } - - @Override - public T unwrap(Class iface) throws SQLException { - return null; - } - - /** - * @return the monitorDbResponse - */ - @Override - public final boolean isMonitorDbResponse() { - return recoveryMode && monitorDbResponse; - } - - public void test(){ - CachedDataSource obj = dsQueue.peek(); - Exception ption = new Exception(); - try { - for(int i=0; i<5; i++) - { - handleGetConnectionException(obj, ption); - } - } catch(Throwable exc){ - LOGGER.warn("", exc); - } - } - - public String getPreferredDSName(){ - if(isActive()){ - return getPreferredDataSourceName(dsSelector); - } - return ""; - } - - public String getPreferredDataSourceName(AtomicBoolean flipper) { - - LinkedList snapshot = new LinkedList<>(dsQueue); - if(snapshot.size() > 1){ - CachedDataSource first = snapshot.getFirst(); - CachedDataSource last = snapshot.getLast(); - - int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount(); - if(delta < 0) { - flipper.set(false); - } else if(delta > 0) { - flipper.set(true); - } else { - // check the last value and return !last - flipper.getAndSet(!flipper.get()); - } - - if (flipper.get()) - Collections.reverse(snapshot); - } - return snapshot.peek().getDbConnectionName(); - } - - @Override - public java.util.logging.Logger getParentLogger() - throws SQLFeatureNotSupportedException { - return null; - } - - public String getMasterName() { - if(isActive()){ - return getMasterDataSourceName(dsSelector); - } - return ""; - } - - - private String getMasterDataSourceName(AtomicBoolean flipper) { - - LinkedList snapshot = new LinkedList<>(dsQueue); - if(snapshot.size() > 1){ - CachedDataSource first = snapshot.getFirst(); - CachedDataSource last = snapshot.getLast(); - - int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount(); - if(delta < 0) { - flipper.set(false); - } else if(delta > 0) { - flipper.set(true); - } else { - // check the last value and return !last - flipper.getAndSet(!flipper.get()); - } - - if (flipper.get()) - Collections.reverse(snapshot); - } - return snapshot.peek().getDbConnectionName(); - } + SQLExecutionMonitor monitor = (SQLExecutionMonitor)observable; + if(monitor.getParent() instanceof CachedDataSource) + { + CachedDataSource dataSource = (CachedDataSource)monitor.getParent(); + if(dataSource == dsQueue.peek()) + { + if(recoveryMode && dsQueue.size() > 1){ + handleGetConnectionException(dataSource, new Exception(data.toString())); + } + } + } + } + } + + public void testForceRecovery() + { + CachedDataSource active = this.dsQueue.peek(); + handleGetConnectionException(active, new Exception("test")); + } + + class RecoveryMgr extends Thread { + + @Override + public void run() { + while(!terminating) + { + try { + Thread.sleep(retryInterval); + } catch (InterruptedException e1) { } + CachedDataSource brokenSource = null; + try { + if (!broken.isEmpty()) { + CachedDataSource[] sourceArray = broken.toArray(new CachedDataSource[0]); + for (int i = 0; i < sourceArray.length; i++) + { + brokenSource = sourceArray[i]; + if (brokenSource instanceof TerminatingCachedDataSource) + break; + if (resetConnectionPool(brokenSource)) { + broken.remove(brokenSource); + brokenSource.blockImmediateOffLine(); + dsQueue.add(brokenSource); + LOGGER.info("DataSource <" + + brokenSource.getDbConnectionName() + + "> recovered."); + } + brokenSource = null; + } + } + } catch (Exception exc) { + LOGGER.warn(exc.getMessage()); + if(brokenSource != null){ + try { + if(!broken.contains(brokenSource)) + broken.add(brokenSource); + brokenSource = null; + } catch (Exception e1) { } + } + } + } + LOGGER.info("DBResourceManager.RecoveryMgr <"+this.toString() +"> terminated." ); + } + + private boolean resetConnectionPool(CachedDataSource dataSource){ + try { + return dataSource.testConnection(); + } catch (Exception exc) { + LOGGER.info("DataSource <" + dataSource.getDbConnectionName() + "> resetCache failed with error: "+ exc.getMessage()); + return false; + } + } + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#getData(java.lang.String, java.util.ArrayList, java.lang.String) + */ + @Override + public CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) throws SQLException { + ArrayList newList= new ArrayList<>(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + if(recoveryMode) + return requestDataWithRecovery(statement, newList, preferredDS); + else + return requestDataNoRecovery(statement, newList, preferredDS); + } + + private CachedRowSet requestDataWithRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + Throwable lastException = null; + CachedDataSource active = null; + + // test if there are any connection pools available + LinkedList sources = new LinkedList<>(this.dsQueue); + if(sources.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); + } + if(preferredDS != null && !sources.peek().getDbConnectionName().equals(preferredDS)) { + Collections.reverse(sources); + } + + + // loop through available data sources to retrieve data. + while(!sources.isEmpty()) + { + active = sources.peek(); + + long time = System.currentTimeMillis(); + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + master = null; + } + } + sources.remove(active); + return active.getData(statement, arguments); + } catch(SQLDataException | SQLSyntaxErrorException | SQLIntegrityConstraintViolationException exc){ + throw exc; + } catch(Throwable exc){ + lastException = exc; + String message = exc.getMessage(); + if(message == null) { + if(exc.getCause() != null) { + message = exc.getCause().getMessage(); + } + if(message == null) + message = exc.getClass().getName(); + } + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + handleGetConnectionException(active, exc); + if(sources.contains(active)) + sources.remove(active); + } finally { + if(LOGGER.isDebugEnabled()){ + time = System.currentTimeMillis() - time; + LOGGER.debug("getData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + if(lastException instanceof SQLException){ + throw (SQLException)lastException; + } + // repackage the exception + // you are here because either you run out of available data sources + // or the last exception was not of SQLException type. + // repackage the exception + if(lastException == null) { + throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); + } else { + SQLException exception = new DBLibException(lastException.getMessage()); + exception.setStackTrace(lastException.getStackTrace()); + if(lastException.getCause() instanceof SQLException) { + throw (SQLException)lastException.getCause(); + } + throw exception; + } + } + + private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + if(dsQueue.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); + } + CachedDataSource active = this.dsQueue.peek(); + long time = System.currentTimeMillis(); + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) + active = master; + } + return active.getData(statement, arguments); +// } catch(SQLDataException exc){ +// throw exc; + } catch(Throwable exc){ + String message = exc.getMessage(); + if(message == null) + message = exc.getClass().getName(); + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + if(exc instanceof SQLException) + throw (SQLException)exc; + else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } finally { + if(LOGGER.isDebugEnabled()){ + time = System.currentTimeMillis() - time; + LOGGER.debug(">> getData : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#writeData(java.lang.String, java.util.ArrayList, java.lang.String) + */ + @Override + public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException + { + ArrayList newList= new ArrayList<>(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + + return writeDataNoRecovery(statement, newList, preferredDS); + } + + CachedDataSource findMaster() throws PoolExhaustedException { + CachedDataSource master = null; + CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); + for(int i=0; i arguments, String preferredDS) throws SQLException { + if(dsQueue.isEmpty()){ + LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); + } + + boolean initialRequest = true; + boolean retryAllowed = true; + CachedDataSource active = this.dsQueue.peek(); + long time = System.currentTimeMillis(); + while(initialRequest) { + initialRequest = false; + try { + if(!active.isFabric()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } + + return active.writeData(statement, arguments); + } catch(Throwable exc){ + String message = exc.getMessage(); + if(message == null) + message = exc.getClass().getName(); + LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + if(exc instanceof SQLException) { + SQLException sqlExc = SQLException.class.cast(exc); + // handle read-only exception + if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { + LOGGER.warn("retrying due to: " + sqlExc.getMessage()); + dsQueue.remove(active); + dsQueue.add(active); + if(retryAllowed){ + retryAllowed = false; + initialRequest = true; + continue; + } + } + throw (SQLException)exc; + } else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } finally { + if(LOGGER.isDebugEnabled()){ + time = System.currentTimeMillis() - time; + LOGGER.debug("writeData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + } + } + } + return true; + } + + public void setDataSource(CachedDataSource dataSource) { + if(this.dsQueue.contains(dataSource)) + return; + if(this.broken.contains(dataSource)) + return; + + if(dataSource.testConnection(true)){ + this.dsQueue.add(dataSource); + } else { + this.broken.add(dataSource); + } + } + + @Override + public Connection getConnection() throws SQLException { + Throwable lastException = null; + CachedDataSource active = null; + + if(dsQueue.isEmpty()){ + throw new DBLibException("No active DB connection pools are available in GetConnection call."); + } + + try { + active = dsQueue.peek(); + CachedDataSource tmpActive = findMaster(); + if(tmpActive != null) { + active = tmpActive; + } + return new DBLibConnection(active.getConnection(), active); + } catch(javax.sql.rowset.spi.SyncFactoryException exc){ + LOGGER.debug("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); + LOGGER.warn("CLASSPATH issue. Allowing retry", exc); + lastException = exc; + } catch(PoolExhaustedException exc) { + throw new NoAvailableConnectionsException(exc); + } catch(Exception exc){ + lastException = exc; + if(recoveryMode){ + handleGetConnectionException(active, exc); + } else { + if(exc instanceof SQLException) { + throw (SQLException)exc; + } else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } + } catch (Throwable trwb) { + DBLibException excptn = new DBLibException(trwb.getMessage()); + excptn.setStackTrace(trwb.getStackTrace()); + throw excptn; + } finally { + if(LOGGER.isDebugEnabled()){ + displayState(); + } + } + + if(lastException instanceof SQLException){ + throw (SQLException)lastException; + } + // repackage the exception + if(lastException == null) { + throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); + } else { + SQLException exception = new DBLibException(lastException.getMessage()); + exception.setStackTrace(lastException.getStackTrace()); + if(lastException.getCause() instanceof SQLException) { +// exception.setNextException((SQLException)lastException.getCause()); + throw (SQLException)lastException.getCause(); + } + throw exception; + } + } + + @Override + public Connection getConnection(String username, String password) + throws SQLException { + CachedDataSource active = null; + + if(dsQueue.isEmpty()){ + throw new DBLibException("No active DB connection pools are available in GetConnection call."); + } + + + try { + active = dsQueue.peek(); + CachedDataSource tmpActive = findMaster(); + if(tmpActive != null) { + active = tmpActive; + } + return active.getConnection(username, password); + } catch(Throwable exc){ + if(recoveryMode){ + handleGetConnectionException(active, exc); + } else { + if(exc instanceof SQLException) + throw (SQLException)exc; + else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } + + } + + throw new DBLibException("No connections available in DBResourceManager in GetConnection call."); + } + + private void handleGetConnectionException(CachedDataSource source, Throwable exc) { + try { + if(!source.canTakeOffLine()) + { + LOGGER.error("Could not switch due to blocking"); + return; + } + + boolean removed = dsQueue.remove(source); + if(!broken.contains(source)) + { + if(broken.add(source)) + { + LOGGER.warn("DB Recovery: DataSource <" + source.getDbConnectionName() + "> put in the recovery mode. Reason : " + exc.getMessage()); + } else { + LOGGER.warn("Error putting DataSource <" +source.getDbConnectionName()+ "> in recovery mode."); + } + } else { + LOGGER.info("DB Recovery: DataSource <" + source.getDbConnectionName() + "> already in recovery queue"); + } + if(removed) + { + if(!dsQueue.isEmpty()) + { + LOGGER.warn("DB DataSource <" + dsQueue.peek().getDbConnectionName() + "> became active"); + } + } + } catch (Exception e) { + LOGGER.error("", e); + } + } + + public void cleanUp() { + for(Iterator it=dsQueue.iterator();it.hasNext();){ + CachedDataSource cds = it.next(); + it.remove(); + cds.cleanUp(); + } + + try { + this.terminating = true; + if(broken != null) + { + try { + broken.add( new TerminatingCachedDataSource(null)); + } catch(Exception exc){ + LOGGER.error("Waiting for Worker to stop", exc); + } + } + worker.join(terminationTimeOut); + LOGGER.info("DBResourceManager.RecoveryMgr <"+worker.toString() +"> termination was successful: " + worker.getState()); + } catch(Exception exc){ + LOGGER.error("Waiting for Worker thread to terminate ", exc); + } + } + + @Override + public PrintWriter getLogWriter() throws SQLException { + return this.dsQueue.peek().getLogWriter(); + } + + @Override + public int getLoginTimeout() throws SQLException { + return this.dsQueue.peek().getLoginTimeout(); + } + + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + this.dsQueue.peek().setLogWriter(out); + } + + @Override + public void setLoginTimeout(int seconds) throws SQLException { + this.dsQueue.peek().setLoginTimeout(seconds); + } + + public void displayState(){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); + CachedDataSource current = dsQueue.peek(); + if(current != null) { + LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); + } + } + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#isActive() + */ + @Override + public boolean isActive() { + return this.dsQueue.size()>0; + } + + public String getActiveStatus(){ + return "Connected: " + dsQueue.size()+"\tIn-recovery: "+broken.size(); + } + + public String getDBStatus(boolean htmlFormat) { + StringBuilder buffer = new StringBuilder(); + + ArrayList list = new ArrayList<>(); + list.addAll(dsQueue); + list.addAll(broken); + if (htmlFormat) + { + buffer.append("") + .append("Name:").append(""); + for (int i = 0; i < list.size(); i++) { + buffer.append(""); + buffer.append(list.get(i).getDbConnectionName()).append(""); + } + buffer.append(""); + + buffer.append("State:"); + for (int i = 0; i < list.size(); i++) { + if (broken.contains(list.get(i))) { + buffer.append("in recovery"); + } + if (dsQueue.contains(list.get(i))) { + if (dsQueue.peek() == list.get(i)) + buffer.append("active"); + else + buffer.append("standby"); + } + } + buffer.append(""); + + } else { + for (int i = 0; i < list.size(); i++) { + buffer.append("Name: ").append(list.get(i).getDbConnectionName()); + buffer.append("\tState: "); + if (broken.contains(list.get(i))) { + buffer.append("in recovery"); + } else + if (dsQueue.contains(list.get(i))) { + if (dsQueue.peek() == list.get(i)) + buffer.append("active"); + else + buffer.append("standby"); + } + + buffer.append("\n"); + + } + } + return buffer.toString(); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + /** + * @return the monitorDbResponse + */ + @Override + public final boolean isMonitorDbResponse() { + return recoveryMode && monitorDbResponse; + } + + public void test(){ + CachedDataSource obj = dsQueue.peek(); + Exception ption = new Exception(); + try { + for(int i=0; i<5; i++) + { + handleGetConnectionException(obj, ption); + } + } catch(Throwable exc){ + LOGGER.warn("", exc); + } + } + + public String getPreferredDSName(){ + if(isActive()){ + return getPreferredDataSourceName(dsSelector); + } + return ""; + } + + public String getPreferredDataSourceName(AtomicBoolean flipper) { + + LinkedList snapshot = new LinkedList<>(dsQueue); + if(snapshot.size() > 1){ + CachedDataSource first = snapshot.getFirst(); + CachedDataSource last = snapshot.getLast(); + + int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount(); + if(delta < 0) { + flipper.set(false); + } else if(delta > 0) { + flipper.set(true); + } else { + // check the last value and return !last + flipper.getAndSet(!flipper.get()); + } + + if (flipper.get()) + Collections.reverse(snapshot); + } + return snapshot.peek().getDbConnectionName(); + } + + @Override + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + return null; + } + + public String getMasterName() { + if(isActive()){ + return getMasterDataSourceName(dsSelector); + } + return ""; + } + + + private String getMasterDataSourceName(AtomicBoolean flipper) { + + LinkedList snapshot = new LinkedList<>(dsQueue); + if(snapshot.size() > 1){ + CachedDataSource first = snapshot.getFirst(); + CachedDataSource last = snapshot.getLast(); + + int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount(); + if(delta < 0) { + flipper.set(false); + } else if(delta > 0) { + flipper.set(true); + } else { + // check the last value and return !last + flipper.getAndSet(!flipper.get()); + } + + if (flipper.get()) + Collections.reverse(snapshot); + } + return snapshot.peek().getDbConnectionName(); + } class RemindTask extends TimerTask { @Override - public void run() { - CachedDataSource ds = dsQueue.peek(); - if(ds != null) - ds.getPoolInfo(false); + public void run() { + CachedDataSource ds = dsQueue.peek(); + if(ds != null) + ds.getPoolInfo(false); } } - public int poolSize() { - return dsQueue.size(); - } + public int poolSize() { + return dsQueue.size(); + } } diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java old mode 100644 new mode 100755 index 3e438d1a9..5e87412a5 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java @@ -27,7 +27,7 @@ import java.nio.file.Paths; import java.util.Optional; /** - * Resolves dblib properties files relative to the directory identified by the SDNC_CONFIG_DIR + * Resolves properties files relative to the directory identified by the SDNC_CONFIG_DIR * environment variable. */ public abstract class EnvVarFileResolver implements PropertiesFileResolver { 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 old mode 100644 new mode 100755 index 5cd6c3606..844c6949c --- 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 @@ -23,13 +23,15 @@ package org.onap.ccsdk.sli.core.utils; import java.io.File; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.FileSystemNotFoundException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; import org.osgi.framework.FrameworkUtil; +import org.slf4j.LoggerFactory; /** - * Resolves dblib properties files relative to the directory identified by the JRE property + * Resolves project properties files relative to the directory identified by the JRE property * dblib.properties. */ public class JREFileResolver implements PropertiesFileResolver { @@ -37,7 +39,6 @@ public class JREFileResolver implements PropertiesFileResolver { /** * Key for JRE argument representing the configuration directory */ - private static final String DBLIB_JRE_PROPERTY_KEY = "dblib.properties"; private final String successMessage; private final Class clazz; @@ -55,14 +56,15 @@ public class JREFileResolver implements PropertiesFileResolver { @Override public Optional resolveFile(final String filename) { final URL jreArgumentUrl = FrameworkUtil.getBundle(this.clazz) - .getResource(DBLIB_JRE_PROPERTY_KEY); + .getResource(filename); try { if (jreArgumentUrl == null) { return Optional.empty(); } final Path dblibPath = Paths.get(jreArgumentUrl.toURI()); return Optional.of(dblibPath.resolve(filename).toFile()); - } catch(final URISyntaxException e) { + } catch(final URISyntaxException | FileSystemNotFoundException e) { + LoggerFactory.getLogger(this.getClass()).error("", e); return Optional.empty(); } } diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java new file mode 100755 index 000000000..9496d90e2 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils.common; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; + +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; +import org.osgi.framework.FrameworkUtil; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Strings; + +/** + * Resolves properties files from runtime property value SDNC_CONFIG_DIR defined in the osgi properties. + */ +public class BundleContextFileResolver implements PropertiesFileResolver { + + /** + * Key for osgi variable representing the configuration directory + */ + private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; + + private final String successMessage; + private final Class clazz; + + public BundleContextFileResolver(final String successMessage, final Class clazz) { + this.successMessage = successMessage; + this.clazz = clazz; + } + + /** + * Parse a properties file location based on JRE argument + * + * @return an Optional File containing the location if it exists, or an empty Optional + */ + @Override + public Optional resolveFile(final String filename) { + if(FrameworkUtil.getBundle(clazz) == null) { + return Optional.empty(); + } else { + try { + final String pathProperty = FrameworkUtil.getBundle(this.clazz).getBundleContext().getProperty(SDNC_CONFIG_DIR_PROP_KEY); + if(Strings.isNullOrEmpty(pathProperty)) { + return Optional.empty(); + } + final Path dblibPath = Paths.get(pathProperty); + return Optional.of(dblibPath.resolve(filename).toFile()); + } catch(final Exception e) { + LoggerFactory.getLogger(this.getClass()).error("", e); + return Optional.empty(); + } + } + } + + @Override + public String getSuccessfulResolutionMessage() { + return this.successMessage; + } +} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolver.java new file mode 100755 index 000000000..4d7e90261 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolver.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils.common; + +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.onap.ccsdk.sli.core.utils.DefaultFileResolver; + +/** + * Resolve properties file location based on the default directory name. + */ +public class CoreDefaultFileResolver extends DefaultFileResolver { + + /** + * Default path to look for the configuration directory + */ + private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("/opt", "sdnc", "data", "properties"); + + public CoreDefaultFileResolver(final String successMessage) { + super(successMessage, DEFAULT_DBLIB_PROP_DIR); + } +} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolver.java new file mode 100755 index 000000000..51b6134f7 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolver.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.utils.common; + +import org.onap.ccsdk.sli.core.utils.EnvVarFileResolver; + +/** + * Resolve properties file location based on the default directory name. + */ +public class SdncConfigEnvVarFileResolver extends EnvVarFileResolver { + + /** + * Key for environment variable representing the configuration directory + */ + private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; + + public SdncConfigEnvVarFileResolver(final String successMessage) { + super(successMessage, SDNC_CONFIG_DIR_PROP_KEY); + } +} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java old mode 100644 new mode 100755 index 56b4ca1b6..082bdf403 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java @@ -4,12 +4,20 @@ import java.nio.file.Path; import java.nio.file.Paths; import org.onap.ccsdk.sli.core.utils.DefaultFileResolver; +/** + * Resolve properties file location based on the default directory name. + * + * @deprecated + * This class has been replaced by generic version of this class + * {@link #CoreDefaultFileResolver} in common package. + */ +@Deprecated public class DblibDefaultFileResolver extends DefaultFileResolver { /** * Default path to look for the configuration directory */ - private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("opt", "sdnc", "data", "properties"); + private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("/opt", "sdnc", "data", "properties"); public DblibDefaultFileResolver(final String successMessage) { super(successMessage, DEFAULT_DBLIB_PROP_DIR); diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java index 9eef4cee2..959271cb7 100644 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java @@ -2,6 +2,14 @@ package org.onap.ccsdk.sli.core.utils.dblib; import org.onap.ccsdk.sli.core.utils.EnvVarFileResolver; +/** + * Resolve properties file location based on the default directory name. + * + * @deprecated + * This class has been replaced by generic version of this class + * {@link #SdncConfigEnvVarFileResolver} in common package. + */ +@Deprecated public class DblibEnvVarFileResolver extends EnvVarFileResolver { /** diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java new file mode 100644 index 000000000..4ec5e1b48 --- /dev/null +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java @@ -0,0 +1,16 @@ +package org.onap.ccsdk.sli.core.utils.common; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class BundleContexFileResolverTest { + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new BundleContextFileResolver("success", BundleContexFileResolverTest.class); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java new file mode 100644 index 000000000..a4f8817fa --- /dev/null +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java @@ -0,0 +1,25 @@ +package org.onap.ccsdk.sli.core.utils.common; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class CoreDefaultFileResolverTest { + + @Test + public void resolveFile() throws Exception { + final PropertiesFileResolver resolver = new CoreDefaultFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new CoreDefaultFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java new file mode 100644 index 000000000..0f3536b78 --- /dev/null +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.sli.core.utils.common; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Optional; +import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; + +public class SdncConfigEnvVarFileResolverTest { + @Test + public void resolveFile() throws Exception { + final PropertiesFileResolver resolver = new SdncConfigEnvVarFileResolver("success"); + final Optional file = resolver.resolveFile("doesnotexist.cfg"); + assertFalse(file.isPresent()); + } + + @Test + public void getSuccessfulResolutionMessage() throws Exception { + final PropertiesFileResolver resolver = new SdncConfigEnvVarFileResolver("success"); + assertEquals("success", resolver.getSuccessfulResolutionMessage()); + } + +} \ No newline at end of file -- cgit 1.2.3-korg From bbf595ed4b60792db86de93aa3f9707082d5bb1a Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Tue, 30 Jan 2018 21:18:21 +0000 Subject: Upgrade sli/core to Nitrogen Changes made: * Updated JREFileResolver to retrieve data file from Bundle instead of InputStream. Change-Id: Ib2f93378117afaa2501b870aba513a77073b462f Issue-ID: CCSDK-175 Signed-off-by: Rich Tabedzki --- .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 43 +++++++++++++++------- 1 file changed, 29 insertions(+), 14 deletions(-) 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 844c6949c..8da9b7ef0 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 @@ -21,14 +21,13 @@ package org.onap.ccsdk.sli.core.utils; import java.io.File; -import java.net.URISyntaxException; +import java.io.InputStream; import java.net.URL; -import java.nio.file.FileSystemNotFoundException; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.nio.file.Files; import java.util.Optional; + +import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; -import org.slf4j.LoggerFactory; /** * Resolves project properties files relative to the directory identified by the JRE property @@ -41,9 +40,9 @@ public class JREFileResolver implements PropertiesFileResolver { */ private final String successMessage; - private final Class clazz; + private final Class clazz; - public JREFileResolver(final String successMessage, final Class clazz) { + public JREFileResolver(final String successMessage, final Class clazz) { this.successMessage = successMessage; this.clazz = clazz; } @@ -55,16 +54,32 @@ public class JREFileResolver implements PropertiesFileResolver { */ @Override public Optional resolveFile(final String filename) { - final URL jreArgumentUrl = FrameworkUtil.getBundle(this.clazz) - .getResource(filename); + final Bundle bundle = FrameworkUtil.getBundle(this.clazz); + final File dataFile; + try { - if (jreArgumentUrl == null) { + if (bundle == null) { + return Optional.empty(); + } + + URL jreArgumentEntry = bundle.getEntry(filename); + if (jreArgumentEntry == null) { return Optional.empty(); } - final Path dblibPath = Paths.get(jreArgumentUrl.toURI()); - return Optional.of(dblibPath.resolve(filename).toFile()); - } catch(final URISyntaxException | FileSystemNotFoundException e) { - LoggerFactory.getLogger(this.getClass()).error("", e); + + dataFile = bundle.getDataFile(filename); + if(dataFile.exists()) { + dataFile.delete(); + } + + try (InputStream input = jreArgumentEntry.openStream()){ + Files.copy(input, dataFile.toPath()); + } catch(Exception exc) { + return Optional.empty(); + } + + return Optional.of(dataFile); + } catch(final Exception e) { return Optional.empty(); } } -- cgit 1.2.3-korg From d714334ac9e367173efa6801d531272f8c9eaed4 Mon Sep 17 00:00:00 2001 From: Kevin Smokowski Date: Fri, 9 Feb 2018 14:18:39 +0000 Subject: CallNodeExecutor patch Merging an old change that prevents a nullpointerexception when calledgraph is null Change-Id: I936afec383fcf4ba98e1d9d0a00c0d1e492766ca Issue-ID: CCSDK-185 Signed-off-by: Kevin Smokowski --- .../sli/core/sli/provider/CallNodeExecutor.java | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java index 72158e911..d11a2828d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java @@ -120,21 +120,18 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { SvcLogicStore store = getStore(); if (store != null) { - SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); - LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); - ctx.setAttribute("currentGraph", calledGraph.toString()); + SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); if (calledGraph != null) { - svc.execute(calledGraph, ctx); - - outValue = ctx.getStatus(); + LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); + ctx.setAttribute("currentGraph", calledGraph.toString()); + svc.execute(calledGraph, ctx); + outValue = ctx.getStatus(); } else { - LOG.error("Could not find service logic for [" + module + "," + rpc + "," + version + "," + mode + "]"); - } - } - else - { - LOG.debug("Could not get SvcLogicStore reference"); - } + LOG.debug("Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found"); + } + } else { + LOG.debug("Could not get SvcLogicStore reference"); + } SvcLogicNode nextNode = node.getOutcomeValue(outValue); if (nextNode != null) { -- cgit 1.2.3-korg From 72d3e768c26bfc2a7f298bb1d19ca389897d58e1 Mon Sep 17 00:00:00 2001 From: Kevin Smokowski Date: Fri, 9 Feb 2018 15:14:01 +0000 Subject: Iso8601 format fix fix format in method asIso8601 in metric logger Change-Id: I50de2397231ff8b298e3a75b3220315c255c26db Issue-ID: CCSDK-186 Signed-off-by: Kevin Smokowski --- sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index e70d08a5f..394ec0af2 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -246,7 +246,7 @@ public class MetricLogger { public static String asIso8601(Date date) { TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); + DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss.SS'+00:00'"); df.setTimeZone(tz); return df.format(date); } -- cgit 1.2.3-korg From 131cb46f6109a6099a445cb8e1b12ff5b68ae6de Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 1 Feb 2018 16:57:00 -0500 Subject: Upgrade sli/core to Nitrogen Use Apache derby for dblib SingleFeatureTest Change-Id: I6b41f7ede1a98b33824fceea9100e75c1ce8dda4 Issue-ID: CCSDK-175 Signed-off-by: Dan Timoney Generalization of CCSDK core/utils framework Changes made: * Created generalized version of core/utils/dblib as core/utils/common * Deprecated core/utils/dblib package Change-Id: I0992c43910278fbe254674d1e39d7e4fcad0a592 Issue-ID: CCSDK-168 Signed-off-by: Rich Tabedzki Use Apache derby for dblib test Use Apache derby for dblib SingleFeatureTest Change-Id: Ie497557f162e203fa5c5c82c17ddc55ba0c11b38 Issue-ID: CCSDK-175 Signed-off-by: Dan Timoney --- dblib/features/ccsdk-dblib/pom.xml | 96 ++ .../ccsdk-dblib/src/main/feature/feature.xml | 14 + dblib/features/features-dblib/pom.xml | 29 + dblib/features/pom.xml | 143 +-- dblib/features/src/main/resources/features.xml | 18 - dblib/installer/pom.xml | 268 +++--- dblib/pom.xml | 87 +- dblib/provider/pom.xml | 90 +- .../ccsdk/sli/core/dblib/CachedDataSource.java | 1008 ++++++++++---------- dblib/provider/src/main/resources/dblib.properties | 7 +- filters/features/ccsdk-filters/pom.xml | 61 ++ filters/features/features-filters/pom.xml | 29 + filters/features/pom.xml | 105 +- filters/features/src/main/resources/features.xml | 32 - filters/installer/pom.xml | 23 +- filters/pom.xml | 87 +- filters/provider/pom.xml | 126 ++- pom.xml | 92 +- sli/common/pom.xml | 289 +++--- .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 42 +- sli/features/features-sli/pom.xml | 29 + sli/features/odl-sli/pom.xml | 86 ++ sli/features/pom.xml | 161 +--- sli/features/src/main/resources/features.xml | 39 - sli/installer/pom.xml | 25 +- sli/model/pom.xml | 89 +- sli/pom.xml | 61 +- sli/provider/pom.xml | 186 +--- .../sli/core/sli/provider/CallNodeExecutor.java | 38 +- .../sli/core/sli/provider/SvcLogicActivator.java | 181 ---- .../core/sli/provider/SvcLogicNodeExecutor.java | 21 +- .../sli/provider/SvcLogicPropertiesProvider.java | 188 ++++ .../sli/core/sli/provider/SvcLogicServiceImpl.java | 55 +- .../org/opendaylight/blueprint/sli-blueprint.xml | 21 + .../src/main/resources/svclogic.properties | 25 + .../core/sli/provider/ExecuteNodeExecutorTest.java | 7 +- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 7 +- .../src/test/resources/svclogic.properties | 11 +- sli/recording/pom.xml | 71 +- .../features/ccsdk-sliPluginUtils/pom.xml | 65 ++ .../features/features-sliPluginUtils/pom.xml | 29 + sliPluginUtils/features/pom.xml | 130 +-- .../features/src/main/resources/features.xml | 38 - sliPluginUtils/installer/pom.xml | 23 +- sliPluginUtils/pom.xml | 38 +- sliPluginUtils/provider/pom.xml | 47 +- .../slipluginutils/Dme2PropertiesProvider.java | 421 ++++---- .../provider/src/main/resources/dme2.properties | 7 + sliapi/features/ccsdk-sliapi/pom.xml | 60 ++ sliapi/features/features-sliapi/pom.xml | 29 + sliapi/features/pom.xml | 139 +-- sliapi/features/src/main/resources/features.xml | 39 - sliapi/installer/pom.xml | 24 +- .../src/assembly/assemble_mvnrepo_zip.xml | 10 +- sliapi/model/pom.xml | 78 +- sliapi/pom.xml | 56 +- sliapi/provider/pom.xml | 116 +-- .../onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 17 +- .../impl/rev140523/SliapiProviderModule.java | 64 -- .../rev140523/SliapiProviderModuleFactory.java | 34 - .../src/main/resources/initial/sliapi-provider.xml | 70 -- .../opendaylight/blueprint/sliapi-blueprint.xml | 28 + utils/features/features-util/pom.xml | 29 + utils/features/features3-util/pom.xml | 141 +++ .../features3-util/src/main/resources/features.xml | 16 + utils/features/pom.xml | 146 +-- utils/features/sdnc-slicore-utils/pom.xml | 52 + utils/features/src/main/resources/features.xml | 16 - utils/installer/pom.xml | 25 +- utils/pom.xml | 87 +- utils/provider/pom.xml | 35 +- .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 7 +- 72 files changed, 2728 insertions(+), 3335 deletions(-) create mode 100644 dblib/features/ccsdk-dblib/pom.xml create mode 100644 dblib/features/ccsdk-dblib/src/main/feature/feature.xml create mode 100644 dblib/features/features-dblib/pom.xml delete mode 100755 dblib/features/src/main/resources/features.xml create mode 100644 filters/features/ccsdk-filters/pom.xml create mode 100644 filters/features/features-filters/pom.xml delete mode 100644 filters/features/src/main/resources/features.xml create mode 100644 sli/features/features-sli/pom.xml create mode 100644 sli/features/odl-sli/pom.xml mode change 100755 => 100644 sli/features/pom.xml delete mode 100644 sli/features/src/main/resources/features.xml delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java create mode 100755 sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml create mode 100644 sli/provider/src/main/resources/svclogic.properties create mode 100644 sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml create mode 100644 sliPluginUtils/features/features-sliPluginUtils/pom.xml delete mode 100644 sliPluginUtils/features/src/main/resources/features.xml create mode 100644 sliPluginUtils/provider/src/main/resources/dme2.properties create mode 100644 sliapi/features/ccsdk-sliapi/pom.xml create mode 100644 sliapi/features/features-sliapi/pom.xml delete mode 100644 sliapi/features/src/main/resources/features.xml delete mode 100644 sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModule.java delete mode 100644 sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java delete mode 100644 sliapi/provider/src/main/resources/initial/sliapi-provider.xml create mode 100644 sliapi/provider/src/main/resources/org/opendaylight/blueprint/sliapi-blueprint.xml create mode 100644 utils/features/features-util/pom.xml create mode 100755 utils/features/features3-util/pom.xml create mode 100755 utils/features/features3-util/src/main/resources/features.xml create mode 100644 utils/features/sdnc-slicore-utils/pom.xml delete mode 100755 utils/features/src/main/resources/features.xml diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml new file mode 100644 index 000000000..8cf1c93f3 --- /dev/null +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: dblib :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + 0.11.1 + pom + import + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + + ${project.groupId} + dblib-provider + ${project.version} + + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + provided + + + org.apache.derby + derby + 10.11.1.1 + + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + true + + + slf4j-api + tomcat-jdbc + tomcat-juli + + + + + + diff --git a/dblib/features/ccsdk-dblib/src/main/feature/feature.xml b/dblib/features/ccsdk-dblib/src/main/feature/feature.xml new file mode 100644 index 000000000..514ce8de4 --- /dev/null +++ b/dblib/features/ccsdk-dblib/src/main/feature/feature.xml @@ -0,0 +1,14 @@ + + + mvn:org.opendaylight.controller/odl-mdsal-broker/1.6.1/xml/features + +
    Root POM to be used in place of odlparent for CCSDK based projects
    + odl-mdsal-broker + wrap + mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} + mvn:org.mariadb.jdbc/mariadb-java-client/2.1.1 + wrap:mvn:org.apache.tomcat/tomcat-jdbc/8.5.14/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge + wrap:mvn:org.apache.tomcat/tomcat-juli/8.5.14/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge + mvn:org.onap.ccsdk.sli.core/utils-provider/${project.version} +
    +
    diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml new file mode 100644 index 000000000..b7c2150dd --- /dev/null +++ b/dblib/features/features-dblib/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + features-dblib + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: dblib :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-dblib + ${project.version} + xml + features + + + + diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index e9cb6dd0b..18f087397 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -1,138 +1,23 @@ 4.0.0 + - dblib - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - dblib-features - DBLIB Adaptor - Features - - jar - - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - commons-lang - commons-lang - ${commons.lang.version} - compile - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - runtime - - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - - - org.opendaylight.odlparent - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - + org.onap.ccsdk.sli.core + dblib-feature-aggregator + 0.2.1-SNAPSHOT + pom - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + features-dblib + ccsdk-dblib + diff --git a/dblib/features/src/main/resources/features.xml b/dblib/features/src/main/resources/features.xml deleted file mode 100755 index aa31db751..000000000 --- a/dblib/features/src/main/resources/features.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - - odl-mdsal-broker - wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*&overwrite=merge - mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} - mvn:org.mariadb.jdbc/mariadb-java-client/${mariadb.connector.version} - - - diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index bff158011..8d6147b72 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -1,143 +1,149 @@ - - 4.0.0 - - dblib - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT - - dblib-installer - DBLIB Adaptor - Karaf Installer - pom + + 4.0.0 - - sdnc-dblib - sdnc-dblib - mvn:org.onap.ccsdk.sli.core/dblib-features/${project.version}/xml/features - false - + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + - + org.onap.ccsdk.sli.core + dblib-installer + 0.2.1-SNAPSHOT + pom - - org.onap.ccsdk.sli.core - dblib-features - ${project.version} - features - xml - - - * - * - - - + ccsdk-sli-core :: dblib :: ${project.artifactId} - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - + + ccsdk-dblib + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features + false + + - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - + + org.onap.ccsdk.sli.core + ${application.name} + ${project.version} + xml + features + + + * + * + + + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - false - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - false - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli,org.apache.tomcat - sli-common,sli-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + - - - - + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli,org.apache.tomcat + sli-common,sli-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + diff --git a/dblib/pom.xml b/dblib/pom.xml index e7743d81c..58f40ff69 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -1,77 +1,26 @@ - - - org.onap.ccsdk.sli.core - ccsdk-sli-core - 0.2.0-SNAPSHOT + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + org.onap.ccsdk.sli.core + dblib + 0.2.1-SNAPSHOT + pom - 4.0.0 - pom - org.onap.ccsdk.sli.core - dblib - - - DBLIB Adaptor - The DBLIB adaptor allows service logic to access persistent data in a local sql database - - 0.2.0-SNAPSHOT - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compile.plugin.version} - - ${java.version.source} - ${java.version.target} - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10 - - - - aggregate - - aggregate - - site - - - - - - maven-source-plugin - 2.1.1 - - - bundle-sources - package - - - jar-no-fork - - - test-jar-no-fork - - - - - - - - - - AT&T + ccsdk-sli-core :: dblib + The DBLIB adaptor allows service logic to access persistent data in a local sql database + + ONAP - + + provider features installer diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 3bdd7e67b..e6fd1bcb1 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -1,19 +1,27 @@ - + 4.0.0 + - org.onap.ccsdk.sli.core - dblib - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core dblib-provider - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT bundle - DBLIB Adaptor - Provider + + ccsdk-sli-core :: dblib :: ${project.artifactId} http://maven.apache.org + UTF-8 + junit @@ -21,12 +29,12 @@ ${junit.version} test - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + equinoxSDK381 org.eclipse.osgi @@ -48,53 +56,31 @@ ${slf4j.version} test - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + com.google.guava + guava - - com.google.guava - guava - org.onap.ccsdk.sli.core utils-provider ${project.version} - - - org.mockito - mockito-core - test - + + + org.mockito + mockito-core + test + - - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - org.onap.ccsdk.sli.core.dblib - org.onap.ccsdk.sli.core.dblib;version=${project.version} - *,org.mariadb.jdbc - true - - - - - - - - diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index d2331786e..8dac33611 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -56,500 +56,516 @@ import org.slf4j.LoggerFactory; public abstract class CachedDataSource implements DataSource, SQLExecutionMonitorObserver { - private static final Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); - - private static final String SQL_FAILURE = "SQL FAILURE. time(ms): "; - private static final String FAILED_TO_EXECUTE = "> Failed to execute: "; - private static final String WITH_ARGUMENTS = " with arguments: "; - private static final String WITH_NO_ARGUMENTS = " with no arguments. "; - private static final String SQL_DATA_SOURCE = "SQL DataSource <"; - - - protected long connReqTimeout = 30L; - protected long dataReqTimeout = 100L; - - private final SQLExecutionMonitor monitor; - protected DataSource ds = null; - protected String connectionName = null; - protected boolean initialized = false; - - private long interval = 1000; - private long initialDelay = 5000; - private long expectedCompletionTime = 50L; - private boolean canTakeOffLine = true; - private long unprocessedFailoverThreshold = 3L; - - private long nextErrorReportTime = 0L; - - private String globalHostName = null; - - - public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { - configure(jdbcElem); - monitor = new SQLExecutionMonitor(this); - } - - protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; - - /* (non-Javadoc) - * @see javax.sql.DataSource#getConnection() - */ - @Override - public Connection getConnection() throws SQLException { - return ds.getConnection(); - } - - public CachedRowSet getData(String statement, List arguments) - throws SQLException { - TestObject testObject = monitor.registerRequest(); - - try (Connection connection = this.getConnection()) { - if (connection == null) { - throw new SQLException("Connection invalid"); - } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); - } - return executePreparedStatement(connection, statement, arguments, true); - } finally { - monitor.deregisterRequest(testObject); - } - } - - public boolean writeData(String statement, List arguments) - throws SQLException { - TestObject testObject = monitor.registerRequest(); - - try (Connection connection = this.getConnection()) { - if (connection == null) { - throw new SQLException("Connection invalid"); - } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); - } - return executeUpdatePreparedStatement(connection, statement, arguments, true); - } finally { - monitor.deregisterRequest(testObject); - } - } - - CachedRowSet executePreparedStatement(Connection conn, String statement, - List arguments, boolean close) throws SQLException { - long time = System.currentTimeMillis(); - - CachedRowSet data = null; - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL Statement: {}", statement); - if (arguments != null && !arguments.isEmpty()) { - LOGGER.debug("Argunments: {}", arguments); - } - } - - ResultSet rs = null; - try (PreparedStatement ps = conn.prepareStatement(statement)) { - data = RowSetProvider.newFactory().createCachedRowSet(); - if (arguments != null) { - for (int i = 0, max = arguments.size(); i < max; i++) { - ps.setObject(i + 1, arguments.get(i)); - } - } - rs = ps.executeQuery(); - data.populate(rs); - // Point the rowset Cursor to the start - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), (System.currentTimeMillis() - - time)); - } - } catch (SQLException exc) { - handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); - } finally { - handleFinallyBlockForExecutePreparedStatement(rs, conn, close); - } - - return data; - } - - private void handleSqlExceptionForExecuteStatement(Connection conn, String statement, - List arguments, SQLException exc, long time) throws SQLException { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(SQL_FAILURE + (System.currentTimeMillis() - time)); - } - try { - conn.rollback(); - } catch (Exception thr) { - LOGGER.error(thr.getLocalizedMessage(), thr); - } - if (arguments != null && !arguments.isEmpty()) { - LOGGER.error(String.format("<%s%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_ARGUMENTS, - arguments), exc); - } else { - LOGGER.error(String.format("<%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_NO_ARGUMENTS), - exc); - } - throw exc; - } - - private void handleFinallyBlockForExecutePreparedStatement(ResultSet rs, Connection conn, boolean close) { - try { - if (rs != null) { - rs.close(); - } - } catch (Exception exc) { - LOGGER.error(exc.getLocalizedMessage(), exc); - } - try { - if (conn != null && close) { - conn.close(); - } - } catch (Exception exc) { - LOGGER.error(exc.getLocalizedMessage(), exc); - } - } - - boolean executeUpdatePreparedStatement(Connection conn, String statement, List arguments, - boolean close) throws SQLException { - long time = System.currentTimeMillis(); - - CachedRowSet data; - - try (PreparedStatement ps = conn.prepareStatement(statement)) { - data = RowSetProvider.newFactory().createCachedRowSet(); - if (arguments != null) { - prepareStatementForExecuteUpdate(arguments, ps); - } - ps.executeUpdate(); - // Point the rowset Cursor to the start - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), (System.currentTimeMillis() - - time)); - } - ps.close(); - } catch (SQLException exc) { - handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); - } finally { - try { - if (close) { - conn.close(); - } - } catch (Exception exc) { - LOGGER.error(exc.getLocalizedMessage(), exc); - } - } - - return true; - } - - private void prepareStatementForExecuteUpdate(List arguments, PreparedStatement ps) - throws SQLException { - for (int i = 0, max = arguments.size(); i < max; i++) { - Object value = arguments.get(i); - if (value instanceof Blob) { - ps.setBlob(i + 1, (Blob) value); - } else if (value instanceof Timestamp) { - ps.setTimestamp(i + 1, (Timestamp) value); - } else if (value instanceof Integer) { - ps.setInt(i + 1, (Integer) value); - } else if (value instanceof Long) { - ps.setLong(i + 1, (Long) value); - } else if (value instanceof Date) { - ps.setDate(i + 1, (Date) value); - } else { - ps.setObject(i + 1, value); - } - } - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) - */ - @Override - public Connection getConnection(String username, String password) - throws SQLException { - return ds.getConnection(username, password); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getLogWriter() - */ - @Override - public PrintWriter getLogWriter() throws SQLException { - return ds.getLogWriter(); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#getLoginTimeout() - */ - @Override - public int getLoginTimeout() throws SQLException { - return ds.getLoginTimeout(); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) - */ - @Override - public void setLogWriter(PrintWriter out) throws SQLException { - ds.setLogWriter(out); - } - - /* (non-Javadoc) - * @see javax.sql.DataSource#setLoginTimeout(int) - */ - @Override - public void setLoginTimeout(int seconds) throws SQLException { - ds.setLoginTimeout(seconds); - } - - - @Override - public final String getDbConnectionName() { - return connectionName; - } - - protected final void setDbConnectionName(String name) { - this.connectionName = name; - } - - public void cleanUp() { - if (ds != null && ds instanceof Closeable) { - try { - ((Closeable) ds).close(); - } catch (IOException e) { - LOGGER.warn(e.getMessage()); - } - } - ds = null; - monitor.deleteObservers(); - monitor.cleanup(); - } - - public boolean isInitialized() { - return initialized; - } - - protected boolean testConnection() { - return testConnection(false); - } - - protected boolean testConnection(boolean errorLevel) { - ResultSet rs = null; - try (Connection conn = this.getConnection(); Statement stmt = conn.createStatement()) { - Boolean readOnly; - String hostname; - rs = stmt.executeQuery( - "SELECT @@global.read_only, @@global.hostname"); //("SELECT 1 FROM DUAL"); //"select BANNER from SYS.V_$VERSION" - while (rs.next()) { - readOnly = rs.getBoolean(1); - hostname = rs.getString(2); - - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - SQL_DATA_SOURCE + getDbConnectionName() + "> connected to " + hostname + ", read-only is " - + readOnly + ", tested successfully "); - } - } - } catch (Exception exc) { - if (errorLevel) { - LOGGER.error( - SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); - } else { - LOGGER.info( - SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); - } - return false; - } finally { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - LOGGER.error(e.getLocalizedMessage(), e); - } - } - } - return true; - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } - - @Override - public T unwrap(Class iface) throws SQLException { - return null; - } - - @SuppressWarnings("deprecation") - public void setConnectionCachingEnabled(boolean state) { -// if(ds != null && ds instanceof OracleDataSource) -// try { -// ((OracleDataSource)ds).setConnectionCachingEnabled(true); -// } catch (SQLException exc) { -// LOGGER.warn("", exc); -// } - } - - public void addObserver(Observer observer) { - monitor.addObserver(observer); - } - - public void deleteObserver(Observer observer) { - monitor.deleteObserver(observer); - } - - @Override - public long getInterval() { - return interval; - } - - @Override - public long getInitialDelay() { - return initialDelay; - } - - @Override - public void setInterval(long value) { - interval = value; - } - - @Override - public void setInitialDelay(long value) { - initialDelay = value; - } - - @Override - public long getExpectedCompletionTime() { - return expectedCompletionTime; - } - - @Override - public void setExpectedCompletionTime(long value) { - expectedCompletionTime = value; - } - - @Override - public long getUnprocessedFailoverThreshold() { - return unprocessedFailoverThreshold; - } - - @Override - public void setUnprocessedFailoverThreshold(long value) { - this.unprocessedFailoverThreshold = value; - } - - public boolean canTakeOffLine() { - return canTakeOffLine; - } - - public void blockImmediateOffLine() { - canTakeOffLine = false; - final Thread offLineTimer = new Thread(() -> { - try { - Thread.sleep(30000L); - } catch (Exception exc) { - LOGGER.error(exc.getLocalizedMessage(), exc); - } finally { - canTakeOffLine = true; - } - }); - offLineTimer.setDaemon(true); - offLineTimer.start(); - } - - /** - * @return the monitor - */ - final SQLExecutionMonitor getMonitor() { - return monitor; - } - - protected boolean isSlave() throws PoolExhaustedException { - CachedRowSet rs; - boolean isSlave; - String hostname = "UNDETERMINED"; - try { - boolean localSlave = true; - rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList<>()); - while (rs.next()) { - localSlave = rs.getBoolean(1); - hostname = rs.getString(2); - } - isSlave = localSlave; - } catch (PoolExhaustedException peexc) { - throw peexc; - } catch (Exception e) { - LOGGER.error("", e); - isSlave = true; - } - if (isSlave) { - LOGGER.debug("SQL SLAVE : {} on server {}", connectionName, hostname); - } else { - LOGGER.debug("SQL MASTER : {} on server {}", connectionName, hostname); - } - return isSlave; - } - - public boolean isFabric() { - return false; - } - - protected boolean lockTable(Connection conn, String tableName) { - boolean retValue = false; - String query = "LOCK TABLES " + tableName + " WRITE"; - try (Statement preStmt = conn.createStatement(); Statement lock = conn.prepareStatement(query); - ResultSet rs = preStmt.executeQuery("GETDATE()")) { - if (tableName != null) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); - if ("SVC_LOGIC".equals(tableName)) { - Exception e = new Exception(); - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - LOGGER.debug(sw.toString()); - } - } - lock.execute(query); - retValue = true; - } - } catch (Exception exc) { - LOGGER.error("", exc); - retValue = false; - } - return retValue; - } - - protected boolean unlockTable(Connection conn) { - boolean retValue; - try (Statement lock = conn.createStatement()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'UNLOCK TABLES' on connection {}", conn); - } - retValue = lock.execute("UNLOCK TABLES"); - } catch (Exception exc) { - LOGGER.error("", exc); - retValue = false; - } - return retValue; - } - - public void getPoolInfo(boolean allocation) { - - } - - public long getNextErrorReportTime() { - return nextErrorReportTime; - } - - public void setNextErrorReportTime(long nextTime) { - this.nextErrorReportTime = nextTime; - } - - public void setGlobalHostName(String hostname) { - this.globalHostName = hostname; - } - - public String getGlobalHostName() { - return globalHostName; - } + private static final Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); + + private static final String SQL_FAILURE = "SQL FAILURE. time(ms): "; + private static final String FAILED_TO_EXECUTE = "> Failed to execute: "; + private static final String WITH_ARGUMENTS = " with arguments: "; + private static final String WITH_NO_ARGUMENTS = " with no arguments. "; + private static final String SQL_DATA_SOURCE = "SQL DataSource <"; + + protected long connReqTimeout = 30L; + protected long dataReqTimeout = 100L; + + private final SQLExecutionMonitor monitor; + protected DataSource ds = null; + protected String connectionName = null; + protected boolean initialized = false; + + private long interval = 1000; + private long initialDelay = 5000; + private long expectedCompletionTime = 50L; + private boolean canTakeOffLine = true; + private long unprocessedFailoverThreshold = 3L; + + private long nextErrorReportTime = 0L; + + private String globalHostName = null; + + private boolean isDerby = false; + + public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { + configure(jdbcElem); + + if ("org.apache.derby.jdbc.EmbeddedDriver".equals(jdbcElem.getDriverName())) { + isDerby = true; + } + monitor = new SQLExecutionMonitor(this); + } + + protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#getConnection() + */ + @Override + public Connection getConnection() throws SQLException { + return ds.getConnection(); + } + + public CachedRowSet getData(String statement, List arguments) throws SQLException { + TestObject testObject = monitor.registerRequest(); + + try (Connection connection = this.getConnection()) { + if (connection == null) { + throw new SQLException("Connection invalid"); + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); + } + return executePreparedStatement(connection, statement, arguments, true); + } finally { + monitor.deregisterRequest(testObject); + } + } + + public boolean writeData(String statement, List arguments) throws SQLException { + TestObject testObject = monitor.registerRequest(); + + try (Connection connection = this.getConnection()) { + if (connection == null) { + throw new SQLException("Connection invalid"); + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); + } + return executeUpdatePreparedStatement(connection, statement, arguments, true); + } finally { + monitor.deregisterRequest(testObject); + } + } + + CachedRowSet executePreparedStatement(Connection conn, String statement, List arguments, boolean close) + throws SQLException { + long time = System.currentTimeMillis(); + + CachedRowSet data = null; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL Statement: {}", statement); + if (arguments != null && !arguments.isEmpty()) { + LOGGER.debug("Argunments: {}", arguments); + } + } + + ResultSet rs = null; + try (PreparedStatement ps = conn.prepareStatement(statement)) { + data = RowSetProvider.newFactory().createCachedRowSet(); + if (arguments != null) { + for (int i = 0, max = arguments.size(); i < max; i++) { + ps.setObject(i + 1, arguments.get(i)); + } + } + rs = ps.executeQuery(); + data.populate(rs); + // Point the rowset Cursor to the start + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), + (System.currentTimeMillis() - time)); + } + } catch (SQLException exc) { + handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); + } finally { + handleFinallyBlockForExecutePreparedStatement(rs, conn, close); + } + + return data; + } + + private void handleSqlExceptionForExecuteStatement(Connection conn, String statement, List arguments, + SQLException exc, long time) throws SQLException { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(SQL_FAILURE + (System.currentTimeMillis() - time)); + } + try { + conn.rollback(); + } catch (Exception thr) { + LOGGER.error(thr.getLocalizedMessage(), thr); + } + if (arguments != null && !arguments.isEmpty()) { + LOGGER.error(String.format("<%s%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_ARGUMENTS, + arguments), exc); + } else { + LOGGER.error(String.format("<%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_NO_ARGUMENTS), + exc); + } + throw exc; + } + + private void handleFinallyBlockForExecutePreparedStatement(ResultSet rs, Connection conn, boolean close) { + try { + if (rs != null) { + rs.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + try { + if (conn != null && close) { + conn.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + } + + boolean executeUpdatePreparedStatement(Connection conn, String statement, List arguments, boolean close) + throws SQLException { + long time = System.currentTimeMillis(); + + CachedRowSet data; + + try (PreparedStatement ps = conn.prepareStatement(statement)) { + data = RowSetProvider.newFactory().createCachedRowSet(); + if (arguments != null) { + prepareStatementForExecuteUpdate(arguments, ps); + } + ps.executeUpdate(); + // Point the rowset Cursor to the start + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), + (System.currentTimeMillis() - time)); + } + ps.close(); + } catch (SQLException exc) { + handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); + } finally { + try { + if (close) { + conn.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + } + + return true; + } + + private void prepareStatementForExecuteUpdate(List arguments, PreparedStatement ps) throws SQLException { + for (int i = 0, max = arguments.size(); i < max; i++) { + Object value = arguments.get(i); + if (value instanceof Blob) { + ps.setBlob(i + 1, (Blob) value); + } else if (value instanceof Timestamp) { + ps.setTimestamp(i + 1, (Timestamp) value); + } else if (value instanceof Integer) { + ps.setInt(i + 1, (Integer) value); + } else if (value instanceof Long) { + ps.setLong(i + 1, (Long) value); + } else if (value instanceof Date) { + ps.setDate(i + 1, (Date) value); + } else { + ps.setObject(i + 1, value); + } + } + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) + */ + @Override + public Connection getConnection(String username, String password) throws SQLException { + return ds.getConnection(username, password); + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#getLogWriter() + */ + @Override + public PrintWriter getLogWriter() throws SQLException { + return ds.getLogWriter(); + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#getLoginTimeout() + */ + @Override + public int getLoginTimeout() throws SQLException { + return ds.getLoginTimeout(); + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) + */ + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + ds.setLogWriter(out); + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#setLoginTimeout(int) + */ + @Override + public void setLoginTimeout(int seconds) throws SQLException { + ds.setLoginTimeout(seconds); + } + + @Override + public final String getDbConnectionName() { + return connectionName; + } + + protected final void setDbConnectionName(String name) { + this.connectionName = name; + } + + public void cleanUp() { + if (ds != null && ds instanceof Closeable) { + try { + ((Closeable) ds).close(); + } catch (IOException e) { + LOGGER.warn(e.getMessage()); + } + } + ds = null; + monitor.deleteObservers(); + monitor.cleanup(); + } + + public boolean isInitialized() { + return initialized; + } + + protected boolean testConnection() { + return testConnection(false); + } + + protected boolean testConnection(boolean errorLevel) { + ResultSet rs = null; + try (Connection conn = this.getConnection(); Statement stmt = conn.createStatement()) { + Boolean readOnly; + String hostname; + rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); // ("SELECT 1 FROM DUAL"); //"select + // BANNER from SYS.V_$VERSION" + while (rs.next()) { + readOnly = rs.getBoolean(1); + hostname = rs.getString(2); + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(SQL_DATA_SOURCE + getDbConnectionName() + "> connected to " + hostname + + ", read-only is " + readOnly + ", tested successfully "); + } + } + } catch (Exception exc) { + if (errorLevel) { + LOGGER.error( + SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } else { + LOGGER.info( + SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } + return false; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + LOGGER.error(e.getLocalizedMessage(), e); + } + } + } + return true; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @SuppressWarnings("deprecation") + public void setConnectionCachingEnabled(boolean state) { + // if(ds != null && ds instanceof OracleDataSource) + // try { + // ((OracleDataSource)ds).setConnectionCachingEnabled(true); + // } catch (SQLException exc) { + // LOGGER.warn("", exc); + // } + } + + public void addObserver(Observer observer) { + monitor.addObserver(observer); + } + + public void deleteObserver(Observer observer) { + monitor.deleteObserver(observer); + } + + @Override + public long getInterval() { + return interval; + } + + @Override + public long getInitialDelay() { + return initialDelay; + } + + @Override + public void setInterval(long value) { + interval = value; + } + + @Override + public void setInitialDelay(long value) { + initialDelay = value; + } + + @Override + public long getExpectedCompletionTime() { + return expectedCompletionTime; + } + + @Override + public void setExpectedCompletionTime(long value) { + expectedCompletionTime = value; + } + + @Override + public long getUnprocessedFailoverThreshold() { + return unprocessedFailoverThreshold; + } + + @Override + public void setUnprocessedFailoverThreshold(long value) { + this.unprocessedFailoverThreshold = value; + } + + public boolean canTakeOffLine() { + return canTakeOffLine; + } + + public void blockImmediateOffLine() { + canTakeOffLine = false; + final Thread offLineTimer = new Thread(() -> { + try { + Thread.sleep(30000L); + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } finally { + canTakeOffLine = true; + } + }); + offLineTimer.setDaemon(true); + offLineTimer.start(); + } + + /** + * @return the monitor + */ + final SQLExecutionMonitor getMonitor() { + return monitor; + } + + protected boolean isSlave() throws PoolExhaustedException { + + // If using Apache derby, just return false + if (isDerby) { + return false; + } + CachedRowSet rs; + boolean isSlave; + String hostname = "UNDETERMINED"; + try { + boolean localSlave = true; + rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList<>()); + while (rs.next()) { + localSlave = rs.getBoolean(1); + hostname = rs.getString(2); + } + isSlave = localSlave; + } catch (PoolExhaustedException peexc) { + throw peexc; + } catch (Exception e) { + LOGGER.error("", e); + isSlave = true; + } + if (isSlave) { + LOGGER.debug("SQL SLAVE : {} on server {}", connectionName, hostname); + } else { + LOGGER.debug("SQL MASTER : {} on server {}", connectionName, hostname); + } + return isSlave; + } + + public boolean isFabric() { + return false; + } + + protected boolean lockTable(Connection conn, String tableName) { + boolean retValue = false; + String query = "LOCK TABLES " + tableName + " WRITE"; + try (Statement preStmt = conn.createStatement(); + Statement lock = conn.prepareStatement(query); + ResultSet rs = preStmt.executeQuery("GETDATE()")) { + if (tableName != null) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); + if ("SVC_LOGIC".equals(tableName)) { + Exception e = new Exception(); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + LOGGER.debug(sw.toString()); + } + } + lock.execute(query); + retValue = true; + } + } catch (Exception exc) { + LOGGER.error("", exc); + retValue = false; + } + return retValue; + } + + protected boolean unlockTable(Connection conn) { + boolean retValue; + try (Statement lock = conn.createStatement()) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'UNLOCK TABLES' on connection {}", conn); + } + retValue = lock.execute("UNLOCK TABLES"); + } catch (Exception exc) { + LOGGER.error("", exc); + retValue = false; + } + return retValue; + } + + public void getPoolInfo(boolean allocation) { + + } + + public long getNextErrorReportTime() { + return nextErrorReportTime; + } + + public void setNextErrorReportTime(long nextTime) { + this.nextErrorReportTime = nextTime; + } + + public void setGlobalHostName(String hostname) { + this.globalHostName = hostname; + } + + public String getGlobalHostName() { + return globalHostName; + } } diff --git a/dblib/provider/src/main/resources/dblib.properties b/dblib/provider/src/main/resources/dblib.properties index 3e62308fc..e0399cc31 100755 --- a/dblib/provider/src/main/resources/dblib.properties +++ b/dblib/provider/src/main/resources/dblib.properties @@ -1,9 +1,10 @@ org.onap.ccsdk.sli.dbtype=jdbc org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01,sdnctldb02 -org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://DBHOST:3306/sdnctl +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={user for sdnctl} -org.onap.ccsdk.sli.jdbc.password={password for sdnctl} +org.onap.ccsdk.sli.jdbc.user=test +org.onap.ccsdk.sli.jdbc.password=test org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01 org.onap.ccsdk.sli.jdbc.connection.timeout=50 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml new file mode 100644 index 000000000..9b5c73bab --- /dev/null +++ b/filters/features/ccsdk-filters/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-filters + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: filters :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + 0.11.1 + pom + import + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + + ${project.groupId} + filters-provider + ${project.version} + + + + diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml new file mode 100644 index 000000000..5072971aa --- /dev/null +++ b/filters/features/features-filters/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + features-filters + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: filters :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-filters + ${project.version} + xml + features + + + + diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 3662f3368..bf9868404 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -1,101 +1,22 @@ 4.0.0 + - filters - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - filters-features - Filters - Features - - jar - - - - - - org.onap.ccsdk.sli.core - filters-provider - ${project.version} - - - + org.onap.ccsdk.sli.core + filters-features-aggregator + pom - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + features-filters + ccsdk-filters + diff --git a/filters/features/src/main/resources/features.xml b/filters/features/src/main/resources/features.xml deleted file mode 100644 index 7ede2083a..000000000 --- a/filters/features/src/main/resources/features.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - mvn:org.onap.ccsdk.sli.core/filters-provider/${project.version} - - - diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index a22e9ab72..a16b6a60c 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -1,18 +1,24 @@ 4.0.0 + - org.onap.ccsdk.sli.core - filters - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core filters-installer - Filters - Karaf Installer + 0.2.1-SNAPSHOT pom + ccsdk-sli-core :: filters :: ${project.artifactId} + - sdnc-filters - sdnc-filters + ccsdk-filters + ${application.name} mvn:org.onap.ccsdk.sli.core/filters-features/${project.version}/xml/features false @@ -21,10 +27,10 @@ org.onap.ccsdk.sli.core - filters-features + ${application.name} ${project.version} - features xml + features * @@ -134,5 +140,4 @@ - diff --git a/filters/pom.xml b/filters/pom.xml index 7780dcecb..b40d0d318 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -1,79 +1,26 @@ - - - - org.onap.ccsdk.sli.core - ccsdk-sli-core - 0.2.0-SNAPSHOT + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - 4.0.0 - pom - org.onap.ccsdk.sli.core - filters - - - Filters - Servlet filter to implement ECOMP logging spec - - 0.2.0-SNAPSHOT - - + org.onap.ccsdk.sli.core + filters + 0.2.1-SNAPSHOT + pom - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compile.plugin.version} - - ${java.version.source} - ${java.version.target} - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10 - - - - aggregate - - aggregate - - site - - - - - - - maven-source-plugin - 2.1.1 - - - bundle-sources - package - - - jar-no-fork - - - test-jar-no-fork - - - - - - - - - + ccsdk-sli-core :: filters + Servlet filter to implement ONAP logging spec + ONAP - + + provider features installer diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 51d0c63aa..4fdd83280 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -1,82 +1,66 @@ - 4.0.0 - - org.onap.ccsdk.sli.core - filters - 0.2.0-SNAPSHOT - - filters-provider - bundle - Filters - Provider - http://maven.apache.org - - UTF-8 - - - - junit - junit - ${junit.version} - test - - - javax.servlet - javax.servlet-api - 3.0.1 - provided - + 4.0.0 + + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - + org.onap.ccsdk.sli.core + filters-provider + 0.2.1-SNAPSHOT + bundle - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - commons-codec - commons-codec - ${commons.codec.version} - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - + ccsdk-sli-core :: filters :: ${project.artifactId} + http://maven.apache.org - + + UTF-8 + - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - org.onap.ccsdk.sli.core.filters - org.onap.ccsdk.sli.core.filters - org.onap.ccsdk.sli.core.filters - javax.servlet.*,java.io.*,org.osgi.framework.*,org.slf4j.*,org.apache.commons.codec.binary.* - true - - + + + junit + junit + ${junit.version} + test + + + javax.servlet + javax.servlet-api + - + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + provided + - - + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + commons-codec + commons-codec + ${commons.codec.version} + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + diff --git a/pom.xml b/pom.xml index c7885a9b6..7ab4d4630 100755 --- a/pom.xml +++ b/pom.xml @@ -1,20 +1,34 @@ - - + 4.0.0 - pom + + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core ccsdk-sli-core + 0.2.1-SNAPSHOT + pom ccsdk-sli-core - https://wiki.onap.org CCSDK core components contains the SLI, dblib + https://wiki.onap.org + + ONAP + - - org.onap.ccsdk.parent - odlparent-carbon-sr1 - 0.2.0-SNAPSHOT - + + utils + dblib + sli + filters + sliPluginUtils + sliapi + scm:git:ssh://git@${onap.git.host}/sdnc-code.git @@ -24,25 +38,6 @@ - - blackduck @@ -81,45 +76,4 @@ - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.17 - - false - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - https://${onap.nexus.host} - ${onap.nexus.staging.profile-id} - ${onap.nexus.staging.server-id} - - - - - - - - utils - dblib - sli - filters - sliPluginUtils - sliapi - - - ONAP - - 0.2.0-SNAPSHOT - - diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 4c7daa395..167a776e4 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -1,163 +1,136 @@ - - 4.0.0 - - sli - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT - - sli-common - bundle + + + 4.0.0 - SLI - Common Classes - The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter + + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + - - - junit - junit - ${junit.version} - test - - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - - - org.antlr - antlr4 - ${antlr.version} - jar - compile - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-simple - 1.7.5 - compile - - - org.apache.commons - commons-lang3 - ${commons.lang3.version} - - - org.opendaylight.mdsal - yang-binding - ${odl.mdsal.yang.binding.version} - - - org.opendaylight.yangtools - yang-common - ${odl.yangtools.version} - - - org.opendaylight.mdsal.model - ietf-inet-types - ${odl.ietf-inet-types.version} - - - org.opendaylight.mdsal.model - ietf-yang-types - ${odl.ietf-yang-types.version} - - - org.opendaylight.controller - sal-core-api - ${odl.mdsal.version} - - - org.opendaylight.yangtools - yang-data-impl - ${odl.yangtools.version} - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - jar - compile - - - org.onap.ccsdk.sli.core - dblib-provider - ${sdnctl.dblib.version} - - - org.onap.ccsdk.sli.core - sliapi-model - ${project.version} - test - - + org.onap.ccsdk.sli.core + sli-common + 0.2.1-SNAPSHOT + bundle - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - **/*.xsd - - - org.onap.ccsdk.sli.core.sli.SvcLogicParser - org.onap.ccsdk.sli.core.sli - true - - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.onap.ccsdk.sli.core.sli;version=${project.version} - * - *;scope=compile;artifactId=commons-lang|commons-lang3 - true - - - - - org.antlr - antlr4-maven-plugin - ${antlr.version} - - - - ${project.basedir}/src/main/java/ - - antlr - - antlr4 - - - - - - + ccsdk-sli-core :: sli :: ${project.artifactId} + The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter + + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + org.antlr + antlr4 + ${antlr.version} + jar + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + 1.7.5 + compile + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + jar + compile + + + org.onap.ccsdk.sli.core + dblib-provider + ${sdnctl.dblib.version} + + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + test + + + org.opendaylight.mdsal.model + ietf-inet-types + + + org.opendaylight.mdsal.model + ietf-yang-types + + + org.opendaylight.controller + sal-core-api + + + + org.opendaylight.controller + sal-binding-api + + + + + junit + junit + test + + + + org.mockito + mockito-core + test + + + + + + + org.antlr + antlr4-maven-plugin + ${antlr.version} + + + + ${project.basedir}/src/main/java/ + + antlr + + antlr4 + + + + + + diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 74fa1dd66..ee3bcca5c 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -54,10 +54,22 @@ public class SvcLogicDblibStore implements SvcLogicStore { private static final String DBLIB_SERVICE = "org.onap.ccsdk.sli.core.dblib.DbLibService"; + private DbLibService dbSvc; + + public SvcLogicDblibStore() + { + // Does nothing, but needed so that argumentless constructor + // still works. + } + + public SvcLogicDblibStore(DbLibService dbsvc) { + this.dbSvc = dbsvc; + } + @Override public void init(Properties props) throws ConfigurationException { - DbLibService dbSvc = getDbLibService(); + dbSvc = getDbLibService(); if(dbSvc == null) { LOG.error("SvcLogic cannot acquire DBLIB_SERVICE"); return; @@ -74,7 +86,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - DbLibService dbSvc = getDbLibService(); + boolean retval = false; CachedRowSet results = null; @@ -124,7 +136,6 @@ public class SvcLogicDblibStore implements SvcLogicStore { public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { - DbLibService dbSvc = getDbLibService(); PreparedStatement fetchGraphStmt = null; Connection dbConn = null; SvcLogicGraph retval = null; @@ -210,7 +221,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { public void store(SvcLogicGraph graph) throws SvcLogicException { - DbLibService dbSvc = getDbLibService(); + String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph)" + " VALUES(?, ?, ?, ?, ?, ?)"; @@ -283,7 +294,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { public void delete(String module, String rpc, String version, String mode) throws SvcLogicException { - DbLibService dbSvc = getDbLibService(); + String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; @@ -302,7 +313,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { } public void activate(SvcLogicGraph graph) throws SvcLogicException { - DbLibService dbSvc = getDbLibService(); + String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; @@ -328,8 +339,11 @@ public class SvcLogicDblibStore implements SvcLogicStore { private DbLibService getDbLibService() { + if (dbSvc != null) { + return dbSvc; + } + // Get DbLibService interface object. - DbLibService dblibSvc = null; ServiceReference sref = null; BundleContext bctx = null; @@ -345,8 +359,8 @@ public class SvcLogicDblibStore implements SvcLogicStore { if (sref == null) { LOG.warn("Could not find service reference for DBLIB service ({})", DBLIB_SERVICE); } else { - dblibSvc = (DbLibService) bctx.getService(sref); - if (dblibSvc == null) { + dbSvc = (DbLibService) bctx.getService(sref); + if (dbSvc == null) { LOG.warn("Could not find service reference for DBLIB service ({})", DBLIB_SERVICE); } @@ -385,16 +399,16 @@ public class SvcLogicDblibStore implements SvcLogicStore { } try { - dblibSvc = new DBResourceManager(dblibProps); - JavaSingleton.setInstance(dblibSvc); + dbSvc = new DBResourceManager(dblibProps); + JavaSingleton.setInstance(dbSvc); } catch (Exception e) { LOG.warn("Caught exception trying to create DBResourceManager", e); } } else { - dblibSvc = JavaSingleton.getInstance(); + dbSvc = JavaSingleton.getInstance(); } } - return dblibSvc; + return dbSvc; } @@ -419,7 +433,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { @Override public void activate(String module, String rpc, String version, String mode) throws SvcLogicException { - DbLibService dbSvc = getDbLibService(); + String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml new file mode 100644 index 000000000..de617baad --- /dev/null +++ b/sli/features/features-sli/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + features-sli + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: sli :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + + diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml new file mode 100644 index 000000000..907cef6a2 --- /dev/null +++ b/sli/features/odl-sli/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-sli + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: sli :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + 0.11.1 + pom + import + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + + org.onap.ccsdk.sli.core + sli-recording + ${project.version} + + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + ${project.version} + xml + features + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + provided + + + diff --git a/sli/features/pom.xml b/sli/features/pom.xml old mode 100755 new mode 100644 index 4630b7833..fbb864efa --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -1,137 +1,30 @@ - - 4.0.0 - - sli - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT - - sli-features - SLI - Features - - jar - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - - - commons-lang - commons-lang - ${commons.lang.version} - compile - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - runtime - - + - - - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - +This program and the accompanying materials are made available under the +terms of the Eclipse Public License v1.0 which accompanies this distribution, +and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL +--> + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + sli-feature-aggregator + 0.1.0 + pom + + ccsdk-sli-core :: sli :: ${project.artifactId} + + + features-sli + odl-sli + diff --git a/sli/features/src/main/resources/features.xml b/sli/features/src/main/resources/features.xml deleted file mode 100644 index 1f17c1a95..000000000 --- a/sli/features/src/main/resources/features.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - - odl-mdsal-broker - mvn:org.onap.ccsdk.sli.core/sli-common/${project.version} - mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version} - mvn:org.onap.ccsdk.sli.core/sli-recording/${project.version} - sdnc-dblib - mvn:org.mariadb.jdbc/mariadb-java-client/${mariadb.connector.version} - - - diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 23b747130..ec2b43cff 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -1,19 +1,25 @@ 4.0.0 + - sli - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core sli-installer - SLI - Karaf Installer + 0.2.1-SNAPSHOT pom + ccsdk-sli-core :: sli :: ${project.artifactId} + - sdnc-sli - sdnc-sli - mvn:org.onap.ccsdk.sli.core/sli-features/${project.version}/xml/features + ccsdk-sli + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false @@ -21,10 +27,10 @@ org.onap.ccsdk.sli.core - sli-features + ${application.name} ${project.version} - features xml + features * @@ -145,5 +151,4 @@ - diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 59658a3e1..3a78c4788 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -1,82 +1,29 @@ 4.0.0 + - sli - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core sli-model + 0.2.1-SNAPSHOT bundle - SLI - Model - - - - org.apache.felix - maven-bundle-plugin - true - - - * - - - - - org.opendaylight.yangtools - yang-maven-plugin - ${odl.yangtools.yang.maven.plugin.version} - - - org.opendaylight.mdsal - maven-sal-api-gen-plugin - ${odl.sal.api.gen.plugin.version} - jar - - - - - - generate-sources - - - ${yang.file.directory} - - - - org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl - ${salGeneratorPath} - - - true - - - - - - + ccsdk-sli-core :: sli :: ${project.artifactId} + - - org.opendaylight.mdsal - yang-binding - ${odl.mdsal.yang.binding.version} - - - org.opendaylight.yangtools - yang-common - ${odl.yangtools.version} - - - org.opendaylight.mdsal.model - ietf-inet-types - ${odl.ietf-inet-types.version} - - - org.opendaylight.mdsal.model - ietf-yang-types - ${odl.ietf-yang-types.version} - + + org.opendaylight.mdsal.model + ietf-inet-types + + + org.opendaylight.mdsal.model + ietf-yang-types + diff --git a/sli/pom.xml b/sli/pom.xml index 95417c3c8..985fa1d3e 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -1,53 +1,24 @@ - - + + 4.0.0 - org.onap.ccsdk.sli.core - ccsdk-sli-core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - 4.0.0 - pom + org.onap.ccsdk.sli.core sli + 0.2.1-SNAPSHOT + pom - - - - - org.onap.ccsdk.sli.core - sli-features - features - xml - ${project.version} - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - - - - - - - - Service Logic Interpreter + ccsdk-sli-core :: sli The Service Logic Interpreter (SLI) allows service planners to design the flow of logic within the SDN controller in an XML format, without a need for custom Java code. + + ONAP + model @@ -57,10 +28,4 @@ features installer - - ONAP - - 0.2.0-SNAPSHOT - - diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 4f410ab01..4a90ae005 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -1,25 +1,38 @@ - - 4.0.0 - - org.onap.ccsdk.sli.core - sli - 0.2.0-SNAPSHOT + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + - sli-provider - bundle - SLI - Provider - + + org.onap.ccsdk.sli.core + sli-provider + 0.2.1-SNAPSHOT + bundle + + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. + + UTF-8 - - - junit - junit - ${junit.version} - test - + + + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + ch.vorburger.mariaDB4j mariaDB4j @@ -60,129 +73,24 @@ compile - - - - - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - org.onap.ccsdk.sli.core.sli.provider.SvcLogicActivator - org.onap.ccsdk.sli.core.sli.provider;version=${project.version} - - * + + org.opendaylight.controller + sal-binding-api + - org.onap.ccsdk.sli.core.sli;version="${project.version}",* + + + junit + junit + test + - *;scope=compile;artifactId=commons-lang|commons-lang3 + + org.mockito + mockito-core + test + - true - - - - - - org.opendaylight.yangtools - yang-maven-plugin - ${odl.yangtools.yang.maven.plugin.version} - - - config - - generate-sources - - - src/test/resources - - - - org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - - ${jmxGeneratorPath} - - - urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang - - - - - - org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl - - ${salGeneratorPath} - - - true - - - - - - org.opendaylight.mdsal - maven-sal-api-gen-plugin - ${odl.sal.api.gen.plugin.version} - jar - - - org.opendaylight.controller - yang-jmx-generator-plugin - ${odl.yang.jmx.generator.version} - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - prepare-package - - run - - - - - - - - - - - - - - - - - - SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. + diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java index d11a2828d..24774af24 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java @@ -8,9 +8,9 @@ * 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. @@ -34,15 +34,15 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory .getLogger(CallNodeExecutor.class); - + @Override public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String outValue = "not-found"; - + SvcLogicGraph myGraph = node.getGraph(); - + if (myGraph == null) { LOG.debug("execute: getGraph returned null"); @@ -51,17 +51,17 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { { LOG.debug("execute: got SvcLogicGraph"); } - + SvcLogicExpression moduleExpr = null; - + String module = null; - + moduleExpr = node.getAttribute("module"); if (moduleExpr != null) { module = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); } - + if ((module == null) || (module.length() == 0)) { if (myGraph != null) @@ -70,7 +70,7 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { LOG.debug("myGraph.getModule() returned "+module); } } - + SvcLogicExpression rpcExpr = null; String rpc = null; rpcExpr = node.getAttribute("rpc"); @@ -78,7 +78,7 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { { rpc = SvcLogicExpressionResolver.evaluate(rpcExpr, node, ctx); } - + if ((rpc == null) || (rpc.length() == 0)) { if (myGraph != null) @@ -87,9 +87,9 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { LOG.debug("myGraph.getRpc() returned "+rpc); } } - + String mode = null; - + moduleExpr = node.getAttribute("mode"); if (moduleExpr != null) { @@ -105,9 +105,9 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { LOG.debug("myGraph.getMode() returned "+mode); } } - + String version = null; - + moduleExpr = node.getAttribute("version"); if (moduleExpr != null) { @@ -116,9 +116,9 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { String parentGraph = ctx.getAttribute("currentGraph"); ctx.setAttribute("parentGraph", parentGraph); - - SvcLogicStore store = getStore(); - + + SvcLogicStore store = svc.getStore(); + if (store != null) { SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); if (calledGraph != null) { @@ -132,7 +132,7 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { } else { LOG.debug("Could not get SvcLogicStore reference"); } - + SvcLogicNode nextNode = node.getOutcomeValue(outValue); if (nextNode != null) { if (LOG.isDebugEnabled()) { diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java deleted file mode 100644 index 95dfb2b88..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicActivator.java +++ /dev/null @@ -1,181 +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.provider; - -import java.io.File; -import java.io.FileInputStream; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.LinkedList; -import java.util.Map; -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class SvcLogicActivator implements BundleActivator { - - private static final String SVCLOGIC_PROP_VAR = "SDNC_SLI_PROPERTIES"; - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - - private static final Map BUILTIN_NODES = new HashMap() { - { - put("block", new BlockNodeExecutor()); - put("call", new CallNodeExecutor()); - put("configure", new ConfigureNodeExecutor()); - put("delete", new DeleteNodeExecutor()); - put("execute", new ExecuteNodeExecutor()); - put("exists", new ExistsNodeExecutor()); - put("for", new ForNodeExecutor()); - put("get-resource", new GetResourceNodeExecutor()); - put("is-available", new IsAvailableNodeExecutor()); - put("notify", new NotifyNodeExecutor()); - put("record", new RecordNodeExecutor()); - put("release", new ReleaseNodeExecutor()); - put("reserve", new ReserveNodeExecutor()); - put("return", new ReturnNodeExecutor()); - put("save", new SaveNodeExecutor()); - put("set", new SetNodeExecutor()); - put("switch", new SwitchNodeExecutor()); - put("update", new UpdateNodeExecutor()); - put("break", new BreakNodeExecutor()); - put("while", new WhileNodeExecutor()); - } - }; - - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicActivator.class); - - private static LinkedList registrations = new LinkedList<>(); - - private static HashMap adaptorMap; - - private static Properties props; - - private static BundleContext bundleCtx; - - private static SvcLogicService svcLogicServiceImpl; - - @Override - public void start(BundleContext ctx) throws Exception { - - LOG.info("Activating SLI"); - - synchronized (SvcLogicActivator.class) { - bundleCtx = ctx; - props = new Properties(); - } - - // Read properties - String propPath = System.getenv(SVCLOGIC_PROP_VAR); - - if (propPath == null) { - String propDir = System.getenv(SDNC_CONFIG_DIR); - if (propDir == null) { - - propDir = "/opt/sdnc/data/properties"; - } - propPath = propDir + "/svclogic.properties"; - LOG.warn("Environment variable {} unset - defaulting to {}", SVCLOGIC_PROP_VAR, propPath); - } - - File propFile = new File(propPath); - - if (!propFile.exists()) { - throw new ConfigurationException("Missing configuration properties file : " + propFile); - } - - try { - props.load(new FileInputStream(propFile)); - } catch (Exception e) { - throw new ConfigurationException("Could not load properties file " + propPath, e); - - } - - synchronized (SvcLogicActivator.class) { - if (registrations == null) { - registrations = new LinkedList<>(); - } - // Advertise SvcLogicService - svcLogicServiceImpl = new SvcLogicServiceImpl(); - } - - LOG.info("SLI: Registering service {} in bundle {}", SvcLogicService.NAME, ctx.getBundle().getSymbolicName()); - ServiceRegistration reg = ctx.registerService(SvcLogicService.NAME, svcLogicServiceImpl, null); - registrations.add(reg); - - // Initialize SvcLogicStore - try { - SvcLogicStore store = getStore(); - } catch (ConfigurationException e) { - LOG.warn("Could not initialize SvcLogicScore", e); - } - - LOG.info("SLI - done registering services"); - } - - @Override - public void stop(BundleContext ctx) throws Exception { - - if (registrations != null) { - for (ServiceRegistration reg : registrations) { - ServiceReference regRef = reg.getReference(); - reg.unregister(); - } - synchronized (SvcLogicActivator.class) { - registrations = null; - } - } - } - - public static SvcLogicStore getStore() throws SvcLogicException { - // Create and initialize SvcLogicStore object - used to access - // saved service logic. - - SvcLogicStore store; - - try { - store = SvcLogicStoreFactory.getSvcLogicStore(props); - } catch (Exception e) { - throw new ConfigurationException("Could not get service logic store", e); - - } - - try { - store.init(props); - } catch (Exception e) { - throw new ConfigurationException("Could not get service logic store", e); - } - - return(store); - } - - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java index 43296c6cd..951536b50 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java @@ -8,9 +8,9 @@ * 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. @@ -36,7 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class SvcLogicNodeExecutor { - + public abstract SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class); @@ -51,15 +51,12 @@ public abstract class SvcLogicNodeExecutor { node, ctx)); } - - protected SvcLogicStore getStore() throws SvcLogicException { - return SvcLogicActivator.getStore(); - } - + + protected SvcLogicAdaptor getAdaptor(String adaptorName) { return SvcLogicAdaptorFactory.getInstance(adaptorName); } - + protected SvcLogicResource getSvcLogicResource(String plugin) { BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); @@ -75,7 +72,7 @@ public abstract class SvcLogicNodeExecutor { return null; } } - + protected SvcLogicRecorder getSvcLogicRecorder(String plugin) { BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); @@ -90,7 +87,7 @@ public abstract class SvcLogicNodeExecutor { return null; } } - + protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){ BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); @@ -106,5 +103,5 @@ public abstract class SvcLogicNodeExecutor { return plugin; } } - + } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java new file mode 100644 index 000000000..6e8597210 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Optional; +import java.util.Properties; +import java.util.Vector; + +import org.onap.ccsdk.sli.core.dblib.DblibConfigurationException; +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.utils.JREFileResolver; +import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; +import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Responsible for determining the properties file to use and instantiating the + * DBResourceManager Service. The priority for properties file + * resolution is as follows: + * + *
      + *
    1. A directory identified by the system environment variable + * SDNC_CONFIG_DIR
    2. + *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. + *
    5. A directory identified by the JRE argument + * dblib.properties
    6. + *
    7. A dblib.properties file located in the karaf root + * directory
    8. + *
    + */ +public class SvcLogicPropertiesProvider { + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicPropertiesProvider.class); + + /** + * The name of the properties file for database configuration + */ + private static final String SVCLOGIC_PROP_FILE_NAME = "svclogic.properties"; + + /** + * A prioritized list of strategies for resolving dblib properties files. + */ + private Vector sliPropertiesFileResolvers = new Vector<>(); + + /** + * The configuration properties for the db connection. + */ + private Properties properties; + + /** + * Set up the prioritized list of strategies for resolving dblib properties + * files. + */ + public SvcLogicPropertiesProvider() { + sliPropertiesFileResolvers + .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); + sliPropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); + + sliPropertiesFileResolvers.add( + new JREFileResolver("Using property file (3) from JRE argument", SvcLogicPropertiesProvider.class)); + sliPropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); + + // determines properties file as according to the priority described in the + // class header comment + final File propertiesFile = determinePropertiesFile(this); + if (propertiesFile != null) { + try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { + properties = new Properties(); + properties.load(fileInputStream); + } catch (final IOException e) { + LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), + new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(), + e)); + } + } else { + // Try to read properties as resource + + InputStream propStr = getClass().getResourceAsStream("/" + SVCLOGIC_PROP_FILE_NAME); + if (propStr != null) { + properties = new Properties(); + try { + properties.load(propStr); + propStr.close(); + } catch (IOException e) { + properties = null; + } + } + + } + + if (properties == null) { + reportFailure("Missing configuration properties resource(3)", new ConfigurationException( + "Missing configuration properties resource(3): " + SVCLOGIC_PROP_FILE_NAME)); + } + } + + /** + * Extract svclogic config properties. + * + * @return the svclogic config properties + */ + public Properties getProperties() { + return properties; + } + + /** + * Reports the method chosen for properties resolution to the + * Logger. + * + * @param message + * Some user friendly message + * @param fileOptional + * The file location of the chosen properties file + * @return the file location of the chosen properties file + */ + private static File reportSuccess(final String message, final Optional fileOptional) { + if (fileOptional.isPresent()) { + final File file = fileOptional.get(); + LOG.info("{} {}", message, file.getPath()); + return file; + } + return null; + } + + /** + * Reports fatal errors. This is the case in which no properties file could be + * found. + * + * @param message + * An appropriate fatal error message + * @param configurationException + * An exception describing what went wrong during resolution + */ + private static void reportFailure(final String message, final ConfigurationException configurationException) { + + LOG.error("{}", message, configurationException); + } + + /** + * Determines the dblib properties file to use based on the following priority: + *
      + *
    1. A directory identified by the system environment variable + * SDNC_CONFIG_DIR
    2. + *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. + *
    5. A directory identified by the JRE argument + * dblib.properties
    6. + *
    7. A dblib.properties file located in the karaf root + * directory
    8. + *
    + */ + File determinePropertiesFile(final SvcLogicPropertiesProvider resourceProvider) { + + for (final PropertiesFileResolver sliPropertiesFileResolver : sliPropertiesFileResolvers) { + final Optional fileOptional = sliPropertiesFileResolver.resolveFile(SVCLOGIC_PROP_FILE_NAME); + if (fileOptional.isPresent()) { + return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); + } + } + + return null; + } +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 5f4d3653e..53875b35a 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -8,9 +8,9 @@ * 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. @@ -24,12 +24,16 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.util.HashMap; import java.util.Properties; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.core.sli.ConfigurationException; import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -51,6 +55,25 @@ public class SvcLogicServiceImpl implements SvcLogicService { private BundleContext bctx = null; + private Properties properties; + + private SvcLogicStore store; + + public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider) throws SvcLogicException{ + + properties = resourceProvider.getProperties(); + + getStore(); + } + + public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc) throws SvcLogicException{ + + properties = resourceProvider.getProperties(); + store = new SvcLogicDblibStore(dbSvc); +} + + + private void registerExecutors() { LOG.info("Entered register executors"); @@ -210,8 +233,6 @@ public class SvcLogicServiceImpl implements SvcLogicService { @Override public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - SvcLogicStore store = SvcLogicActivator.getStore(); - return (store.hasGraph(module, rpc, version, mode)); } @@ -226,8 +247,6 @@ public class SvcLogicServiceImpl implements SvcLogicService { public Properties execute(String module, String rpc, String version, String mode, Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { - // See if there is a service logic defined - SvcLogicStore store = SvcLogicActivator.getStore(); LOG.info("Fetching service logic from data store"); SvcLogicGraph graph = store.fetch(module, rpc, version, mode); @@ -249,4 +268,28 @@ public class SvcLogicServiceImpl implements SvcLogicService { return(ctx.toProperties()); } + + public SvcLogicStore getStore() throws SvcLogicException { + // Create and initialize SvcLogicStore object - used to access + // saved service logic. + + if (store != null) { + return store; + } + + try { + store = SvcLogicStoreFactory.getSvcLogicStore(properties); + } catch (Exception e) { + throw new ConfigurationException("Could not get service logic store", e); + + } + + try { + store.init(properties); + } catch (SvcLogicException e) { + throw new ConfigurationException("Could not get service logic store", e); + } + + return store; + } } 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 new file mode 100755 index 000000000..829057426 --- /dev/null +++ b/sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + org.onap.ccsdk.sli.core.sli.provider.SvcLogicService + + + + \ No newline at end of file diff --git a/sli/provider/src/main/resources/svclogic.properties b/sli/provider/src/main/resources/svclogic.properties new file mode 100644 index 000000000..49d39ab40 --- /dev/null +++ b/sli/provider/src/main/resources/svclogic.properties @@ -0,0 +1,25 @@ +### +# ============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 = dblib +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 diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java index 48e49f812..eccbfc9e8 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java @@ -8,9 +8,9 @@ * 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. @@ -53,7 +53,8 @@ public class ExecuteNodeExecutorTest extends TestCase { MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor(); SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph()); node.setAttribute("method", "selectLunch"); - execute.execute(new SvcLogicServiceImpl(), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); + SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider(); + execute.execute(new SvcLogicServiceImpl(resourceProvider), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); } } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 724e946d5..18f044b30 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -102,8 +102,8 @@ public class ITCaseSvcLogicGraphExecutor { SvcLogicParser parser = new SvcLogicParser(); // Loop through executor tests - - SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); + SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider(); + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); for (String nodeType : BUILTIN_NODES.keySet()) { LOG.info("SLI - registering node executor for node type " + nodeType); @@ -156,8 +156,9 @@ public class ITCaseSvcLogicGraphExecutor { SvcLogicParser parser = new SvcLogicParser(); // Loop through executor tests + SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider(); - SvcLogicServiceImpl svc = new SvcLogicServiceImpl(); + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); for (String nodeType : BUILTIN_NODES.keySet()) { diff --git a/sli/provider/src/test/resources/svclogic.properties b/sli/provider/src/test/resources/svclogic.properties index 25eb3bd47..49d39ab40 100644 --- a/sli/provider/src/test/resources/svclogic.properties +++ b/sli/provider/src/test/resources/svclogic.properties @@ -8,9 +8,9 @@ # 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. @@ -19,8 +19,7 @@ # ============LICENSE_END========================================================= ### -org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url = jdbc:mysql://localhost:3306/sdnctl +org.onap.ccsdk.sli.dbtype = dblib +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 = sdnctl -org.onap.ccsdk.sli.jdbc.password = gamma diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index b571cfbb9..e8b136fdd 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -1,24 +1,38 @@ 4.0.0 + - org.onap.ccsdk.sli.core - sli - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core sli-recording + 0.2.1-SNAPSHOT bundle - SLI - Recording + + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Recording is an OSGi bundle that implements recording service for the service logic record node. + UTF-8 + + + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + - - junit - junit - ${junit.version} - test - org.onap.ccsdk.sli.core sli-common @@ -48,28 +62,23 @@ compile - - - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - org.onap.ccsdk.sli.core.sli.recording;version=${project.version} - true - - - - + + org.opendaylight.controller + sal-binding-api + - + + + junit + junit + test + + + org.mockito + mockito-core + test + - - - SLI Recording is an OSGi bundle that implements recording service for the service logic record node. + diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml new file mode 100644 index 000000000..8ea5ca86e --- /dev/null +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-sliPluginUtils + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + 0.11.1 + pom + import + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + + ${project.groupId} + sliPluginUtils-provider + ${project.version} + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + provided + + + diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml new file mode 100644 index 000000000..004277dd3 --- /dev/null +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + features-sliPluginUtils + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-sliPluginUtils + ${project.version} + xml + features + + + + diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 19d32f7a2..4a1f89947 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -1,127 +1,23 @@ - - sliPluginUtils-features - jar 4.0.0 - sliPluginUtils - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - SliPluginUtils Plugin - Features - - - - org.onap.ccsdk.sli.core - sliPluginUtils-provider - ${project.version} - - - commons-lang - commons-lang - ${commons.lang.version} - compile - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - runtime - - - - org.opendaylight.odlparent - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - + org.onap.ccsdk.sli.core + sliPluginUtils-features + 0.2.1-SNAPSHOT + pom - + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + features-sliPluginUtils + ccsdk-sliPluginUtils + diff --git a/sliPluginUtils/features/src/main/resources/features.xml b/sliPluginUtils/features/src/main/resources/features.xml deleted file mode 100644 index f59cea423..000000000 --- a/sliPluginUtils/features/src/main/resources/features.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - - odl-mdsal-broker - sdnc-sli - mvn:org.onap.ccsdk.sli.core/sliPluginUtils-provider/${project.version} - - - diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 736d22202..1c0704af6 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -1,18 +1,24 @@ 4.0.0 + - sliPluginUtils - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + org.onap.ccsdl.sli.core sliPluginUtils-installer - SLI Plugin Utilities - Karaf Installer + 0.2.1-SNAPSHOT pom + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + - sdnc-sliPluginUtils - sdnc-sliPluginUtils + ccsdk-sliPluginUtils + ${application.name} mvn:org.onap.ccsdk.sli.core/sliPluginUtils-features/${project.version}/xml/features false @@ -21,10 +27,10 @@ org.onap.ccsdk.sli.core - sliPluginUtils-features + ${application.name} ${project.version} - features xml + features * @@ -134,5 +140,4 @@ - diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 21efb170b..45be684f7 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -1,38 +1,22 @@ - + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + org.onap.ccsdk.sli.core sliPluginUtils - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT pom - 4.0.0 - - - org.onap.ccsdk.sli.core - ccsdk-sli-core - 0.2.0-SNAPSHOT - - Service Logic Interface Plugin Utilities + ccsdk-sli-core :: sliPluginUtils A package of static utility functions to be used when developing SLI plugins - - - - org.onap.ccsdk.sli.core - SliPluginUtils-features - features - xml - ${project.version} - - - org.onap.ccsdk.sli.core - SliPluginUtils-provider - ${project.version} - - - - provider features diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 61b5e958f..0a274edd0 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -1,17 +1,20 @@ - - sliPluginUtils-provider - bundle 4.0.0 - org.onap.ccsdk.sli.core - sliPluginUtils - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + - SliPluginUtils Plugin - Provider + org.onap.ccsdk.sli.core + sliPluginUtils-provider + 0.2.1-SNAPSHOT + bundle + + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} http://maven.apache.org @@ -22,11 +25,10 @@ junit junit - ${junit.version} test - org.onap.ccsdk.sli.core + ${project.groupId} sli-common ${project.version} compile @@ -34,22 +36,18 @@ equinoxSDK381 org.eclipse.osgi - ${equinox.osgi.version} org.slf4j slf4j-api - ${slf4j.version} org.slf4j jcl-over-slf4j - ${slf4j.version} org.apache.commons commons-lang3 - 3.1 org.hamcrest @@ -68,27 +66,4 @@ 1.1 - - - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - org.onap.ccsdk.sli.core.slipluginutils - org.onap.ccsdk.sli.core.slipluginutils - org.onap.ccsdk.sli.core.*,org.osgi.framework.*,org.slf4j.*,java.net.* - *;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mariadb-java-client|slf4j-api|jcl-over-slf4j - true - - - - - - - diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java index 07c84c66f..6802c9a8b 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java @@ -8,9 +8,9 @@ * 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. @@ -31,193 +31,248 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; import java.util.Properties; +import java.util.Vector; +import org.onap.ccsdk.sli.core.utils.JREFileResolver; +import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; +import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Immutable properties container for dme2 properties. Since the initial design decision was made to - * utilize Properties instead of an OSGi ManagedService, it was decided - * to make these properties immutable. + * Immutable properties container for dme2 properties. Since the initial design + * decision was made to utilize Properties instead of an OSGi + * ManagedService, it was decided to make these properties + * immutable. */ public final class Dme2PropertiesProvider { - private static final Logger LOG = LoggerFactory.getLogger(Dme2PropertiesProvider.class); - - /** - * The name of the environment variable to specify the configuration directory. - */ - private static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR"; - - /** - * the dme2 properties file name. - */ - private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; - - /** - * the key for proxyUrl, which represents a CSV list of urls - */ - static final String PROXY_URL_KEY = "proxyUrl"; - - /** - * indicates that proxy urls are separated by commas - */ - private static final String PROXY_URLS_VALUE_SEPARATOR = ","; - - /** - * the key for aafUserName - */ - static final String AAF_USERNAME_KEY = "aafUserName"; - - /** - * the key for aafPassword - */ - static final String AAF_PASSWORD_KEY = "aafPassword"; - - /** - * the key for envContext - */ - static final String ENV_CONTEXT_KEY = "envContext"; - - /** - * the key for routeOffer - */ - static final String ROUTE_OFFER_KEY = "routeOffer"; - - /** - * the key for commonServiceVersion - */ - static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; - - /** - * the key for partner - */ - static final String PARTNER_KEY = "partner"; - - private Optional proxyUrls = Optional.empty(); - - private Optional aafUsername = Optional.empty(); - - private Optional aafPassword = Optional.empty(); - - private Optional envContext = Optional.empty(); - - private Optional routeOffer = Optional.empty(); - - private Optional commonServiceVersion = Optional.empty(); - - private Optional partner = Optional.empty(); - - - /** - * Instantiates the properties provider, which involves loading the appropriate properties for dme2. - */ - public Dme2PropertiesProvider() { - this(getDme2Path(SDNC_ROOT_DIR_ENV_VAR_KEY, DME2_PROPERTIES_FILE_NAME).toString()); - } - - /** - * Instantiates the properties provider, which involves loading the appropriate properties for dme2. - * - * @param dme2Path location of the dme2.properties file - */ - @VisibleForTesting - Dme2PropertiesProvider(final String dme2Path) { - final Properties properties; - try { - properties = getProperties(dme2Path); - this.proxyUrls = getProxyUrls(properties); - this.aafUsername = getAafUsername(properties); - this.aafPassword = getAafPassword(properties); - this.envContext = getEnvContext(properties); - this.routeOffer = getRouteOffer(properties); - this.commonServiceVersion = getCommonServiceVersion(properties); - this.partner = getPartner(properties); - } catch (final FileNotFoundException e) { - LOG.error("dme2.properties file could not be found at path: {}", dme2Path, e); - } catch (final IOException e) { - LOG.error("fatal error reading dme2.properties at path: {}", dme2Path, e); - } - } - - private static Path getDme2Path(final String sdncRootDirectory, final String dme2Filename) { - return Paths.get(sdncRootDirectory, dme2Filename); - } - - private static Properties getProperties(final String dme2Path) throws IOException { - final File dme2File = new File(dme2Path); - final Properties properties = new Properties(); - properties.load(new FileReader(dme2File)); - return properties; - } - - private String getProxyUrl(final Properties properties) { - return properties.getProperty(PROXY_URL_KEY); - } - - private Optional getProxyUrls(final Properties properties) { - final String proxyUrlsValue = getProxyUrl(properties); - if (!Strings.isNullOrEmpty(proxyUrlsValue)) { - return Optional.ofNullable(proxyUrlsValue.split(PROXY_URLS_VALUE_SEPARATOR)); - } - return Optional.empty(); - } - - public Optional getProxyUrls() { - return this.proxyUrls; - } - - private Optional getAafUsername(final Properties properties) { - final String aafUsernameValue = properties.getProperty(AAF_USERNAME_KEY); - return Optional.ofNullable(aafUsernameValue); - } - - Optional getAafUsername() { - return this.aafUsername; - } - - private Optional getAafPassword(final Properties properties) { - final String aafPassword = properties.getProperty(AAF_PASSWORD_KEY); - return Optional.ofNullable(aafPassword); - } - - Optional getAafPassword() { - return this.aafPassword; - } - - private Optional getEnvContext(final Properties properties) { - final String envContext = properties.getProperty(ENV_CONTEXT_KEY); - return Optional.ofNullable(envContext); - } - - Optional getEnvContext() { - return this.envContext; - } - - private Optional getRouteOffer(final Properties properties) { - final String routeOffer = properties.getProperty(ROUTE_OFFER_KEY); - return Optional.ofNullable(routeOffer); - } - - Optional getRouteOffer() { - return this.routeOffer; - } - - private Optional getCommonServiceVersion(final Properties properties) { - final String commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY); - return Optional.ofNullable(commonServiceVersion); - } - - Optional getCommonServiceVersion() { - return this.commonServiceVersion; - } - - private Optional getPartner(final Properties properties) { - final String partner = properties.getProperty(PARTNER_KEY); - return Optional.ofNullable(partner); - } - - Optional getPartner() { - return this.partner; - } + private static final Logger LOG = LoggerFactory.getLogger(Dme2PropertiesProvider.class); + + /** + * The name of the environment variable to specify the configuration directory. + */ + private static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR"; + + /** + * the dme2 properties file name. + */ + private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; + + /** + * the key for proxyUrl, which represents a CSV list of urls + */ + static final String PROXY_URL_KEY = "proxyUrl"; + + /** + * indicates that proxy urls are separated by commas + */ + private static final String PROXY_URLS_VALUE_SEPARATOR = ","; + + /** + * the key for aafUserName + */ + static final String AAF_USERNAME_KEY = "aafUserName"; + + /** + * the key for aafPassword + */ + static final String AAF_PASSWORD_KEY = "aafPassword"; + + /** + * the key for envContext + */ + static final String ENV_CONTEXT_KEY = "envContext"; + + /** + * the key for routeOffer + */ + static final String ROUTE_OFFER_KEY = "routeOffer"; + + /** + * the key for commonServiceVersion + */ + static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; + + /** + * the key for partner + */ + static final String PARTNER_KEY = "partner"; + + private Optional proxyUrls = Optional.empty(); + + private Optional aafUsername = Optional.empty(); + + private Optional aafPassword = Optional.empty(); + + private Optional envContext = Optional.empty(); + + private Optional routeOffer = Optional.empty(); + + private Optional commonServiceVersion = Optional.empty(); + + private Optional partner = Optional.empty(); + + /** + * A prioritized list of strategies for resolving dme2 properties files. + */ + private Vector dme2PropertiesFileResolvers = new Vector<>(); + + /** + * Instantiates the properties provider, which involves loading the appropriate + * properties for dme2. + */ + public Dme2PropertiesProvider() { + this(DME2_PROPERTIES_FILE_NAME); + } + + /** + * Instantiates the properties provider, which involves loading the appropriate + * properties for dme2. + * + * @param dme2Path + * location of the dme2.properties file + */ + @VisibleForTesting + Dme2PropertiesProvider(final String dme2FileName) { + dme2PropertiesFileResolvers + .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); + dme2PropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); + + dme2PropertiesFileResolvers + .add(new JREFileResolver("Using property file (3) from JRE argument", Dme2PropertiesProvider.class)); + dme2PropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); + + File dme2File = getDme2File(dme2FileName); + + init(dme2File); + } + + private void init(final File dme2Path) { + final Properties properties; + try { + properties = getProperties(dme2Path); + this.proxyUrls = getProxyUrls(properties); + this.aafUsername = getAafUsername(properties); + this.aafPassword = getAafPassword(properties); + this.envContext = getEnvContext(properties); + this.routeOffer = getRouteOffer(properties); + this.commonServiceVersion = getCommonServiceVersion(properties); + this.partner = getPartner(properties); + } catch (final FileNotFoundException e) { + + LOG.error("dme2.properties file could not be found at path: {}", dme2Path, e); + } catch (final IOException e) { + LOG.error("fatal error reading dme2.properties at path: {}", dme2Path, e); + } + } + + /** + * Reports the method chosen for properties resolution to the + * Logger. + * + * @param message + * Some user friendly message + * @param fileOptional + * The file location of the chosen properties file + * @return the file location of the chosen properties file + */ + private static File reportSuccess(final String message, final Optional fileOptional) { + if (fileOptional.isPresent()) { + final File file = fileOptional.get(); + LOG.info("{} {}", message, file.getPath()); + return file; + } + return null; + } + + private File getDme2File(final String dme2Filename) { + + for (final PropertiesFileResolver dblibPropertiesFileResolver : dme2PropertiesFileResolvers) { + final Optional fileOptional = dblibPropertiesFileResolver.resolveFile(dme2Filename); + if (fileOptional.isPresent()) { + return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); + } + } + return (new File(dme2Filename)); + } + + private static Properties getProperties(final File dme2File) throws IOException { + + final Properties properties = new Properties(); + properties.load(new FileReader(dme2File)); + return properties; + } + + private String getProxyUrl(final Properties properties) { + return properties.getProperty(PROXY_URL_KEY); + } + + private Optional getProxyUrls(final Properties properties) { + final String proxyUrlsValue = getProxyUrl(properties); + if (!Strings.isNullOrEmpty(proxyUrlsValue)) { + return Optional.ofNullable(proxyUrlsValue.split(PROXY_URLS_VALUE_SEPARATOR)); + } + return Optional.empty(); + } + + public Optional getProxyUrls() { + return this.proxyUrls; + } + + private Optional getAafUsername(final Properties properties) { + final String aafUsernameValue = properties.getProperty(AAF_USERNAME_KEY); + return Optional.ofNullable(aafUsernameValue); + } + + Optional getAafUsername() { + return this.aafUsername; + } + + private Optional getAafPassword(final Properties properties) { + final String aafPassword = properties.getProperty(AAF_PASSWORD_KEY); + return Optional.ofNullable(aafPassword); + } + + Optional getAafPassword() { + return this.aafPassword; + } + + private Optional getEnvContext(final Properties properties) { + final String envContext = properties.getProperty(ENV_CONTEXT_KEY); + return Optional.ofNullable(envContext); + } + + Optional getEnvContext() { + return this.envContext; + } + + private Optional getRouteOffer(final Properties properties) { + final String routeOffer = properties.getProperty(ROUTE_OFFER_KEY); + return Optional.ofNullable(routeOffer); + } + + Optional getRouteOffer() { + return this.routeOffer; + } + + private Optional getCommonServiceVersion(final Properties properties) { + final String commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY); + return Optional.ofNullable(commonServiceVersion); + } + + Optional getCommonServiceVersion() { + return this.commonServiceVersion; + } + + private Optional getPartner(final Properties properties) { + final String partner = properties.getProperty(PARTNER_KEY); + return Optional.ofNullable(partner); + } + + Optional getPartner() { + return this.partner; + } } diff --git a/sliPluginUtils/provider/src/main/resources/dme2.properties b/sliPluginUtils/provider/src/main/resources/dme2.properties new file mode 100644 index 000000000..373448447 --- /dev/null +++ b/sliPluginUtils/provider/src/main/resources/dme2.properties @@ -0,0 +1,7 @@ +aafUserName=user@sample.com +aafPassword=fake +envContext=UAT +routeOffer=UAT +proxyUrl=http://sample.com:25055,http://sample.com:25055 +commonServiceVersion=1702.0 +partner= \ No newline at end of file diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml new file mode 100644 index 000000000..be4025b4a --- /dev/null +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-sliapi + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: sliapi :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + 0.11.1 + pom + import + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + + ${project.groupId} + sliapi-provider + ${project.version} + + + + diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml new file mode 100644 index 000000000..f3481cba8 --- /dev/null +++ b/sliapi/features/features-sliapi/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + features-sliapi + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: sliapi :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-sliapi + ${project.version} + xml + features + + + + diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 78bfb89a4..17fa8fb41 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -1,134 +1,23 @@ 4.0.0 + - sliapi - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - sliapi-features - - jar - - - - org.onap.ccsdk.sli.core - sliapi-model - - - org.onap.ccsdk.sli.core - sliapi-provider - config - xml - - - org.onap.ccsdk.sli.core - sliapi-provider - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - runtime - - - - - - - org.opendaylight.odlparent - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - - org.opendaylight.odlparent - features-test - test - ${odl.commons.opendaylight.version} - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - + org.onap.ccsdk.sli.core + sliapi-feature-aggregator + 0.2.1-SNAPSHOT + pom - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + features-sliapi + ccsdk-sliapi + diff --git a/sliapi/features/src/main/resources/features.xml b/sliapi/features/src/main/resources/features.xml deleted file mode 100644 index c5df348fa..000000000 --- a/sliapi/features/src/main/resources/features.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - odl-mdsal-broker - sdnc-sli - mvn:org.onap.ccsdk.sli.core/sliapi-model/${project.version} - mvn:org.onap.ccsdk.sli.core/sliapi-provider/${project.version} - mvn:org.onap.ccsdk.sli.core/sliapi-provider/${project.version}/xml/config - - - diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index cddcf6dd7..290524e32 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -1,18 +1,25 @@ 4.0.0 + - sliapi - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core sliapi-installer + 0.2.1-SNAPSHOT pom + ccsdk-sli-core :: sliapi :: ${project.artifactId} + - sdnc-sliapi - sdnc-sliapi - mvn:org.onap.ccsdk.sli.core/sliapi-features/${project.version}/xml/features + ccsdk-sliapi + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false @@ -20,10 +27,10 @@ org.onap.ccsdk.sli.core - sliapi-features + ${application.name} ${project.version} - features xml + features * @@ -133,5 +140,4 @@ - diff --git a/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml b/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml index e22c6f567..5f3e3af31 100644 --- a/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -8,9 +8,9 @@ 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. @@ -44,12 +44,6 @@ - - - ../provider/src/main/resources/initial/${feature-name}-provider.xml - ./etc/opendaylight/karaf/200-${feature-name}provider.xml - - diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 4ea88516a..bbdcea051 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -1,89 +1,29 @@ 4.0.0 + - sliapi - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core sliapi-model + 0.2.1-SNAPSHOT bundle - + ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - org.apache.felix - maven-bundle-plugin - true - - - * - - - - - org.opendaylight.yangtools - yang-maven-plugin - ${odl.yangtools.yang.maven.plugin.version} - - - org.opendaylight.mdsal - maven-sal-api-gen-plugin - ${odl.sal.api.gen.plugin.version} - jar - - - org.opendaylight.netconf - sal-rest-docgen-maven - ${odl.restconf.version} - jar - - - - - - generate-sources - - - ${yang.file.directory} - - - org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl - ${salGeneratorPath} - - - org.opendaylight.netconf.sal.rest.doc.maven.StaticDocGenerator - target/swagger - - - true - - - - - - - - org.opendaylight.mdsal - yang-binding - ${odl.mdsal.yang.binding.version} - - - org.opendaylight.yangtools - yang-common - ${odl.yangtools.version} - org.opendaylight.mdsal.model ietf-inet-types - ${odl.ietf-inet-types.version} org.opendaylight.mdsal.model ietf-yang-types - ${odl.ietf-yang-types.version} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index a08d8fcb8..46057da0f 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -1,56 +1,20 @@ - + 4.0.0 - - org.onap.ccsdk.sli.core - ccsdk-sli-core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + - pom org.onap.ccsdk.sli.core sliapi - 0.2.0-SNAPSHOT - - - sliapi - - - - - - - - org.onap.ccsdk.sli.core - sliapi-features - features - xml - ${project.version} - - - - org.onap.ccsdk.sli.core - sliapi-model - ${project.version} - - - org.onap.ccsdk.sli.core - sliapi-provider - ${project.version} - config - xml - - - org.onap.ccsdk.sli.core - sliapi-provider - ${project.version} - - - + 0.2.1-SNAPSHOT + pom - + ccsdk-sli-core :: sliapi model @@ -58,4 +22,8 @@ provider installer + + + sliapi + diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 5db9671d6..cb4dfc898 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -1,125 +1,53 @@ 4.0.0 + - sliapi - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core sliapi-provider + 0.2.1-SNAPSHOT bundle - - - - org.apache.felix - maven-bundle-plugin - true - - - org.opendaylight.controller.config.yang.config.sliapi.impl - * - - - - - org.opendaylight.yangtools - yang-maven-plugin - ${odl.yangtools.yang.maven.plugin.version} - - - config - - generate-sources - - - - - org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - ${jmxGeneratorPath} - - urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang - - - - - org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl - ${salGeneratorPath} - - - true - - - - - - org.opendaylight.mdsal - maven-sal-api-gen-plugin - ${odl.sal.api.gen.plugin.version} - jar - - - org.opendaylight.controller - yang-jmx-generator-plugin - ${odl.yang.jmx.generator.version} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/initial/sliapi-provider.xml - xml - config - - - - - - - - + ccsdk-sli-core :: sliapi :: ${project.artifactId} + + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + org.onap.ccsdk.sli.core sliapi-model - - - org.opendaylight.controller - config-api - ${odl.controller.config.api.version} + ${project.version} org.opendaylight.controller sal-binding-config - ${odl.mdsal.version} org.opendaylight.controller sal-binding-api - ${odl.mdsal.version} org.opendaylight.controller sal-common-util - ${odl.mdsal.version} @@ -136,12 +64,10 @@ org.opendaylight.controller sal-core-api - ${odl.mdsal.version} org.opendaylight.yangtools yang-data-impl - ${odl.yangtools.version} diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index 82e660083..c3ad4ed60 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -31,6 +31,7 @@ import java.util.Properties; import java.util.concurrent.Future; import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.binding.impl.AbstractForwardedDataBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -118,7 +119,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ protected DataBroker dataBroker; protected DOMDataBroker domDataBroker; - protected NotificationProviderService notificationService; + protected NotificationPublishService notificationService; protected RpcProviderRegistry rpcRegistry; protected BindingAwareBroker.RpcRegistration rpcRegistration; @@ -142,16 +143,24 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } - public sliapiProvider() { + public sliapiProvider( + DataBroker dataBroker, + NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry) { this.LOG.info( "Creating provider for " + appName ); + this.dataBroker = dataBroker; + this.notificationService = notificationPublishService; + this.rpcRegistry = rpcProviderRegistry; + initialize(); } + + public void initialize(){ LOG.info( "Initializing provider for " + appName ); //initialization code goes here. sdncStatusFile = System.getenv(SDNC_STATUS_FILE); LOG.info( "SDNC STATUS FILE = " + sdncStatusFile ); - rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); LOG.info( "Initialization complete for " + appName ); } @@ -179,7 +188,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } public void setNotificationService( - NotificationProviderService notificationService) { + NotificationPublishService notificationService) { this.notificationService = notificationService; if( LOG.isDebugEnabled() ){ LOG.debug( "Notification Service set to " + (notificationService==null?"null":"non-null") + "." ); diff --git a/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModule.java b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModule.java deleted file mode 100644 index e7444e318..000000000 --- a/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModule.java +++ /dev/null @@ -1,64 +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.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523; - -import org.onap.ccsdk.sli.core.sliapi.sliapiProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SliapiProviderModule extends org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523.AbstractSliapiProviderModule { - private final Logger LOG = LoggerFactory.getLogger( SliapiProviderModule.class ); - - public SliapiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public SliapiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523.SliapiProviderModule oldModule, java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - - LOG.info("Calling SliapiProviderModule.createInstance"); - final sliapiProvider provider = new sliapiProvider(); - provider.setDataBroker( getDataBrokerDependency() ); - provider.setNotificationService( getNotificationServiceDependency() ); - provider.setRpcRegistry( getRpcRegistryDependency() ); - provider.initialize(); - return new AutoCloseable() { - - @Override - public void close() throws Exception { - //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION - //SERVIE/RPC REGISTRY - provider.close(); - } - }; - } - -} diff --git a/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java b/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java deleted file mode 100644 index 6454d17c4..000000000 --- a/sliapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/ccsdk/sli/core/sliapi/provider/impl/rev140523/SliapiProviderModuleFactory.java +++ /dev/null @@ -1,34 +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========================================================= - */ - -/* -* Generated file -* -* Generated from: yang module name: sliapi-provider-impl yang module local name: sliapi-provider-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Thu Aug 03 16:10:18 EDT 2017 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523; -public class SliapiProviderModuleFactory extends org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.provider.impl.rev140523.AbstractSliapiProviderModuleFactory { - -} diff --git a/sliapi/provider/src/main/resources/initial/sliapi-provider.xml b/sliapi/provider/src/main/resources/initial/sliapi-provider.xml deleted file mode 100644 index 47d31d0ab..000000000 --- a/sliapi/provider/src/main/resources/initial/sliapi-provider.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - prefix:sliapi-provider-impl - - sliapi-provider-impl - - - - binding:binding-rpc-registry - binding-rpc-broker - - - - binding:binding-async-data-broker - binding-data-broker - - - - - binding:binding-notification-service - - binding-notification-broker - - - - - - - - - - - org:onap:ccsdk:sli:core:sliapi:provider:impl?module=sliapi-provider-impl&revision=2014-05-23 - - - diff --git a/sliapi/provider/src/main/resources/org/opendaylight/blueprint/sliapi-blueprint.xml b/sliapi/provider/src/main/resources/org/opendaylight/blueprint/sliapi-blueprint.xml new file mode 100644 index 000000000..761b014a0 --- /dev/null +++ b/sliapi/provider/src/main/resources/org/opendaylight/blueprint/sliapi-blueprint.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml new file mode 100644 index 000000000..9a4cd43c5 --- /dev/null +++ b/utils/features/features-util/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + features-util + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: utils :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-slicore-utils + ${project.version} + xml + features + + + + diff --git a/utils/features/features3-util/pom.xml b/utils/features/features3-util/pom.xml new file mode 100755 index 000000000..5cc0d8995 --- /dev/null +++ b/utils/features/features3-util/pom.xml @@ -0,0 +1,141 @@ + + + 4.0.0 + + utils + org.onap.ccsdk.sli.core + 0.2.0-SNAPSHOT + + + org.onap.ccsdk.sli.core + utils-features + ccsdk-sli-core :: utils :: ${project.artifactId} + DBLIB Adaptor - Features + + jar + + + + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + + + + commons-lang + commons-lang + ${commons.lang.version} + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + + + org.opendaylight.odlparent + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/utils/features/features3-util/src/main/resources/features.xml b/utils/features/features3-util/src/main/resources/features.xml new file mode 100755 index 000000000..547832ba6 --- /dev/null +++ b/utils/features/features3-util/src/main/resources/features.xml @@ -0,0 +1,16 @@ + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + + odl-mdsal-broker + mvn:org.onap.ccsdk.sli.core/utils-provider/${project.version} + + + diff --git a/utils/features/pom.xml b/utils/features/pom.xml index be6227d7e..8bc1cd8a8 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -1,138 +1,22 @@ - 4.0.0 - - utils - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT - - utils-features - DBLIB Adaptor - Features + 4.0.0 - jar + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + - + org.onap.ccsdk.sli.core + utils-features-aggregator + pom + ccsdk-sli-core :: utils :: ${project.artifactId} - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - - - - commons-lang - commons-lang - ${commons.lang.version} - compile - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - runtime - - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - - - org.opendaylight.odlparent - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + + features-util + sdnc-slicore-utils + diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml new file mode 100644 index 000000000..85c81ff67 --- /dev/null +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.0.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-slicore-utils + 0.2.1-SNAPSHOT + feature + + ccsdk-sli-core :: utils :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + 0.11.1 + pom + import + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + org.opendaylight.controller + odl-mdsal-broker + xml + features + + + + ${project.groupId} + utils-provider + ${project.version} + + + + diff --git a/utils/features/src/main/resources/features.xml b/utils/features/src/main/resources/features.xml deleted file mode 100755 index 547832ba6..000000000 --- a/utils/features/src/main/resources/features.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - - odl-mdsal-broker - mvn:org.onap.ccsdk.sli.core/utils-provider/${project.version} - - - diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index df7fc0de8..c19ac8c67 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -1,19 +1,25 @@ 4.0.0 + - utils - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + + org.onap.ccsdk.sli.core utils-installer - SLI core utils - Karaf Installer + 0.2.1-SNAPSHOT pom + ccsdk-sli-core :: utils :: ${project.artifactId} + - sdnc-slicore-utils - sdnc-slicore-utils - mvn:org.onap.ccsdk.sli.core/utils-features/${project.version}/xml/features + ccsdk-slicore-utils + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false @@ -21,10 +27,10 @@ org.onap.ccsdk.sli.core - utils-features + ${application.name} ${project.version} - features xml + features * @@ -134,5 +140,4 @@ - diff --git a/utils/pom.xml b/utils/pom.xml index 17a0f6b6e..cd342f774 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -1,77 +1,26 @@ - - - org.onap.ccsdk.sli.core - ccsdk-sli-core - 0.2.0-SNAPSHOT + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.0.1-SNAPSHOT + + org.onap.ccsdk.sli.core + utils + 0.2.1-SNAPSHOT + pom - 4.0.0 - pom - org.onap.ccsdk.sli.core - utils - - - SLI Utils - Utilities used across sli-core - - 0.2.0-SNAPSHOT - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compile.plugin.version} - - ${java.version.source} - ${java.version.target} - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10 - - - - aggregate - - aggregate - - site - - - - - - maven-source-plugin - 2.1.1 - - - bundle-sources - package - - - jar-no-fork - - - test-jar-no-fork - - - - - - - - - - AT&T + ccsdk-sli-core :: utils + Utilities used across sli-core + + ONAP - + + provider features installer diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index b0adc7d46..7a4e8c9ed 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -1,21 +1,26 @@ - + + 4.0.0 - org.onap.ccsdk.sli.core - utils - 0.2.0-SNAPSHOT + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + - 4.0.0 - bundle + org.onap.ccsdk.sli.core utils-provider - SLI Core Utilities Package + 0.2.1-SNAPSHOT + bundle + ccsdk-sli-core :: utils :: ${project.artifactId} The SLI Core Utilities Package provides common functionality for setting up SLI connectivity. + + ONAP + @@ -26,6 +31,7 @@ equinoxSDK381 org.eclipse.osgi ${equinox.osgi.version} + provided @@ -41,17 +47,4 @@ test - - - - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - - - - - Inocybe Technologies and Others - 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 8da9b7ef0..cc164d042 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 @@ -7,9 +7,9 @@ * 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. @@ -54,9 +54,11 @@ public class JREFileResolver implements PropertiesFileResolver { */ @Override public Optional resolveFile(final String filename) { + final Bundle bundle = FrameworkUtil.getBundle(this.clazz); final File dataFile; + try { if (bundle == null) { return Optional.empty(); @@ -67,6 +69,7 @@ public class JREFileResolver implements PropertiesFileResolver { return Optional.empty(); } + dataFile = bundle.getDataFile(filename); if(dataFile.exists()) { dataFile.delete(); -- cgit 1.2.3-korg From 7f2452b38b0d69ce51888ec0aefc7ada4281e864 Mon Sep 17 00:00:00 2001 From: Kevin Smokowski Date: Fri, 9 Feb 2018 21:36:38 +0000 Subject: Reset MDC after invoking node collapse get node into a common metho, reset MDC right before getting next node for certain executor Change-Id: I85b1cf0dfd595deee42dc93f4095ecbc6c831998 Issue-ID: CCSDK-187 Signed-off-by: Kevin Smokowski --- .../org/onap/ccsdk/sli/core/sli/MetricLogger.java | 9 ++ .../sli/core/sli/provider/DeleteNodeExecutor.java | 96 +++++------- .../sli/core/sli/provider/ExecuteNodeExecutor.java | 22 +-- .../sli/core/sli/provider/ExistsNodeExecutor.java | 112 ++++++-------- .../core/sli/provider/GetResourceNodeExecutor.java | 163 ++++++++------------- .../core/sli/provider/IsAvailableNodeExecutor.java | 96 ++++-------- .../sli/core/sli/provider/NotifyNodeExecutor.java | 98 +++++-------- .../sli/core/sli/provider/RecordNodeExecutor.java | 125 ++++++---------- .../sli/core/sli/provider/ReleaseNodeExecutor.java | 95 +++++------- .../sli/core/sli/provider/ReserveNodeExecutor.java | 109 ++++++-------- .../sli/core/sli/provider/SaveNodeExecutor.java | 141 +++++++----------- .../core/sli/provider/SvcLogicNodeExecutor.java | 23 ++- .../sli/core/sli/provider/UpdateNodeExecutor.java | 131 +++++++---------- 13 files changed, 459 insertions(+), 761 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 394ec0af2..9d263456c 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -304,4 +304,13 @@ public class MetricLogger { str = str.replaceAll("\\|","%7C"); //log records should not contain a pipe, encode the pipe character return str; } + + public static void resetContext() { + MDC.remove(TARGET_ENTITY); + MDC.remove(TARGET_SERVICE_NAME); + MDC.remove(TARGET_VIRTUAL_ENTITY); + MDC.remove(STATUS_CODE); + MDC.remove(RESPONSE_CODE); + MDC.remove(RESPONSE_DESCRIPTION); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java index 4eba29d58..a7c3c8e63 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java @@ -30,72 +30,44 @@ import org.slf4j.LoggerFactory; public class DeleteNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(DeleteNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { + private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class); - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { - String outValue = "failure"; + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - if (LOG.isDebugEnabled()) { - LOG.debug("delete node encountered - looking for resource class " - + plugin); - } + String outValue = "failure"; + if (LOG.isDebugEnabled()) { + LOG.debug("delete node encountered - looking for resource class " + plugin); + } - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - - switch (resourcePlugin.delete(resourceType, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + try { + switch (resourcePlugin.delete(resourceType, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java index eb06f66b2..2da0241ab 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java @@ -118,26 +118,7 @@ public class ExecuteNodeExecutor extends SvcLogicNodeExecutor { } } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no " + outValue + " or Other branch found"); - } - } - return (nextNode); + return (getNextNode(node, outValue)); } protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { @@ -152,7 +133,6 @@ public class ExecuteNodeExecutor extends SvcLogicNodeExecutor { } else { return "success"; } - } else { return "success"; } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java index 3a59a2d6c..69b1132b9 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java @@ -30,76 +30,46 @@ import org.slf4j.LoggerFactory; public class ExistsNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(ExistsNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("exists node encountered - looking for resource class " - + plugin); - } - - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - - try { - - switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) { - case SUCCESS: - outValue = "true"; - break; - case NOT_FOUND: - outValue = "false"; - break; - case FAILURE: - default: - outValue = "false"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + private static final Logger LOG = LoggerFactory.getLogger(ExistsNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("exists node encountered - looking for resource class " + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + try { + switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) { + case SUCCESS: + outValue = "true"; + break; + case NOT_FOUND: + outValue = "false"; + break; + case FAILURE: + default: + outValue = "false"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java index 82734af64..64cf5bc97 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java @@ -31,104 +31,69 @@ import org.slf4j.LoggerFactory; public class GetResourceNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(GetResourceNodeExecutor.class); - - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); - - String localOnlyStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("local-only"), node, ctx); - - // Note: for get-resource, only refresh from A&AI if the DG explicitly set - // local-only to false. Otherwise, just read from local database. - boolean localOnly = true; - - if ("false".equalsIgnoreCase(localOnlyStr)) { - localOnly = false; - } - - SvcLogicExpression selectExpr = node.getAttribute("select"); - String select = null; - - if (selectExpr != null) { - select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, - ctx); - } - - SvcLogicExpression orderByExpr = node.getAttribute("order-by"); - String orderBy = null; - - if (orderByExpr != null) { - orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, - ctx); - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug(node.getNodeType() - + " node encountered - looking for resource class " - + plugin); - } - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.query(resourceType, localOnly, select, key, - pfx, orderBy, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + private static final Logger LOG = LoggerFactory.getLogger(GetResourceNodeExecutor.class); + + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx); + + // Note: for get-resource, only refresh from A&AI if the DG explicitly set + // local-only to false. Otherwise, just read from local database. + boolean localOnly = true; + + if ("false".equalsIgnoreCase(localOnlyStr)) { + localOnly = false; + } + + SvcLogicExpression selectExpr = node.getAttribute("select"); + String select = null; + + if (selectExpr != null) { + select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); + } + + SvcLogicExpression orderByExpr = node.getAttribute("order-by"); + String orderBy = null; + + if (orderByExpr != null) { + orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, ctx); + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug(node.getNodeType() + " node encountered - looking for resource class " + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + try { + switch (resourcePlugin.query(resourceType, localOnly, select, key, pfx, orderBy, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java index 2d8377cdf..d2a4bfad4 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java @@ -30,74 +30,42 @@ import org.slf4j.LoggerFactory; public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(IsAvailableNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { + private static final Logger LOG = LoggerFactory.getLogger(IsAvailableNodeExecutor.class); - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { - String outValue = "failure"; + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - if (LOG.isDebugEnabled()) { - LOG.debug("is-available node encountered - looking for resource class " - + plugin); - } + String outValue = "failure"; - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - try { - switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) { - case SUCCESS: - outValue = "true"; - break; - case NOT_FOUND: - outValue = "false"; - break; - case FAILURE: - default: - outValue = "false"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + if (resourcePlugin != null) { + try { + switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) { + case SUCCESS: + outValue = "true"; + break; + case NOT_FOUND: + outValue = "false"; + break; + case FAILURE: + default: + outValue = "false"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java index ba8d9ba53..cfeab7975 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java @@ -30,73 +30,45 @@ import org.slf4j.LoggerFactory; public class NotifyNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(NotifyNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { + private static final Logger LOG = LoggerFactory.getLogger(NotifyNodeExecutor.class); - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String action = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("action"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { - String outValue = "failure"; + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String action = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("action"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - if (LOG.isDebugEnabled()) { - LOG.debug("release node encountered - looking for resource class " - + plugin); - } + String outValue = "failure"; - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - - switch (resourcePlugin.notify(resourceType, action, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } + if (LOG.isDebugEnabled()) { + LOG.debug("release node encountered - looking for resource class " + plugin); + } - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + try { + switch (resourcePlugin.notify(resourceType, action, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java index 9ed28d79f..42e215356 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; - import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -36,84 +35,48 @@ import org.slf4j.LoggerFactory; public class RecordNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(RecordNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String outValue = "failure"; - - if (LOG.isTraceEnabled()) { - LOG.trace(node.getNodeType() - + " node encountered - looking for recorder class " - + plugin); - } - - Map parmMap = new HashMap(); - - Set> parmSet = node - .getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, - node, ctx); - - if (LOG.isTraceEnabled()) { - LOG.trace("executeRecordNode : parameter " + curName + " = " - + curExpr + " => " + curExprValue); - } - parmMap.put(curName, curExprValue); - } - - - SvcLogicRecorder recorder = getSvcLogicRecorder(plugin); - - if (recorder != null) { - - try { - recorder.record(parmMap); - } catch (SvcLogicException e) { - LOG.error("Caught exception from recorder plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicRecorder object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isTraceEnabled()) { - LOG.trace("no failure or Other branch found"); - } - } - return (nextNode); - } - - - - - + private static final Logger LOG = LoggerFactory.getLogger(RecordNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String outValue = "failure"; + + if (LOG.isTraceEnabled()) { + LOG.trace(node.getNodeType() + " node encountered - looking for recorder class " + plugin); + } + + Map parmMap = new HashMap(); + + Set> parmSet = node.getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + if (LOG.isTraceEnabled()) { + LOG.trace("executeRecordNode : parameter " + curName + " = " + curExpr + " => " + curExprValue); + } + parmMap.put(curName, curExprValue); + } + + SvcLogicRecorder recorder = getSvcLogicRecorder(plugin); + if (recorder != null) { + try { + recorder.record(parmMap); + } catch (SvcLogicException e) { + LOG.error("Caught exception from recorder plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicRecorder object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java index 58013cb8b..c1ea96412 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java @@ -30,71 +30,44 @@ import org.slf4j.LoggerFactory; public class ReleaseNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(ReleaseNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { + private static final Logger LOG = LoggerFactory.getLogger(ReleaseNodeExecutor.class); - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { - String outValue = "failure"; + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - if (LOG.isDebugEnabled()) { - LOG.debug("release node encountered - looking for resource class " - + plugin); - } + String outValue = "failure"; - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - - switch (resourcePlugin.release(resourceType, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } + if (LOG.isDebugEnabled()) { + LOG.debug("release node encountered - looking for resource class " + plugin); + } - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + try { + switch (resourcePlugin.release(resourceType, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java index fc180a71d..646650c68 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java @@ -31,84 +31,57 @@ import org.slf4j.LoggerFactory; public class ReserveNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(ReserveNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"),node,ctx); - - + private static final Logger LOG = LoggerFactory.getLogger(ReserveNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + SvcLogicExpression selectExpr = node.getAttribute("select"); String select = null; - if (selectExpr != null) - { - select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); + if (selectExpr != null) { + select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); } - String outValue = "failure"; + String outValue = "failure"; - if (LOG.isDebugEnabled()) { - LOG.debug("reserve node encountered - looking for resource class " - + plugin); - } + if (LOG.isDebugEnabled()) { + LOG.debug("reserve node encountered - looking for resource class " + plugin); + } SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java index 2df85ac8f..d2b8b0a50 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; - import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -36,107 +35,73 @@ import org.slf4j.LoggerFactory; public class SaveNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(SaveNodeExecutor.class); + private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String forceStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("force"), node, ctx); - String localOnlyStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("local-only"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String forceStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("force"), node, ctx); + String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - boolean force = "true".equalsIgnoreCase(forceStr); - boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); + boolean force = "true".equalsIgnoreCase(forceStr); + boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); - Map parmMap = new HashMap(); + Map parmMap = new HashMap(); - Set> parmSet = node - .getParameterSet(); - boolean hasParms = false; + Set> parmSet = node.getParameterSet(); + boolean hasParms = false; - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate( - curExpr, node, ctx); + for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - LOG.debug("Parameter " + curName + " = " - + curExpr.asParsedExpr() + " resolves to " - + curExprValue); + LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); - parmMap.put(curName, curExprValue); - } - } + parmMap.put(curName, curExprValue); + } + } - String outValue = "failure"; + String outValue = "failure"; - if (LOG.isDebugEnabled()) { - LOG.debug("save node encountered - looking for resource class " - + plugin); - } + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + plugin); + } SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.save(resourceType, force, localOnly, key, - parmMap, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.save(resourceType, force, localOnly, key, parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java index 951536b50..0cfcfb91a 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider; +import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -28,7 +29,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; @@ -103,5 +103,26 @@ public abstract class SvcLogicNodeExecutor { return plugin; } } + protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) { + MetricLogger.resetContext(); + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + return (nextNode); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java index 9206b5d86..148745f62 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; - import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -36,101 +35,69 @@ import org.slf4j.LoggerFactory; public class UpdateNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(UpdateNodeExecutor.class); + private static final Logger LOG = LoggerFactory.getLogger(UpdateNodeExecutor.class); - @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { + @Override + public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { - String plugin = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate( - node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey( - node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate( - node.getAttribute("pfx"), node, ctx); + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - Map parmMap = new HashMap(); + Map parmMap = new HashMap(); - Set> parmSet = node - .getParameterSet(); - boolean hasParms = false; + Set> parmSet = node.getParameterSet(); + boolean hasParms = false; - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate( - curExpr, node, ctx); + for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - LOG.debug("Parameter " + curName + " = " - + curExpr.asParsedExpr() + " resolves to " - + curExprValue); + LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); - parmMap.put(curName, curExprValue); - } - } + parmMap.put(curName, curExprValue); + } + } - String outValue = "failure"; + String outValue = "failure"; - if (LOG.isDebugEnabled()) { - LOG.debug("save node encountered - looking for resource class " - + plugin); - } + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + plugin); + } SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.update(resourceType, key, - parmMap, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " - + plugin); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no "+outValue+" or Other branch found"); - } - } - return (nextNode); - } + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.update(resourceType, key, parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } } -- cgit 1.2.3-korg From 650bf0cbd81be4af3203103188e69f68fdca3a01 Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Wed, 14 Feb 2018 14:17:50 +0000 Subject: Fixed Java Code Conventions issue Changes made: * corrected sonar related issue in CachedDataSource class Change-Id: If84b9abcd115ad042f2cc0527b5ab8c8e12cae5a Issue-ID: CCSDK-151 Signed-off-by: Rich Tabedzki --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 1023 ++++++++++---------- 1 file changed, 511 insertions(+), 512 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 8dac33611..e5eff24a5 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -56,516 +56,515 @@ import org.slf4j.LoggerFactory; public abstract class CachedDataSource implements DataSource, SQLExecutionMonitorObserver { - private static final Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); - - private static final String SQL_FAILURE = "SQL FAILURE. time(ms): "; - private static final String FAILED_TO_EXECUTE = "> Failed to execute: "; - private static final String WITH_ARGUMENTS = " with arguments: "; - private static final String WITH_NO_ARGUMENTS = " with no arguments. "; - private static final String SQL_DATA_SOURCE = "SQL DataSource <"; - - protected long connReqTimeout = 30L; - protected long dataReqTimeout = 100L; - - private final SQLExecutionMonitor monitor; - protected DataSource ds = null; - protected String connectionName = null; - protected boolean initialized = false; - - private long interval = 1000; - private long initialDelay = 5000; - private long expectedCompletionTime = 50L; - private boolean canTakeOffLine = true; - private long unprocessedFailoverThreshold = 3L; - - private long nextErrorReportTime = 0L; - - private String globalHostName = null; - - private boolean isDerby = false; - - public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { - configure(jdbcElem); - - if ("org.apache.derby.jdbc.EmbeddedDriver".equals(jdbcElem.getDriverName())) { - isDerby = true; - } - monitor = new SQLExecutionMonitor(this); - } - - protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; - - /* - * (non-Javadoc) - * - * @see javax.sql.DataSource#getConnection() - */ - @Override - public Connection getConnection() throws SQLException { - return ds.getConnection(); - } - - public CachedRowSet getData(String statement, List arguments) throws SQLException { - TestObject testObject = monitor.registerRequest(); - - try (Connection connection = this.getConnection()) { - if (connection == null) { - throw new SQLException("Connection invalid"); - } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); - } - return executePreparedStatement(connection, statement, arguments, true); - } finally { - monitor.deregisterRequest(testObject); - } - } - - public boolean writeData(String statement, List arguments) throws SQLException { - TestObject testObject = monitor.registerRequest(); - - try (Connection connection = this.getConnection()) { - if (connection == null) { - throw new SQLException("Connection invalid"); - } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); - } - return executeUpdatePreparedStatement(connection, statement, arguments, true); - } finally { - monitor.deregisterRequest(testObject); - } - } - - CachedRowSet executePreparedStatement(Connection conn, String statement, List arguments, boolean close) - throws SQLException { - long time = System.currentTimeMillis(); - - CachedRowSet data = null; - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL Statement: {}", statement); - if (arguments != null && !arguments.isEmpty()) { - LOGGER.debug("Argunments: {}", arguments); - } - } - - ResultSet rs = null; - try (PreparedStatement ps = conn.prepareStatement(statement)) { - data = RowSetProvider.newFactory().createCachedRowSet(); - if (arguments != null) { - for (int i = 0, max = arguments.size(); i < max; i++) { - ps.setObject(i + 1, arguments.get(i)); - } - } - rs = ps.executeQuery(); - data.populate(rs); - // Point the rowset Cursor to the start - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), - (System.currentTimeMillis() - time)); - } - } catch (SQLException exc) { - handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); - } finally { - handleFinallyBlockForExecutePreparedStatement(rs, conn, close); - } - - return data; - } - - private void handleSqlExceptionForExecuteStatement(Connection conn, String statement, List arguments, - SQLException exc, long time) throws SQLException { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(SQL_FAILURE + (System.currentTimeMillis() - time)); - } - try { - conn.rollback(); - } catch (Exception thr) { - LOGGER.error(thr.getLocalizedMessage(), thr); - } - if (arguments != null && !arguments.isEmpty()) { - LOGGER.error(String.format("<%s%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_ARGUMENTS, - arguments), exc); - } else { - LOGGER.error(String.format("<%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_NO_ARGUMENTS), - exc); - } - throw exc; - } - - private void handleFinallyBlockForExecutePreparedStatement(ResultSet rs, Connection conn, boolean close) { - try { - if (rs != null) { - rs.close(); - } - } catch (Exception exc) { - LOGGER.error(exc.getLocalizedMessage(), exc); - } - try { - if (conn != null && close) { - conn.close(); - } - } catch (Exception exc) { - LOGGER.error(exc.getLocalizedMessage(), exc); - } - } - - boolean executeUpdatePreparedStatement(Connection conn, String statement, List arguments, boolean close) - throws SQLException { - long time = System.currentTimeMillis(); - - CachedRowSet data; - - try (PreparedStatement ps = conn.prepareStatement(statement)) { - data = RowSetProvider.newFactory().createCachedRowSet(); - if (arguments != null) { - prepareStatementForExecuteUpdate(arguments, ps); - } - ps.executeUpdate(); - // Point the rowset Cursor to the start - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), - (System.currentTimeMillis() - time)); - } - ps.close(); - } catch (SQLException exc) { - handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); - } finally { - try { - if (close) { - conn.close(); - } - } catch (Exception exc) { - LOGGER.error(exc.getLocalizedMessage(), exc); - } - } - - return true; - } - - private void prepareStatementForExecuteUpdate(List arguments, PreparedStatement ps) throws SQLException { - for (int i = 0, max = arguments.size(); i < max; i++) { - Object value = arguments.get(i); - if (value instanceof Blob) { - ps.setBlob(i + 1, (Blob) value); - } else if (value instanceof Timestamp) { - ps.setTimestamp(i + 1, (Timestamp) value); - } else if (value instanceof Integer) { - ps.setInt(i + 1, (Integer) value); - } else if (value instanceof Long) { - ps.setLong(i + 1, (Long) value); - } else if (value instanceof Date) { - ps.setDate(i + 1, (Date) value); - } else { - ps.setObject(i + 1, value); - } - } - } - - /* - * (non-Javadoc) - * - * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) - */ - @Override - public Connection getConnection(String username, String password) throws SQLException { - return ds.getConnection(username, password); - } - - /* - * (non-Javadoc) - * - * @see javax.sql.DataSource#getLogWriter() - */ - @Override - public PrintWriter getLogWriter() throws SQLException { - return ds.getLogWriter(); - } - - /* - * (non-Javadoc) - * - * @see javax.sql.DataSource#getLoginTimeout() - */ - @Override - public int getLoginTimeout() throws SQLException { - return ds.getLoginTimeout(); - } - - /* - * (non-Javadoc) - * - * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) - */ - @Override - public void setLogWriter(PrintWriter out) throws SQLException { - ds.setLogWriter(out); - } - - /* - * (non-Javadoc) - * - * @see javax.sql.DataSource#setLoginTimeout(int) - */ - @Override - public void setLoginTimeout(int seconds) throws SQLException { - ds.setLoginTimeout(seconds); - } - - @Override - public final String getDbConnectionName() { - return connectionName; - } - - protected final void setDbConnectionName(String name) { - this.connectionName = name; - } - - public void cleanUp() { - if (ds != null && ds instanceof Closeable) { - try { - ((Closeable) ds).close(); - } catch (IOException e) { - LOGGER.warn(e.getMessage()); - } - } - ds = null; - monitor.deleteObservers(); - monitor.cleanup(); - } - - public boolean isInitialized() { - return initialized; - } - - protected boolean testConnection() { - return testConnection(false); - } - - protected boolean testConnection(boolean errorLevel) { - ResultSet rs = null; - try (Connection conn = this.getConnection(); Statement stmt = conn.createStatement()) { - Boolean readOnly; - String hostname; - rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); // ("SELECT 1 FROM DUAL"); //"select - // BANNER from SYS.V_$VERSION" - while (rs.next()) { - readOnly = rs.getBoolean(1); - hostname = rs.getString(2); - - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(SQL_DATA_SOURCE + getDbConnectionName() + "> connected to " + hostname - + ", read-only is " + readOnly + ", tested successfully "); - } - } - } catch (Exception exc) { - if (errorLevel) { - LOGGER.error( - SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); - } else { - LOGGER.info( - SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); - } - return false; - } finally { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - LOGGER.error(e.getLocalizedMessage(), e); - } - } - } - return true; - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } - - @Override - public T unwrap(Class iface) throws SQLException { - return null; - } - - @SuppressWarnings("deprecation") - public void setConnectionCachingEnabled(boolean state) { - // if(ds != null && ds instanceof OracleDataSource) - // try { - // ((OracleDataSource)ds).setConnectionCachingEnabled(true); - // } catch (SQLException exc) { - // LOGGER.warn("", exc); - // } - } - - public void addObserver(Observer observer) { - monitor.addObserver(observer); - } - - public void deleteObserver(Observer observer) { - monitor.deleteObserver(observer); - } - - @Override - public long getInterval() { - return interval; - } - - @Override - public long getInitialDelay() { - return initialDelay; - } - - @Override - public void setInterval(long value) { - interval = value; - } - - @Override - public void setInitialDelay(long value) { - initialDelay = value; - } - - @Override - public long getExpectedCompletionTime() { - return expectedCompletionTime; - } - - @Override - public void setExpectedCompletionTime(long value) { - expectedCompletionTime = value; - } - - @Override - public long getUnprocessedFailoverThreshold() { - return unprocessedFailoverThreshold; - } - - @Override - public void setUnprocessedFailoverThreshold(long value) { - this.unprocessedFailoverThreshold = value; - } - - public boolean canTakeOffLine() { - return canTakeOffLine; - } - - public void blockImmediateOffLine() { - canTakeOffLine = false; - final Thread offLineTimer = new Thread(() -> { - try { - Thread.sleep(30000L); - } catch (Exception exc) { - LOGGER.error(exc.getLocalizedMessage(), exc); - } finally { - canTakeOffLine = true; - } - }); - offLineTimer.setDaemon(true); - offLineTimer.start(); - } - - /** - * @return the monitor - */ - final SQLExecutionMonitor getMonitor() { - return monitor; - } - - protected boolean isSlave() throws PoolExhaustedException { - - // If using Apache derby, just return false - if (isDerby) { - return false; - } - CachedRowSet rs; - boolean isSlave; - String hostname = "UNDETERMINED"; - try { - boolean localSlave = true; - rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList<>()); - while (rs.next()) { - localSlave = rs.getBoolean(1); - hostname = rs.getString(2); - } - isSlave = localSlave; - } catch (PoolExhaustedException peexc) { - throw peexc; - } catch (Exception e) { - LOGGER.error("", e); - isSlave = true; - } - if (isSlave) { - LOGGER.debug("SQL SLAVE : {} on server {}", connectionName, hostname); - } else { - LOGGER.debug("SQL MASTER : {} on server {}", connectionName, hostname); - } - return isSlave; - } - - public boolean isFabric() { - return false; - } - - protected boolean lockTable(Connection conn, String tableName) { - boolean retValue = false; - String query = "LOCK TABLES " + tableName + " WRITE"; - try (Statement preStmt = conn.createStatement(); - Statement lock = conn.prepareStatement(query); - ResultSet rs = preStmt.executeQuery("GETDATE()")) { - if (tableName != null) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); - if ("SVC_LOGIC".equals(tableName)) { - Exception e = new Exception(); - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - LOGGER.debug(sw.toString()); - } - } - lock.execute(query); - retValue = true; - } - } catch (Exception exc) { - LOGGER.error("", exc); - retValue = false; - } - return retValue; - } - - protected boolean unlockTable(Connection conn) { - boolean retValue; - try (Statement lock = conn.createStatement()) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Executing 'UNLOCK TABLES' on connection {}", conn); - } - retValue = lock.execute("UNLOCK TABLES"); - } catch (Exception exc) { - LOGGER.error("", exc); - retValue = false; - } - return retValue; - } - - public void getPoolInfo(boolean allocation) { - - } - - public long getNextErrorReportTime() { - return nextErrorReportTime; - } - - public void setNextErrorReportTime(long nextTime) { - this.nextErrorReportTime = nextTime; - } - - public void setGlobalHostName(String hostname) { - this.globalHostName = hostname; - } - - public String getGlobalHostName() { - return globalHostName; - } + private static final Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); + + private static final String SQL_FAILURE = "SQL FAILURE. time(ms): "; + private static final String FAILED_TO_EXECUTE = "> Failed to execute: "; + private static final String WITH_ARGUMENTS = " with arguments: "; + private static final String WITH_NO_ARGUMENTS = " with no arguments. "; + private static final String SQL_DATA_SOURCE = "SQL DataSource <"; + + protected long connReqTimeout = 30L; + protected long dataReqTimeout = 100L; + + private final SQLExecutionMonitor monitor; + protected DataSource ds = null; + protected String connectionName = null; + protected boolean initialized = false; + + private long interval = 1000; + private long initialDelay = 5000; + private long expectedCompletionTime = 50L; + private boolean canTakeOffLine = true; + private long unprocessedFailoverThreshold = 3L; + + private long nextErrorReportTime = 0L; + + private String globalHostName = null; + + private boolean isDerby = false; + + public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { + configure(jdbcElem); + + if ("org.apache.derby.jdbc.EmbeddedDriver".equals(jdbcElem.getDriverName())) { + isDerby = true; + } + monitor = new SQLExecutionMonitor(this); + } + + protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#getConnection() + */ + @Override + public Connection getConnection() throws SQLException { + return ds.getConnection(); + } + + public CachedRowSet getData(String statement, List arguments) throws SQLException { + TestObject testObject = monitor.registerRequest(); + + try (Connection connection = this.getConnection()) { + if (connection == null) { + throw new SQLException("Connection invalid"); + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); + } + return executePreparedStatement(connection, statement, arguments, true); + } finally { + monitor.deregisterRequest(testObject); + } + } + + public boolean writeData(String statement, List arguments) throws SQLException { + TestObject testObject = monitor.registerRequest(); + + try (Connection connection = this.getConnection()) { + if (connection == null) { + throw new SQLException("Connection invalid"); + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Obtained connection <{}>: {}", connectionName, connection); + } + return executeUpdatePreparedStatement(connection, statement, arguments, true); + } finally { + monitor.deregisterRequest(testObject); + } + } + + CachedRowSet executePreparedStatement(Connection conn, String statement, List arguments, boolean close) + throws SQLException { + long time = System.currentTimeMillis(); + + CachedRowSet data = null; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL Statement: {}", statement); + if (arguments != null && !arguments.isEmpty()) { + LOGGER.debug("Argunments: {}", arguments); + } + } + + ResultSet rs = null; + try (PreparedStatement ps = conn.prepareStatement(statement)) { + data = RowSetProvider.newFactory().createCachedRowSet(); + if (arguments != null) { + for (int i = 0, max = arguments.size(); i < max; i++) { + ps.setObject(i + 1, arguments.get(i)); + } + } + rs = ps.executeQuery(); + data.populate(rs); + // Point the rowset Cursor to the start + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), + (System.currentTimeMillis() - time)); + } + } catch (SQLException exc) { + handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); + } finally { + handleFinallyBlockForExecutePreparedStatement(rs, conn, close); + } + + return data; + } + + private void handleSqlExceptionForExecuteStatement(Connection conn, String statement, List arguments, + SQLException exc, long time) throws SQLException { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(SQL_FAILURE + (System.currentTimeMillis() - time)); + } + try { + conn.rollback(); + } catch (Exception thr) { + LOGGER.error(thr.getLocalizedMessage(), thr); + } + if (arguments != null && !arguments.isEmpty()) { + LOGGER.error(String.format("<%s%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_ARGUMENTS, + arguments), exc); + } else { + LOGGER.error(String.format("<%s%s%s%s", connectionName, FAILED_TO_EXECUTE, statement, WITH_NO_ARGUMENTS), + exc); + } + throw exc; + } + + private void handleFinallyBlockForExecutePreparedStatement(ResultSet rs, Connection conn, boolean close) { + try { + if (rs != null) { + rs.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + try { + if (conn != null && close) { + conn.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + } + + boolean executeUpdatePreparedStatement(Connection conn, String statement, List arguments, boolean close) + throws SQLException { + long time = System.currentTimeMillis(); + + CachedRowSet data; + + try (PreparedStatement ps = conn.prepareStatement(statement)) { + data = RowSetProvider.newFactory().createCachedRowSet(); + if (arguments != null) { + prepareStatementForExecuteUpdate(arguments, ps); + } + ps.executeUpdate(); + // Point the rowset Cursor to the start + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), + (System.currentTimeMillis() - time)); + } + ps.close(); + } catch (SQLException exc) { + handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); + } finally { + try { + if (close) { + conn.close(); + } + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } + } + + return true; + } + + private void prepareStatementForExecuteUpdate(List arguments, PreparedStatement ps) throws SQLException { + for (int i = 0, max = arguments.size(); i < max; i++) { + Object value = arguments.get(i); + if (value instanceof Blob) { + ps.setBlob(i + 1, (Blob) value); + } else if (value instanceof Timestamp) { + ps.setTimestamp(i + 1, (Timestamp) value); + } else if (value instanceof Integer) { + ps.setInt(i + 1, (Integer) value); + } else if (value instanceof Long) { + ps.setLong(i + 1, (Long) value); + } else if (value instanceof Date) { + ps.setDate(i + 1, (Date) value); + } else { + ps.setObject(i + 1, value); + } + } + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) + */ + @Override + public Connection getConnection(String username, String password) throws SQLException { + return ds.getConnection(username, password); + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#getLogWriter() + */ + @Override + public PrintWriter getLogWriter() throws SQLException { + return ds.getLogWriter(); + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#getLoginTimeout() + */ + @Override + public int getLoginTimeout() throws SQLException { + return ds.getLoginTimeout(); + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) + */ + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + ds.setLogWriter(out); + } + + /* + * (non-Javadoc) + * + * @see javax.sql.DataSource#setLoginTimeout(int) + */ + @Override + public void setLoginTimeout(int seconds) throws SQLException { + ds.setLoginTimeout(seconds); + } + + @Override + public final String getDbConnectionName() { + return connectionName; + } + + protected final void setDbConnectionName(String name) { + this.connectionName = name; + } + + public void cleanUp() { + if (ds != null && ds instanceof Closeable) { + try { + ((Closeable) ds).close(); + } catch (IOException e) { + LOGGER.warn(e.getMessage()); + } + } + ds = null; + monitor.deleteObservers(); + monitor.cleanup(); + } + + public boolean isInitialized() { + return initialized; + } + + protected boolean testConnection() { + return testConnection(false); + } + + protected boolean testConnection(boolean errorLevel) { + ResultSet rs = null; + try (Connection conn = this.getConnection(); Statement stmt = conn.createStatement()) { + Boolean readOnly; + String hostname; + rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); // ("SELECT 1 FROM DUAL"); //"select + // BANNER from SYS.V_$VERSION" + while (rs.next()) { + readOnly = rs.getBoolean(1); + hostname = rs.getString(2); + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(SQL_DATA_SOURCE + getDbConnectionName() + "> connected to " + hostname + + ", read-only is " + readOnly + ", tested successfully "); + } + } + } catch (Exception exc) { + if (errorLevel) { + LOGGER.error( + SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } else { + LOGGER.info( + SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + } + return false; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + LOGGER.error(e.getLocalizedMessage(), e); + } + } + } + return true; + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + @SuppressWarnings("deprecation") + public void setConnectionCachingEnabled(boolean state) { + // if(ds != null && ds instanceof OracleDataSource) + // try { + // ((OracleDataSource)ds).setConnectionCachingEnabled(true); + // } catch (SQLException exc) { + // LOGGER.warn("", exc); + // } + } + + public void addObserver(Observer observer) { + monitor.addObserver(observer); + } + + public void deleteObserver(Observer observer) { + monitor.deleteObserver(observer); + } + + @Override + public long getInterval() { + return interval; + } + + @Override + public long getInitialDelay() { + return initialDelay; + } + + @Override + public void setInterval(long value) { + interval = value; + } + + @Override + public void setInitialDelay(long value) { + initialDelay = value; + } + + @Override + public long getExpectedCompletionTime() { + return expectedCompletionTime; + } + + @Override + public void setExpectedCompletionTime(long value) { + expectedCompletionTime = value; + } + + @Override + public long getUnprocessedFailoverThreshold() { + return unprocessedFailoverThreshold; + } + + @Override + public void setUnprocessedFailoverThreshold(long value) { + this.unprocessedFailoverThreshold = value; + } + + public boolean canTakeOffLine() { + return canTakeOffLine; + } + + public void blockImmediateOffLine() { + canTakeOffLine = false; + final Thread offLineTimer = new Thread(() -> { + try { + Thread.sleep(30000L); + } catch (Exception exc) { + LOGGER.error(exc.getLocalizedMessage(), exc); + } finally { + canTakeOffLine = true; + } + }); + offLineTimer.setDaemon(true); + offLineTimer.start(); + } + + /** + * @return the monitor + */ + final SQLExecutionMonitor getMonitor() { + return monitor; + } + + protected boolean isSlave() throws PoolExhaustedException { + + // If using Apache derby, just return false + if (isDerby) { + return false; + } + CachedRowSet rs; + boolean isSlave; + String hostname = "UNDETERMINED"; + try { + boolean localSlave = true; + rs = this.getData("SELECT @@global.read_only, @@global.hostname", new ArrayList<>()); + while (rs.next()) { + localSlave = rs.getBoolean(1); + hostname = rs.getString(2); + } + isSlave = localSlave; + } catch (PoolExhaustedException peexc) { + throw peexc; + } catch (Exception e) { + LOGGER.error("", e); + isSlave = true; + } + if (isSlave) { + LOGGER.debug("SQL SLAVE : {} on server {}", connectionName, hostname); + } else { + LOGGER.debug("SQL MASTER : {} on server {}", connectionName, hostname); + } + return isSlave; + } + + public boolean isFabric() { + return false; + } + + protected boolean lockTable(Connection conn, String tableName) { + boolean retValue = false; + String query = "LOCK TABLES " + tableName + " WRITE"; + try (Statement preStmt = conn.createStatement(); + Statement lock = conn.prepareStatement(query)) { + if (tableName != null) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'LOCK TABLES " + tableName + " WRITE' on connection " + conn.toString()); + if ("SVC_LOGIC".equals(tableName)) { + Exception e = new Exception(); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + LOGGER.debug(sw.toString()); + } + } + lock.execute(query); + retValue = true; + } + } catch (Exception exc) { + LOGGER.error("", exc); + retValue = false; + } + return retValue; + } + + protected boolean unlockTable(Connection conn) { + boolean retValue; + try (Statement lock = conn.createStatement()) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Executing 'UNLOCK TABLES' on connection {}", conn); + } + retValue = lock.execute("UNLOCK TABLES"); + } catch (Exception exc) { + LOGGER.error("", exc); + retValue = false; + } + return retValue; + } + + public void getPoolInfo(boolean allocation) { + + } + + public long getNextErrorReportTime() { + return nextErrorReportTime; + } + + public void setNextErrorReportTime(long nextTime) { + this.nextErrorReportTime = nextTime; + } + + public void setGlobalHostName(String hostname) { + this.globalHostName = hostname; + } + + public String getGlobalHostName() { + return globalHostName; + } } -- cgit 1.2.3-korg From d873c2251b596c5dc15c0899b22ea0b7fdd6a286 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 14 Feb 2018 14:28:47 -0500 Subject: Fix install issues Fixed issues in installation scripts Change-Id: I4bd59ab16b55555ded8d9c2b0e8486d3df88fb44 Issue-ID: CCSDK-175 Signed-off-by: Dan Timoney --- dblib/installer/pom.xml | 10 +++++++--- .../installer/src/main/resources/scripts/install-feature.sh | 5 ++--- filters/installer/pom.xml | 6 +++--- .../installer/src/main/resources/scripts/install-feature.sh | 9 ++++----- sli/installer/pom.xml | 10 +++++++--- sli/installer/src/main/resources/scripts/install-feature.sh | 9 ++++----- sliPluginUtils/installer/pom.xml | 13 ++++++++----- .../installer/src/main/resources/scripts/install-feature.sh | 9 ++++----- sliPluginUtils/provider/pom.xml | 2 +- sliapi/installer/pom.xml | 3 +-- .../installer/src/main/resources/scripts/install-feature.sh | 9 ++++----- .../installer/src/main/resources/scripts/install-feature.sh | 5 ++--- 12 files changed, 47 insertions(+), 43 deletions(-) diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 8d6147b72..3f581957a 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -46,7 +46,11 @@ ${project.version} - + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + org.apache.tomcat tomcat-jdbc @@ -110,8 +114,8 @@ true false false - org.onap.ccsdk.sli,org.apache.tomcat - sli-common,sli-provider + org.onap.ccsdk.sli.core,org.apache.tomcat,org.slf4j + utils-provider,slf4j-api provided diff --git a/dblib/installer/src/main/resources/scripts/install-feature.sh b/dblib/installer/src/main/resources/scripts/install-feature.sh index 16b5be8c4..e16e79a12 100644 --- a/dblib/installer/src/main/resources/scripts/install-feature.sh +++ b/dblib/installer/src/main/resources/scripts/install-feature.sh @@ -2,7 +2,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -15,5 +14,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index a16b6a60c..6cc9e5e34 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -19,7 +19,7 @@ ccsdk-filters ${application.name} - mvn:org.onap.ccsdk.sli.core/filters-features/${project.version}/xml/features + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false @@ -104,8 +104,8 @@ true false false - org.onap.ccsdk.sli - sli-common,sli-provider + org.onap.ccsdk.sli.core + sli-common,sli-provider,utils-provider,dblib-provider provided diff --git a/filters/installer/src/main/resources/scripts/install-feature.sh b/filters/installer/src/main/resources/scripts/install-feature.sh index 70cd85162..74b95b5c8 100644 --- a/filters/installer/src/main/resources/scripts/install-feature.sh +++ b/filters/installer/src/main/resources/scripts/install-feature.sh @@ -10,9 +10,9 @@ # 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. @@ -23,7 +23,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -36,5 +35,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index ec2b43cff..e84ae6d09 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -56,7 +56,11 @@ sli-recording ${project.version} - + + org.antlr + antlr4 + ${antlr.version} + @@ -115,8 +119,8 @@ true false false - org.onap.ccsdk.sli - dblib-provider + org.onap.ccsdk.sli.core,org.antlr + utils-provider,dblib-provider provided diff --git a/sli/installer/src/main/resources/scripts/install-feature.sh b/sli/installer/src/main/resources/scripts/install-feature.sh index 70cd85162..74b95b5c8 100644 --- a/sli/installer/src/main/resources/scripts/install-feature.sh +++ b/sli/installer/src/main/resources/scripts/install-feature.sh @@ -10,9 +10,9 @@ # 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. @@ -23,7 +23,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -36,5 +35,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 1c0704af6..f11b27ca3 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -9,7 +9,7 @@ - org.onap.ccsdl.sli.core + org.onap.ccsdk.sli.core sliPluginUtils-installer 0.2.1-SNAPSHOT pom @@ -19,7 +19,7 @@ ccsdk-sliPluginUtils ${application.name} - mvn:org.onap.ccsdk.sli.core/sliPluginUtils-features/${project.version}/xml/features + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false @@ -45,7 +45,11 @@ ${project.version} - + + org.apache.commons + commons-text + 1.1 + @@ -104,8 +108,7 @@ true false false - org.onap.ccsdk.sli - sli-common,sli-provider,dblib-provider + sliPluginUtils-provider,ccsdk-sliPluginUtils,features-sliPluginUtils,commons-text provided diff --git a/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh b/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh index 70cd85162..74b95b5c8 100644 --- a/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh +++ b/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh @@ -10,9 +10,9 @@ # 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. @@ -23,7 +23,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -36,5 +35,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 0a274edd0..c09029fa0 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -58,7 +58,7 @@ com.google.code.gson gson - 2.6.2 + 2.7 org.apache.commons diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 290524e32..d9da9794e 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -104,8 +104,7 @@ true false false - org.onap.ccsdk.sli.core - sli-common,sli-provider,dblib-provider + sliapi-model,sliapi-provider,ccsdk-sliapi,features-sliapi provided diff --git a/sliapi/installer/src/main/resources/scripts/install-feature.sh b/sliapi/installer/src/main/resources/scripts/install-feature.sh index 70cd85162..74b95b5c8 100644 --- a/sliapi/installer/src/main/resources/scripts/install-feature.sh +++ b/sliapi/installer/src/main/resources/scripts/install-feature.sh @@ -10,9 +10,9 @@ # 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. @@ -23,7 +23,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -36,5 +35,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/utils/installer/src/main/resources/scripts/install-feature.sh b/utils/installer/src/main/resources/scripts/install-feature.sh index 16b5be8c4..e16e79a12 100644 --- a/utils/installer/src/main/resources/scripts/install-feature.sh +++ b/utils/installer/src/main/resources/scripts/install-feature.sh @@ -2,7 +2,6 @@ ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} INSTALLERDIR=$(dirname $0) REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip @@ -15,5 +14,5 @@ else exit 1 fi -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} -- cgit 1.2.3-korg From 3cc57351f6b8e438ac6d6ed98cb098a22c62608f Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 26 Feb 2018 10:58:32 -0500 Subject: Fixed antlr dependencies Should depend on antlr4-runtime instead of antlr4 to avoid unnecessary compile-time-only dependencies Change-Id: I720628786676dfc81b4aadd4f3da752af2d92451 Issue-ID: CCSDK-175 Signed-off-by: Dan Timoney --- sli/common/pom.xml | 4 +--- sli/installer/pom.xml | 8 ++------ sliPluginUtils/provider/pom.xml | 2 -- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 167a776e4..1ab787e50 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -37,10 +37,8 @@ org.antlr - antlr4 + antlr4-runtime ${antlr.version} - jar - compile org.slf4j diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index e84ae6d09..5586f7d53 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -56,11 +56,7 @@ sli-recording ${project.version} - - org.antlr - antlr4 - ${antlr.version} - + @@ -119,7 +115,7 @@ true false false - org.onap.ccsdk.sli.core,org.antlr + org.onap.ccsdk.sli.core utils-provider,dblib-provider provided diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index c09029fa0..cd3704915 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -52,13 +52,11 @@ org.hamcrest hamcrest-library - 1.3 test com.google.code.gson gson - 2.7 org.apache.commons -- cgit 1.2.3-korg From feb6e30fa49c9de9bfd3076b05d1c77a508d06da Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 1 Mar 2018 17:18:50 -0500 Subject: Fix broken merge Fix antlr compile error. Change-Id: Ibe7c897e4de2d6d34f842fb89fc27d210f6c8c27 Issue-ID: CCSDK-175 Signed-off-by: Timoney, Dan (dt5972) --- sli/common/pom.xml | 250 +++++++++++---------- .../org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 | 2 +- 2 files changed, 127 insertions(+), 125 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 1ab787e50..2fb3f8370 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -1,134 +1,136 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.0.1-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - sli-common - 0.2.1-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sli-common + 0.2.1-SNAPSHOT + bundle - ccsdk-sli-core :: sli :: ${project.artifactId} - The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter + ccsdk-sli-core :: sli :: ${project.artifactId} + The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter - - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - - - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - - - org.antlr - antlr4-runtime - ${antlr.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-simple - 1.7.5 - compile - - - org.apache.commons - commons-lang3 - ${commons.lang3.version} - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - jar - compile - - - org.onap.ccsdk.sli.core - dblib-provider - ${sdnctl.dblib.version} - - - org.onap.ccsdk.sli.core - sli-model - ${project.version} - test - - - org.opendaylight.mdsal.model - ietf-inet-types - - - org.opendaylight.mdsal.model - ietf-yang-types - - - org.opendaylight.controller - sal-core-api - + + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + org.antlr + antlr4-runtime + ${antlr.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + 1.7.5 + compile + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + jar + compile + + + org.onap.ccsdk.sli.core + dblib-provider + ${sdnctl.dblib.version} + + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + test + + + org.opendaylight.mdsal.model + ietf-inet-types + + + org.opendaylight.mdsal.model + ietf-yang-types + + + org.opendaylight.controller + sal-core-api + - - org.opendaylight.controller - sal-binding-api - + + org.opendaylight.controller + sal-binding-api + - - - junit - junit - test - + + + junit + junit + test + - - org.mockito - mockito-core - test - - + + org.mockito + mockito-core + test + + - - - - org.antlr - antlr4-maven-plugin - ${antlr.version} - - - - ${project.basedir}/src/main/java/ - - antlr - - antlr4 - - - - - - + + + + org.antlr + antlr4-maven-plugin + ${antlr.version} + + + + ${basedir}/src/main/antlr4 + ${project.basedir}/src/main/java/ + + antlr + + antlr4 + + + + + + diff --git a/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 b/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 index 1b026bb1a..42563168c 100755 --- a/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 +++ b/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 @@ -16,7 +16,7 @@ MULTOP : '/' | '*'; NUMBER : ('0'..'9')+; -STRING : '\'' ~[\']* '\''; +STRING : '\'' ~[']* '\''; IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*; -- cgit 1.2.3-korg From e69c6e3320f27d31d6dcd86a1ab40960758b59cb Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Fri, 2 Mar 2018 04:42:45 +0000 Subject: Updated master database detection algorithm Changes made: * updated algorithm in DBResourceManager * Updated CachedDataSource, JdbcDBCachedDataSource * added new unit tests Change-Id: I4f6bbeb3839f55d183d7e762743fbc9171b63b1a Issue-ID: CCSDK-192 Signed-off-by: Rich Tabedzki --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 19 +- .../ccsdk/sli/core/dblib/DBResourceManager.java | 279 +++++++++------------ .../onap/ccsdk/sli/core/dblib/DataAccessor.java | 1 + .../core/dblib/TerminatingCachedDataSource.java | 120 ++++----- .../core/dblib/jdbc/JdbcDBCachedDataSource.java | 29 ++- .../ccsdk/sli/core/dblib/DBLibExceptionTest.java | 14 ++ .../dblib/NoAvailableConnectionsExceptionTest.java | 16 ++ .../org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 | 2 +- 8 files changed, 227 insertions(+), 253 deletions(-) mode change 100644 => 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBLibExceptionTest.java create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/NoAvailableConnectionsExceptionTest.java diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index e5eff24a5..02cce3cf1 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -47,7 +47,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ * Change Log * Author Date Comments * ============== ======== ==================================================== @@ -68,7 +68,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito protected long dataReqTimeout = 100L; private final SQLExecutionMonitor monitor; - protected DataSource ds = null; + protected final DataSource ds; protected String connectionName = null; protected boolean initialized = false; @@ -85,7 +85,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito private boolean isDerby = false; public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { - configure(jdbcElem); + ds = configure(jdbcElem); if ("org.apache.derby.jdbc.EmbeddedDriver".equals(jdbcElem.getDriverName())) { isDerby = true; @@ -93,7 +93,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito monitor = new SQLExecutionMonitor(this); } - protected abstract void configure(BaseDBConfiguration jdbcElem) throws DBConfigException; + protected abstract DataSource configure(BaseDBConfiguration jdbcElem) throws DBConfigException; /* * (non-Javadoc) @@ -329,7 +329,6 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito LOGGER.warn(e.getMessage()); } } - ds = null; monitor.deleteObservers(); monitor.cleanup(); } @@ -389,16 +388,6 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito return null; } - @SuppressWarnings("deprecation") - public void setConnectionCachingEnabled(boolean state) { - // if(ds != null && ds instanceof OracleDataSource) - // try { - // ((OracleDataSource)ds).setConnectionCachingEnabled(true); - // } catch (SQLException exc) { - // LOGGER.warn("", exc); - // } - } - public void addObserver(Observer observer) { monitor.addObserver(observer); } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index b31645d41..27c14d2a4 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -20,39 +20,39 @@ package org.onap.ccsdk.sli.core.dblib; -import org.apache.tomcat.jdbc.pool.PoolExhaustedException; -import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; -import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; -import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.sql.DataSource; -import javax.sql.rowset.CachedRowSet; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLDataException; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLIntegrityConstraintViolationException; +import java.sql.SQLNonTransientConnectionException; import java.sql.SQLSyntaxErrorException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.Observable; -import java.util.PriorityQueue; import java.util.Properties; -import java.util.Queue; import java.util.Set; +import java.util.SortedSet; import java.util.TimerTask; import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.ConcurrentSkipListSet; + +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; +import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @version $Revision: 1.15 $ @@ -68,31 +68,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb transient protected long retryInterval = 10000L; transient boolean recoveryMode = true; - protected final AtomicBoolean dsSelector = new AtomicBoolean(); - - Queue dsQueue = new PriorityQueue<>(4, new Comparator() { - @Override - public int compare(CachedDataSource left, CachedDataSource right) { - try { - if (left == null) { - return 1; - } - if (right == null) { - return -1; - } - - if (!left.isSlave()) { - return -1; - } - if (!right.isSlave()) { - return 1; - } - } catch (Throwable e) { - LOGGER.warn("", e); - } - return 0; - } -}); + SortedSet dsQueue = new ConcurrentSkipListSet(new DataSourceComparator()); protected final Set broken = Collections.synchronizedSet(new HashSet()); protected final Object monitor = new Object(); protected final Properties configProps; @@ -174,7 +150,6 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb cachedDS[i].addObserver(DBResourceManager.this); } -// CachedDataSource[] cachedDS = factory.initDBResourceManager(dbConfig, DBResourceManager.this, semaphore); DataSourceTester[] tester = new DataSourceTester[config.length]; for(int i=0; i { + @Override + public int compare(CachedDataSource left, CachedDataSource right) { + if(LOGGER.isTraceEnabled()) + LOGGER.trace("----------SORTING-------- () : ()", left.getDbConnectionName(), right.getDbConnectionName()); + try { + if(left == right) { + return 0; + } + if(left == null){ + return 1; + } + if(right == null){ + return -1; + } + + if(!left.isSlave()) + return -1; + if(!right.isSlave()) + return 1; + + } catch (Throwable e) { + LOGGER.warn("", e); + } + return -1; + } + } + class DataSourceTester extends Thread { private final CachedDataSource ds; @@ -224,7 +227,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } if(!slave) { - LOGGER.info(String.format("Adding MASTER (%s) to active queue", ds.getDbConnectionName())); + LOGGER.info("Adding MASTER {} to active queue", ds.getDbConnectionName()); try { synchronized (semaphoreQ) { semaphoreQ.notifyAll(); @@ -245,7 +248,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } catch(Exception exc) { LOGGER.warn("", exc); } - LOGGER.info(String.format("Thread DataSourceTester terminated %s for %s", this.getName(), ds.getDbConnectionName())); + LOGGER.info("Thread DataSourceTester terminated {} for {}", this.getName(), ds.getDbConnectionName()); } } @@ -300,7 +303,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb if(monitor.getParent() instanceof CachedDataSource) { CachedDataSource dataSource = (CachedDataSource)monitor.getParent(); - if(dataSource == dsQueue.peek()) + if(dataSource == dsQueue.first()) { if(recoveryMode && dsQueue.size() > 1){ handleGetConnectionException(dataSource, new Exception(data.toString())); @@ -312,7 +315,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public void testForceRecovery() { - CachedDataSource active = this.dsQueue.peek(); + CachedDataSource active = this.dsQueue.first(); handleGetConnectionException(active, new Exception("test")); } @@ -386,51 +389,45 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb private CachedRowSet requestDataWithRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { Throwable lastException = null; - CachedDataSource active = null; // test if there are any connection pools available - LinkedList sources = new LinkedList<>(this.dsQueue); - if(sources.isEmpty()){ + if(this.dsQueue.isEmpty()){ LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); } - if(preferredDS != null && !sources.peek().getDbConnectionName().equals(preferredDS)) { - Collections.reverse(sources); - } - // loop through available data sources to retrieve data. - while(!sources.isEmpty()) + for(int i=0; i< 2; i++) { - active = sources.peek(); + CachedDataSource active = this.dsQueue.first(); long time = System.currentTimeMillis(); try { if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { CachedDataSource master = findMaster(); if(master != null) { active = master; - master = null; } } - sources.remove(active); + } + return active.getData(statement, arguments); } catch(SQLDataException | SQLSyntaxErrorException | SQLIntegrityConstraintViolationException exc){ throw exc; } catch(Throwable exc){ - lastException = exc; - String message = exc.getMessage(); - if(message == null) { - if(exc.getCause() != null) { - message = exc.getCause().getMessage(); + if(exc instanceof SQLException) { + SQLException sqlExc = (SQLException)exc; + int code = sqlExc.getErrorCode(); + String state = sqlExc.getSQLState(); + LOGGER.debug("SQLException code: {} state: {}", code, state); + if("07001".equals(sqlExc.getSQLState())) { + throw sqlExc; } - if(message == null) - message = exc.getClass().getName(); } - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + lastException = exc; + LOGGER.error("Generated alarm: "+active.getDbConnectionName(), exc); handleGetConnectionException(active, exc); - if(sources.contains(active)) - sources.remove(active); } finally { if(LOGGER.isDebugEnabled()){ time = System.currentTimeMillis() - time; @@ -462,13 +459,16 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); } - CachedDataSource active = this.dsQueue.peek(); + CachedDataSource active = this.dsQueue.first(); long time = System.currentTimeMillis(); try { if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { CachedDataSource master = findMaster(); - if(master != null) + if(master != null) { active = master; + } + } } return active.getData(statement, arguments); // } catch(SQLDataException exc){ @@ -508,17 +508,21 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb return writeDataNoRecovery(statement, newList, preferredDS); } - CachedDataSource findMaster() throws PoolExhaustedException { - CachedDataSource master = null; - CachedDataSource[] dss = this.dsQueue.toArray(new CachedDataSource[0]); - for(int i=0; i 1 && active.isSlave()) { CachedDataSource master = findMaster(); if(master != null) { active = master; } } + } return active.writeData(statement, arguments); } catch(Throwable exc){ @@ -557,8 +563,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb // handle read-only exception if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { LOGGER.warn("retrying due to: " + sqlExc.getMessage()); - dsQueue.remove(active); - dsQueue.add(active); + this.findMaster(); if(retryAllowed){ retryAllowed = false; initialRequest = true; @@ -604,10 +609,15 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } try { - active = dsQueue.peek(); - CachedDataSource tmpActive = findMaster(); - if(tmpActive != null) { - active = tmpActive; + active = dsQueue.first(); + + if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } } return new DBLibConnection(active.getConnection(), active); } catch(javax.sql.rowset.spi.SyncFactoryException exc){ @@ -616,6 +626,8 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb lastException = exc; } catch(PoolExhaustedException exc) { throw new NoAvailableConnectionsException(exc); + } catch(SQLNonTransientConnectionException exc){ + throw new NoAvailableConnectionsException(exc); } catch(Exception exc){ lastException = exc; if(recoveryMode){ @@ -667,10 +679,14 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb try { - active = dsQueue.peek(); - CachedDataSource tmpActive = findMaster(); - if(tmpActive != null) { - active = tmpActive; + active = dsQueue.first(); + if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } } return active.getConnection(username, password); } catch(Throwable exc){ @@ -691,7 +707,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb throw new DBLibException("No connections available in DBResourceManager in GetConnection call."); } - private void handleGetConnectionException(CachedDataSource source, Throwable exc) { + private void handleGetConnectionException(final CachedDataSource source, Throwable exc) { try { if(!source.canTakeOffLine()) { @@ -715,7 +731,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb { if(!dsQueue.isEmpty()) { - LOGGER.warn("DB DataSource <" + dsQueue.peek().getDbConnectionName() + "> became active"); + LOGGER.warn("DB DataSource <" + dsQueue.first().getDbConnectionName() + "> became active"); } } } catch (Exception e) { @@ -749,28 +765,28 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb @Override public PrintWriter getLogWriter() throws SQLException { - return this.dsQueue.peek().getLogWriter(); + return this.dsQueue.first().getLogWriter(); } @Override public int getLoginTimeout() throws SQLException { - return this.dsQueue.peek().getLoginTimeout(); + return this.dsQueue.first().getLoginTimeout(); } @Override public void setLogWriter(PrintWriter out) throws SQLException { - this.dsQueue.peek().setLogWriter(out); + this.dsQueue.first().setLogWriter(out); } @Override public void setLoginTimeout(int seconds) throws SQLException { - this.dsQueue.peek().setLoginTimeout(seconds); + this.dsQueue.first().setLoginTimeout(seconds); } public void displayState(){ if(LOGGER.isDebugEnabled()){ LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); - CachedDataSource current = dsQueue.peek(); + CachedDataSource current = dsQueue.first(); if(current != null) { LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); } @@ -811,7 +827,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb buffer.append("in recovery"); } if (dsQueue.contains(list.get(i))) { - if (dsQueue.peek() == list.get(i)) + if (dsQueue.first() == list.get(i)) buffer.append("active"); else buffer.append("standby"); @@ -827,7 +843,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb buffer.append("in recovery"); } else if (dsQueue.contains(list.get(i))) { - if (dsQueue.peek() == list.get(i)) + if (dsQueue.first() == list.get(i)) buffer.append("active"); else buffer.append("standby"); @@ -859,7 +875,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } public void test(){ - CachedDataSource obj = dsQueue.peek(); + CachedDataSource obj = dsQueue.first(); Exception ption = new Exception(); try { for(int i=0; i<5; i++) @@ -871,77 +887,16 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } - public String getPreferredDSName(){ - if(isActive()){ - return getPreferredDataSourceName(dsSelector); - } - return ""; - } - - public String getPreferredDataSourceName(AtomicBoolean flipper) { - - LinkedList snapshot = new LinkedList<>(dsQueue); - if(snapshot.size() > 1){ - CachedDataSource first = snapshot.getFirst(); - CachedDataSource last = snapshot.getLast(); - - int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount(); - if(delta < 0) { - flipper.set(false); - } else if(delta > 0) { - flipper.set(true); - } else { - // check the last value and return !last - flipper.getAndSet(!flipper.get()); - } - - if (flipper.get()) - Collections.reverse(snapshot); - } - return snapshot.peek().getDbConnectionName(); - } - @Override public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { return null; } - public String getMasterName() { - if(isActive()){ - return getMasterDataSourceName(dsSelector); - } - return ""; - } - - - private String getMasterDataSourceName(AtomicBoolean flipper) { - - LinkedList snapshot = new LinkedList<>(dsQueue); - if(snapshot.size() > 1){ - CachedDataSource first = snapshot.getFirst(); - CachedDataSource last = snapshot.getLast(); - - int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount(); - if(delta < 0) { - flipper.set(false); - } else if(delta > 0) { - flipper.set(true); - } else { - // check the last value and return !last - flipper.getAndSet(!flipper.get()); - } - - if (flipper.get()) - Collections.reverse(snapshot); - } - return snapshot.peek().getDbConnectionName(); - } - class RemindTask extends TimerTask { @Override public void run() { - CachedDataSource ds = dsQueue.peek(); + CachedDataSource ds = dsQueue.first(); if(ds != null) ds.getPoolInfo(false); } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java index fdfb47bca..93d8b6bf5 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DataAccessor.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import javax.sql.rowset.CachedRowSet; +@FunctionalInterface public interface DataAccessor { CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java old mode 100644 new mode 100755 index b4d1ef679..92b31470e --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java @@ -22,71 +22,71 @@ package org.onap.ccsdk.sli.core.dblib; import java.sql.SQLFeatureNotSupportedException; import java.util.logging.Logger; - +import javax.sql.DataSource; import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; public class TerminatingCachedDataSource extends CachedDataSource implements SQLExecutionMonitorObserver { - public TerminatingCachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { - super(jdbcElem); - } - - @Override - protected void configure(BaseDBConfiguration jdbcElem) throws DBConfigException { - // no action - } - - @Override - public long getInterval() { - return 1000; - } - - @Override - public long getInitialDelay() { - return 1000; - } - - @Override - public long getExpectedCompletionTime() { - return 50; - } - - @Override - public void setExpectedCompletionTime(long value) { - - } - - @Override - public void setInterval(long value) { - - } - - @Override - public void setInitialDelay(long value) { - - } - - @Override - public long getUnprocessedFailoverThreshold() { - return 3; - } - - @Override - public void setUnprocessedFailoverThreshold(long value) { - - } - - public int compareTo(CachedDataSource ods) - { - return 0; - } - - @Override - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub - return null; - } + public TerminatingCachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { + super(jdbcElem); + } + + @Override + protected DataSource configure(BaseDBConfiguration jdbcElem) throws DBConfigException { + return null; + } + + @Override + public long getInterval() { + return 1000; + } + + @Override + public long getInitialDelay() { + return 1000; + } + + @Override + public long getExpectedCompletionTime() { + return 50; + } + + @Override + public void setExpectedCompletionTime(long value) { + + } + + @Override + public void setInterval(long value) { + + } + + @Override + public void setInitialDelay(long value) { + + } + + @Override + public long getUnprocessedFailoverThreshold() { + return 3; + } + + @Override + public void setUnprocessedFailoverThreshold(long value) { + + } + + public int compareTo(CachedDataSource ods) + { + return 0; + } + + @Override + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + // TODO Auto-generated method stub + return null; + } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java index ca16834c4..a6582b9e7 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java @@ -53,7 +53,7 @@ public class JdbcDBCachedDataSource extends CachedDataSource { } @Override - protected void configure(BaseDBConfiguration xmlElem) throws DBConfigException { + protected DataSource configure(BaseDBConfiguration xmlElem) throws DBConfigException { BaseDBConfiguration jdbcConfig = xmlElem; if (jdbcConfig.getConnTimeout() > 0) { this.connReqTimeout = jdbcConfig.getConnTimeout(); @@ -90,23 +90,23 @@ public class JdbcDBCachedDataSource extends CachedDataSource { minLimit = jdbcConfig.getDbMinLimit(); // if (minLimit == null) // { -// String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); +// String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); // } maxLimit = jdbcConfig.getDbMaxLimit(); // if (maxLimit == null) // { -// String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); +// String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); // } initialLimit = jdbcConfig.getDbInitialLimit(); // if (initialLimit == null) // { -// String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); +// String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; +// LOGGER.error(AS_CONF_ERROR + errorMsg); +// throw new DBConfigException(errorMsg); // } dbUrl = jdbcConfig.getDbUrl(); @@ -142,20 +142,19 @@ public class JdbcDBCachedDataSource extends CachedDataSource { p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"); - DataSource dataSource = new DataSource(p); + final DataSource dataSource = new DataSource(p); synchronized (this) { - this.ds = dataSource; - initialized = true; + } LOGGER.info(String.format("JdbcDBCachedDataSource <%s> configured successfully. Using URL: %s", dbConnectionName, dbUrl)); - } + return dataSource; } catch (Exception exc) { initialized = false; LOGGER.error(String.format("AS_CONF_ERROR: Failed to initialize MySQLCachedDataSource <%s>. Reason: %s", dbConnectionName, exc.getMessage())); -// throw new DBConfigException(e.getMessage()); + return null; } } diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBLibExceptionTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBLibExceptionTest.java new file mode 100644 index 000000000..cab24042c --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBLibExceptionTest.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.dblib; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class DBLibExceptionTest { + + @Test + public void testDBLibException() { + assertNotNull(new DBLibException("test")); + } + +} diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/NoAvailableConnectionsExceptionTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/NoAvailableConnectionsExceptionTest.java new file mode 100644 index 000000000..2fdacb922 --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/NoAvailableConnectionsExceptionTest.java @@ -0,0 +1,16 @@ +package org.onap.ccsdk.sli.core.dblib; + +import static org.junit.Assert.*; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class NoAvailableConnectionsExceptionTest { + + @Test + public void testNoAvailableConnectionsException() { + assertNotNull(new NoAvailableConnectionsException(new Exception("test"))); + } + +} diff --git a/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 b/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 index 1b026bb1a..42563168c 100755 --- a/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 +++ b/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 @@ -16,7 +16,7 @@ MULTOP : '/' | '*'; NUMBER : ('0'..'9')+; -STRING : '\'' ~[\']* '\''; +STRING : '\'' ~[']* '\''; IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*; -- cgit 1.2.3-korg From 7d82b39d7007df02bdd050ed1d46111d29fa6ade Mon Sep 17 00:00:00 2001 From: Kevin Smokowski Date: Fri, 23 Feb 2018 18:09:55 +0000 Subject: Favor interfaces Favor using interfaces over concrete implementations Change-Id: Ie7541eeefa69671cc7ed39fba37fdd2e24380770 Issue-ID: CCSDK-189 Signed-off-by: Kevin Smokowski Favor interfaces Favor using interfaces over concrete implementations Change-Id: Ie3b71833c0f31f67288430c25ca31ca07c0449e0 Issue-ID: CCSDK-189 Signed-off-by: Kevin Smokowski --- .../org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 | 2 +- .../onap/ccsdk/sli/core/sli/SvcLogicLoader.java | 212 +++++++++-------- .../sli/core/sli/provider/BlockNodeExecutor.java | 2 +- .../sli/core/sli/provider/BreakNodeExecutor.java | 2 +- .../sli/core/sli/provider/CallNodeExecutor.java | 2 +- .../core/sli/provider/ConfigureNodeExecutor.java | 2 +- .../sli/core/sli/provider/DeleteNodeExecutor.java | 2 +- .../sli/core/sli/provider/ExecuteNodeExecutor.java | 2 +- .../sli/core/sli/provider/ExistsNodeExecutor.java | 2 +- .../sli/core/sli/provider/ForNodeExecutor.java | 2 +- .../core/sli/provider/GetResourceNodeExecutor.java | 2 +- .../core/sli/provider/IsAvailableNodeExecutor.java | 2 +- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 254 ++++++++++----------- .../sli/core/sli/provider/NotifyNodeExecutor.java | 2 +- .../sli/core/sli/provider/RecordNodeExecutor.java | 2 +- .../sli/core/sli/provider/ReleaseNodeExecutor.java | 2 +- .../sli/core/sli/provider/ReserveNodeExecutor.java | 2 +- .../sli/core/sli/provider/ReturnNodeExecutor.java | 2 +- .../sli/core/sli/provider/SaveNodeExecutor.java | 2 +- .../sli/core/sli/provider/SetNodeExecutor.java | 18 +- .../core/sli/provider/SvcLogicNodeExecutor.java | 2 +- .../sli/provider/SvcLogicPropertiesProvider.java | 164 +------------ .../provider/SvcLogicPropertiesProviderImpl.java | 188 +++++++++++++++ .../sli/core/sli/provider/SvcLogicService.java | 11 +- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 109 ++++----- .../sli/core/sli/provider/SwitchNodeExecutor.java | 2 +- .../sli/core/sli/provider/UpdateNodeExecutor.java | 2 +- .../sli/core/sli/provider/WhileNodeExecutor.java | 2 +- .../org/opendaylight/blueprint/sli-blueprint.xml | 2 +- .../core/sli/provider/ExecuteNodeExecutorTest.java | 2 +- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 4 +- 31 files changed, 508 insertions(+), 498 deletions(-) create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java mode change 100755 => 100644 sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml diff --git a/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 b/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 index 1b026bb1a..42563168c 100755 --- a/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 +++ b/sli/common/src/main/antlr4/org/onap/ccsdk/sli/core/sli/ExprGrammar.g4 @@ -16,7 +16,7 @@ MULTOP : '/' | '*'; NUMBER : ('0'..'9')+; -STRING : '\'' ~[\']* '\''; +STRING : '\'' ~[']* '\''; IDENTIFIER : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'-')*; diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java index bc8c1bdf3..95f73f960 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java @@ -32,137 +32,133 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SvcLogicLoader { - private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicLoader.class); - SvcLogicStore store; - String directoryRoot; - String propFile; - - public SvcLogicLoader(String directoryRoot, String propFile) { - store = SvcLogicParser.getStore(propFile); - this.directoryRoot = directoryRoot; - this.propFile = propFile; - } - - public void loadAndActivate() throws IOException { - SvcLogicCrawler slc = new SvcLogicCrawler(); - Files.walkFileTree(Paths.get(this.directoryRoot), slc); - - loadGraphs(slc.getGraphPaths(), directoryRoot); - - List activationEntries = processActivationFiles(slc.getActivationPaths()); - activateGraphs(activationEntries); - } - - private List processActivationFiles(List activationPaths) { - List activationEntries = new ArrayList(); - for (Path activationFile : activationPaths) { - activationEntries.addAll(getActivationEntries(activationFile)); + private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicLoader.class); + protected SvcLogicStore store; + protected String directoryRoot; + + public SvcLogicLoader(String directoryRoot, SvcLogicStore store) { + this.store = store; + this.directoryRoot = directoryRoot; } - return activationEntries; - } + public SvcLogicLoader(String directoryRoot, String propFile) { + this.store = SvcLogicParser.getStore(propFile); + this.directoryRoot = directoryRoot; + } - private void activateGraphs(List activationEntries) { - for (ActivationEntry entry : activationEntries) { - try { - if (store.hasGraph(entry.module, entry.rpc, entry.version, entry.mode)) { - store.activate(entry.module, entry.rpc, entry.version, entry.mode); - } else { - LOGGER.error("hasGraph returned false for " + entry.toString()); - } - } catch (SvcLogicException e) { - LOGGER.error("Failed to call hasGraph for " + entry.toString(), e); - } + public void loadAndActivate() throws IOException { + SvcLogicCrawler slc = new SvcLogicCrawler(); + Files.walkFileTree(Paths.get(directoryRoot), slc); + loadGraphs(slc.getGraphPaths(), directoryRoot); + List activationEntries = processActivationFiles(slc.getActivationPaths()); + activateGraphs(activationEntries); } - } - - protected List getActivationEntries(Path activationFilePath) { - List activationEntries = new ArrayList<>(); - int lineNumber = 1; - try (BufferedReader br = Files.newBufferedReader(activationFilePath, StandardCharsets.US_ASCII)) { - String fileRead = br.readLine(); - while (fileRead != null) { - String[] fields = fileRead.split("\\s"); - if (fields.length == 4) { - activationEntries.add(parseActivationEntry(fields)); - } else { - LOGGER.error("Activation entry [" + fileRead + "] is declared at line number " + lineNumber + " in the file " + activationFilePath + " and is invalid."); + + private List processActivationFiles(List activationPaths) { + List activationEntries = new ArrayList(); + for (Path activationFile : activationPaths) { + activationEntries.addAll(getActivationEntries(activationFile)); } - fileRead = br.readLine(); - lineNumber++; - } - return activationEntries; - } catch (IOException ioe) { - LOGGER.error("Couldn't read the activation file at " + activationFilePath, ioe); - return null; - } - } - - protected void loadGraphs(List graphPaths, String directoryRoot) { - for (Path graphPath : graphPaths) { - try { - saveGraph(graphPath.toString()); - } catch (Exception e) { - LOGGER.error("Couldn't load graph at " + graphPath, e); - } + return activationEntries; } - } - private void saveGraph(String xmlFile) throws SvcLogicException { - File f = new File(xmlFile); - if (!f.canRead()) { - throw new ConfigurationException("Cannot read xml file (" + xmlFile + ")"); + private void activateGraphs(List activationEntries) { + for (ActivationEntry entry : activationEntries) { + try { + if (store.hasGraph(entry.module, entry.rpc, entry.version, entry.mode)) { + store.activate(entry.module, entry.rpc, entry.version, entry.mode); + } else { + LOGGER.error("hasGraph returned false for " + entry.toString()); + } + } catch (SvcLogicException e) { + LOGGER.error("Failed to call hasGraph for " + entry.toString(), e); + } + } } - SvcLogicParser parser = new SvcLogicParser(); - LinkedList graphs = null; - - try { - graphs = parser.parse(xmlFile); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); + protected List getActivationEntries(Path activationFilePath) { + List activationEntries = new ArrayList<>(); + int lineNumber = 1; + try (BufferedReader br = Files.newBufferedReader(activationFilePath, StandardCharsets.US_ASCII)) { + String fileRead = br.readLine(); + while (fileRead != null) { + String[] fields = fileRead.split("\\s"); + if (fields.length == 4) { + activationEntries.add(parseActivationEntry(fields)); + } else { + LOGGER.error("Activation entry [" + fileRead + "] is declared at line number " + lineNumber + + " in the file " + activationFilePath + " and is invalid."); + } + fileRead = br.readLine(); + lineNumber++; + } + return activationEntries; + } catch (IOException ioe) { + LOGGER.error("Couldn't read the activation file at " + activationFilePath, ioe); + return null; + } } - if (graphs == null) { - throw new SvcLogicException("Could not parse " + xmlFile); + protected void loadGraphs(List graphPaths, String directoryRoot) { + for (Path graphPath : graphPaths) { + try { + saveGraph(graphPath.toString()); + } catch (Exception e) { + LOGGER.error("Couldn't load graph at " + graphPath, e); + } + } } - for (Iterator iter = graphs.iterator(); iter.hasNext();) { - - SvcLogicGraph graph = iter.next(); + private void saveGraph(String xmlFile) throws SvcLogicException { + File f = new File(xmlFile); + if (!f.canRead()) { + throw new ConfigurationException("Cannot read xml file (" + xmlFile + ")"); + } - try { - LOGGER.info("Saving " + graph.toString() + " to database"); - store.store(graph); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); - } + SvcLogicParser parser = new SvcLogicParser(); + LinkedList graphs = null; - } - } + try { + graphs = parser.parse(xmlFile); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } - protected ActivationEntry parseActivationEntry(String[] fileInput) { - return new ActivationEntry(fileInput[0], fileInput[1], fileInput[2], fileInput[3]); - } + if (graphs == null) { + throw new SvcLogicException("Could not parse " + xmlFile); + } - protected String getValue(String raw, String attributeName) { - raw = raw.substring(attributeName.length() + 1); - if (raw.contains(">")) { - raw = raw.substring(0, raw.lastIndexOf('>')); - } - if (raw.endsWith("'")) { - raw = raw.substring(0, raw.lastIndexOf('\'')); + for (Iterator iter = graphs.iterator(); iter.hasNext();) { + SvcLogicGraph graph = iter.next(); + try { + LOGGER.info("Saving " + graph.toString() + " to database"); + store.store(graph); + } catch (Exception e) { + throw new SvcLogicException(e.getMessage(), e); + } + } } - if (raw.endsWith("\"")) { - raw = raw.substring(0, raw.lastIndexOf('"')); + + protected ActivationEntry parseActivationEntry(String[] fileInput) { + return new ActivationEntry(fileInput[0], fileInput[1], fileInput[2], fileInput[3]); } - return raw; - } + protected String getValue(String raw, String attributeName) { + raw = raw.substring(attributeName.length() + 1); + if (raw.contains(">")) { + raw = raw.substring(0, raw.lastIndexOf('>')); + } + if (raw.endsWith("'")) { + raw = raw.substring(0, raw.lastIndexOf('\'')); + } + if (raw.endsWith("\"")) { + raw = raw.substring(0, raw.lastIndexOf('"')); + } + return raw; + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java index 644284094..e5ae021fa 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java @@ -34,7 +34,7 @@ public class BlockNodeExecutor extends SvcLogicNodeExecutor { .getLogger(BlockNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { SvcLogicExpression atomicExpr = node.getAttribute("atomic"); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java index 3bbb3a155..fc6f0a505 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java @@ -33,7 +33,7 @@ public class BreakNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(BreakNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String message = "BreakNodeExecutor encountered break with nodeId " + node.getNodeId(); LOG.debug(message); throw new BreakNodeException(message); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java index 24774af24..6036c38ac 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java @@ -36,7 +36,7 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { .getLogger(CallNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String outValue = "not-found"; diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java index aaadaae36..337b7064b 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java @@ -38,7 +38,7 @@ public class ConfigureNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory .getLogger(ConfigureNodeExecutor.class); - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String adaptorName = SvcLogicExpressionResolver.evaluate( diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java index a7c3c8e63..571dd37cd 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java @@ -33,7 +33,7 @@ public class DeleteNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java index 2da0241ab..ed75c335a 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java @@ -41,7 +41,7 @@ public class ExecuteNodeExecutor extends SvcLogicNodeExecutor { .getLogger(ExecuteNodeExecutor.class); private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure."; - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String pluginName = SvcLogicExpressionResolver.evaluate( diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java index 69b1132b9..80aec0756 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java @@ -33,7 +33,7 @@ public class ExistsNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(ExistsNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java index e9011c802..6c6b4ca27 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java @@ -35,7 +35,7 @@ public class ForNodeExecutor extends SvcLogicNodeExecutor { .getLogger(ForNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { SvcLogicExpression atomicExpr = node.getAttribute("atomic"); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java index 64cf5bc97..468a6fffc 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java @@ -33,7 +33,7 @@ public class GetResourceNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(GetResourceNodeExecutor.class); - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java index d2a4bfad4..72d99e4f2 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java @@ -33,7 +33,7 @@ public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(IsAvailableNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 39a87a91d..bea21387b 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -23,7 +23,7 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; +import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.lang.reflect.Constructor; @@ -34,14 +34,14 @@ import java.lang.reflect.Type; import java.util.LinkedList; import java.util.List; import java.util.Properties; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; import org.opendaylight.yangtools.yang.binding.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -287,52 +287,52 @@ public class MdsalHelper { LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); } - } else if (isPortNumber(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - PortNumber retValue = (PortNumber) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = "" + retValue.getValue(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } else if (isDscp(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Dscp retValue = (Dscp) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = "" + retValue.getValue(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } + } else if (isPortNumber(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + PortNumber retValue = (PortNumber) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = "" + retValue.getValue(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } + } else if (isDscp(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Dscp retValue = (Dscp) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + propVal = "" + retValue.getValue(); + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } } else { try { boolean isAccessible = m.isAccessible(); @@ -621,9 +621,9 @@ public class MdsalHelper { String paramValue = props.getProperty(propName); if (paramValue == null) { LOG.trace(propName + " is unset"); - } else if ("".equals(paramValue)) { - LOG.trace(propName + " was set to the empty string, setting it to null"); - paramValue = null; + } else if ("".equals(paramValue)) { + LOG.trace(propName + " was set to the empty string, setting it to null"); + paramValue = null; } else { LOG.trace(propName + " = " + paramValue); } @@ -720,28 +720,28 @@ public class MdsalHelper { + "(" + paramValue + ")", e); } } - } else if ("PortNumber".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - PortNumber portNumber = PortNumber.getDefaultInstance(paramValue); - m.invoke(toObj, portNumber); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - } - } - } else if ("Dscp".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - Dscp dscp = Dscp.getDefaultInstance(paramValue); - m.invoke(toObj, dscp); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - } - } + } else if ("PortNumber".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + PortNumber portNumber = PortNumber.getDefaultInstance(paramValue); + m.invoke(toObj, portNumber); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } else if ("Dscp".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + Dscp dscp = Dscp.getDefaultInstance(paramValue); + m.invoke(toObj, dscp); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } } else { // setter expects a yang-generated class. Need // to @@ -1095,8 +1095,8 @@ public class MdsalHelper { String simpleName = returnClass.getSimpleName(); if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName) - || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { + || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName) + || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { LOG.trace(m.getName() + " is an " + simpleName); pstr.print("\n\n * " + propName); } else { @@ -1155,9 +1155,9 @@ public class MdsalHelper { if (c == null) { return (false); } - if (!isIetfInet(c)) { - return (false); - } + if (!isIetfInet(c)) { + return (false); + } String simpleName = c.getSimpleName(); return ("IpPrefix".equals(simpleName)); } @@ -1167,9 +1167,9 @@ public class MdsalHelper { if (c == null) { return (false); } - if (!isIetfInet(c)) { - return (false); - } + if (!isIetfInet(c)) { + return (false); + } String simpleName = c.getSimpleName(); return ("Ipv4Address".equals(simpleName)); } @@ -1179,9 +1179,9 @@ public class MdsalHelper { if (c == null) { return (false); } - if (!isIetfInet(c)) { - return (false); - } + if (!isIetfInet(c)) { + return (false); + } String simpleName = c.getSimpleName(); return ("Ipv6Address".equals(simpleName)); } @@ -1191,52 +1191,52 @@ public class MdsalHelper { if (c == null) { return (false); } - if (!isIetfInet(c)) { - return (false); - } + if (!isIetfInet(c)) { + return (false); + } String simpleName = c.getSimpleName(); return ("IpAddress".equals(simpleName)); } - public static boolean isPortNumber(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - - String simpleName = c.getSimpleName(); - return ("PortNumber".equals(simpleName)); - } - - public static boolean isDscp(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Dscp".equals(simpleName)); - } - - public static boolean isIetfInet(Class c) { - - Package p = c.getPackage(); - if (p != null) { - String pkgName = p.getName(); - - if ((pkgName != null) && (pkgName.indexOf("yang.ietf.inet.types") > -1)) { - return (true); - } - } - - return (false); - } - + public static boolean isPortNumber(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + + String simpleName = c.getSimpleName(); + return ("PortNumber".equals(simpleName)); + } + + public static boolean isDscp(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Dscp".equals(simpleName)); + } + + public static boolean isIetfInet(Class c) { + + Package p = c.getPackage(); + if (p != null) { + String pkgName = p.getName(); + + if ((pkgName != null) && (pkgName.indexOf("yang.ietf.inet.types") > -1)) { + return (true); + } + } + + return (false); + } + public static String toLowerHyphen(String inStr) { if (inStr == null) { return (null); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java index cfeab7975..44d1ec8fd 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java @@ -33,7 +33,7 @@ public class NotifyNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(NotifyNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java index 42e215356..e39414461 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java @@ -38,7 +38,7 @@ public class RecordNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(RecordNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java index c1ea96412..b0453fadc 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java @@ -33,7 +33,7 @@ public class ReleaseNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(ReleaseNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java index 646650c68..00355cd0e 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java @@ -34,7 +34,7 @@ public class ReserveNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(ReserveNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java index 7f9241809..e05692d5d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java @@ -38,7 +38,7 @@ public class ReturnNodeExecutor extends SvcLogicNodeExecutor { .getLogger(ReturnNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String status = SvcLogicExpressionResolver.evaluate( diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java index d2b8b0a50..1b5219bea 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java @@ -38,7 +38,7 @@ public class SaveNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java index d0c052a16..dc7fad0a8 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java @@ -41,7 +41,7 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { .getLogger(SetNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String ifunsetStr = SvcLogicExpressionResolver.evaluate( @@ -60,16 +60,16 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { // Resolve LHS of assignment (could contain index variables) try { - //Backticks symbolize the variable should be handled as an expression instead of as a variable - if (curName.trim().startsWith("`")) { - int lastParen = curName.lastIndexOf("`"); - String evalExpr = curName.trim().substring(1, lastParen); - SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(evalExpr); - lhsVarName = SvcLogicExpressionResolver.evaluate(lhsExpr, node, ctx); - } else { + //Backticks symbolize the variable should be handled as an expression instead of as a variable + if (curName.trim().startsWith("`")) { + int lastParen = curName.lastIndexOf("`"); + String evalExpr = curName.trim().substring(1, lastParen); + SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(evalExpr); + lhsVarName = SvcLogicExpressionResolver.evaluate(lhsExpr, node, ctx); + } else { SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); - } + } } catch (Exception e) { LOG.warn("Caught exception trying to resolve variable name ("+curName+")", e); } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java index 0cfcfb91a..593c972a7 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; public abstract class SvcLogicNodeExecutor { - public abstract SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; + public abstract SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java index 6e8597210..9debd6bc5 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java @@ -20,169 +20,9 @@ package org.onap.ccsdk.sli.core.sli.provider; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Optional; import java.util.Properties; -import java.util.Vector; -import org.onap.ccsdk.sli.core.dblib.DblibConfigurationException; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.utils.JREFileResolver; -import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; -import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; -import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +public interface SvcLogicPropertiesProvider { -/** - * Responsible for determining the properties file to use and instantiating the - * DBResourceManager Service. The priority for properties file - * resolution is as follows: - * - *
      - *
    1. A directory identified by the system environment variable - * SDNC_CONFIG_DIR
    2. - *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. - *
    5. A directory identified by the JRE argument - * dblib.properties
    6. - *
    7. A dblib.properties file located in the karaf root - * directory
    8. - *
    - */ -public class SvcLogicPropertiesProvider { - - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicPropertiesProvider.class); - - /** - * The name of the properties file for database configuration - */ - private static final String SVCLOGIC_PROP_FILE_NAME = "svclogic.properties"; - - /** - * A prioritized list of strategies for resolving dblib properties files. - */ - private Vector sliPropertiesFileResolvers = new Vector<>(); - - /** - * The configuration properties for the db connection. - */ - private Properties properties; - - /** - * Set up the prioritized list of strategies for resolving dblib properties - * files. - */ - public SvcLogicPropertiesProvider() { - sliPropertiesFileResolvers - .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); - sliPropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); - - sliPropertiesFileResolvers.add( - new JREFileResolver("Using property file (3) from JRE argument", SvcLogicPropertiesProvider.class)); - sliPropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); - - // determines properties file as according to the priority described in the - // class header comment - final File propertiesFile = determinePropertiesFile(this); - if (propertiesFile != null) { - try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); - properties.load(fileInputStream); - } catch (final IOException e) { - LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), - new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(), - e)); - } - } else { - // Try to read properties as resource - - InputStream propStr = getClass().getResourceAsStream("/" + SVCLOGIC_PROP_FILE_NAME); - if (propStr != null) { - properties = new Properties(); - try { - properties.load(propStr); - propStr.close(); - } catch (IOException e) { - properties = null; - } - } - - } - - if (properties == null) { - reportFailure("Missing configuration properties resource(3)", new ConfigurationException( - "Missing configuration properties resource(3): " + SVCLOGIC_PROP_FILE_NAME)); - } - } - - /** - * Extract svclogic config properties. - * - * @return the svclogic config properties - */ - public Properties getProperties() { - return properties; - } - - /** - * Reports the method chosen for properties resolution to the - * Logger. - * - * @param message - * Some user friendly message - * @param fileOptional - * The file location of the chosen properties file - * @return the file location of the chosen properties file - */ - private static File reportSuccess(final String message, final Optional fileOptional) { - if (fileOptional.isPresent()) { - final File file = fileOptional.get(); - LOG.info("{} {}", message, file.getPath()); - return file; - } - return null; - } - - /** - * Reports fatal errors. This is the case in which no properties file could be - * found. - * - * @param message - * An appropriate fatal error message - * @param configurationException - * An exception describing what went wrong during resolution - */ - private static void reportFailure(final String message, final ConfigurationException configurationException) { - - LOG.error("{}", message, configurationException); - } - - /** - * Determines the dblib properties file to use based on the following priority: - *
      - *
    1. A directory identified by the system environment variable - * SDNC_CONFIG_DIR
    2. - *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. - *
    5. A directory identified by the JRE argument - * dblib.properties
    6. - *
    7. A dblib.properties file located in the karaf root - * directory
    8. - *
    - */ - File determinePropertiesFile(final SvcLogicPropertiesProvider resourceProvider) { - - for (final PropertiesFileResolver sliPropertiesFileResolver : sliPropertiesFileResolvers) { - final Optional fileOptional = sliPropertiesFileResolver.resolveFile(SVCLOGIC_PROP_FILE_NAME); - if (fileOptional.isPresent()) { - return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); - } - } - - return null; - } + public Properties getProperties();; } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java new file mode 100644 index 000000000..a9992a094 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.provider; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Optional; +import java.util.Properties; +import java.util.Vector; + +import org.onap.ccsdk.sli.core.dblib.DblibConfigurationException; +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.utils.JREFileResolver; +import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; +import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Responsible for determining the properties file to use and instantiating the + * DBResourceManager Service. The priority for properties file + * resolution is as follows: + * + *
      + *
    1. A directory identified by the system environment variable + * SDNC_CONFIG_DIR
    2. + *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. + *
    5. A directory identified by the JRE argument + * dblib.properties
    6. + *
    7. A dblib.properties file located in the karaf root + * directory
    8. + *
    + */ +public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvider { + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicPropertiesProviderImpl.class); + + /** + * The name of the properties file for database configuration + */ + private static final String SVCLOGIC_PROP_FILE_NAME = "svclogic.properties"; + + /** + * A prioritized list of strategies for resolving dblib properties files. + */ + private Vector sliPropertiesFileResolvers = new Vector<>(); + + /** + * The configuration properties for the db connection. + */ + private Properties properties; + + /** + * Set up the prioritized list of strategies for resolving dblib properties + * files. + */ + public SvcLogicPropertiesProviderImpl() { + sliPropertiesFileResolvers + .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); + sliPropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); + + sliPropertiesFileResolvers.add( + new JREFileResolver("Using property file (3) from JRE argument", SvcLogicPropertiesProviderImpl.class)); + sliPropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); + + // determines properties file as according to the priority described in the + // class header comment + final File propertiesFile = determinePropertiesFile(this); + if (propertiesFile != null) { + try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { + properties = new Properties(); + properties.load(fileInputStream); + } catch (final IOException e) { + LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), + new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(), + e)); + } + } else { + // Try to read properties as resource + + InputStream propStr = getClass().getResourceAsStream("/" + SVCLOGIC_PROP_FILE_NAME); + if (propStr != null) { + properties = new Properties(); + try { + properties.load(propStr); + propStr.close(); + } catch (IOException e) { + properties = null; + } + } + + } + + if (properties == null) { + reportFailure("Missing configuration properties resource(3)", new ConfigurationException( + "Missing configuration properties resource(3): " + SVCLOGIC_PROP_FILE_NAME)); + } + } + + /** + * Extract svclogic config properties. + * + * @return the svclogic config properties + */ + public Properties getProperties() { + return properties; + } + + /** + * Reports the method chosen for properties resolution to the + * Logger. + * + * @param message + * Some user friendly message + * @param fileOptional + * The file location of the chosen properties file + * @return the file location of the chosen properties file + */ + private static File reportSuccess(final String message, final Optional fileOptional) { + if (fileOptional.isPresent()) { + final File file = fileOptional.get(); + LOG.info("{} {}", message, file.getPath()); + return file; + } + return null; + } + + /** + * Reports fatal errors. This is the case in which no properties file could be + * found. + * + * @param message + * An appropriate fatal error message + * @param configurationException + * An exception describing what went wrong during resolution + */ + private static void reportFailure(final String message, final ConfigurationException configurationException) { + + LOG.error("{}", message, configurationException); + } + + /** + * Determines the dblib properties file to use based on the following priority: + *
      + *
    1. A directory identified by the system environment variable + * SDNC_CONFIG_DIR
    2. + *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. + *
    5. A directory identified by the JRE argument + * dblib.properties
    6. + *
    7. A dblib.properties file located in the karaf root + * directory
    8. + *
    + */ + File determinePropertiesFile(final SvcLogicPropertiesProviderImpl resourceProvider) { + + for (final PropertiesFileResolver sliPropertiesFileResolver : sliPropertiesFileResolvers) { + final Optional fileOptional = sliPropertiesFileResolver.resolveFile(SVCLOGIC_PROP_FILE_NAME); + if (fileOptional.isPresent()) { + return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); + } + } + + return null; + } +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java index 19d985dd4..3f24adff7 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java @@ -22,8 +22,11 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.util.Properties; - +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; public interface SvcLogicService { @@ -73,4 +76,10 @@ public interface SvcLogicService { */ Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException; + SvcLogicStore getStore() throws SvcLogicException; + + SvcLogicContext execute(SvcLogicGraph calledGraph, SvcLogicContext ctx) throws SvcLogicException; + + SvcLogicNode executeNode(SvcLogicNode nextNode, SvcLogicContext ctx) throws SvcLogicException; + } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 53875b35a..3bd896c5d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -23,7 +23,6 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.util.HashMap; import java.util.Properties; - import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.core.sli.ConfigurationException; import org.onap.ccsdk.sli.core.sli.MetricLogger; @@ -47,35 +46,24 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; public class SvcLogicServiceImpl implements SvcLogicService { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicServiceImpl.class); - - private HashMap nodeExecutors = null; - - private BundleContext bctx = null; - - private Properties properties; - - private SvcLogicStore store; - - public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider) throws SvcLogicException{ - - properties = resourceProvider.getProperties(); - - getStore(); + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImpl.class); + protected HashMap nodeExecutors = null; + protected BundleContext bctx = null; + protected Properties properties; + protected SvcLogicStore store; + + public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider) throws SvcLogicException { + properties = resourceProvider.getProperties(); + getStore(); } - public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc) throws SvcLogicException{ - - properties = resourceProvider.getProperties(); - store = new SvcLogicDblibStore(dbSvc); -} - - - - private void registerExecutors() { + public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc) + throws SvcLogicException { + properties = resourceProvider.getProperties(); + store = new SvcLogicDblibStore(dbSvc); + } + protected void registerExecutors() { LOG.info("Entered register executors"); if (bctx == null) { bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); @@ -91,25 +79,23 @@ public class SvcLogicServiceImpl implements SvcLogicService { tracker.open(); ServiceListener listener = new ServiceListener() { - public void serviceChanged(ServiceEvent ev) { ServiceReference sr = ev.getServiceReference(); switch (ev.getType()) { - case ServiceEvent.REGISTERED: { - registerExecutor(sr); - } - break; - case ServiceEvent.UNREGISTERING: { - unregisterExecutor(sr); - } - break; + case ServiceEvent.REGISTERED: { + registerExecutor(sr); + } + break; + case ServiceEvent.UNREGISTERING: { + unregisterExecutor(sr); + } + break; } } }; LOG.info("Adding service listener"); - String filter = "(objectclass=" + SvcLogicNodeExecutor.class.getName() - + ")"; + String filter = "(objectclass=" + SvcLogicNodeExecutor.class.getName() + ")"; try { bctx.addServiceListener(listener, filter); ServiceReference[] srl = bctx.getServiceReferences(SvcLogicNodeExecutor.class.getName(), null); @@ -123,7 +109,6 @@ public class SvcLogicServiceImpl implements SvcLogicService { } public void registerExecutor(ServiceReference sr) { - String nodeName = (String) sr.getProperty("nodeType"); if (nodeName != null) { @@ -139,8 +124,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { } } - public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) - { + public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) { if (nodeExecutors == null) { nodeExecutors = new HashMap<>(); } @@ -152,7 +136,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { String nodeName = (String) sr.getProperty("nodeType"); if (nodeName != null) { - unregisterExecutor(nodeName); + unregisterExecutor(nodeName); } } @@ -162,13 +146,12 @@ public class SvcLogicServiceImpl implements SvcLogicService { } public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException { - if (nodeExecutors == null) { registerExecutors(); } // Set service name in MDC to reference current working directed graph - MDC.put(MetricLogger.SERVICE_NAME, graph.getModule()+":"+graph.getRpc()+"/v"+graph.getVersion()); + MDC.put(MetricLogger.SERVICE_NAME, graph.getModule() + ":" + graph.getRpc() + "/v" + graph.getVersion()); MDC.put("currentGraph", graph.toString()); @@ -176,7 +159,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { LOG.info("About to execute graph {}", graph.toString()); while (curNode != null) { - MDC.put("nodeId", curNode.getNodeId()+" ("+curNode.getNodeType()+")"); + MDC.put("nodeId", curNode.getNodeId() + " (" + curNode.getNodeType() + ")"); LOG.info("About to execute node # {} ({})", curNode.getNodeId(), curNode.getNodeType()); SvcLogicNode nextNode = executeNode(curNode, ctx); @@ -200,8 +183,8 @@ public class SvcLogicServiceImpl implements SvcLogicService { SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); if (executor != null) { - LOG.debug("Executing node executor for node type {} - {}", - node.getNodeType(), executor.getClass().getName()); + LOG.debug("Executing node executor for node type {} - {}", node.getNodeType(), + executor.getClass().getName()); return (executor.execute(this, node, ctx)); } else { if (LOG.isDebugEnabled()) { @@ -227,36 +210,31 @@ public class SvcLogicServiceImpl implements SvcLogicService { } return (nextNode); } - } @Override - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException - { + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { return (store.hasGraph(module, rpc, version, mode)); } @Override public Properties execute(String module, String rpc, String version, String mode, Properties props) throws SvcLogicException { - return(execute(module, rpc, version, mode, props, null)); + return (execute(module, rpc, version, mode, props, null)); } - @Override - public Properties execute(String module, String rpc, String version, String mode, - Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { - - + public Properties execute(String module, String rpc, String version, String mode, Properties props, + DOMDataBroker domDataBroker) throws SvcLogicException { LOG.info("Fetching service logic from data store"); SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - if (graph == null) - { + if (graph == null) { Properties retProps = new Properties(); retProps.setProperty("error-code", "401"); - retProps.setProperty("error-message", "No service logic found for ["+module+","+rpc+","+version+","+mode+"]"); - return(retProps); + retProps.setProperty("error-message", + "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]"); + return (retProps); } SvcLogicContext ctx = new SvcLogicContext(props); @@ -266,16 +244,15 @@ public class SvcLogicServiceImpl implements SvcLogicService { execute(graph, ctx); - return(ctx.toProperties()); + return (ctx.toProperties()); } - public SvcLogicStore getStore() throws SvcLogicException { + public SvcLogicStore getStore() throws SvcLogicException { // Create and initialize SvcLogicStore object - used to access // saved service logic. - - if (store != null) { - return store; - } + if (store != null) { + return store; + } try { store = SvcLogicStoreFactory.getSvcLogicStore(properties); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java index fa3bbcf4d..592fb2885 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java @@ -34,7 +34,7 @@ public class SwitchNodeExecutor extends SvcLogicNodeExecutor { @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java index 148745f62..a783df41f 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java @@ -38,7 +38,7 @@ public class UpdateNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(UpdateNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java index 69ac61388..b717aa986 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java @@ -34,7 +34,7 @@ public class WhileNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class); @Override - public SvcLogicNode execute(SvcLogicServiceImpl svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String testResult = evaluateNodeTest(node, ctx); SvcLogicExpression silentFailureExpr = node.getAttribute("do"); 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 old mode 100755 new mode 100644 index 829057426..bb14477e4 --- a/sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml +++ b/sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml @@ -3,7 +3,7 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java index eccbfc9e8..33ce6f69e 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java @@ -53,7 +53,7 @@ public class ExecuteNodeExecutorTest extends TestCase { MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor(); SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph()); node.setAttribute("method", "selectLunch"); - SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider(); + SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl(); execute.execute(new SvcLogicServiceImpl(resourceProvider), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 18f044b30..5e627cdb9 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -102,7 +102,7 @@ public class ITCaseSvcLogicGraphExecutor { SvcLogicParser parser = new SvcLogicParser(); // Loop through executor tests - SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider(); + SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl(); SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); for (String nodeType : BUILTIN_NODES.keySet()) { @@ -156,7 +156,7 @@ public class ITCaseSvcLogicGraphExecutor { SvcLogicParser parser = new SvcLogicParser(); // Loop through executor tests - SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider(); + SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl(); SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); -- cgit 1.2.3-korg From 168181418de462c53f7c0c326ea3ce5200467f09 Mon Sep 17 00:00:00 2001 From: Kevin Smokowski Date: Fri, 23 Feb 2018 20:51:21 +0000 Subject: fix setnode null feature short prefixes could cause bad behavior in the setnode null feature Change-Id: I3876eaece8b8d695b0a98d8b5d69f955f2149402 Issue-ID: CCSDK-190 Signed-off-by: Kevin Smokowski --- .../sli/core/sli/provider/SetNodeExecutor.java | 267 +++++++++------------ .../sli/core/sli/provider/SetNodeExecutorTest.java | 56 +++++ sli/provider/src/test/resources/clearValues.xml | 18 ++ sli/provider/src/test/resources/copyValues.xml | 16 ++ 4 files changed, 208 insertions(+), 149 deletions(-) create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java create mode 100644 sli/provider/src/test/resources/clearValues.xml create mode 100644 sli/provider/src/test/resources/copyValues.xml diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java index dc7fad0a8..cd478977c 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java @@ -3,14 +3,14 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * 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. @@ -26,7 +26,6 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Set; - import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -37,161 +36,131 @@ import org.slf4j.LoggerFactory; public class SetNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(SetNodeExecutor.class); + private static final Logger LOG = LoggerFactory.getLogger(SetNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + execute(node,ctx); + return null; + } - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { + public void execute(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + String ifunsetStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("only-if-unset"), node, ctx); - String ifunsetStr = SvcLogicExpressionResolver.evaluate( - node.getAttribute("only-if-unset"), node, ctx); + boolean ifunset = "true".equalsIgnoreCase(ifunsetStr); - boolean ifunset = "true".equalsIgnoreCase(ifunsetStr); + Set> parameterSet = node.getParameterSet(); - Set> parameterSet = node - .getParameterSet(); + for (Iterator> iter = parameterSet.iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + String lhsVarName = curName; - for (Iterator> iter = parameterSet - .iterator(); iter.hasNext();) { - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - String lhsVarName = curName; - - // Resolve LHS of assignment (could contain index variables) - try { - //Backticks symbolize the variable should be handled as an expression instead of as a variable + // Resolve LHS of assignment (could contain index variables) + try { + // Backticks symbolize the variable should be handled as an expression instead of as a variable if (curName.trim().startsWith("`")) { int lastParen = curName.lastIndexOf("`"); String evalExpr = curName.trim().substring(1, lastParen); SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(evalExpr); lhsVarName = SvcLogicExpressionResolver.evaluate(lhsExpr, node, ctx); } else { - SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); - lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); + SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); + lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); } - } catch (Exception e) { - LOG.warn("Caught exception trying to resolve variable name ("+curName+")", e); - } - - - boolean setValue = true; - - if (curName.endsWith(".")) { - - // Copy subtree - value should be a variable name - SvcLogicExpression curValue = curEnt.getValue(); - - if (curValue != null) { - String rhsRoot = curValue.toString(); - - if ((rhsRoot != null) && (rhsRoot.length() > 0)) { - if (rhsRoot.endsWith(".")) { - rhsRoot = rhsRoot - .substring(0, rhsRoot.length() - 1); - } - - - // SDNGC-2321 : rhsRoot is variable name, possibly with subscript(s) to be resolved - try { - SvcLogicExpression rhsExpr = SvcLogicExpressionFactory.parse(rhsRoot); - rhsRoot = SvcLogicExpressionResolver.resolveVariableName(rhsExpr, node, ctx); - } catch (Exception e) { - LOG.warn("Caught exception trying to resolve variable name ("+rhsRoot+")", e); - } - - // See if the parameters are reversed (copying service-data to input) .. this - // was done as a workaround to earlier issue - if (curName.endsWith("-input.") && rhsRoot.startsWith("service-data")) { - LOG.warn("Arguments appear to be reversed .. will copy input to service-data instead"); - lhsVarName = rhsRoot + "."; - rhsRoot = curName.substring(0, curName.length()-1); - } - - rhsRoot = rhsRoot + "."; - String lhsPrefix = lhsVarName; - - if (lhsPrefix.endsWith(".")) { - lhsPrefix = lhsPrefix.substring(0, - lhsPrefix.length()-1); - } - int lhsPfxLength = lhsPrefix.length(); - HashMap parmsToAdd = new HashMap(); - - for (String sourceVarName : ctx.getAttributeKeySet()) { - - if (sourceVarName.startsWith(rhsRoot)) { - - String targetVar = lhsPrefix - + "." - + sourceVarName - .substring(rhsRoot.length()); - - LOG.debug("Copying " + sourceVarName - + " value to " + targetVar); - - parmsToAdd.put(targetVar, - ctx.getAttribute(sourceVarName)); - } - } - - for (String newParmName : parmsToAdd.keySet()) { - ctx.setAttribute(newParmName, parmsToAdd.get(newParmName)); - } - - } else { - // If RHS is empty, unset attributes in LHS - String lhsPrefix = lhsVarName.substring(0, - lhsVarName.length() - 1); - int lhsPfxLength = lhsPrefix.length(); - - LinkedList parmsToRemove = new LinkedList (); - - for (String curCtxVarname : ctx.getAttributeKeySet()) { - - if (curCtxVarname.startsWith(lhsPrefix)) { - LOG.debug("Unsetting " + curCtxVarname); - parmsToRemove.add(curCtxVarname); - } - } - - for (String parmName : parmsToRemove) { - ctx.setAttribute(parmName, null); - } - - } - } - - } else { - - if (ifunset) { - String ctxValue = ctx.getAttribute(lhsVarName); - - if ((ctxValue != null) && (ctxValue.length() > 0)) { - setValue = false; - LOG.debug("Attribute " - + lhsVarName - + " already set and only-if-unset is true, so not overriding"); - } - } - - if (setValue) { - String curValue = SvcLogicExpressionResolver.evaluate( - curEnt.getValue(), node, ctx); - - if (LOG.isDebugEnabled()) { - LOG.trace("Parameter value " - + curEnt.getValue().asParsedExpr() - + " resolves to " + curValue); - LOG.debug("Setting context attribute " + lhsVarName - + " to " + curValue); - } - ctx.setAttribute(lhsVarName, curValue); - } - } - } - - return null; - } - + } catch (Exception e) { + LOG.warn("Caught exception trying to resolve variable name (" + curName + ")", e); + } + + boolean setValue = true; + + if (curName.endsWith(".")) { + // Copy subtree - value should be a variable name + SvcLogicExpression curValue = curEnt.getValue(); + + if (curValue != null) { + String rhsRoot = curValue.toString(); + + if ((rhsRoot != null) && (rhsRoot.length() > 0)) { + if (rhsRoot.endsWith(".")) { + rhsRoot = rhsRoot.substring(0, rhsRoot.length() - 1); + } + + // SDNGC-2321 : rhsRoot is variable name, possibly with subscript(s) to be resolved + try { + SvcLogicExpression rhsExpr = SvcLogicExpressionFactory.parse(rhsRoot); + rhsRoot = SvcLogicExpressionResolver.resolveVariableName(rhsExpr, node, ctx); + } catch (Exception e) { + LOG.warn("Caught exception trying to resolve variable name (" + rhsRoot + ")", e); + } + + // See if the parameters are reversed (copying service-data to input) .. this + // was done as a workaround to earlier issue + if (curName.endsWith("-input.") && rhsRoot.startsWith("service-data")) { + LOG.warn("Arguments appear to be reversed .. will copy input to service-data instead"); + lhsVarName = rhsRoot + "."; + rhsRoot = curName.substring(0, curName.length() - 1); + } + + rhsRoot = rhsRoot + "."; + String lhsPrefix = lhsVarName; + + if (lhsPrefix.endsWith(".")) { + lhsPrefix = lhsPrefix.substring(0, lhsPrefix.length() - 1); + } + int lhsPfxLength = lhsPrefix.length(); + HashMap parmsToAdd = new HashMap(); + + for (String sourceVarName : ctx.getAttributeKeySet()) { + + if (sourceVarName.startsWith(rhsRoot)) { + + String targetVar = lhsPrefix + "." + sourceVarName.substring(rhsRoot.length()); + + LOG.debug("Copying " + sourceVarName + " value to " + targetVar); + + parmsToAdd.put(targetVar, ctx.getAttribute(sourceVarName)); + } + } + for (String newParmName : parmsToAdd.keySet()) { + ctx.setAttribute(newParmName, parmsToAdd.get(newParmName)); + } + } else { + // If RHS is empty, unset attributes in LHS + LinkedList parmsToRemove = new LinkedList(); + String prefix = lhsVarName + "."; + for (String curCtxVarname : ctx.getAttributeKeySet()) { + if (curCtxVarname.startsWith(prefix)) { + LOG.debug("Unsetting " + curCtxVarname); + parmsToRemove.add(curCtxVarname); + } + } + for (String parmName : parmsToRemove) { + ctx.setAttribute(parmName, null); + } + } + } + } else { + if (ifunset) { + String ctxValue = ctx.getAttribute(lhsVarName); + if ((ctxValue != null) && (ctxValue.length() > 0)) { + setValue = false; + LOG.debug("Attribute " + lhsVarName + + " already set and only-if-unset is true, so not overriding"); + } + } + if (setValue) { + String curValue = SvcLogicExpressionResolver.evaluate(curEnt.getValue(), node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.trace("Parameter value " + curEnt.getValue().asParsedExpr() + " resolves to " + curValue); + LOG.debug("Setting context attribute " + lhsVarName + " to " + curValue); + } + ctx.setAttribute(lhsVarName, curValue); + } + } + } + } } + diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java new file mode 100644 index 000000000..1333d0702 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java @@ -0,0 +1,56 @@ +package org.onap.ccsdk.sli.core.sli.provider; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import java.util.LinkedList; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; + +public class SetNodeExecutorTest { + @Test + public void clearProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertNull(ctx.getAttribute("si.field1")); + assertNull(ctx.getAttribute("si.field2")); + assertNull(ctx.getAttribute("si.field3")); + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void subtreeCopy() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/copyValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1",ctx.getAttribute("si.field1")); + assertEquals("2",ctx.getAttribute("si.field2")); + assertEquals("3",ctx.getAttribute("si.field3")); + assertEquals("1",ctx.getAttribute("rootTwo.field1")); + assertEquals("2",ctx.getAttribute("rootTwo.field2")); + assertEquals("3",ctx.getAttribute("rootTwo.field3")); + } + +} diff --git a/sli/provider/src/test/resources/clearValues.xml b/sli/provider/src/test/resources/clearValues.xml new file mode 100644 index 000000000..615c8566a --- /dev/null +++ b/sli/provider/src/test/resources/clearValues.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider/src/test/resources/copyValues.xml b/sli/provider/src/test/resources/copyValues.xml new file mode 100644 index 000000000..f56f7140a --- /dev/null +++ b/sli/provider/src/test/resources/copyValues.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg From d1fcd126f971380f3e6a2401902ca4a261147324 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Mon, 5 Mar 2018 16:41:54 -0500 Subject: re-use parser instance add an additional logging statement and save memory Change-Id: Idc8bdefb00ac61317cc38848dce670d76b6d89f7 Issue-ID: CCSDK-204 Signed-off-by: Smokowski, Kevin (ks6305) --- .../onap/ccsdk/sli/core/sli/SvcLogicLoader.java | 14 ++-- .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 74 ++++++++++++---------- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java index 95f73f960..37d7faae0 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java @@ -39,15 +39,18 @@ public class SvcLogicLoader { private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicLoader.class); protected SvcLogicStore store; protected String directoryRoot; + protected SvcLogicParser parser; public SvcLogicLoader(String directoryRoot, SvcLogicStore store) { this.store = store; this.directoryRoot = directoryRoot; + this.parser = new SvcLogicParser(); } - + public SvcLogicLoader(String directoryRoot, String propFile) { this.store = SvcLogicParser.getStore(propFile); this.directoryRoot = directoryRoot; + this.parser = new SvcLogicParser(); } public void loadAndActivate() throws IOException { @@ -58,7 +61,7 @@ public class SvcLogicLoader { activateGraphs(activationEntries); } - private List processActivationFiles(List activationPaths) { + protected List processActivationFiles(List activationPaths) { List activationEntries = new ArrayList(); for (Path activationFile : activationPaths) { activationEntries.addAll(getActivationEntries(activationFile)); @@ -66,10 +69,12 @@ public class SvcLogicLoader { return activationEntries; } - private void activateGraphs(List activationEntries) { + protected void activateGraphs(List activationEntries) { for (ActivationEntry entry : activationEntries) { try { if (store.hasGraph(entry.module, entry.rpc, entry.version, entry.mode)) { + LOGGER.info("Activating SvcLogicGraph [module=" + entry.module + ", rpc=" + entry.rpc + ", mode=" + + entry.mode + ", version=" + entry.version + "]"); store.activate(entry.module, entry.rpc, entry.version, entry.mode); } else { LOGGER.error("hasGraph returned false for " + entry.toString()); @@ -113,13 +118,12 @@ public class SvcLogicLoader { } } - private void saveGraph(String xmlFile) throws SvcLogicException { + protected void saveGraph(String xmlFile) throws SvcLogicException { File f = new File(xmlFile); if (!f.canRead()) { throw new ConfigurationException("Cannot read xml file (" + xmlFile + ")"); } - SvcLogicParser parser = new SvcLogicParser(); LinkedList graphs = null; try { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 51eb18e44..3d9caffbd 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.net.URL; import java.util.LinkedList; import javax.xml.XMLConstants; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import javax.xml.validation.Schema; @@ -59,6 +60,7 @@ public class SvcLogicParser { private static final Logger LOGGER = LoggerFactory.getLogger(SvcLogicParser.class); private static final String SLI_VALIDATING_PARSER = "org.onap.ccsdk.sli.parser.validate"; private static final String SVCLOGIC_XSD = "/svclogic.xsd"; + private SAXParser saxParser; private class SvcLogicHandler extends DefaultHandler { private Locator locator = null; @@ -309,41 +311,12 @@ public class SvcLogicParser { public LinkedList parse(String fileName) throws SvcLogicException { LinkedList graphs; - URL xsdUrl = null; - Schema schema = null; - String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true"); - - if ("true".equalsIgnoreCase(validateSchema)) { - xsdUrl = getClass().getResource(SVCLOGIC_XSD); - } - - if (xsdUrl != null) { - try { - SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - schema = schemaFactory.newSchema(xsdUrl); - LOGGER.info("Schema path {}", xsdUrl.getPath()); - } catch (Exception e) { - LOGGER.warn("Could not validate using schema {}", xsdUrl.getPath(), e); - } - } else { - LOGGER.warn("Could not find resource {}", SVCLOGIC_XSD); - } - try { - SAXParserFactory factory = SAXParserFactory.newInstance(); - - if (schema != null) { - factory.setNamespaceAware(true); - factory.setSchema(schema); - } - SAXParser saxParser = factory.newSAXParser(); - - if (saxParser.isValidating()) { - LOGGER.info("Parser configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null)); + if (saxParser == null) { + saxParser = initParser(); } graphs = new LinkedList<>(); - saxParser.parse(fileName, new SvcLogicHandler(graphs)); try { @@ -353,7 +326,6 @@ public class SvcLogicParser { } catch (Exception exc) { LOGGER.error("Couldn't set md5sum on graphs", exc); } - } catch (Exception e) { LOGGER.error("Parsing failed ", e); String msg = e.getMessage(); @@ -363,7 +335,6 @@ public class SvcLogicParser { throw new SvcLogicException("Compiler error: " + fileName, e); } } - return graphs; } @@ -466,6 +437,7 @@ public class SvcLogicParser { } + public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException { File xmlFile = new File(xmlfile); if (!xmlFile.canRead()) { @@ -588,5 +560,41 @@ public class SvcLogicParser { System.exit(1); } + + protected SAXParser initParser() throws ParserConfigurationException, SAXException { + URL xsdUrl = null; + Schema schema = null; + String validateSchema = System.getProperty(SLI_VALIDATING_PARSER, "true"); + + if ("true".equalsIgnoreCase(validateSchema)) { + xsdUrl = getClass().getResource(SVCLOGIC_XSD); + } + + if (xsdUrl != null) { + try { + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + schema = schemaFactory.newSchema(xsdUrl); + LOGGER.info("Schema path {}", xsdUrl.getPath()); + } catch (Exception e) { + LOGGER.warn("Could not validate using schema {}", xsdUrl.getPath(), e); + } + } else { + LOGGER.warn("Could not find resource {}", SVCLOGIC_XSD); + } + + SAXParserFactory factory = SAXParserFactory.newInstance(); + + if (schema != null) { + factory.setNamespaceAware(true); + factory.setSchema(schema); + } + + SAXParser saxParser = factory.newSAXParser(); + if (saxParser.isValidating()) { + LOGGER.info("Parser configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null)); + } + return saxParser; + } + } -- cgit 1.2.3-korg From a9e89cccc344b5f1aecbe3936f6bb917cfe7b20f Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Thu, 8 Mar 2018 14:50:22 +0000 Subject: Fix sonar related items Changes made: * Optimized TerminatingCachedDataSource * Added additional unit tests Change-Id: I0a83c993898e2bee11b8d3c5df8f95b4b216e9b8 Issue-ID: CCSDK-151 Signed-off-by: Rich Tabedzki --- .../ccsdk/sli/core/dblib/DBResourceManager.java | 3 +- .../core/dblib/TerminatingCachedDataSource.java | 46 ----------- .../core/dblib/jdbc/JdbcDBCachedDataSource.java | 1 - .../ccsdk/sli/core/dblib/CachedDataSourceTest.java | 94 ++++++++++++++++++++++ .../sli/core/dblib/DBConfigExceptionTest.java | 19 +++++ .../dblib/DblibConfigurationExceptionTest.java | 24 ++++++ .../dblib/TerminatingCachedDataSourceTest.java | 94 ++++++++++++++++++++++ 7 files changed, 233 insertions(+), 48 deletions(-) create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBConfigExceptionTest.java create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DblibConfigurationExceptionTest.java create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSourceTest.java diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 27c14d2a4..9acae340b 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -248,7 +248,8 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } catch(Exception exc) { LOGGER.warn("", exc); } - LOGGER.info("Thread DataSourceTester terminated {} for {}", this.getName(), ds.getDbConnectionName()); + if(ds != null) + LOGGER.info("Thread DataSourceTester terminated {} for {}", this.getName(), ds.getDbConnectionName()); } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java index 92b31470e..e1afcc22e 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java @@ -38,54 +38,8 @@ public class TerminatingCachedDataSource extends CachedDataSource implements SQL return null; } - @Override - public long getInterval() { - return 1000; - } - - @Override - public long getInitialDelay() { - return 1000; - } - - @Override - public long getExpectedCompletionTime() { - return 50; - } - - @Override - public void setExpectedCompletionTime(long value) { - - } - - @Override - public void setInterval(long value) { - - } - - @Override - public void setInitialDelay(long value) { - - } - - @Override - public long getUnprocessedFailoverThreshold() { - return 3; - } - - @Override - public void setUnprocessedFailoverThreshold(long value) { - - } - - public int compareTo(CachedDataSource ods) - { - return 0; - } - @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub return null; } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java index a6582b9e7..80ca577cf 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java @@ -180,7 +180,6 @@ public class JdbcDBCachedDataSource extends CachedDataSource { public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { - // TODO Auto-generated method stub return null; } diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java new file mode 100644 index 000000000..6385c1b57 --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java @@ -0,0 +1,94 @@ +package org.onap.ccsdk.sli.core.dblib; + +import static org.junit.Assert.*; + +import java.sql.SQLFeatureNotSupportedException; +import java.util.Properties; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.onap.ccsdk.sli.core.dblib.jdbc.JdbcDBCachedDataSource; +import org.slf4j.LoggerFactory; + +public class CachedDataSourceTest { + + private static final Properties props = new Properties(); + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + props.setProperty("org.onap.ccsdk.sli.dbtype", "jdbc"); + props.setProperty("org.onap.ccsdk.sli.jdbc.hosts", "localhost"); + props.setProperty("org.onap.ccsdk.sli.jdbc.url", "jdbc:mysql://dbhost:3306/test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.driver", "org.mariadb.jdbc.Driver"); + props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.user", "dbuser"); + props.setProperty("org.onap.ccsdk.sli.jdbc.password", "passw0rd"); + props.setProperty("org.onap.ccsdk.sli.jdbc.connection.name", "testdb01"); + props.setProperty("org.onap.ccsdk.sli.jdbc.connection.timeout", "50"); + props.setProperty("org.onap.ccsdk.sli.jdbc.request.timeout", "100"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.init", "10"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.min", "10"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.max", "20"); + props.setProperty("org.onap.dblib.connection.recovery", "false"); + } + + @Test + public void testCachedDataSource() { + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new JdbcDBCachedDataSource(config); + assertNotNull(ds); + } + + @Test + public void testConfigure() { + BaseDBConfiguration config = new JDBCConfiguration(props); + + CachedDataSource ds = new JdbcDBCachedDataSource(config); + assertNotNull(ds.configure(config)); + } + + @Test + public void testSetInitialDelay() { + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new JdbcDBCachedDataSource(config); + ds.setInitialDelay(1000L); + assertTrue(ds.getInitialDelay() == 1000L); + } + + @Test + public void testSetInterval() { + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new JdbcDBCachedDataSource(config); + ds.setInterval(1000L); + assertTrue(ds.getInterval() == 1000L); + } + + @Test + public void testSetExpectedCompletionTime() { + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new JdbcDBCachedDataSource(config); + ds.setExpectedCompletionTime(100L); + assertTrue(ds.getExpectedCompletionTime() == 100L); + } + + @Test + public void testSetUnprocessedFailoverThreshold() { + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new JdbcDBCachedDataSource(config); + ds.setUnprocessedFailoverThreshold(100L); + assertTrue(ds.getUnprocessedFailoverThreshold() == 100L); + } + + @Test + public void testGetParentLogger() { + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new JdbcDBCachedDataSource(config); + try { + assertNull(ds.getParentLogger()); + } catch (SQLFeatureNotSupportedException e) { + LoggerFactory.getLogger(CachedDataSourceTest.class).warn("Test Failure", e); + } + } +} \ No newline at end of file diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBConfigExceptionTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBConfigExceptionTest.java new file mode 100644 index 000000000..2a5b65c7a --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBConfigExceptionTest.java @@ -0,0 +1,19 @@ +package org.onap.ccsdk.sli.core.dblib; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class DBConfigExceptionTest { + + @Test + public void testDBConfigExceptionException() { + assertNotNull(new DBConfigException("JUnit Test")); + } + + @Test + public void testDBConfigExceptionString() { + assertNotNull(new DBConfigException(new Exception("JUnit Test"))); + } + +} diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DblibConfigurationExceptionTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DblibConfigurationExceptionTest.java new file mode 100644 index 000000000..7becd1ae4 --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DblibConfigurationExceptionTest.java @@ -0,0 +1,24 @@ +package org.onap.ccsdk.sli.core.dblib; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class DblibConfigurationExceptionTest { + + @Test + public void testDblibConfigurationException() { + assertNotNull(new DblibConfigurationException()); + } + + @Test + public void testDblibConfigurationExceptionString() { + assertNotNull(new DblibConfigurationException("JUnit Test")); + } + + @Test + public void testDblibConfigurationExceptionStringThrowable() { + assertNotNull(new DblibConfigurationException("JUnit Test", new Exception("JUnit Test"))); + } + +} diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSourceTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSourceTest.java new file mode 100644 index 000000000..160a3d4ae --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSourceTest.java @@ -0,0 +1,94 @@ +package org.onap.ccsdk.sli.core.dblib; + +import static org.junit.Assert.*; + +import java.sql.SQLFeatureNotSupportedException; +import java.util.Properties; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.slf4j.LoggerFactory; + +public class TerminatingCachedDataSourceTest { + + @Test + public void testTerminatingCachedDataSource() { + Properties props = new Properties(); + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new TerminatingCachedDataSource(config); + assertNotNull(ds); + } + + @Test + public void testConfigure() { + Properties props = new Properties(); + props.setProperty("org.onap.ccsdk.sli.dbtype", "jdbc"); + props.setProperty("org.onap.ccsdk.sli.jdbc.hosts", "localhost"); + props.setProperty("org.onap.ccsdk.sli.jdbc.url", "jdbc:mysql://dbhost:3306/test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.driver", "org.mariadb.jdbc.Driver"); + props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.user", "dbuser"); + props.setProperty("org.onap.ccsdk.sli.jdbc.password", "passw0rd"); + props.setProperty("org.onap.ccsdk.sli.jdbc.connection.name", "testdb01"); + props.setProperty("org.onap.ccsdk.sli.jdbc.connection.timeout", "50"); + props.setProperty("org.onap.ccsdk.sli.jdbc.request.timeout", "100"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.init", "10"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.min", "10"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.max", "20"); + props.setProperty("org.onap.dblib.connection.recovery", "false"); + BaseDBConfiguration config = new JDBCConfiguration(props); + + CachedDataSource ds = new TerminatingCachedDataSource(config); + assertNull(ds.configure(config)); + } + + @Test + public void testSetInitialDelay() { + Properties props = new Properties(); + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new TerminatingCachedDataSource(config); + ds.setInitialDelay(1000L); + assertTrue(ds.getInitialDelay() == 1000L); + } + + @Test + public void testSetInterval() { + Properties props = new Properties(); + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new TerminatingCachedDataSource(config); + ds.setInterval(1000L); + assertTrue(ds.getInterval() == 1000L); + } + + @Test + public void testSetExpectedCompletionTime() { + Properties props = new Properties(); + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new TerminatingCachedDataSource(config); + ds.setExpectedCompletionTime(100L); + assertTrue(ds.getExpectedCompletionTime() == 100L); + } + + @Test + public void testSetUnprocessedFailoverThreshold() { + Properties props = new Properties(); + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new TerminatingCachedDataSource(config); + ds.setUnprocessedFailoverThreshold(100L); + assertTrue(ds.getUnprocessedFailoverThreshold() == 100L); + } + + @Test + public void testGetParentLogger() { + Properties props = new Properties(); + BaseDBConfiguration config = new JDBCConfiguration(props); + CachedDataSource ds = new TerminatingCachedDataSource(config); + ds.setInterval(100L); + try { + assertNull(ds.getParentLogger()); + } catch (SQLFeatureNotSupportedException e) { + LoggerFactory.getLogger(TerminatingCachedDataSourceTest.class).warn("Test Failure", e); + } + } +} \ No newline at end of file -- cgit 1.2.3-korg From 52769e979a907fbd862789c973ba29e644931954 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 9 Mar 2018 21:05:19 +0000 Subject: Check system property before environment variable Allow system property to take precedence over environment variable when searching for the properties file Change-Id: I1c6f7099551d814ca388f4694a0bb24409a7167b Issue-ID: CCSDK-209 Signed-off-by: Smokowski, Kevin (ks6305) --- .../org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java index 5e87412a5..669b3992b 100755 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java @@ -28,7 +28,7 @@ import java.util.Optional; /** * Resolves properties files relative to the directory identified by the SDNC_CONFIG_DIR - * environment variable. + * environment variable. If a system property with the same name is set it is given precedence. */ public abstract class EnvVarFileResolver implements PropertiesFileResolver { @@ -51,8 +51,14 @@ public abstract class EnvVarFileResolver implements PropertiesFileResolver { */ @Override public Optional resolveFile(final String filename) { - // attempt to resolve the property directory from the corresponding environment variable - final String propDirectoryFromEnvVariable = System.getenv(propertyKey); + // attempt to read the system property first + String propDirectoryFromEnvVariable = System.getProperty(propertyKey); + + if(propDirectoryFromEnvVariable == null) { + // attempt to resolve the property directory from the corresponding environment variable + propDirectoryFromEnvVariable = System.getenv(propertyKey); + } + final File fileFromEnvVariable; if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(filename).toFile(); -- cgit 1.2.3-korg From 67414f17e30d04ad278fe7ab73c0bed8c44c0523 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 16 Mar 2018 13:58:47 -0400 Subject: Add test cases for sli Added test cases for sli in sli/core Change-Id: Ic8614f199ae843a46ec3441f0ae247f065b33322 Issue-ID: CCSDK-213 Signed-off-by: Timoney, Dan (dt5972) --- .../core/sli/provider/SvcLogicAdaptorFactory.java | 46 ++---- .../core/sli/provider/SvcLogicClassResolver.java | 41 +++++ .../core/sli/provider/SvcLogicNodeExecutor.java | 48 ++---- .../ccsdk/sli/core/sli/provider/DummyAdaptor.java | 42 +++++ .../ccsdk/sli/core/sli/provider/DummyRecorder.java | 14 ++ .../ccsdk/sli/core/sli/provider/DummyResource.java | 97 ++++++++++++ .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 8 +- sli/provider/src/test/resources/executor.tests | 6 +- .../src/test/resources/l3sdn_logic_v10.xml | 172 ++++++++++++++++----- .../sli/core/sli/recording/TestFileRecorder.java | 35 +++++ .../sli/core/sli/recording/TestSlf4jRecorder.java | 33 ++++ 11 files changed, 429 insertions(+), 113 deletions(-) create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java create mode 100644 sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java create mode 100644 sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java index 7316db57c..ecfe6b69a 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java @@ -8,9 +8,9 @@ * 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. @@ -35,7 +35,7 @@ public class SvcLogicAdaptorFactory { private static final Logger LOG = LoggerFactory .getLogger(SvcLogicAdaptorFactory.class); - private static HashMap adaptorMap = new HashMap(); + private static HashMap adaptorMap = new HashMap<>(); public static void registerAdaptor(SvcLogicAdaptor adaptor) { String name = adaptor.getClass().getName(); @@ -51,36 +51,18 @@ public class SvcLogicAdaptorFactory { } } - public static SvcLogicAdaptor getInstance(String name) { - if (adaptorMap.containsKey(name)) { - return (adaptorMap.get(name)); - } else { - BundleContext bctx = null; - try - { - bctx = FrameworkUtil.getBundle(SvcLogicAdaptorFactory.class) - .getBundleContext(); - } - catch (Exception e) - { - LOG.debug("Caught exception trying to locate device adaptor "+name, e); - return(null); - } - - ServiceReference sref = bctx.getServiceReference(name); + public static SvcLogicAdaptor getInstance(String name) { + if (adaptorMap.containsKey(name)) { + return adaptorMap.get(name); + } else { - if (sref != null) { - SvcLogicAdaptor adaptor = (SvcLogicAdaptor) bctx - .getService(sref); + SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.resolve(name); - if (adaptor != null) { - registerAdaptor(adaptor); + if (adaptor != null) { + registerAdaptor(adaptor); + } - return (adaptor); - } - return (null); - } - } - return(null); - } + return adaptor; + } + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java new file mode 100644 index 000000000..d2b733fc3 --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java @@ -0,0 +1,41 @@ +package org.onap.ccsdk.sli.core.sli.provider; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicClassResolver { + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class); + + public static Object resolve(String className) { + + Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class); + + if (bundle == null) { + // Running outside OSGi container (e.g. jUnit). Use Reflection + // to resolve class + try { + return(Class.forName(className).newInstance()); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + + LOG.error("Could not resolve class "+className, e); + return null; + } + + } else { + BundleContext bctx = bundle.getBundleContext(); + ServiceReference sref = bctx.getServiceReference(className); + if (sref != null) { + return bctx.getService(sref); + } else { + + LOG.warn("Could not find service reference object for class " + className); + return null; + } + } + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java index 593c972a7..f34c261d6 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java @@ -29,6 +29,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; @@ -53,56 +54,25 @@ public abstract class SvcLogicNodeExecutor { } + protected SvcLogicAdaptor getAdaptor(String adaptorName) { return SvcLogicAdaptorFactory.getInstance(adaptorName); } protected SvcLogicResource getSvcLogicResource(String plugin) { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(plugin); - if (sref != null) { - SvcLogicResource resourcePlugin = (SvcLogicResource) bctx - .getService(sref); - return resourcePlugin; - } - else { - LOG.warn("Could not find service reference object for plugin " + plugin); - return null; - } + + return((SvcLogicResource) SvcLogicClassResolver.resolve(plugin)); } protected SvcLogicRecorder getSvcLogicRecorder(String plugin) { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(plugin); - if (sref != null) { - SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx - .getService(sref); - return resourcePlugin; - } - else { - return null; - } + return((SvcLogicRecorder) SvcLogicClassResolver.resolve(plugin)); } protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){ - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(pluginName); - - if (sref == null) { - LOG.warn("Could not find service reference object for plugin " + pluginName); - return null; - } else { - SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx - .getService(sref); - return plugin; - } - } + return((SvcLogicJavaPlugin) SvcLogicClassResolver.resolve(pluginName)); + + } + protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) { MetricLogger.resetContext(); SvcLogicNode nextNode = node.getOutcomeValue(outValue); diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java new file mode 100644 index 000000000..877653441 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java @@ -0,0 +1,42 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.provider; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +/** + * @author dt5972 + * + */ + +public class DummyAdaptor implements SvcLogicAdaptor { + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#configure(java.lang.String, java.util.Map, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus configure(String key, Map parameters, SvcLogicContext ctx) { + + return ConfigStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#activate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus activate(String key, SvcLogicContext ctx) { + return ConfigStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#deactivate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus deactivate(String key, SvcLogicContext ctx) { + return ConfigStatus.SUCCESS; + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java new file mode 100644 index 000000000..e87f9628d --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.sli.provider; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; + +public class DummyRecorder implements SvcLogicRecorder { + + @Override + public void record(Map parmMap) throws SvcLogicException { + return; + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java new file mode 100644 index 000000000..2f784186e --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java @@ -0,0 +1,97 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.provider; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; + +/** + * @author dt5972 + * + */ +public class DummyResource implements SvcLogicResource { + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#isAvailable(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#exists(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#query(java.lang.String, boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, + String orderBy, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#reserve(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#save(java.lang.String, boolean, boolean, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map parms, + String prefix, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#release(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { + + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#delete(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#notify(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#update(java.lang.String, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus update(String resource, String key, Map parms, String prefix, + SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 5e627cdb9..4c112ab25 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -45,6 +45,9 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicParser; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -101,7 +104,6 @@ public class ITCaseSvcLogicGraphExecutor { SvcLogicParser parser = new SvcLogicParser(); - // Loop through executor tests SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl(); SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); @@ -109,6 +111,10 @@ public class ITCaseSvcLogicGraphExecutor { LOG.info("SLI - registering node executor for node type " + nodeType); svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } + + + + } @AfterClass diff --git a/sli/provider/src/test/resources/executor.tests b/sli/provider/src/test/resources/executor.tests index e7547e633..e4e60208a 100755 --- a/sli/provider/src/test/resources/executor.tests +++ b/sli/provider/src/test/resources/executor.tests @@ -1,2 +1,6 @@ l3sdn_logic_v10.xml:switchTester:test-value="" -l3sdn_logic_v10.xml:switchTester:test-value="hi" \ No newline at end of file +l3sdn_logic_v10.xml:switchTester:test-value="hi" +l3sdn_logic_v10.xml:forRecordTester +l3sdn_logic_v10.xml:resourceTester +l3sdn_logic_v10.xml:configureTester +l3sdn_logic_v10.xml:javaPluginTester \ No newline at end of file diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml index 127c181fb..c1123d13d 100644 --- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml +++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml @@ -1,22 +1,14 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - + + + + + + + + - + 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 new file mode 100644 index 000000000..c879d8f62 --- /dev/null +++ b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java @@ -0,0 +1,35 @@ +/** + * + */ +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 TestFileRecorder { + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sli.recording.FileRecorder#record(java.util.Map)}. + */ + @Test + public void testRecord() { + + FileRecorder recorder = new FileRecorder(); + + 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()); + } + } + +} 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 new file mode 100644 index 000000000..c696f25b5 --- /dev/null +++ b/sli/recording/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()); + } + } + +} -- cgit 1.2.3-korg From 6a0812672bc3d8032f170d72854fec45023cffa5 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 16 Mar 2018 19:46:56 +0000 Subject: Additional enum support support enumerations containing whitespace Change-Id: I91971a111e67e0faf757c954fb6658529e3020d2 Issue-ID: CCSDK-214 Signed-off-by: Smokowski, Kevin (ks6305) --- .../java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 3 +++ .../org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index bea21387b..76101514a 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -1267,6 +1267,9 @@ public class MdsalHelper { // This will strip out all periods, which cannot be in a java enum inStr = inStr.replaceAll("\\.", ""); + //This is needed for enums containing spaces + inStr = inStr.replaceAll(" ", ""); + String[] terms = inStr.split("-"); StringBuffer sbuff = new StringBuffer(); diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index c00da68c5..e7f1e18b9 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -28,7 +28,10 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; +import static org.junit.Assert.*; + import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; @@ -132,4 +135,10 @@ public class MdsalHelperTest extends TestCase { } + + public void testToJavaEnum() throws Exception{ + assertEquals("_2018HelloWorld",MdsalHelper.toJavaEnum("2018Hello World")); + assertEquals("SomethingElse",MdsalHelper.toJavaEnum("Something.Else")); + assertEquals("MyTestString",MdsalHelper.toJavaEnum("my-test-string")); + } } -- cgit 1.2.3-korg From 5f5c7d60935f8ed4bf46ebce574c8495c8121e3d Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 20 Mar 2018 14:00:22 -0400 Subject: Register sliapi RPC implementation When porting sliapi to use blueprints, neglected to update sliapiProvider to register itself as RPC implementor. Change-Id: I653ccf4db737e8745715d5e4b07352045c9c9c5e Issue-ID: CCSDK-217 Signed-off-by: Timoney, Dan (dt5972) --- .../src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index c3ad4ed60..3ff2f52d4 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -159,6 +159,8 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ public void initialize(){ LOG.info( "Initializing provider for " + appName ); //initialization code goes here. + rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); + sdncStatusFile = System.getenv(SDNC_STATUS_FILE); LOG.info( "SDNC STATUS FILE = " + sdncStatusFile ); LOG.info( "Initialization complete for " + appName ); -- cgit 1.2.3-korg From 5e0f12e215d579b2adff145a8527cc6a225d8db9 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 21 Mar 2018 19:15:29 -0400 Subject: Add unit tests for sli/provider Add additional unit testing for configure node Change-Id: I867fd1aae54e956bdbe8a2f2fd406b46304b4a91 Issue-ID: CCSDK-213 Signed-off-by: Timoney, Dan (dt5972) --- sli/common/pom.xml | 5 ++++ .../ccsdk/sli/core/sli/provider/DummyAdaptor.java | 12 ++++++++ .../src/test/resources/l3sdn_logic_v10.xml | 33 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 2fb3f8370..1d35dfb1b 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -98,6 +98,11 @@ sal-binding-api + + com.att.eelf + eelf-core + + junit diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java index 877653441..0f3893efb 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java @@ -20,6 +20,18 @@ public class DummyAdaptor implements SvcLogicAdaptor { @Override public ConfigStatus configure(String key, Map parameters, SvcLogicContext ctx) { + if ("ALREADY_ACTIVE".equalsIgnoreCase(key)) { + return ConfigStatus.ALREADY_ACTIVE; + } else if ("NOT_FOUND".equalsIgnoreCase(key)) { + return ConfigStatus.NOT_FOUND; + }else if ("NOT_READY".equalsIgnoreCase(key)) { + return ConfigStatus.NOT_READY; + } else if ("FAILURE".equalsIgnoreCase(key)) { + return ConfigStatus.FAILURE; + } else if ("SUCCESS".equalsIgnoreCase(key)) { + return ConfigStatus.SUCCESS; + } + return ConfigStatus.SUCCESS; } diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml index c1123d13d..1386df10d 100644 --- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml +++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml @@ -97,6 +97,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg From 8550176e6fd49c28cf9d9a5c79cc363eb91e6335 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 27 Mar 2018 17:48:55 +0000 Subject: Simplify enumeration handling Use getName() on the java object instead of relying on a mapping file created by yang2props Change-Id: Ie3405903af5211c019c93a9a0b49ba9159b0bbe2 Issue-ID: CCSDK-227 Signed-off-by: Smokowski, Kevin (ks6305) --- .../java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 76101514a..b652c433c 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -56,6 +56,7 @@ public class MdsalHelper { setYangMappingProperties(input); } + @Deprecated public static void setYangMappingProperties(Properties properties) { for (Object propNameObj : properties.keySet()) { String propName = (String) propNameObj; @@ -63,6 +64,7 @@ public class MdsalHelper { } } + @Deprecated public static void loadProperties(String propertiesFile) { File file = new File(propertiesFile); Properties properties = new Properties(); @@ -186,8 +188,9 @@ public class MdsalHelper { } if (retValue != null) { String propName = propNamePfx + "." + fieldName; - propVal = retValue.toString(); - props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); + Method method = retValue.getClass().getMethod("getName"); + String yangValue = (String) method.invoke(retValue); + props.setProperty(propName, yangValue); } } catch (Exception e) { LOG.error( @@ -1333,11 +1336,13 @@ public class MdsalHelper { return (false); } + @Deprecated public static String getFullPropertiesPath(String propertiesFileName) { return "/opt/bvc/controller/configuration/" + propertiesFileName; } // This is called when mapping a valid java enumeration back to the yang model value + @Deprecated public static String mapEnumeratedValue(String propertyName, String propertyValue) { LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); String mappingKey = "yang." + propertyName + "." + propertyValue; -- cgit 1.2.3-korg From a0ab49e6c1ea41af18656d6e9efb3377051f2528 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Sat, 24 Mar 2018 19:11:10 -0400 Subject: Add unit tests for sli Added unit tests for ccsdk/sli/core/sli Change-Id: I0d2408c43b9e56a78f3e01e87985aedb6cad5953 Issue-ID: CCSDK-213 Signed-off-by: Timoney, Dan (dt5972) --- .gitignore | 2 + .../ccsdk/sli/core/dblib/CachedDataSource.java | 7 +- filters/provider/pom.xml | 8 + .../filters/RequestResponseDbLoggingFilter.java | 5 +- .../onap/ccsdk/sli/core/filters/TestLogFilter.java | 71 +++++++ .../filters/TestRequestResponseLoggingFilter.java | 129 +++++++++++++ sli/common/pom.xml | 12 +- .../org/onap/ccsdk/sli/core/sli/MessageWriter.java | 6 +- .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 13 ++ .../onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 1 - .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 6 +- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 139 ++++++++++++-- .../ccsdk/sli/core/sli/PrintYangToPropTest.java | 22 +++ .../onap/ccsdk/sli/core/sli/TestMetricLogger.java | 135 +++++++++++++ .../ccsdk/sli/core/sli/TestSvcLogicLoader.java | 38 ++++ sli/common/src/test/resources/dblib.properties | 14 ++ .../test/resources/graphs/sliapi/graph.versions | 1 + .../resources/graphs/sliapi/sli_healthcheck.xml | 27 +++ sli/common/src/test/resources/l3sdn_logic_v10.xml | 208 +++++++++++++++++++++ sli/common/src/test/resources/parser-good.tests | 1 + sli/common/src/test/resources/svclogic.properties | 7 +- sli/common/src/test/resources/svclogic.xsd | 11 ++ sli/provider/pom.xml | 96 +++++----- .../src/main/resources/svclogic.properties | 25 --- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 29 +-- sli/provider/src/test/resources/executor.tests | 4 +- .../src/test/resources/l3sdn_logic_v10.xml | 23 +++ .../src/test/resources/svclogic.properties | 4 +- sliapi/provider/pom.xml | 143 ++++++++------ .../onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 23 ++- .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 171 +++++++++++++++++ .../src/test/resources/sli_healthcheck.xml | 27 +++ .../src/test/resources/svclogic.properties | 27 +++ 33 files changed, 1241 insertions(+), 194 deletions(-) create mode 100644 filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java create mode 100644 filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java create mode 100755 sli/common/src/test/resources/dblib.properties create mode 100644 sli/common/src/test/resources/graphs/sliapi/graph.versions create mode 100644 sli/common/src/test/resources/graphs/sliapi/sli_healthcheck.xml create mode 100644 sli/common/src/test/resources/l3sdn_logic_v10.xml delete mode 100644 sli/provider/src/main/resources/svclogic.properties create mode 100644 sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java create mode 100644 sliapi/provider/src/test/resources/sli_healthcheck.xml create mode 100644 sliapi/provider/src/test/resources/svclogic.properties diff --git a/.gitignore b/.gitignore index a36bed326..a5a0d80e3 100755 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,5 @@ sdnc-core_bdio.jsonld blackDuckHubProjectName.txt blackDuckHubProjectVersionName.txt +# Derby log +derby.log diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 02cce3cf1..97380f58d 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -342,11 +342,16 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } protected boolean testConnection(boolean errorLevel) { + + String testQuery = "SELECT @@global.read_only, @@global.hostname"; + if (isDerby) { + testQuery = "SELECT 'false', 'localhost' FROM SYSIBM.SYSDUMMY1"; + } ResultSet rs = null; try (Connection conn = this.getConnection(); Statement stmt = conn.createStatement()) { Boolean readOnly; String hostname; - rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); // ("SELECT 1 FROM DUAL"); //"select + rs = stmt.executeQuery(testQuery); // ("SELECT 1 FROM DUAL"); //"select // BANNER from SYS.V_$VERSION" while (rs.next()) { readOnly = rs.getBoolean(1); diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 4fdd83280..a60c0be05 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -19,6 +19,8 @@ UTF-8 + + **/RequestResponseDbLoggingFilter.java @@ -28,6 +30,12 @@ ${junit.version} test + + + org.mockito + mockito-core + test + javax.servlet javax.servlet-api diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java index 8b67276b0..359136565 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java @@ -8,9 +8,9 @@ * 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. @@ -47,6 +47,7 @@ import org.onap.ccsdk.sli.core.sli.MessageWriter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Deprecated public class RequestResponseDbLoggingFilter implements Filter { private static Logger log = LoggerFactory.getLogger(RequestResponseDbLoggingFilter.class); diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java new file mode 100644 index 000000000..a900b246c --- /dev/null +++ b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java @@ -0,0 +1,71 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.filters; + +import static org.junit.Assert.*; +import org.apache.commons.codec.binary.Base64; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.mockito.Mockito.*; +import java.io.IOException; +import java.util.UUID; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author dt5972 + * + */ +public class TestLogFilter { + + LogFilter logFilter; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + logFilter = new LogFilter(); + logFilter.init(null); + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + logFilter.destroy(); + } + + /** + * Test method for {@link org.onap.ccsdk.sli.core.filters.LogFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}. + * @throws ServletException + * @throws IOException + */ + @Test + public void testDoFilter() throws IOException, ServletException { + + // Test failed request with minimal headers + HttpServletRequest servletReq = mock(HttpServletRequest.class); + when(servletReq.getRequestURL()).thenReturn(new StringBuffer("SLI-API:healthcheck")); + when(servletReq.getPathInfo()).thenReturn("/hello:world"); + HttpServletResponse servletResp = mock(HttpServletResponse.class); + when(servletResp.getStatus()).thenReturn(400); + FilterChain filterChain = mock(FilterChain.class); + logFilter.doFilter(servletReq, servletResp, filterChain); + + // Test successful request with valid header + when(servletReq.getHeader(LogFilter.REQUEST_ID)).thenReturn(UUID.randomUUID().toString()); + when(servletReq.getHeader("Authorization")).thenReturn("Basic "+Base64.encodeBase64String("username:password".getBytes())); + when(servletResp.getStatus()).thenReturn(200); + logFilter.doFilter(servletReq, servletResp, filterChain); + + + } + +} diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java new file mode 100644 index 000000000..9f36fe11e --- /dev/null +++ b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java @@ -0,0 +1,129 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.filters; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.StringBufferInputStream; +import java.io.StringReader; +import java.util.LinkedList; +import java.util.UUID; +import java.util.Vector; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.codec.binary.Base64; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * @author dt5972 + * + */ +public class TestRequestResponseLoggingFilter { + + RequestResponseLoggingFilter filter; + + private class DummyServletInputStream extends ServletInputStream { + + InputStream stream; + + public DummyServletInputStream(InputStream stream) { + this.stream = stream; + } + + + @Override + public void close() throws IOException { + super.close(); + stream.close(); + } + + + @Override + public int read() throws IOException { + return stream.read(); + } + + + + } + + private class DummyServletOutputStream extends ServletOutputStream { + + OutputStream ostr; + + public DummyServletOutputStream(OutputStream ostr) { + this.ostr = ostr; + } + + @Override + public void write(int b) throws IOException { + ostr.write(b); + } + + } + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + filter = new RequestResponseLoggingFilter(); + filter.init(null); + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception {} + + /** + * Test method for {@link org.onap.ccsdk.sli.core.filters.RequestResponseLoggingFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}. + * @throws IOException + * @throws ServletException + */ + @Test + public void testDoFilter() throws IOException, ServletException { + + HttpServletRequest request = mock(HttpServletRequest.class); + String msgBody = "hello world"; + InputStream reqInputStream = new ByteArrayInputStream(msgBody.getBytes()); + when(request.getInputStream()).thenReturn(new DummyServletInputStream(reqInputStream)); + when(request.getMethod()).thenReturn("POST"); + when(request.getRequestURL()).thenReturn(new StringBuffer("/HELLO:world")); + when(request.getPathInfo()).thenReturn("/hello:world"); + Vector headerList = new Vector<>(); + headerList.add(LogFilter.REQUEST_ID); + headerList.add("Authorization"); + when(request.getHeaderNames()).thenReturn(headerList.elements()); + + when(request.getHeader(LogFilter.REQUEST_ID)).thenReturn(UUID.randomUUID().toString()); + when(request.getHeader("Authorization")).thenReturn("Basic "+Base64.encodeBase64String("username:password".getBytes())); + + HttpServletResponse response = mock(HttpServletResponse.class); + OutputStream outStr = new ByteArrayOutputStream(); + when(response.getOutputStream()).thenReturn(new DummyServletOutputStream(outStr)); + + FilterChain filterChain = mock(FilterChain.class); + + filter.doFilter(request, response, filterChain); + + + + } + +} diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 1d35dfb1b..c22c1ae69 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -18,6 +18,12 @@ ccsdk-sli-core :: sli :: ${project.artifactId} The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter + + + **/MessageWriter.java + + + @@ -31,9 +37,9 @@ - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 + org.apache.derby + derby + 10.11.1.1 test diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java index c75873eb6..0e39896e0 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java @@ -8,9 +8,9 @@ * 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. @@ -38,7 +38,7 @@ import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +@Deprecated public class MessageWriter { private static final Logger LOG = LoggerFactory.getLogger(MessageWriter.class); diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index ee3bcca5c..864652b40 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -66,6 +66,19 @@ public class SvcLogicDblibStore implements SvcLogicStore { this.dbSvc = dbsvc; } + public SvcLogicDblibStore(Properties props) { + try { + dbSvc = new DBResourceManager(props); + JavaSingleton.setInstance(dbSvc); + } catch (Exception e) { + LOG.warn("Caught exception trying to create DBResourceManager", e); + } + } + + public Connection getConnection() throws SQLException { + return(dbSvc.getConnection()); + } + @Override public void init(Properties props) throws ConfigurationException { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index e2fbdf726..0e7d05a6e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -38,7 +38,6 @@ import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class SvcLogicJdbcStore implements SvcLogicStore { private static final Logger LOG = LoggerFactory.getLogger(SvcLogicJdbcStore.class); diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 3d9caffbd..2804f6205 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -437,7 +437,7 @@ public class SvcLogicParser { } - + public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException { File xmlFile = new File(xmlfile); if (!xmlFile.canRead()) { @@ -531,7 +531,7 @@ public class SvcLogicParser { } - private static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) { + public static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) { String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")"; try { @@ -560,7 +560,7 @@ public class SvcLogicParser { System.exit(1); } - + protected SAXParser initParser() throws ParserConfigurationException, SAXException { URL xsdUrl = null; Schema schema = null; diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 368d9f95d..6ee18e922 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -32,11 +32,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; import java.util.Properties; -import ch.vorburger.mariadb4j.DB; -import ch.vorburger.mariadb4j.DBConfigurationBuilder; - import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -67,17 +69,9 @@ public class ITCaseSvcLogicParser { props.load(propStr); + store = SvcLogicStoreFactory.getSvcLogicStore(props); - // Start MariaDB4j database - DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); - config.setPort(0); // 0 => autom. detect free port - DB db = DB.newEmbeddedDB(config.build()); - db.start(); - - - // Override jdbc URL and database name - props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); - props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + assertNotNull(store); } @@ -120,8 +114,123 @@ public class ITCaseSvcLogicParser { } try { - SvcLogicParser.validate(testCaseUrl.getPath(), store); + SvcLogicParser.load(testCaseUrl.getPath(), store); } catch (Exception e) { + + fail("Validation failure [" + e.getMessage() + "]"); + } + } + } + } catch (SvcLogicParserException e) { + fail("Parser error : " + e.getMessage()); + } catch (Exception e) { + LOG.error("", e); + fail("Caught exception processing test cases"); + } + } + + @Test + public void testDblibLoadValidXml() throws IOException, SQLException, ConfigurationException { + + URL propUrl = ITCaseSvcLogicParser.class.getResource("/dblib.properties"); + + InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/dblib.properties"); + + Properties props = new Properties(); + + props.load(propStr); + + SvcLogicDblibStore dblibStore = new SvcLogicDblibStore(props); + + Connection dbConn = dblibStore.getConnection(); + + String dbName = props.getProperty("org.onap.ccsdk.sli.jdbc.database", "sdnctl"); + + DatabaseMetaData dbm; + + try { + dbm = dbConn.getMetaData(); + } catch (SQLException e) { + + throw new ConfigurationException("could not get databse metadata", e); + } + + // See if table SVC_LOGIC exists. If not, create it. + Statement stmt = null; + try { + + ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null); + if (tables.next()) { + LOG.debug("SVC_LOGIC table already exists"); + } else { + String crTableCmd = "CREATE TABLE " + dbName + ".SVC_LOGIC (" + "module varchar(80) NOT NULL," + + "rpc varchar(80) NOT NULL," + "version varchar(40) NOT NULL," + "mode varchar(5) NOT NULL," + + "active varchar(1) NOT NULL," + "graph BLOB," + + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; + + stmt = dbConn.createStatement(); + stmt.executeUpdate(crTableCmd); + } + } catch (Exception e) { + throw new ConfigurationException("could not create SVC_LOGIC table", e); + } finally { + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + LOG.error("Statement close error ", e); + } + } + } + + // See if NODE_TYPES table exists and, if not, create it + stmt = null; + try { + + ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null); + if (tables.next()) { + LOG.debug("NODE_TYPES table already exists"); + } else { + String crTableCmd = "CREATE TABLE " + dbName + ".NODE_TYPES (" + "nodetype varchar(80) NOT NULL," + + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))"; + + stmt = dbConn.createStatement(); + + stmt.executeUpdate(crTableCmd); + } + } catch (Exception e) { + throw new ConfigurationException("could not create SVC_LOGIC table", e); + } finally { + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + LOG.error("Statement close error ", e); + } + } + } + + try { + InputStream testStr = getClass().getResourceAsStream("/parser-good.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + String testCaseFile = null; + while ((testCaseFile = testsReader.readLine()) != null) { + + testCaseFile = testCaseFile.trim(); + + if (testCaseFile.length() > 0) { + if (!testCaseFile.startsWith("/")) { + testCaseFile = "/" + testCaseFile; + } + URL testCaseUrl = getClass().getResource(testCaseFile); + if (testCaseUrl == null) { + fail("Could not resolve test case file " + testCaseFile); + } + + try { + SvcLogicParser.load(testCaseUrl.getPath(), dblibStore); + } catch (Exception e) { + fail("Validation failure [" + e.getMessage() + "]"); } } @@ -152,7 +261,7 @@ public class ITCaseSvcLogicParser { if (testCaseUrl == null) { fail("Could not resolve test case file " + testCaseFile); } - SvcLogicParser.load(testCaseUrl.getPath(), store); + SvcLogicParser.validate(testCaseUrl.getPath(), store); } } } diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java index 21d3e59c3..fb6eaf70b 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java @@ -15,6 +15,9 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.Exe import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,6 +53,22 @@ public class PrintYangToPropTest { pBuilder.setIntValue(null); pBuilder.setBooleanValue(true); pList.add(pBuilder.build()); + pBuilder.setParameterName("ipaddress-value1"); + pBuilder.setBooleanValue(null); + pBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); + pList.add(pBuilder.build()); + pBuilder.setParameterName("ipaddress-value1"); + pBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("::1")); + pList.add(pBuilder.build()); + pBuilder.setParameterName("ipprefix-value1"); + pBuilder.setIpaddressValue(null); + pBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("192.168.0.0/16")); + pList.add(pBuilder.build()); + pBuilder.setParameterName("ipprefix-value2"); + pBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("2001:db8:3c4d::/48")); + pList.add(pBuilder.build()); + + egBuilder.setSliParameter(pList); @@ -64,6 +83,9 @@ public class PrintYangToPropTest { LOG.info("Property {} = {}", propName, props.getProperty(propName)); } + // Generate builder from properties just generated + PrintYangToProp.toBuilder(props, pBuilder); + } } diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java new file mode 100644 index 000000000..31a419bb1 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java @@ -0,0 +1,135 @@ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.*; +import java.util.Date; +import org.junit.Before; +import org.junit.Test; + +public class TestMetricLogger { + + MetricLogger logger; + + @Before + public void setUp() throws Exception { + + logger = new MetricLogger(); + logger.resetContext(); + logger.logRequest("svcInstance1", "svcName", "svcPartner", "targetEntity", "targetServiceName", "targetVirtualEntity", "hello-world"); + logger.logResponse("200", "200", "SUCCESS"); + + } + + @Test + public final void testGetBeginTimestamp() { + logger.getBeginTimestamp(); + } + + @Test + public final void testGetEndTimestamp() { + logger.getEndTimestamp(); + } + + @Test + public final void testGetRequestID() { + logger.getRequestID(); + } + + @Test + public final void testGetServiceInstanceID() { + logger.getServiceInstanceID(); + } + + @Test + public final void testGetServiceName() { + logger.getServiceName(); + } + + @Test + public final void testGetPartnerName() { + logger.getPartnerName(); + } + + @Test + public final void testGetTargetEntity() { + logger.getTargetEntity(); + } + + @Test + public final void testGetTargetServiceName() { + logger.getTargetServiceName(); + } + + @Test + public final void testGetStatusCode() { + logger.getStatusCode(); + } + + @Test + public final void testGetResponseCode() { + logger.getResponseCode(); + } + + @Test + public final void testGetResponseDescription() { + logger.getResponseDescription(); + } + + @Test + public final void testGetInstanceUUID() { + logger.getInstanceUUID(); + } + + @Test + public final void testGetCategoryLogLevel() { + logger.getCategoryLogLevel(); + } + + @Test + public final void testGetSeverity() { + logger.getSeverity(); + } + + @Test + public final void testGetServerIpAddress() { + logger.getServerIpAddress(); + } + + @Test + public final void testGetElapsedTime() { + logger.getElapsedTime(); + } + + @Test + public final void testGetServer() { + logger.getServer(); + } + + @Test + public final void testGetClientIp() { + logger.getClientIp(); + } + + @Test + public final void testGetClassName() { + logger.getClassName(); + } + + @Test + public final void testGetTargetVirtualEntity() { + logger.getTargetVirtualEntity(); + } + + @Test + public final void testAsIso8601Date() { + logger.asIso8601(new Date()); + } + + @Test + public final void testAsIso8601Long() { + logger.asIso8601(System.currentTimeMillis()); + } + + + + +} diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java new file mode 100644 index 000000000..8998382ec --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java @@ -0,0 +1,38 @@ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.*; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Properties; +import org.junit.Test; + +public class TestSvcLogicLoader { + + @Test + public void testLoadAndActivate() throws IOException, SvcLogicException { + URL propUrl = ITCaseSvcLogicParser.class.getResource("/svclogic.properties"); + + InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/svclogic.properties"); + + Properties props = new Properties(); + + props.load(propStr); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(props); + + URL graphUrl = TestSvcLogicLoader.class.getClassLoader().getResource("graphs"); + + if (graphUrl == null) { + fail("Cannot find graphs directory"); + } + + SvcLogicLoader loader = new SvcLogicLoader(graphUrl.getPath(), store); + loader.loadAndActivate(); + + + } + + + +} diff --git a/sli/common/src/test/resources/dblib.properties b/sli/common/src/test/resources/dblib.properties new file mode 100755 index 000000000..f08dce7a0 --- /dev/null +++ b/sli/common/src/test/resources/dblib.properties @@ -0,0 +1,14 @@ +org.onap.ccsdk.sli.dbtype=jdbc +org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01,sdnctldb02 +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:test;create=true +org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver +org.onap.ccsdk.sli.jdbc.database=test +org.onap.ccsdk.sli.jdbc.user=test +org.onap.ccsdk.sli.jdbc.password=test +org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01 + +org.onap.ccsdk.sli.jdbc.connection.timeout=50 +org.onap.ccsdk.sli.jdbc.request.timeout=100 +org.onap.ccsdk.sli.jdbc.limit.init=10 +org.onap.ccsdk.sli.jdbc.limit.min=10 +org.onap.ccsdk.sli.jdbc.limit.max=20 diff --git a/sli/common/src/test/resources/graphs/sliapi/graph.versions b/sli/common/src/test/resources/graphs/sliapi/graph.versions new file mode 100644 index 000000000..d72920a43 --- /dev/null +++ b/sli/common/src/test/resources/graphs/sliapi/graph.versions @@ -0,0 +1 @@ +sli healthcheck 1.0.0 sync diff --git a/sli/common/src/test/resources/graphs/sliapi/sli_healthcheck.xml b/sli/common/src/test/resources/graphs/sliapi/sli_healthcheck.xml new file mode 100644 index 000000000..d512f546f --- /dev/null +++ b/sli/common/src/test/resources/graphs/sliapi/sli_healthcheck.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/sli/common/src/test/resources/l3sdn_logic_v10.xml b/sli/common/src/test/resources/l3sdn_logic_v10.xml new file mode 100644 index 000000000..58a420f9e --- /dev/null +++ b/sli/common/src/test/resources/l3sdn_logic_v10.xml @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/common/src/test/resources/parser-good.tests b/sli/common/src/test/resources/parser-good.tests index 06543126f..4147fdb62 100755 --- a/sli/common/src/test/resources/parser-good.tests +++ b/sli/common/src/test/resources/parser-good.tests @@ -1,2 +1,3 @@ ReleasePortSvcLogic_v101.xml neutron_logic_v10.xml +l3sdn_logic_v10.xml diff --git a/sli/common/src/test/resources/svclogic.properties b/sli/common/src/test/resources/svclogic.properties index 33d7ae6e4..426960f76 100644 --- a/sli/common/src/test/resources/svclogic.properties +++ b/sli/common/src/test/resources/svclogic.properties @@ -20,7 +20,8 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url = jdbc:mysql://localhost:3306/test -org.onap.ccsdk.sli.jdbc.database = test +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 = test123 +org.onap.ccsdk.sli.jdbc.password = test diff --git a/sli/common/src/test/resources/svclogic.xsd b/sli/common/src/test/resources/svclogic.xsd index a63758f7c..2704de88e 100755 --- a/sli/common/src/test/resources/svclogic.xsd +++ b/sli/common/src/test/resources/svclogic.xsd @@ -30,6 +30,7 @@ + @@ -320,4 +321,14 @@ + + + + + + + + + + diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 4a90ae005..1b21b0020 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -1,44 +1,40 @@ - - 4.0.0 + + 4.0.0 - + org.onap.ccsdk.parent binding-parent 1.0.1-SNAPSHOT - + - org.onap.ccsdk.sli.core - sli-provider - 0.2.1-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sli-provider + 0.2.1-SNAPSHOT + bundle - ccsdk-sli-core :: sli :: ${project.artifactId} - SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. - + UTF-8 - - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - - - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - + + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + org.onap.ccsdk.sli.core sli-model @@ -61,11 +57,6 @@ slf4j-api ${slf4j.version} - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - commons-lang commons-lang @@ -74,23 +65,28 @@ - - org.opendaylight.controller - sal-binding-api - - - - - junit - junit - test - + + org.opendaylight.controller + sal-binding-api + - - org.mockito - mockito-core - test - + + + junit + junit + test + + + org.mockito + mockito-core + test + + + org.apache.derby + derby + 10.11.1.1 + test + diff --git a/sli/provider/src/main/resources/svclogic.properties b/sli/provider/src/main/resources/svclogic.properties deleted file mode 100644 index 49d39ab40..000000000 --- a/sli/provider/src/main/resources/svclogic.properties +++ /dev/null @@ -1,25 +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 = dblib -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 diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 4c112ab25..0a8bf71ac 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -24,8 +24,7 @@ package org.onap.ccsdk.sli.core.sli.provider; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; -import ch.vorburger.mariadb4j.DB; -import ch.vorburger.mariadb4j.DBConfigurationBuilder; + import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; @@ -40,6 +39,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicParser; @@ -74,6 +74,7 @@ public class ITCaseSvcLogicGraphExecutor { put("set", new SetNodeExecutor()); put("switch", new SwitchNodeExecutor()); put("update", new UpdateNodeExecutor()); + put("while", new WhileNodeExecutor()); } }; @@ -88,16 +89,6 @@ public class ITCaseSvcLogicGraphExecutor { Properties svcprops = new Properties(); svcprops.load(propStr); - // Start MariaDB4j database - DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); - config.setPort(0); // 0 => autom. detect free port - DB db = DB.newEmbeddedDB(config.build()); - db.start(); - - // Override jdbc URL and database name - svcprops.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); - svcprops.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); assertNotNull(store); @@ -144,18 +135,9 @@ public class ITCaseSvcLogicGraphExecutor { Properties svcprops = new Properties(); svcprops.load(propStr); - // Start MariaDB4j database - DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); - config.setPort(0); // 0 => autom. detect free port - DB db = DB.newEmbeddedDB(config.build()); - db.start(); - - // Override jdbc URL and database name - svcprops.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); - svcprops.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); + assertNotNull(store); @@ -214,10 +196,13 @@ public class ITCaseSvcLogicGraphExecutor { fail("Could not resolve test case file " + testCaseFile); } + LinkedList graphs = parser.parse(testCaseUrl.getPath()); assertNotNull(graphs); + // Load grqphs into db to support call node + parser.load(testCaseUrl.getPath(), store); for (SvcLogicGraph graph : graphs) { if (graph.getRpc().equals(testCaseMethod)) { Properties props = ctx.toProperties(); diff --git a/sli/provider/src/test/resources/executor.tests b/sli/provider/src/test/resources/executor.tests index e4e60208a..5468c8d60 100755 --- a/sli/provider/src/test/resources/executor.tests +++ b/sli/provider/src/test/resources/executor.tests @@ -1,6 +1,8 @@ l3sdn_logic_v10.xml:switchTester:test-value="" l3sdn_logic_v10.xml:switchTester:test-value="hi" l3sdn_logic_v10.xml:forRecordTester +l3sdn_logic_v10.xml:whileNodeTester l3sdn_logic_v10.xml:resourceTester l3sdn_logic_v10.xml:configureTester -l3sdn_logic_v10.xml:javaPluginTester \ No newline at end of file +l3sdn_logic_v10.xml:javaPluginTester +l3sdn_logic_v10.xml:allNodesTester \ No newline at end of file diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml index 1386df10d..cbb5db1ba 100644 --- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml +++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml @@ -49,6 +49,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -167,6 +188,8 @@ + + diff --git a/sli/provider/src/test/resources/svclogic.properties b/sli/provider/src/test/resources/svclogic.properties index 49d39ab40..426960f76 100644 --- a/sli/provider/src/test/resources/svclogic.properties +++ b/sli/provider/src/test/resources/svclogic.properties @@ -19,7 +19,9 @@ # ============LICENSE_END========================================================= ### -org.onap.ccsdk.sli.dbtype = dblib +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/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index cb4dfc898..5650416df 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -1,73 +1,94 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.0.1-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.0.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - sliapi-provider - 0.2.1-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sliapi-provider + 0.2.1-SNAPSHOT + bundle - ccsdk-sli-core :: sliapi :: ${project.artifactId} + ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - - - - org.onap.ccsdk.sli.core - sliapi-model - ${project.version} - + + + + org.opendaylight.controller + mdsal-artifacts + 1.6.1 + pom + import + + + + + + org.onap.ccsdk.sli.core + sliapi-model + ${project.version} + - - org.opendaylight.controller - sal-binding-config - + + org.opendaylight.controller + sal-binding-config + - - org.opendaylight.controller - sal-binding-api - + + org.opendaylight.controller + sal-binding-api + - - org.opendaylight.controller - sal-common-util - + + org.opendaylight.controller + sal-common-util + - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.opendaylight.controller - sal-core-api - - - org.opendaylight.yangtools - yang-data-impl - - + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.opendaylight.controller + sal-core-api + + + org.opendaylight.yangtools + yang-data-impl + + + + junit + junit + ${junit.version} + test + + + + org.mockito + mockito-core + test + + + + org.apache.derby + derby + 10.11.1.1 + test + + diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index 3ff2f52d4..e9a2b8eb2 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -114,14 +114,16 @@ import com.google.common.util.concurrent.Futures; */ public class sliapiProvider implements AutoCloseable, SLIAPIService{ - private final Logger LOG = LoggerFactory.getLogger( sliapiProvider.class ); - private final String appName = "slitester"; + private static final Logger LOG = LoggerFactory.getLogger( sliapiProvider.class ); + private static final String appName = "slitester"; protected DataBroker dataBroker; protected DOMDataBroker domDataBroker; protected NotificationPublishService notificationService; protected RpcProviderRegistry rpcRegistry; + private SvcLogicService svcLogic; + protected BindingAwareBroker.RpcRegistration rpcRegistration; private static String SLIAPI_NAMESPACE = "org:onap:ccsdk:sli:core:sliapi"; @@ -142,15 +144,23 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ RESULTS_QNAME = QName.create(TEST_RESULT_QNAME, "results"); } + public sliapiProvider( + DataBroker dataBroker, + NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry) { + this(dataBroker, notificationPublishService, rpcProviderRegistry, findSvcLogicService()); + } public sliapiProvider( DataBroker dataBroker, NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry) { + RpcProviderRegistry rpcProviderRegistry, + SvcLogicService svcLogic) { this.LOG.info( "Creating provider for " + appName ); this.dataBroker = dataBroker; this.notificationService = notificationPublishService; this.rpcRegistry = rpcProviderRegistry; + this.svcLogic = svcLogic; initialize(); } @@ -357,6 +367,13 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ private SvcLogicService getSvcLogicService() { + if (svcLogic == null) { + svcLogic = findSvcLogicService(); + } + + return(svcLogic); + } + private static SvcLogicService findSvcLogicService() { BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext(); SvcLogicService svcLogic = null; diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java new file mode 100644 index 000000000..38cbd40c9 --- /dev/null +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -0,0 +1,171 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sliapi; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.*; +import java.io.InputStream; +import java.net.URL; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.provider.BlockNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.CallNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ConfigureNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.DeleteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ExistsNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ForNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.GetResourceNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.IsAvailableNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.NotifyNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.RecordNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReleaseNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReserveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.ReturnNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SaveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SetNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; +import org.onap.ccsdk.sli.core.sli.provider.SwitchNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.UpdateNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.WhileNodeExecutor; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; + +/** + * @author dt5972 + * + */ +public class TestSliapiProvider { + + private sliapiProvider provider; + + private static final String HEALTHCHECK_DG = "sli_healthcheck.xml"; + + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + put("while", new WhileNodeExecutor()); + + } + }; + + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + DataBroker dataBroker = mock(DataBroker.class); + NotificationPublishService notifyService = mock(NotificationPublishService.class); + RpcProviderRegistry rpcRegistry = mock(RpcProviderRegistry.class); + BindingAwareBroker.RpcRegistration rpcRegistration = (BindingAwareBroker.RpcRegistration) mock(BindingAwareBroker.RpcRegistration.class); + when(rpcRegistry.addRpcImplementation(any(Class.class), any(SLIAPIService.class))).thenReturn(rpcRegistration); + + + // Load svclogic.properties and get a SvcLogicStore + InputStream propStr = TestSliapiProvider.class.getResourceAsStream("/svclogic.properties"); + Properties svcprops = new Properties(); + svcprops.load(propStr); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); + + assertNotNull(store); + + // Load the DG for the healthcheck api + URL testCaseUrl = TestSliapiProvider.class.getClassLoader().getResource(HEALTHCHECK_DG); + if (testCaseUrl == null) { + fail("Cannot find "+HEALTHCHECK_DG); + } + SvcLogicParser.load(testCaseUrl.getPath(), store); + SvcLogicParser.activate("sli", "healthcheck", "1.0.0", "sync", store); + + // Create a ServiceLogicService and initialize it + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl()); + for (String nodeType : BUILTIN_NODES.keySet()) { + svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + } + + // Finally ready to create sliapiProvider + provider = new sliapiProvider(dataBroker, notifyService, rpcRegistry, svc); + provider.setDataBroker(dataBroker); + provider.setNotificationService(notifyService); + provider.setRpcRegistry(rpcRegistry); + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + provider.close(); + } + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#executeGraph(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)}. + */ + @Test + public void testExecuteGraph() { + ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder(); + + inputBuilder.setMode(ExecuteGraphInput.Mode.Sync); + inputBuilder.setModuleName("sli"); + inputBuilder.setRpcName("healthcheck"); + List pList = new LinkedList<>(); + SliParameterBuilder pBuilder = new SliParameterBuilder(); + pBuilder.setParameterName("int-parameter"); + pBuilder.setIntValue(1); + pList.add(pBuilder.build()); + inputBuilder.setSliParameter(pList); + + + + + provider.executeGraph(inputBuilder.build()); + } + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#healthcheck()}. + */ + @Test + public void testHealthcheck() { + provider.healthcheck(); + } + +} diff --git a/sliapi/provider/src/test/resources/sli_healthcheck.xml b/sliapi/provider/src/test/resources/sli_healthcheck.xml new file mode 100644 index 000000000..d512f546f --- /dev/null +++ b/sliapi/provider/src/test/resources/sli_healthcheck.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/sliapi/provider/src/test/resources/svclogic.properties b/sliapi/provider/src/test/resources/svclogic.properties new file mode 100644 index 000000000..426960f76 --- /dev/null +++ b/sliapi/provider/src/test/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 -- cgit 1.2.3-korg From 17e4844d07eb9ad3f5a3f27db75b957d5d0a52a6 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 4 Apr 2018 15:58:26 -0400 Subject: URGENT : Install logback Install logback packages needed by EELF as part of sli common package. This is urgently needed, since CCSDK is not coming up clean without this fix. Change-Id: I4f47e6146e45e36752454100186851af3eba7491 Issue-ID: CCSDK-235 Signed-off-by: Timoney, Dan (dt5972) --- sli/common/pom.xml | 1 + sli/installer/pom.xml | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index c22c1ae69..94098c145 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -107,6 +107,7 @@ com.att.eelf eelf-core + 1.0.0 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 5586f7d53..cb34f14bc 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -1,12 +1,13 @@ - + 4.0.0 org.onap.ccsdk.parent odlparent-lite 1.0.1-SNAPSHOT - + org.onap.ccsdk.sli.core @@ -19,7 +20,7 @@ ccsdk-sli ${application.name} - mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false @@ -56,6 +57,21 @@ sli-recording ${project.version} + + com.att.eelf + eelf-core + 1.0.0 + + + ch.qos.logback + logback-core + ${logback.version} + + + ch.qos.logback + logback-classic + ${logback.version} + @@ -115,7 +131,7 @@ true false false - org.onap.ccsdk.sli.core + org.onap.ccsdk.sli.core,com.att.eelf,ch.qos.logback utils-provider,dblib-provider provided -- cgit 1.2.3-korg From eaee6ecddd85cc98e755d36cf79fcfd1328ba859 Mon Sep 17 00:00:00 2001 From: "prakash.e" Date: Thu, 5 Apr 2018 10:52:45 +0530 Subject: code coverage for ccsdk sli DG nodes Coverage improvement for SqlResourcePropertiesProviderImpl https://jira.onap.org/browse/CCSDK-213?jql=project%20%3D%20CCSDK%20AND%20text%20~%20coverage Issue-ID: CCSDK-213 Change-Id: Ibc26c319801204df8ab9c7b64a1774eae0c59bd0 Signed-off-by: prakash.e --- sli/provider/src/test/resources/l3sdn_logic_v10.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml index cbb5db1ba..64397236b 100644 --- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml +++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml @@ -151,7 +151,12 @@ - + + + + + + -- cgit 1.2.3-korg From e035f3802ed5970e0f2254ec13b637c0b9398d88 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 6 Apr 2018 14:17:48 -0400 Subject: Fix EELF version Load version 1.0.0 of EELF, based on parent property setting Change-Id: I5e936b651f07ad9af8e4b41c80bbfed98bb67faa Issue-ID: CCSDK-235 Signed-off-by: Timoney, Dan (dt5972) --- sli/common/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 94098c145..c22c1ae69 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -107,7 +107,6 @@ com.att.eelf eelf-core - 1.0.0 -- cgit 1.2.3-korg From daaf4dfe189456b2e0606a72200d872102c4bed9 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 10 Apr 2018 14:56:59 -0400 Subject: URGENT : Add node executors Need to register node executors on SvcServiceImpl start up. This was broken inadvertantly during move to Aries blueprint. NOTE : This is a sev 1 fix for APP-C. Please review and merge ASAP. Change-Id: Ic4ff7c91f2b46ed81fd78a35bf8ea9d37c098c68 Issue-ID: CCSDK-236 Signed-off-by: Timoney, Dan (dt5972) --- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 71 ++++++++++------------ 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 3bd896c5d..05698864e 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -22,6 +22,7 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.util.HashMap; +import java.util.Map; import java.util.Properties; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.core.sli.ConfigurationException; @@ -46,6 +47,32 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; public class SvcLogicServiceImpl implements SvcLogicService { + + private static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + put("while", new WhileNodeExecutor()); + + } + }; + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImpl.class); protected HashMap nodeExecutors = null; protected BundleContext bctx = null; @@ -63,47 +90,13 @@ public class SvcLogicServiceImpl implements SvcLogicService { store = new SvcLogicDblibStore(dbSvc); } - protected void registerExecutors() { - LOG.info("Entered register executors"); - if (bctx == null) { - bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - } - if (nodeExecutors == null) { - nodeExecutors = new HashMap<>(); - } - - LOG.info("Opening service tracker"); - ServiceTracker tracker = new ServiceTracker(bctx, SvcLogicNodeExecutor.class.getName(), null); - - tracker.open(); - - ServiceListener listener = new ServiceListener() { - public void serviceChanged(ServiceEvent ev) { - ServiceReference sr = ev.getServiceReference(); - switch (ev.getType()) { - case ServiceEvent.REGISTERED: { - registerExecutor(sr); - } - break; - case ServiceEvent.UNREGISTERING: { - unregisterExecutor(sr); - } - break; - } - } - }; + protected void registerExecutors() { - LOG.info("Adding service listener"); - String filter = "(objectclass=" + SvcLogicNodeExecutor.class.getName() + ")"; - try { - bctx.addServiceListener(listener, filter); - ServiceReference[] srl = bctx.getServiceReferences(SvcLogicNodeExecutor.class.getName(), null); - for (int i = 0; srl != null && i < srl.length; i++) { - listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, srl[i])); - } - } catch (InvalidSyntaxException e) { - LOG.info("Invalid syntax", e); + LOG.info("Entered register executors"); + for (String nodeType : BUILTIN_NODES.keySet()) { + LOG.info("SLI - registering node executor for node type " + nodeType); + registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } LOG.info("Done registerExecutors"); } -- cgit 1.2.3-korg From 800db9725a780afcbf41b29affecdcca8c6851e9 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 18 Apr 2018 02:22:24 -0400 Subject: Fix release version Fix release version in version.properties Change-Id: I4d354ac42260a4dcd17f516a413c036b85086db3 Issue-ID: CCSDK-242 Signed-off-by: Timoney, Dan (dt5972) --- sli/common/pom.xml | 2 +- version.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index c22c1ae69..17e4dc44e 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -78,7 +78,7 @@ org.onap.ccsdk.sli.core dblib-provider - ${sdnctl.dblib.version} + ${project.version} org.onap.ccsdk.sli.core diff --git a/version.properties b/version.properties index bf303c1bf..26f5c6e32 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=2 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 898ccabd60d1eea9c638386793b2a40215418b5f Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 25 Apr 2018 21:13:56 +0000 Subject: add replaceAll to slistringutils add replaceAll to slistringutils because it supports regular expressions and replace does not Change-Id: Ibff7acd339103a6bb897d14ca3d31736a5b568ef Issue-ID: CCSDK-253 Signed-off-by: Smokowski, Kevin (ks6305) --- .../sli/core/slipluginutils/SliStringUtils.java | 22 ++++++++++++++++++++++ .../core/slipluginutils/SliStringUtilsTest.java | 15 +++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index 6402abd68..63c750cb8 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -304,6 +304,28 @@ public class SliStringUtils implements SvcLogicJavaPlugin { ctx.setAttribute(parameters.get("outputPath"), (parameters.get("source").replace(parameters.get("target"), parameters.get("replacement")))); } + /** + * exposes replaceAll to directed graph + * writes the length of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + * + *
    parameterMandatory/Optionaldescription
    sourceMandatorysource string
    targetMandatoryThis should be a valid regular expression
    replacementMandatoryThe replacement sequence of char values
    outputPathMandatorythe location in context memory the result is written to
    + * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void replaceAll(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath","target","replacement"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").replaceAll(parameters.get("target"), parameters.get("replacement"))); + } + /** * Provides substring functionality to Directed Graphs. *

    diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index 4fc8d1866..4c665121c 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -234,6 +234,21 @@ public class SliStringUtilsTest { SliStringUtils.replace(param, ctx); assertEquals(sourceString.replace(old, neww), ctx.getAttribute(outputPath)); } + + @Test + public void replaceAll() throws SvcLogicException { + String source = "cat Hello World cat"; + String target = "\\s"; + String replacement = ""; + String outputPath = "out"; + + param.put("source", source); + param.put("target", target); + param.put("replacement", replacement); + param.put("outputPath", outputPath); + SliStringUtils.replaceAll(param, ctx); + assertEquals(source.replaceAll(target, replacement), ctx.getAttribute(outputPath)); + } @Test public void concat() throws SvcLogicException { -- cgit 1.2.3-korg From bafe8e8caa6a537f2ac1bda0a8ec2ef36a95e467 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Sun, 29 Apr 2018 18:45:28 -0400 Subject: Roll versions step 2 : sli/core poms Roll to next version for next release candidate. Change-Id: I0a76316934afd79f4ecf3588453ed4d6e34fb615 Issue-ID: CCSDK-257 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 4 +- dblib/features/features-dblib/pom.xml | 4 +- dblib/features/pom.xml | 4 +- dblib/installer/pom.xml | 4 +- dblib/pom.xml | 4 +- dblib/provider/pom.xml | 4 +- filters/features/ccsdk-filters/pom.xml | 4 +- filters/features/features-filters/pom.xml | 4 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 +- filters/pom.xml | 4 +- filters/provider/pom.xml | 4 +- pom.xml | 4 +- sli/common/pom.xml | 4 +- sli/features/features-sli/pom.xml | 4 +- sli/features/odl-sli/pom.xml | 4 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 4 +- sli/model/pom.xml | 4 +- sli/pom.xml | 4 +- sli/provider/pom.xml | 4 +- sli/recording/pom.xml | 4 +- .../features/ccsdk-sliPluginUtils/pom.xml | 4 +- .../features/features-sliPluginUtils/pom.xml | 4 +- sliPluginUtils/features/pom.xml | 4 +- sliPluginUtils/installer/pom.xml | 4 +- sliPluginUtils/pom.xml | 4 +- sliPluginUtils/provider/pom.xml | 4 +- sliapi/features/ccsdk-sliapi/pom.xml | 4 +- sliapi/features/features-sliapi/pom.xml | 4 +- sliapi/features/pom.xml | 4 +- sliapi/installer/pom.xml | 4 +- sliapi/model/pom.xml | 4 +- sliapi/pom.xml | 4 +- sliapi/provider/pom.xml | 4 +- utils/features/features-util/pom.xml | 4 +- utils/features/features3-util/pom.xml | 141 --------------------- .../features3-util/src/main/resources/features.xml | 16 --- utils/features/pom.xml | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 4 +- utils/installer/pom.xml | 4 +- utils/pom.xml | 4 +- utils/provider/pom.xml | 4 +- version.properties | 2 +- 44 files changed, 80 insertions(+), 237 deletions(-) delete mode 100755 utils/features/features3-util/pom.xml delete mode 100755 utils/features/features3-util/src/main/resources/features.xml diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 8cf1c93f3..9094abe69 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index b7c2150dd..9fd5e03ad 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 18f087397..432405d4d 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 3f581957a..bdbf41009 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 58f40ff69..82ed9986f 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index e6fd1bcb1..3eaefd067 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 9b5c73bab..d5924db46 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 5072971aa..d5145f222 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index bf9868404..36da4c608 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 6cc9e5e34..1cdbb06a1 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index b40d0d318..d71df06d9 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index a60c0be05..11ec66aa2 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 7ab4d4630..8b0dcacd5 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 17e4dc44e..e2396e8c4 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index de617baad..b703b9461 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 907cef6a2..d94aed577 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -9,13 +9,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index fbb864efa..79626b8eb 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index cb34f14bc..16861fffb 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 3a78c4788..e2045ee06 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 985fa1d3e..fb1da59fa 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 1b21b0020..8a5e25070 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index e8b136fdd..2bc06f17c 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 8ea5ca86e..9af6124e3 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 004277dd3..7c588698f 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 4a1f89947..4c8414536 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index f11b27ca3..845348e9f 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 45be684f7..b7f31276e 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index cd3704915..158cab354 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index be4025b4a..352335ba9 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index f3481cba8..1d745f32a 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 17fa8fb41..cf61aaa87 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index d9da9794e..3c019e606 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index bbdcea051..3d0b0b950 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 46057da0f..746af7271 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 5650416df..7964a9065 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 9a4cd43c5..5df832c69 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features3-util/pom.xml b/utils/features/features3-util/pom.xml deleted file mode 100755 index 5cc0d8995..000000000 --- a/utils/features/features3-util/pom.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - 4.0.0 - - utils - org.onap.ccsdk.sli.core - 0.2.0-SNAPSHOT - - - org.onap.ccsdk.sli.core - utils-features - ccsdk-sli-core :: utils :: ${project.artifactId} - DBLIB Adaptor - Features - - jar - - - - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - - - - commons-lang - commons-lang - ${commons.lang.version} - compile - - - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml - - runtime - - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - - - org.opendaylight.odlparent - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - - - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - - - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - - diff --git a/utils/features/features3-util/src/main/resources/features.xml b/utils/features/features3-util/src/main/resources/features.xml deleted file mode 100755 index 547832ba6..000000000 --- a/utils/features/features3-util/src/main/resources/features.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features - - - - - odl-mdsal-broker - mvn:org.onap.ccsdk.sli.core/utils-provider/${project.version} - - - diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 8bc1cd8a8..382c5d5cb 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml index 85c81ff67..63f6c8e3f 100644 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index c19ac8c67..b942e7906 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index cd342f774..1c2e4f4a5 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 7a4e8c9ed..ac55d0f64 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.1-SNAPSHOT + 1.0.2-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.2.1-SNAPSHOT + 0.2.2-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 26f5c6e32..5985855ef 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=2 -feature_revision=1 +feature_revision=2 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 979b646bec328670a9ef4c9f24ebd5a4e0ae3987 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 3 May 2018 18:38:16 +0000 Subject: SetNodeExecutor nulling feature enhancement Add special handling for clear a single array element or an entire array Change-Id: Ica73e2af32f4a566219e1487504753276bc98aa2 Issue-ID: CCSDK-265 Signed-off-by: Smokowski, Kevin (ks6305) --- .../sli/core/sli/provider/SetNodeExecutor.java | 11 +- .../sli/core/sli/provider/SetNodeExecutorTest.java | 161 ++++++++++++++------- .../src/test/resources/clearArrayValues.xml | 18 +++ .../src/test/resources/clearSingleArrayValues.xml | 18 +++ 4 files changed, 150 insertions(+), 58 deletions(-) create mode 100644 sli/provider/src/test/resources/clearArrayValues.xml create mode 100644 sli/provider/src/test/resources/clearSingleArrayValues.xml diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java index cd478977c..758f2039c 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; public class SetNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(SetNodeExecutor.class); + protected final String arrayPattern = "\\[\\d*\\]"; @Override public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) @@ -131,8 +132,14 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { LinkedList parmsToRemove = new LinkedList(); String prefix = lhsVarName + "."; for (String curCtxVarname : ctx.getAttributeKeySet()) { - if (curCtxVarname.startsWith(prefix)) { - LOG.debug("Unsetting " + curCtxVarname); + String curCtxVarnameMatchingValue = curCtxVarname; + //Special handling for reseting array values, strips out brackets and any numbers between the brackets + //when testing if a context memory value starts with a prefix + if(!prefix.contains("[") && curCtxVarnameMatchingValue.contains("[")) { + curCtxVarnameMatchingValue = curCtxVarname.replaceAll(arrayPattern, ""); + } + if (curCtxVarnameMatchingValue.startsWith(prefix)) { + LOG.debug("Unsetting " + curCtxVarname + " because matching value " + curCtxVarnameMatchingValue + " starts with the prefix " + prefix); parmsToRemove.add(curCtxVarname); } } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java index 1333d0702..c400bf5d1 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java @@ -1,56 +1,105 @@ -package org.onap.ccsdk.sli.core.sli.provider; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import java.util.LinkedList; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicParser; - -public class SetNodeExecutorTest { - @Test - public void clearProperties() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/clearValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertNull(ctx.getAttribute("si.field1")); - assertNull(ctx.getAttribute("si.field2")); - assertNull(ctx.getAttribute("si.field3")); - assertEquals("6", ctx.getAttribute("search1")); - assertEquals("KeepMe!", ctx.getAttribute("simonSays")); - } - - @Test - public void subtreeCopy() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/copyValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertEquals("1",ctx.getAttribute("si.field1")); - assertEquals("2",ctx.getAttribute("si.field2")); - assertEquals("3",ctx.getAttribute("si.field3")); - assertEquals("1",ctx.getAttribute("rootTwo.field1")); - assertEquals("2",ctx.getAttribute("rootTwo.field2")); - assertEquals("3",ctx.getAttribute("rootTwo.field3")); - } - -} +package org.onap.ccsdk.sli.core.sli.provider; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import java.util.LinkedList; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; + +public class SetNodeExecutorTest { + @Test + public void clearProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertNull(ctx.getAttribute("si.field1")); + assertNull(ctx.getAttribute("si.field2")); + assertNull(ctx.getAttribute("si.field3")); + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void clearMultipleArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertNull(ctx.getAttribute("si[0].field1")); + assertNull(ctx.getAttribute("si[1].field2")); + assertNull(ctx.getAttribute("si[2].field3")); + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void clearSingleArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearSingleArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertNull(ctx.getAttribute("si[0].field1")); + assertEquals("2",ctx.getAttribute("si[1].field2")); + assertEquals("3", ctx.getAttribute("si[2].field3")); + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void arrayPattern() { + SetNodeExecutor sne = new SetNodeExecutor(); + String source = "one.two[0].three[0].four"; + assertEquals("one.two.three.four", source.replaceAll(sne.arrayPattern, "")); + } + + @Test + public void subtreeCopy() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/copyValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1", ctx.getAttribute("si.field1")); + assertEquals("2", ctx.getAttribute("si.field2")); + assertEquals("3", ctx.getAttribute("si.field3")); + assertEquals("1", ctx.getAttribute("rootTwo.field1")); + assertEquals("2", ctx.getAttribute("rootTwo.field2")); + assertEquals("3", ctx.getAttribute("rootTwo.field3")); + } + +} diff --git a/sli/provider/src/test/resources/clearArrayValues.xml b/sli/provider/src/test/resources/clearArrayValues.xml new file mode 100644 index 000000000..629322d65 --- /dev/null +++ b/sli/provider/src/test/resources/clearArrayValues.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearSingleArrayValues.xml b/sli/provider/src/test/resources/clearSingleArrayValues.xml new file mode 100644 index 000000000..3e4e5d98d --- /dev/null +++ b/sli/provider/src/test/resources/clearSingleArrayValues.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg From dc58dd879f9fbac661ef845b6a45e7e0f9bf9175 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 3 May 2018 19:11:40 +0000 Subject: TestSvcLogicLoader for windows TestSvcLogicLoader fails when run against a machine running windows Change-Id: I3687ac21c50cde10b1e8a0ed816b67d48c5e77f9 Issue-ID: CCSDK-266 Signed-off-by: Smokowski, Kevin (ks6305) --- .../test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java index 8998382ec..2dd83e86d 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java @@ -1,6 +1,7 @@ package org.onap.ccsdk.sli.core.sli; import static org.junit.Assert.*; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -21,13 +22,12 @@ public class TestSvcLogicLoader { SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(props); - URL graphUrl = TestSvcLogicLoader.class.getClassLoader().getResource("graphs"); + File graphDirectory = new File(getClass().getClassLoader().getResource("graphs").getFile()); - if (graphUrl == null) { + if (graphDirectory == null) { fail("Cannot find graphs directory"); } - - SvcLogicLoader loader = new SvcLogicLoader(graphUrl.getPath(), store); + SvcLogicLoader loader = new SvcLogicLoader(graphDirectory.getAbsolutePath(), store); loader.loadAndActivate(); -- cgit 1.2.3-korg From 6b70635e6fbd031cce667dd1449c0e7cdcdf73fd Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 4 May 2018 14:02:50 -0400 Subject: SLI provider needs Dynamic-ImportPackage The SLI provider package needs the option Dynamic-ImportPackage set in its manifest to allow it to bypass normal OSGi classpath isolation. Change-Id: I93be9ed111f72197db16f1b486b2102cbb9bbcdb Issue-ID: CCSDK-268 Signed-off-by: Timoney, Dan (dt5972) --- sli/provider/pom.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 8a5e25070..619a8af54 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -89,4 +89,21 @@ test + + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + + + + + + -- cgit 1.2.3-korg From 9353c6f5049a20350de7e827efb07a0f6c150aaf Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 8 May 2018 11:08:01 -0400 Subject: Remove erroneous license header Remove erroneous license headers from pom.xml files. These should be licensed under master license (no separate license header needed). Change-Id: Icaab3bffec0490d2904aa2e9b0a7a6d588ec07a6 Issue-ID: CCSDK-269 Signed-off-by: Timoney, Dan (dt5972) --- sli/features/odl-sli/pom.xml | 4 ---- sli/features/pom.xml | 7 ------- 2 files changed, 11 deletions(-) diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index d94aed577..1e02867e4 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -1,8 +1,4 @@ - 4.0.0 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 79626b8eb..11d48b0f2 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -1,11 +1,4 @@ - 4.0.0 -- cgit 1.2.3-korg From 00f76876657c2239421d3cdfbbd1532833b89e89 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Thu, 3 May 2018 17:27:20 -0700 Subject: Add INFO.yaml file Add INFO.yaml to list: - Project description - Properties - PTL information - Meeting information - Committer information Change-Id: Ib9f13169248d9208b7b334e4c8312304cc60cb3d Issue-ID: CIMAN-134 Signed-off-by: Jessica Wagantall --- INFO.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 INFO.yaml diff --git a/INFO.yaml b/INFO.yaml new file mode 100644 index 000000000..070df112b --- /dev/null +++ b/INFO.yaml @@ -0,0 +1,42 @@ +--- +project: 'ccsdk-sli-core' +project_creation_date: '2017-06-27' +lifecycle_state: 'Incubation' +project_lead: &onap_releng_ptl + name: 'Dan Timoney' + email: 'dtimoney@att.com' + id: 'djtimoney' + company: 'ATT' + timezone: 'America/New York' +primary_contact: *onap_releng_ptl +issue_tracking: + type: 'jira' + url: 'https://jira.onap.org/projects/CCSDK' + key: 'CCDSK' +meetings: + - type: 'zoom' + agenda: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' + url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project#CommonControllerSDKProject-MeetingMinutes' + server: 'n/a' + channel: 'n/a' + repeats: 'weekly' + time: '13:00 UTC' +committers: + - <<: *onap_releng_ptl + - name: 'Jack Lucas' + email: 'jflucas@research.att.com' + company: 'ATT' + id: 'jackl' + timezone: 'America/New York' + - name: 'Jun (Nicolas) Hu' + email: 'jh245g@att.com' + company: 'ATT' + id: 'jh245g' + timezone: 'America/New York' + - name: 'Ryan Goulding' + email: 'ryandgoulding@gmail.com' + company: 'Inocybe Technologies' + id: 'rgoulding' + timezone: 'America/New York' +tsc: + approval: 'https://lists.onap.org/pipermail/onap-tsc' -- cgit 1.2.3-korg From 972b25417e2851486940ca93d73763026eaa13b6 Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Tue, 8 May 2018 11:27:50 -0400 Subject: Provide support for properties encryption Changes made: * Implemented code to decrypt password field in property file Change-Id: I97e5f93fd1f8383c1e2a1e6170489dc1db9d6337 Issue-ID: CCSDK-182 Signed-off-by: Rich Tabedzki --- dblib/provider/pom.xml | 5 ++ .../sli/core/dblib/DBLIBResourceProvider.java | 56 ++++++++++++++++++++++ .../onap/ccsdk/sli/core/dblib/EncShellCommand.java | 48 +++++++++++++++++++ .../org/opendaylight/blueprint/dblib-blueprint.xml | 6 +++ 4 files changed, 115 insertions(+) mode change 100644 => 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java create mode 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/EncShellCommand.java diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 3eaefd067..9bf898f51 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -82,5 +82,10 @@ mockito-core test + + org.apache.karaf.shell + org.apache.karaf.shell.console + 3.0.8 + diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java old mode 100644 new mode 100755 index ddfb73316..6d36d6389 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java @@ -23,6 +23,7 @@ package org.onap.ccsdk.sli.core.dblib; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.lang.reflect.Method; import java.util.Optional; import java.util.Properties; import java.util.Vector; @@ -32,6 +33,9 @@ import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +49,12 @@ import org.slf4j.LoggerFactory; *

  • A directory identified by the JRE argument dblib.properties
  • *
  • A dblib.properties file located in the karaf root directory
  • * + * + * Encryption Support + *
      + *
    1. Uses ecryption provided by AAAEncryptionService
    2. + *
    3. AAA Configuration file is aaa-cert-config.xml
    4. + *
    */ public class DBLIBResourceProvider { @@ -55,6 +65,8 @@ public class DBLIBResourceProvider { */ private static final String DBLIB_PROP_FILE_NAME = "dblib.properties"; + private static final String DBLIB_PROPERTY_NAME = "org.onap.ccsdk.sli.jdbc.password"; + /** * A prioritized list of strategies for resolving dblib properties files. */ @@ -87,6 +99,20 @@ public class DBLIBResourceProvider { try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { properties = new Properties(); properties.load(fileInputStream); + + if(properties.containsKey(DBLIB_PROPERTY_NAME)) { + String sensitive = properties.getProperty(DBLIB_PROPERTY_NAME); + if(sensitive != null && sensitive.startsWith("ENC:")) { + try { + sensitive = sensitive.substring(4); + String postsense = decrypt(sensitive); + properties.setProperty(DBLIB_PROPERTY_NAME, postsense); + } catch(Exception exc) { + LOG.error("Failed to translate property", exc); + } + } + } + } catch (final IOException e) { LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), new DblibConfigurationException("Failed to load properties for file: " @@ -95,6 +121,36 @@ public class DBLIBResourceProvider { } } + /** + * + * @param value + * @return decrypted string if successful or the original value if unsuccessful + */ + private String decrypt(String value) { + try { + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + + ServiceReference sref = bctx.getServiceReference("org.opendaylight.aaa.encrypt.AAAEncryptionService"); + if(sref == null) { + LOG.warn("Could not acquire service reference for 'org.opendaylight.aaa.encrypt.AAAEncryptionService'"); + return value; + } + Object encrSvc = bctx.getService(sref); + if(encrSvc == null) { + LOG.warn("Could not access service for 'org.opendaylight.aaa.encrypt.AAAEncryptionService'"); + return value; + } + + Method gs2Method = encrSvc.getClass().getMethod("decrypt", new Class[] { "".getClass() }); + Object unmasked = gs2Method.invoke(encrSvc, new Object[] { value }); + return unmasked.toString(); + + } catch (Exception exc) { + LOG.error("Failure", exc); + return value; + } + } + /** * Extract db config properties. * diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/EncShellCommand.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/EncShellCommand.java new file mode 100755 index 000000000..eaa5700c9 --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/EncShellCommand.java @@ -0,0 +1,48 @@ +package org.onap.ccsdk.sli.core.dblib; + +import java.lang.reflect.Method; + +/** + * https://karaf.apache.org/manual/latest-2.x/developers-guide/extending-console.html + * https://github.com/apache/karaf/tree/master/shell/console/src/main/java/org/apache/felix/gogo/commands + */ +import org.apache.karaf.shell.commands.Argument; +import org.apache.karaf.shell.commands.Command; +import org.apache.karaf.shell.console.OsgiCommandSupport; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Command(scope = "dblib", name = "encode", description="Says hello") +public class EncShellCommand extends OsgiCommandSupport { + private static Logger LOGGER = LoggerFactory.getLogger(EncShellCommand.class); + + @Argument(index = 0, name = "arg", description = "The command argument", required = true, multiValued = false) + String arg = null; + + @Override + protected Object doExecute() throws Exception { + System.out.println(String.format("Original value: %s", arg)); + System.out.println(String.format("Encrypted value: %s", encrypt(arg))); + return null; + } + + private String encrypt(String value) { + try { + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + + ServiceReference sref = bctx.getServiceReference("org.opendaylight.aaa.encrypt.AAAEncryptionService"); + Object encrSvc = bctx.getService(sref); + + Method gs2Method = encrSvc.getClass().getMethod("encrypt", new Class[] { "".getClass() }); + Object unmasked = gs2Method.invoke(encrSvc, new Object[] { value }); + return String.format("ENC:%s", unmasked.toString()); + + } catch (Exception exc) { + LOGGER.error("Failure", exc); + return value; + } + } +} \ No newline at end of file diff --git a/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml b/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml index f1d5166db..d9bb99c07 100755 --- a/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml +++ b/dblib/provider/src/main/resources/org/opendaylight/blueprint/dblib-blueprint.xml @@ -15,4 +15,10 @@ + + + + + + \ No newline at end of file -- cgit 1.2.3-korg From 58eab69983f07a9841bdd52324a2b9c026487b2b Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Mon, 14 May 2018 13:53:04 -0400 Subject: Update properties encryption change Changes made: * updated version of org.apache.karaf.shell.console plugin Change-Id: I4cb0f5cb9e5a515473d2c60f693efd8dfc872dff Issue-ID: CCSDK-182 Signed-off-by: Rich Tabedzki --- dblib/provider/pom.xml | 160 ++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 9bf898f51..10d8314c9 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -1,91 +1,91 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.0.2-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.0.2-SNAPSHOT + + - org.onap.ccsdk.sli.core - dblib-provider - 0.2.2-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + dblib-provider + 0.2.2-SNAPSHOT + bundle - ccsdk-sli-core :: dblib :: ${project.artifactId} - http://maven.apache.org + ccsdk-sli-core :: dblib :: ${project.artifactId} + http://maven.apache.org - - UTF-8 - + + UTF-8 + - - - junit - junit - ${junit.version} - test - - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - org.slf4j - slf4j-simple - ${slf4j.version} - test - - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - com.google.guava - guava - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - + + + junit + junit + ${junit.version} + test + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + com.google.guava + guava + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + - - - org.mockito - mockito-core - test - + + + org.mockito + mockito-core + test + - org.apache.karaf.shell - org.apache.karaf.shell.console - 3.0.8 + org.apache.karaf.shell + org.apache.karaf.shell.console + ${karaf.plugin.version} - + -- cgit 1.2.3-korg From 6f247b95f9da0339cd268d786a5e9c3f861b38b3 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 17 May 2018 18:30:51 -0400 Subject: Update sli/core to use release 1.0.2 parents Updated pom.xmls to use released version of parent pom. Change-Id: Ib3d1c856691556cbd4c5f51852888f4bfc791a9f Issue-ID: CCSDK-286 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 9094abe69..6fa97f0e8 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 9fd5e03ad..138b3e37d 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 432405d4d..74f48866d 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index bdbf41009..9570f906e 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/dblib/pom.xml b/dblib/pom.xml index 82ed9986f..f197ac8f6 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 10d8314c9..1a07cf411 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index d5924db46..b37d075c6 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index d5145f222..ba2894305 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 36da4c608..1e3fbf3a8 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 1cdbb06a1..99f6ecf76 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/filters/pom.xml b/filters/pom.xml index d71df06d9..0feea7db9 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 11ec66aa2..aa3683e93 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/pom.xml b/pom.xml index 8b0dcacd5..7ec06abfc 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index e2396e8c4..a4914710a 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index b703b9461..6b0740fc8 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 1e02867e4..1005dc707 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 11d48b0f2..cd7674ed8 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 16861fffb..0eef0430f 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index e2045ee06..45b8faff1 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/pom.xml b/sli/pom.xml index fb1da59fa..b2afe9e77 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 619a8af54..68f09311f 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 2bc06f17c..cc8d03b34 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 9af6124e3..352c772d7 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 7c588698f..1fb306f82 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 4c8414536..7cf3f711a 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 845348e9f..a45970b74 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index b7f31276e..3ba0784f4 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 158cab354..98bf46751 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 352335ba9..d7d11e1de 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 1d745f32a..ce3721b9c 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index cf61aaa87..ec274c084 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 3c019e606..05adfc014 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 3d0b0b950..7f26c0d7e 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 746af7271..87a434101 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 7964a9065..d84156bfe 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 5df832c69..49e97c57e 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 382c5d5cb..0e50d4d3c 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml index 63f6c8e3f..08782e3d4 100644 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index b942e7906..42ff1677f 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/utils/pom.xml b/utils/pom.xml index 1c2e4f4a5..0e71278ee 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2-SNAPSHOT + 1.0.2 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index ac55d0f64..df2bd16a1 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.2-SNAPSHOT + 1.0.2 -- cgit 1.2.3-korg From 989b90f408edfe89f34380ab6fa4ca6f80850456 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Mon, 21 May 2018 13:08:09 -0700 Subject: Remove incorrect dblib ref in feature.xml Generated feature.xml contained unnecessary reference to dblib-provider with wrong version. Suppressed by explicitly declaring dblib-provider in features/pom.xml with scope 'provided'. Change-Id: I34571194fca3c24d710ad36c1a99f86ec6bcd9b1 Issue-ID: CCSDK-290 Signed-off-by: Timoney, Dan (dt5972) --- sli/features/odl-sli/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 1005dc707..b0a0cae0a 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -53,6 +53,13 @@ ${project.version}
    + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + provided + + org.mariadb.jdbc mariadb-java-client -- cgit 1.2.3-korg From 78a7af6c5bb10b7b58a46e7fdbdd93098472527b Mon Sep 17 00:00:00 2001 From: "Stilwell, David (stilwelld)" Date: Wed, 23 May 2018 12:34:18 -0400 Subject: Roll to the next snapshot and use new parent pom Updated version to 0.2.3-SNAPSHOT and 1.0.3-SNAPSHOT parent pom Change-Id: I2ac80137aa409d0d13b4bec12beb2b7e74bdfa40 Issue-ID: CCSDK-290 Signed-off-by: Stilwell, David (stilwelld) --- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 4 ++-- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 2 +- 42 files changed, 80 insertions(+), 80 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 6fa97f0e8..66f09c1ee 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 138b3e37d..e575ac344 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 74f48866d..e0a5ec419 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 9570f906e..d8d932d55 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index f197ac8f6..ced9c2eed 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 1a07cf411..8a476ba75 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index b37d075c6..b8e40f34a 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index ba2894305..11d78d1e9 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 1e3fbf3a8..a4800da8f 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 99f6ecf76..b85254e8a 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 0feea7db9..13b2dfda0 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index aa3683e93..5d456e6c2 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 7ec06abfc..3bd209f49 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index a4914710a..2fcfa44ad 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 6b0740fc8..584ddacc9 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index b0a0cae0a..c88a6a567 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index cd7674ed8..434d50d6f 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 0eef0430f..2a52beb43 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 45b8faff1..bdb5338e1 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index b2afe9e77..4c3cb0ecb 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 68f09311f..bc572c084 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index cc8d03b34..55281a269 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 352c772d7..a03a6f191 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 1fb306f82..82e3b0738 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 7cf3f711a..920d25bee 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index a45970b74..82ea5f5d9 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 3ba0784f4..d57fb5d7a 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 98bf46751..5f1aec4e3 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index d7d11e1de..0edd87015 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index ce3721b9c..b96be121f 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index ec274c084..1ebff2281 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 05adfc014..c8ceb8f89 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 7f26c0d7e..68389830a 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 87a434101..ad11d8133 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index d84156bfe..99002dea4 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 49e97c57e..825eccf2c 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 0e50d4d3c..e18674d8b 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml index 08782e3d4..0339d23a2 100644 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 42ff1677f..c1ab25ebe 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 0e71278ee..72b2eb89d 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index df2bd16a1..a2895ce96 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.2 + 1.0.3-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 5985855ef..1abffd200 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=2 -feature_revision=2 +feature_revision=3 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 7538a1c8e40b39066af9825856b4fa99b76d6eee Mon Sep 17 00:00:00 2001 From: "Stilwell, David (stilwelld)" Date: Wed, 23 May 2018 17:07:16 -0400 Subject: Update to release version parent 1.0.3 Update parent version to remove -SNAPSHOT (1.0.3) Change-Id: Ie9680134a643c7cfec3fd774422d8c62637bdbc3 Issue-ID: CCSDK-290 Signed-off-by: Stilwell, David (stilwelld) --- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 66f09c1ee..27a1dedf7 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index e575ac344..7aaba589c 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index e0a5ec419..09e9599ab 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index d8d932d55..524bff683 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/dblib/pom.xml b/dblib/pom.xml index ced9c2eed..1ee5ae335 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 8a476ba75..788ef922b 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index b8e40f34a..323de36cd 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 11d78d1e9..3a2f3deb9 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/filters/features/pom.xml b/filters/features/pom.xml index a4800da8f..47d203032 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index b85254e8a..4f16cca1a 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/filters/pom.xml b/filters/pom.xml index 13b2dfda0..06d8bdd1c 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 5d456e6c2..7e951ecd3 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/pom.xml b/pom.xml index 3bd209f49..d2050e39e 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 2fcfa44ad..0b3bbf909 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 584ddacc9..4c9d57045 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index c88a6a567..982a48432 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 434d50d6f..979e33257 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 2a52beb43..3afc1fe20 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index bdb5338e1..d148fb323 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/pom.xml b/sli/pom.xml index 4c3cb0ecb..067210ffa 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index bc572c084..f4a65a5bd 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 55281a269..c5cb601cb 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index a03a6f191..8582264e3 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 82e3b0738..e85dc049c 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 920d25bee..dac5b38e7 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 82ea5f5d9..c26108929 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index d57fb5d7a..ada57828f 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 5f1aec4e3..eaa6dc0f6 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 0edd87015..c4a13dff7 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index b96be121f..5558cfcd9 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 1ebff2281..04899f1a9 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index c8ceb8f89..4f3e43a06 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 68389830a..c94efa21c 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index ad11d8133..0852ce1a6 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 99002dea4..61f2a9f8c 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 825eccf2c..a9d8761d7 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/utils/features/pom.xml b/utils/features/pom.xml index e18674d8b..6c4851a6b 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml index 0339d23a2..4585fde7f 100644 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index c1ab25ebe..6a6852222 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/utils/pom.xml b/utils/pom.xml index 72b2eb89d..e7920ff32 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3-SNAPSHOT + 1.0.3 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index a2895ce96..128f9caec 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.3-SNAPSHOT + 1.0.3 -- cgit 1.2.3-korg From 4e6e6a3cb67e7ec6f092e1a3e4c0eae36add00d1 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 30 May 2018 16:55:58 -0400 Subject: Roll version to 0.2.4 Roll version to 0.2.4-SNAPSHOT and version 1.0.4-SNAPSHOT of parent Change-Id: I7dda7fc4a25756e129d75e0a79b4d82f5622144f Issue-ID: CCSDK-291 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 4 ++-- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 2 +- 42 files changed, 81 insertions(+), 81 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 27a1dedf7..333a5504a 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 7aaba589c..e905f633c 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 09e9599ab..6cdeeaf7d 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 524bff683..1069f6532 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 1ee5ae335..c31fe6879 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 788ef922b..9a85b5eec 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 323de36cd..2dacbb8c5 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 3a2f3deb9..d24097ab4 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 47d203032..a483b138d 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 4f16cca1a..f379c606e 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 06d8bdd1c..7f78820d4 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 7e951ecd3..9174085f7 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index d2050e39e..606e67231 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 0b3bbf909..eedcd76ac 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 4c9d57045..14a4e0b1b 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 982a48432..2e3daa006 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 979e33257..eb46c875a 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.1.0 + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 3afc1fe20..e769f9c60 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index d148fb323..075b5b7d1 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 067210ffa..6608adc58 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index f4a65a5bd..a4c087bff 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index c5cb601cb..7e630b64a 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 8582264e3..9547242d6 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index e85dc049c..03731ad53 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index dac5b38e7..6c1e39dbe 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index c26108929..cdf8400bb 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index ada57828f..7f50cd2e0 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index eaa6dc0f6..03b5e293d 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index c4a13dff7..c04ffb039 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 5558cfcd9..8d697adab 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 04899f1a9..947af01f7 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 4f3e43a06..7caa091fd 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index c94efa21c..a12c3e7f2 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 0852ce1a6..4e21b8f56 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 61f2a9f8c..d19da49f5 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index a9d8761d7..8dd9c636a 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 6c4851a6b..19ce82486 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml index 4585fde7f..07bad7f53 100644 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 6a6852222..2f9e45a96 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index e7920ff32..bcf39e722 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 128f9caec..a9fcb8771 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.3 + 1.0.4-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 1abffd200..3368e09ca 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=2 -feature_revision=3 +feature_revision=4 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 468235d1ab8e1ee7e9aad309ae58c1afe357915c Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 30 May 2018 20:55:48 -0400 Subject: Use version 1.0.4 of parent Use released version of parent pom Change-Id: Iaf783c89e2afc6e974ba4ea2b286f380a6b84fd8 Issue-ID: CCSDK-291 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 333a5504a..0eaec2e3f 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index e905f633c..879fbd9c0 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 6cdeeaf7d..926305c53 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 1069f6532..08a2718dc 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/dblib/pom.xml b/dblib/pom.xml index c31fe6879..f3d10dc3f 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 9a85b5eec..dcc85b423 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 2dacbb8c5..fc1d32eb1 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index d24097ab4..934839998 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/filters/features/pom.xml b/filters/features/pom.xml index a483b138d..6ba3ebeef 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index f379c606e..184cd8e8d 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/filters/pom.xml b/filters/pom.xml index 7f78820d4..fdc011c3d 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 9174085f7..ab96786e0 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/pom.xml b/pom.xml index 606e67231..8052c5767 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index eedcd76ac..3b7e867ea 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 14a4e0b1b..8d14f71ca 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 2e3daa006..42955b536 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index eb46c875a..ed5734b6d 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index e769f9c60..e0d970b58 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 075b5b7d1..c1be297ca 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/pom.xml b/sli/pom.xml index 6608adc58..9987cc000 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index a4c087bff..f9d17687d 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 7e630b64a..0f3028ea6 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 9547242d6..22989c7ec 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 03731ad53..edc3bab16 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 6c1e39dbe..f420f3b67 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index cdf8400bb..b55e418b2 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 7f50cd2e0..d67167ab3 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 03b5e293d..281115ce9 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index c04ffb039..a6b74fdcf 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 8d697adab..bda006e42 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 947af01f7..6083f7a63 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 7caa091fd..24f66532a 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index a12c3e7f2..b682742f4 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 4e21b8f56..e27a0c989 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index d19da49f5..c563f617f 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 8dd9c636a..42044d9cd 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 19ce82486..42b93fe95 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml index 07bad7f53..aa31eb843 100644 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 2f9e45a96..15a6b3325 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/utils/pom.xml b/utils/pom.xml index bcf39e722..07f2894c7 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4-SNAPSHOT + 1.0.4 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index a9fcb8771..239234721 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.0.4-SNAPSHOT + 1.0.4 -- cgit 1.2.3-korg From 1a71779b7b1104ba6d5e289e6dc839bb4b9493d5 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 6 Jun 2018 13:44:30 -0400 Subject: Roll versions for Casablanca - sli/core Update versions for Casablanca development Change-Id: I0b9d30707033706b35afcd016687fc86c8f2a83e Issue-ID: CCSDK-295 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 4 ++-- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 6 +++--- 42 files changed, 83 insertions(+), 83 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 0eaec2e3f..3a2f7a1bc 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 879fbd9c0..ce31373ce 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 926305c53..a24c558cc 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 08a2718dc..e0710b8fd 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index f3d10dc3f..f34ee2041 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index dcc85b423..e263374a9 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index fc1d32eb1..b35f5ec9e 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 934839998..810d40ab4 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 6ba3ebeef..73192fa8a 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 184cd8e8d..d03afaaa2 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index fdc011c3d..319c4a7ff 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index ab96786e0..dd78b2a64 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 8052c5767..9dc52969d 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 3b7e867ea..7f5ac8074 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 8d14f71ca..7193b2b21 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 42955b536..4d0143664 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index ed5734b6d..9a75ad709 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index e0d970b58..83f059c54 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index c1be297ca..d074e2501 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 9987cc000..d608e341a 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index f9d17687d..ebba283d2 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 0f3028ea6..a13ed13ea 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 22989c7ec..3737f9e73 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index edc3bab16..23e54fe5d 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index f420f3b67..5b4b70fd8 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index b55e418b2..a1737a86d 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index d67167ab3..8ecdf3972 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 281115ce9..ae7506361 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index a6b74fdcf..f868f3453 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index bda006e42..8b0ffecd9 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 6083f7a63..dd0c3bd7d 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 24f66532a..145169ba0 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index b682742f4..594a6dbf4 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index e27a0c989..d59e72aea 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index c563f617f..3be16f42d 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 42044d9cd..8f8748a57 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 42b93fe95..4f3be1b86 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml index aa31eb843..8ff1d4cff 100644 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 15a6b3325..4b445936a 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 07f2894c7..85206f8ad 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 239234721..2ecea40e8 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.0.4 + 1.1.0-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.2.4-SNAPSHOT + 0.3.0-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 3368e09ca..57f71d583 100644 --- a/version.properties +++ b/version.properties @@ -5,11 +5,11 @@ release_name=0 -sprint_number=2 -feature_revision=4 +sprint_number=3 +feature_revision=9 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version} +release_version=${base_version}-STAGING snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg From 88115d6cf23b4d836cb5637905d46412fb82c7e4 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 11 May 2018 14:27:15 +0000 Subject: dme2 plugin improvements DME2 plugin itself will be coded to generic properties object not any custom object. The code is flexible so new query parameters can easily be added without code changes. Default properties which could previously not be overridden can now be overridden if desired. Change-Id: I56b4dfd4dee350198a23ac57c775bd1adacb1a9a Issue-ID: CCSDK-274 Signed-off-by: Smokowski, Kevin (ks6305) --- .../onap/ccsdk/sli/core/slipluginutils/DME2.java | 296 +++++++++++---------- .../ccsdk/sli/core/slipluginutils/Dme2Factory.java | 109 ++++++++ .../slipluginutils/Dme2PropertiesProvider.java | 278 ------------------- .../blueprint/slipluginutils-blueprint.xml | 37 +-- .../ccsdk/sli/core/slipluginutils/Dme2Test.java | 293 ++++++++++++-------- 5 files changed, 462 insertions(+), 551 deletions(-) create mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java index 6bdd87e24..5121e8a56 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java @@ -1,146 +1,150 @@ -/*- - * ============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.slipluginutils; - -import java.util.Map; - -import java.util.Optional; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -/** - * A SvcLogicJavaPlugin that generates DME2 proxy urls using parameters from context memory. - */ -public class DME2 implements SvcLogicJavaPlugin { - - private static final Logger LOG = LoggerFactory.getLogger(DME2.class); - - final String aafUserName; - final String aafPassword; - final String envContext; - final String routeOffer; - final String[] proxyUrls; - final String commonServiceVersion; - - Integer index; - String partner; - - - public void setPartner(String partner) { - if (partner != null && partner.length() > 0) { - this.partner = partner; - } - } - - public DME2(String aafUserName, String aafPassword, String envContext, String routeOffer, String[] proxyUrls, String commonServiceVersion) { - this.aafUserName = aafUserName; - this.aafPassword = aafPassword; - this.envContext = envContext; - this.routeOffer = routeOffer; - this.proxyUrls = proxyUrls; - this.index = 0; - this.commonServiceVersion = commonServiceVersion; - } - - public DME2(final Dme2PropertiesProvider provider) { - this.aafUserName = useProperty(provider.getAafUsername(), Dme2PropertiesProvider.AAF_USERNAME_KEY); - this.aafPassword = useProperty(provider.getAafPassword(), Dme2PropertiesProvider.AAF_PASSWORD_KEY); - this.envContext = useProperty(provider.getEnvContext(), Dme2PropertiesProvider.ENV_CONTEXT_KEY); - this.routeOffer = useProperty(provider.getRouteOffer(), Dme2PropertiesProvider.ROUTE_OFFER_KEY); - this.index = 0; - this.commonServiceVersion = useProperty(provider.getCommonServiceVersion(), - Dme2PropertiesProvider.COMMON_SERVICE_VERSION_KEY); - - final Optional maybeProxyUrls = provider.getProxyUrls(); - if (maybeProxyUrls.isPresent()) { - this.proxyUrls = maybeProxyUrls.get(); - } else { - warnOfMissingProperty(Dme2PropertiesProvider.PROXY_URL_KEY); - this.proxyUrls = null; - } - this.setPartner(useProperty(provider.getPartner(), Dme2PropertiesProvider.PARTNER_KEY)); - } - - private String useProperty(final Optional propertyOptional, final String propertyKey) { - if (propertyOptional.isPresent()) { - return propertyOptional.get(); - } - warnOfMissingProperty(propertyKey); - return null; - } - - private void warnOfMissingProperty(final String propertyName) { - LOG.warn("Utilizing null for {} since it was left unassigned in the properties file"); - } - - // constructs a URL to contact the proxy which contacts a DME2 service - public String constructUrl(String service, String version, String subContext) { - StringBuilder sb = new StringBuilder(); - - // The hostname is assigned in a round robin fashion - sb.append(acquireHostName()); - sb.append("/service=" + service); - - //If the directedGraph passes an explicit version use that, if not use the commonServiceVersion found in the properties file - if (version == null) { - version = this.commonServiceVersion; - } - sb.append("/version=" + version); - - sb.append("/envContext=" + this.envContext); - if (this.routeOffer != null && this.routeOffer.length() > 0) { - sb.append("/routeOffer=" + this.routeOffer); - } - if (subContext != null && subContext.length() > 0) { - sb.append("/subContext=" + subContext); - } - sb.append("?dme2.password=" + this.aafPassword); - sb.append("&dme2.username=" + this.aafUserName); - if (this.partner != null) { - sb.append("&dme2.partner=" + this.partner); - } - sb.append("&dme2.allowhttpcode=true"); - return sb.toString(); - } - - public synchronized String acquireHostName() { - String retVal = proxyUrls[index]; - index++; - if (index == this.proxyUrls.length) { - index = 0; - } - return retVal; - } - - // Node entry point - public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[] { "service", "outputPath" }, LOG); - String completeProxyUrl = constructUrl(parameters.get("service"), parameters.get("version"), parameters.get("subContext")); - ctx.setAttribute(parameters.get("outputPath"), completeProxyUrl); - } - -} +/*- + * ============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.slipluginutils; + +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A SvcLogicJavaPlugin that generates DME2 proxy urls (for calling the DME2 ingress proxy) using + * parameters from context memory. + */ +public class DME2 implements SvcLogicJavaPlugin { + + private static final Logger LOG = LoggerFactory.getLogger(DME2.class); + // the key for proxyUrl, which represents a CSV list of urls + static final String PROXY_URL_KEY = "proxyUrl"; + static final String PROXY_URLS_VALUE_SEPARATOR = ","; + static final String AAF_USERNAME_KEY = "aafUserName"; + static final String AAF_PASSWORD_KEY = "aafPassword"; + static final String ENV_CONTEXT_KEY = "envContext"; + static final String ROUTE_OFFER_KEY = "routeOffer"; + static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; + static final String PARTNER_KEY = "partner"; + static final String VERSION_KEY = "version"; + static final String SERVICE_KEY = "service"; + static final String SUBCONTEXT_KEY = "subContext"; + static final String ENDPOINT_READ_TIMEOUT_KEY = "endpointReadTimeout"; + static final String OUTPUT_PATH_KEY = "outputPath"; + + final String aafUserName; + final String aafPassword; + final String envContext; + final String routeOffer; + final String[] proxyUrls; + final String commonServiceVersion; + final String partner; + final String endpointReadTimeout; + Integer index; + + public DME2(Properties properties) { + Iterator> it = properties.entrySet().iterator(); + while (it.hasNext()) { + Entry entry = it.next(); + if (entry.getValue() == null || entry.getValue().toString().length() < 1) { + it.remove(); + } + } + this.aafUserName = properties.getProperty(AAF_USERNAME_KEY, null); + this.aafPassword = properties.getProperty(AAF_PASSWORD_KEY, null); + this.envContext = properties.getProperty(ENV_CONTEXT_KEY, null); + this.routeOffer = properties.getProperty(ROUTE_OFFER_KEY, null); + this.commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY, null); + this.partner = properties.getProperty(PARTNER_KEY, null); + this.endpointReadTimeout = properties.getProperty(ENDPOINT_READ_TIMEOUT_KEY, null); + String proxyUrlString = properties.getProperty(PROXY_URL_KEY, null); + if (proxyUrlString != null && proxyUrlString.length() > 0) { + this.proxyUrls = proxyUrlString.split(PROXY_URLS_VALUE_SEPARATOR); + } else { + String[] local = {"http://localhost:5000"}; + this.proxyUrls = local; + } + this.index = 0; + } + + // constructs a URL to contact the proxy which contacts a DME2 service + public String constructUrl(Map parameters) { + StringBuilder sb = new StringBuilder(); + + // The hostname is assigned in a round robin fashion + sb.append(acquireHostName()); + sb.append("/service=" + parameters.get(SERVICE_KEY)); + + // If the directedGraph passes an explicit version use that, if not use the commonServiceVersion + // found in the properties file + String version = parameters.getOrDefault(VERSION_KEY, this.commonServiceVersion); + sb.append("/version=" + version); + String envContext = parameters.getOrDefault(ENV_CONTEXT_KEY, this.envContext); + sb.append("/envContext=" + envContext); + String routeOffer = parameters.getOrDefault(ROUTE_OFFER_KEY, this.routeOffer); + sb.append("/routeOffer=" + routeOffer); + + String subContext = parameters.get(SUBCONTEXT_KEY); + if (subContext != null && subContext.length() > 0) { + sb.append("/subContext=" + subContext); + } + sb.append("?dme2.password=" + this.aafPassword); + sb.append("&dme2.username=" + this.aafUserName); + if (this.partner != null) { + sb.append("&dme2.partner=" + this.partner); + } + sb.append("&dme2.allowhttpcode=true"); + String endpointReadTimeout = parameters.getOrDefault(ENDPOINT_READ_TIMEOUT_KEY, this.endpointReadTimeout); + if (endpointReadTimeout != null) { + sb.append("&dme2.endpointReadTimeout=" + endpointReadTimeout); + } + String incompleteUrl = sb.toString(); + + // Support optional parameters in a flexible way + for (Entry param : parameters.entrySet()) { + if (!incompleteUrl.contains(param.getKey() + "=") && param.getValue() != null + && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey())) { + sb.append("&" + param.getKey() + "=" + param.getValue()); + } + } + return sb.toString(); + } + + public synchronized String acquireHostName() { + String retVal = proxyUrls[index]; + index++; + if (index == this.proxyUrls.length) { + index = 0; + } + return retVal; + } + + // Node entry point + public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] {SERVICE_KEY, OUTPUT_PATH_KEY}, LOG); + String completeProxyUrl = constructUrl(parameters); + ctx.setAttribute(parameters.get(OUTPUT_PATH_KEY), completeProxyUrl); + } + +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java new file mode 100644 index 000000000..7013a9c5d --- /dev/null +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java @@ -0,0 +1,109 @@ +/*- + * ============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.slipluginutils; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Optional; +import java.util.Properties; +import java.util.Vector; +import org.onap.ccsdk.sli.core.utils.JREFileResolver; +import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; +import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Immutable properties container for dme2 properties. Since the initial design decision was made to + * utilize Properties instead of an OSGi ManagedService, it was decided to + * make these properties immutable. + */ +public final class Dme2Factory { + + private static final Logger LOG = LoggerFactory.getLogger(Dme2Factory.class); + private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; + + static Properties properties; + private Vector dme2PropertiesFileResolvers = new Vector<>(); + + public Dme2Factory() { + dme2PropertiesFileResolvers + .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); + dme2PropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); + dme2PropertiesFileResolvers + .add(new JREFileResolver("Using property file (3) from JRE argument", Dme2Factory.class)); + dme2PropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); + File dme2File = getDme2File(DME2_PROPERTIES_FILE_NAME); + init(dme2File); + } + + private void init(final File dme2propertiesFile) { + try { + properties = getProperties(dme2propertiesFile); + } catch (final FileNotFoundException e) { + LOG.error("dme2.properties file could not be found at path: {}", dme2propertiesFile, e); + } catch (final IOException e) { + LOG.error("fatal error reading dme2.properties at path: {}", dme2propertiesFile, e); + } + } + + /** + * Reports the method chosen for properties resolution to the Logger. + * + * @param message Some user friendly message + * @param fileOptional The file location of the chosen properties file + * @return the file location of the chosen properties file + */ + private static File reportSuccess(final String message, final Optional fileOptional) { + if (fileOptional.isPresent()) { + final File file = fileOptional.get(); + LOG.info("{} {}", message, file.getPath()); + return file; + } + return null; + } + + private File getDme2File(final String dme2Filename) { + for (final PropertiesFileResolver dblibPropertiesFileResolver : dme2PropertiesFileResolvers) { + final Optional fileOptional = dblibPropertiesFileResolver.resolveFile(dme2Filename); + if (fileOptional.isPresent()) { + return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); + } + } + return (new File(dme2Filename)); + } + + private static Properties getProperties(final File dme2File) throws IOException { + final Properties properties = new Properties(); + properties.load(new FileReader(dme2File)); + return properties; + } + + public DME2 createDme2() { + return new DME2(properties); + } + +} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java deleted file mode 100644 index 6802c9a8b..000000000 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java +++ /dev/null @@ -1,278 +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.slipluginutils; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; -import java.util.Properties; -import java.util.Vector; - -import org.onap.ccsdk.sli.core.utils.JREFileResolver; -import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; -import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; -import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Immutable properties container for dme2 properties. Since the initial design - * decision was made to utilize Properties instead of an OSGi - * ManagedService, it was decided to make these properties - * immutable. - */ -public final class Dme2PropertiesProvider { - - private static final Logger LOG = LoggerFactory.getLogger(Dme2PropertiesProvider.class); - - /** - * The name of the environment variable to specify the configuration directory. - */ - private static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR"; - - /** - * the dme2 properties file name. - */ - private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; - - /** - * the key for proxyUrl, which represents a CSV list of urls - */ - static final String PROXY_URL_KEY = "proxyUrl"; - - /** - * indicates that proxy urls are separated by commas - */ - private static final String PROXY_URLS_VALUE_SEPARATOR = ","; - - /** - * the key for aafUserName - */ - static final String AAF_USERNAME_KEY = "aafUserName"; - - /** - * the key for aafPassword - */ - static final String AAF_PASSWORD_KEY = "aafPassword"; - - /** - * the key for envContext - */ - static final String ENV_CONTEXT_KEY = "envContext"; - - /** - * the key for routeOffer - */ - static final String ROUTE_OFFER_KEY = "routeOffer"; - - /** - * the key for commonServiceVersion - */ - static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; - - /** - * the key for partner - */ - static final String PARTNER_KEY = "partner"; - - private Optional proxyUrls = Optional.empty(); - - private Optional aafUsername = Optional.empty(); - - private Optional aafPassword = Optional.empty(); - - private Optional envContext = Optional.empty(); - - private Optional routeOffer = Optional.empty(); - - private Optional commonServiceVersion = Optional.empty(); - - private Optional partner = Optional.empty(); - - /** - * A prioritized list of strategies for resolving dme2 properties files. - */ - private Vector dme2PropertiesFileResolvers = new Vector<>(); - - /** - * Instantiates the properties provider, which involves loading the appropriate - * properties for dme2. - */ - public Dme2PropertiesProvider() { - this(DME2_PROPERTIES_FILE_NAME); - } - - /** - * Instantiates the properties provider, which involves loading the appropriate - * properties for dme2. - * - * @param dme2Path - * location of the dme2.properties file - */ - @VisibleForTesting - Dme2PropertiesProvider(final String dme2FileName) { - dme2PropertiesFileResolvers - .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); - dme2PropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); - - dme2PropertiesFileResolvers - .add(new JREFileResolver("Using property file (3) from JRE argument", Dme2PropertiesProvider.class)); - dme2PropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); - - File dme2File = getDme2File(dme2FileName); - - init(dme2File); - } - - private void init(final File dme2Path) { - final Properties properties; - try { - properties = getProperties(dme2Path); - this.proxyUrls = getProxyUrls(properties); - this.aafUsername = getAafUsername(properties); - this.aafPassword = getAafPassword(properties); - this.envContext = getEnvContext(properties); - this.routeOffer = getRouteOffer(properties); - this.commonServiceVersion = getCommonServiceVersion(properties); - this.partner = getPartner(properties); - } catch (final FileNotFoundException e) { - - LOG.error("dme2.properties file could not be found at path: {}", dme2Path, e); - } catch (final IOException e) { - LOG.error("fatal error reading dme2.properties at path: {}", dme2Path, e); - } - } - - /** - * Reports the method chosen for properties resolution to the - * Logger. - * - * @param message - * Some user friendly message - * @param fileOptional - * The file location of the chosen properties file - * @return the file location of the chosen properties file - */ - private static File reportSuccess(final String message, final Optional fileOptional) { - if (fileOptional.isPresent()) { - final File file = fileOptional.get(); - LOG.info("{} {}", message, file.getPath()); - return file; - } - return null; - } - - private File getDme2File(final String dme2Filename) { - - for (final PropertiesFileResolver dblibPropertiesFileResolver : dme2PropertiesFileResolvers) { - final Optional fileOptional = dblibPropertiesFileResolver.resolveFile(dme2Filename); - if (fileOptional.isPresent()) { - return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); - } - } - return (new File(dme2Filename)); - } - - private static Properties getProperties(final File dme2File) throws IOException { - - final Properties properties = new Properties(); - properties.load(new FileReader(dme2File)); - return properties; - } - - private String getProxyUrl(final Properties properties) { - return properties.getProperty(PROXY_URL_KEY); - } - - private Optional getProxyUrls(final Properties properties) { - final String proxyUrlsValue = getProxyUrl(properties); - if (!Strings.isNullOrEmpty(proxyUrlsValue)) { - return Optional.ofNullable(proxyUrlsValue.split(PROXY_URLS_VALUE_SEPARATOR)); - } - return Optional.empty(); - } - - public Optional getProxyUrls() { - return this.proxyUrls; - } - - private Optional getAafUsername(final Properties properties) { - final String aafUsernameValue = properties.getProperty(AAF_USERNAME_KEY); - return Optional.ofNullable(aafUsernameValue); - } - - Optional getAafUsername() { - return this.aafUsername; - } - - private Optional getAafPassword(final Properties properties) { - final String aafPassword = properties.getProperty(AAF_PASSWORD_KEY); - return Optional.ofNullable(aafPassword); - } - - Optional getAafPassword() { - return this.aafPassword; - } - - private Optional getEnvContext(final Properties properties) { - final String envContext = properties.getProperty(ENV_CONTEXT_KEY); - return Optional.ofNullable(envContext); - } - - Optional getEnvContext() { - return this.envContext; - } - - private Optional getRouteOffer(final Properties properties) { - final String routeOffer = properties.getProperty(ROUTE_OFFER_KEY); - return Optional.ofNullable(routeOffer); - } - - Optional getRouteOffer() { - return this.routeOffer; - } - - private Optional getCommonServiceVersion(final Properties properties) { - final String commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY); - return Optional.ofNullable(commonServiceVersion); - } - - Optional getCommonServiceVersion() { - return this.commonServiceVersion; - } - - private Optional getPartner(final Properties properties) { - final String partner = properties.getProperty(PARTNER_KEY); - return Optional.ofNullable(partner); - } - - Optional getPartner() { - return this.partner; - } -} diff --git a/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml b/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml index c0952d2a2..283dbbaa9 100644 --- a/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml +++ b/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml @@ -1,19 +1,20 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java index d19fbec43..662df75da 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java @@ -1,109 +1,184 @@ -/*- - * ============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.slipluginutils; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; - -public class Dme2Test { - - @Test - public void createInstarUrl() { - String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(instarUrl, constructedUrl); - } - - @Test - public void createInstarUrlNoSubContext() { - String instarUrl = "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", new String[] { "http://localhost:25055" }, "common"); - Map parameters = new HashMap(); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", parameters.get(null)); - assertEquals(instarUrl, constructedUrl); - } - - @Test - public void testRoundRobin() { - String[] proxyHostNames = new String[] { "http://one:25055", "http://two:25055", "http://three:25055" }; - String urlSuffix = "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - DME2 dme = new DME2("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNames, "common"); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - } - - @Test - public void createDme2EndtoEnd() { - Dme2PropertiesProvider provider = - new Dme2PropertiesProvider("src/test/resources/dme2.e2e.properties"); - DME2 dme2 = new DME2(provider); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("UAT", dme2.envContext); - assertEquals("UAT", dme2.routeOffer); - Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); - assertEquals("1702.0", dme2.commonServiceVersion); - assertEquals(null, dme2.partner); - - String constructedUrl = dme2.constructUrl("sample.com/restservices/instar/v1/assetSearch", null, "/mySubContext"); - assertNotNull(constructedUrl); - System.out.println(constructedUrl); - } - - @Test - public void createDme2Prod() { - Dme2PropertiesProvider provider = - new Dme2PropertiesProvider("src/test/resources/dme2.prod.properties"); - DME2 dme2 = new DME2(provider); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("PROD", dme2.envContext); - assertEquals("", dme2.routeOffer); - Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); - assertEquals("1.0", dme2.commonServiceVersion); - assertEquals("LPP_PROD", dme2.partner); - - String constructedUrl = dme2.constructUrl("sample.com/restservices/instar/v1/assetSearch", null, "/mySubContext"); - assertNotNull(constructedUrl); - System.out.println(constructedUrl); - } - -} +/*- + * ============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.slipluginutils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import org.junit.Assert; +import org.junit.Test; + +public class Dme2Test { + public Properties makesProperties(String aafUserName, String aafPassword, String envContext, String routeOffer, + String proxyUrls, String commonServiceVersion) { + Properties props = new Properties(); + props.put(DME2.AAF_USERNAME_KEY, aafUserName); + props.put(DME2.AAF_PASSWORD_KEY, aafPassword); + props.put(DME2.ENV_CONTEXT_KEY, envContext); + props.put(DME2.ROUTE_OFFER_KEY, routeOffer); + props.put(DME2.PROXY_URL_KEY, proxyUrls); + props.put(DME2.COMMON_SERVICE_VERSION_KEY, commonServiceVersion); + return props; + } + + @Test + public void createUrl() { + String instarUrl = + "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = + makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.VERSION_KEY, "1702.0"); + parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + parameters.put(DME2.OUTPUT_PATH_KEY, "tmp.test"); + + String constructedUrl = dme.constructUrl(parameters); + assertEquals(instarUrl, constructedUrl); + } + + @Test + public void createUrlNoSubContext() { + String instarUrl = + "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = + makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.VERSION_KEY, "1702.0"); + parameters.put(DME2.SUBCONTEXT_KEY, null); + String constructedUrl = dme.constructUrl(parameters); + assertEquals(instarUrl, constructedUrl); + } + + @Test + public void testRoundRobin() { + String[] proxyHostNames = new String[] {"http://one:25055", "http://two:25055", "http://three:25055"}; + String proxyHostNameString = proxyHostNames[0] + "," + proxyHostNames[1] + "," + proxyHostNames[2]; + + String urlSuffix = + "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNameString, "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.VERSION_KEY, "1702.0"); + parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + String constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + } + + @Test + public void createDme2EndtoEnd() throws FileNotFoundException, IOException { + Properties props = new Properties(); + props.load(new FileInputStream("src/test/resources/dme2.e2e.properties")); + DME2 dme2 = new DME2(props); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("UAT", dme2.envContext); + assertEquals("UAT", dme2.routeOffer); + Assert.assertArrayEquals( + "http://sample.com:25055,http://sample.com:25055".split(DME2.PROXY_URLS_VALUE_SEPARATOR), + dme2.proxyUrls); + assertEquals("1702.0", dme2.commonServiceVersion); + assertEquals(null, dme2.partner); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/restservices/instar/v1/assetSearch"); + parameters.put(DME2.VERSION_KEY, null); + parameters.put(DME2.SUBCONTEXT_KEY, "/mySubContext"); + String constructedUrl = dme2.constructUrl(parameters); + assertNotNull(constructedUrl); + } + + @Test + public void createDme2Prod() throws FileNotFoundException, IOException { + Properties props = new Properties(); + props.load(new FileInputStream("src/test/resources/dme2.prod.properties")); + DME2 dme2 = new DME2(props); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("PROD", dme2.envContext); + assertEquals(null, dme2.routeOffer); + Assert.assertArrayEquals( + "http://sample.com:25055,http://sample.com:25055".split(DME2.PROXY_URLS_VALUE_SEPARATOR), + dme2.proxyUrls); + assertEquals("1.0", dme2.commonServiceVersion); + assertEquals("LPP_PROD", dme2.partner); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.VERSION_KEY, "1702.0"); + parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + String constructedUrl = dme2.constructUrl(parameters); + assertNotNull(constructedUrl); + } + + @Test + public void blankProperties() throws Exception { + Properties props = new Properties(); + DME2 dme2 = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "easyService"); + parameters.put(DME2.VERSION_KEY, "3"); + parameters.put(DME2.SUBCONTEXT_KEY, "/sub"); + assertEquals( + "http://localhost:5000/service=easyService/version=3/envContext=null/routeOffer=null/subContext=/sub?dme2.password=null&dme2.username=null&dme2.allowhttpcode=true", + dme2.constructUrl(parameters)); + } + + @Test + public void optionalParameters() { + String instarUrl = + "http://localhost:25055/service=serv/version=4/envContext=TEST/routeOffer=DEFAULT/subContext=/sub?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true&test=123"; + Properties props = + makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "serv"); + parameters.put(DME2.VERSION_KEY, "4"); + parameters.put(DME2.SUBCONTEXT_KEY, "/sub"); + parameters.put("test", "123"); + + String constructedUrl = dme.constructUrl(parameters); + assertEquals(instarUrl, constructedUrl); + } + +} -- cgit 1.2.3-korg From 127401e9fbca889c1a64836ae06ac03309e26e7c Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 12 Jun 2018 14:12:26 +0000 Subject: dme2 partner fix update dme2 query parameter for partner it should be just partner not dme2.partner Change-Id: I2c4304cb2cce4d1def7f4b33bd17bfeca0f68fd3 Issue-ID: CCSDK-301 Signed-off-by: Smokowski, Kevin (ks6305) --- .../src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java index 5121e8a56..422470b8f 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java @@ -112,7 +112,7 @@ public class DME2 implements SvcLogicJavaPlugin { sb.append("?dme2.password=" + this.aafPassword); sb.append("&dme2.username=" + this.aafUserName); if (this.partner != null) { - sb.append("&dme2.partner=" + this.partner); + sb.append("&partner=" + this.partner); } sb.append("&dme2.allowhttpcode=true"); String endpointReadTimeout = parameters.getOrDefault(ENDPOINT_READ_TIMEOUT_KEY, this.endpointReadTimeout); -- cgit 1.2.3-korg From a90bcd956de2f040480c8349548397596094e50d Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 12 Jun 2018 15:51:30 +0000 Subject: Reset root array length when using setnode Reset root array length when using setnode shortcut to support backwards compatibility Change-Id: I0a51e396a9c75a632759cefd82ef4c6c6ca3a384 Issue-ID: CCSDK-302 Signed-off-by: Smokowski, Kevin (ks6305) --- .../java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java | 5 +++++ .../org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java | 5 +++++ sli/provider/src/test/resources/clearArrayValues.xml | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java index 758f2039c..5019b5681 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java @@ -131,6 +131,11 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { // If RHS is empty, unset attributes in LHS LinkedList parmsToRemove = new LinkedList(); String prefix = lhsVarName + "."; + //Clear length value in case an array exists with this prefix + String lengthParamName = lhsVarName + "_length"; + parmsToRemove.add(lengthParamName); + LOG.debug("Unsetting " + lengthParamName + " because prefix " + prefix + " is being cleared."); + for (String curCtxVarname : ctx.getAttributeKeySet()) { String curCtxVarnameMatchingValue = curCtxVarname; //Special handling for reseting array values, strips out brackets and any numbers between the brackets diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java index c400bf5d1..9ba2c05e6 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java @@ -48,6 +48,11 @@ public class SetNodeExecutorTest { assertNull(ctx.getAttribute("si[0].field1")); assertNull(ctx.getAttribute("si[1].field2")); assertNull(ctx.getAttribute("si[2].field3")); + assertNull(ctx.getAttribute("si_length")); + assertNull(ctx.getAttribute("si[0].subarray[0]")); + assertNull(ctx.getAttribute("si[0].subarray[1]")); + assertNull(ctx.getAttribute("si[0].subarray[2]")); + assertNull(ctx.getAttribute("si[0].subarray_length")); assertEquals("6", ctx.getAttribute("search1")); assertEquals("KeepMe!", ctx.getAttribute("simonSays")); } diff --git a/sli/provider/src/test/resources/clearArrayValues.xml b/sli/provider/src/test/resources/clearArrayValues.xml index 629322d65..8f40058f1 100644 --- a/sli/provider/src/test/resources/clearArrayValues.xml +++ b/sli/provider/src/test/resources/clearArrayValues.xml @@ -7,6 +7,11 @@ + + + + + -- cgit 1.2.3-korg From a7d1da3308031c3cce5e2e09b1f2727f1fceef02 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 15 Jun 2018 16:13:55 -0400 Subject: Update sli/core to ODL Oxygen Update sli/core artifacts to compile cleanly against ODL Oxygen version of CCSDK parent poms. Change-Id: I9f3b4c40b1ae62cdda1c35836466f8faf7da3b39 Issue-ID: CCSDK-280 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 33 +-- .../ccsdk-dblib/src/main/feature/feature.xml | 9 +- dblib/provider/pom.xml | 162 ++++++----- filters/features/ccsdk-filters/pom.xml | 25 +- filters/provider/pom.xml | 14 +- .../filters/RequestResponseDbLoggingFilter.java | 299 --------------------- .../core/filters/RequestResponseLoggingFilter.java | 28 ++ .../filters/TestRequestResponseLoggingFilter.java | 36 +++ sli/common/pom.xml | 29 +- sli/features/odl-sli/pom.xml | 31 +-- sli/provider/pom.xml | 176 ++++++------ sli/recording/pom.xml | 93 +++---- .../features/ccsdk-sliPluginUtils/pom.xml | 17 +- sliPluginUtils/provider/pom.xml | 5 +- sliapi/features/ccsdk-sliapi/pom.xml | 21 +- sliapi/provider/pom.xml | 18 +- utils/provider/pom.xml | 11 +- 17 files changed, 320 insertions(+), 687 deletions(-) delete mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 3a2f7a1bc..5d05f84b3 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -17,31 +17,8 @@ ccsdk-sli-core :: dblib :: ${project.artifactId} - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - 0.11.1 - pom - import - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - + - - org.opendaylight.controller - odl-mdsal-broker - xml - features - ${project.groupId} @@ -64,16 +41,10 @@ utils-provider ${project.version} - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - provided - + org.apache.derby derby - 10.11.1.1 diff --git a/dblib/features/ccsdk-dblib/src/main/feature/feature.xml b/dblib/features/ccsdk-dblib/src/main/feature/feature.xml index 514ce8de4..771c37455 100644 --- a/dblib/features/ccsdk-dblib/src/main/feature/feature.xml +++ b/dblib/features/ccsdk-dblib/src/main/feature/feature.xml @@ -1,14 +1,13 @@ - mvn:org.opendaylight.controller/odl-mdsal-broker/1.6.1/xml/features +
    Root POM to be used in place of odlparent for CCSDK based projects
    - odl-mdsal-broker wrap mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} - mvn:org.mariadb.jdbc/mariadb-java-client/2.1.1 - wrap:mvn:org.apache.tomcat/tomcat-jdbc/8.5.14/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge - wrap:mvn:org.apache.tomcat/tomcat-juli/8.5.14/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge + mvn:org.mariadb.jdbc/mariadb-java-client/${mariadb.connector.version} + wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge + wrap:mvn:org.apache.tomcat/tomcat-juli/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge mvn:org.onap.ccsdk.sli.core/utils-provider/${project.version}
    diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index e263374a9..78e701654 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -1,91 +1,87 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.1.0-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.1.0-SNAPSHOT + + - org.onap.ccsdk.sli.core - dblib-provider - 0.3.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + dblib-provider + 0.3.0-SNAPSHOT + bundle - ccsdk-sli-core :: dblib :: ${project.artifactId} - http://maven.apache.org + ccsdk-sli-core :: dblib :: ${project.artifactId} + http://maven.apache.org - - UTF-8 - + + UTF-8 + - - - junit - junit - ${junit.version} - test - - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - org.slf4j - slf4j-simple - ${slf4j.version} - test - - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - com.google.guava - guava - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - + + + junit + junit + test + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + org.osgi + org.osgi.core + provided + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + + + org.slf4j + slf4j-simple + test + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + com.google.guava + guava + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + - - - org.mockito - mockito-core - test - - - org.apache.karaf.shell - org.apache.karaf.shell.console - ${karaf.plugin.version} - - + + + org.mockito + mockito-core + test + + + org.apache.karaf.shell + org.apache.karaf.shell.console + + diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index b35f5ec9e..a995790d5 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -17,31 +17,8 @@ ccsdk-sli-core :: filters :: ${project.artifactId} - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - 0.11.1 - pom - import - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - + - - org.opendaylight.controller - odl-mdsal-broker - xml - features - ${project.groupId} diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index dd78b2a64..c7d356ba3 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -42,27 +42,23 @@ - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - provided - + + org.osgi + org.osgi.core + provided + org.slf4j slf4j-api - ${slf4j.version} org.slf4j jcl-over-slf4j - ${slf4j.version} commons-codec commons-codec - ${commons.codec.version} org.onap.ccsdk.sli.core diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java deleted file mode 100644 index 359136565..000000000 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java +++ /dev/null @@ -1,299 +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.filters; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.zip.GZIPInputStream; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletOutputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; - -import org.onap.ccsdk.sli.core.sli.MessageWriter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class RequestResponseDbLoggingFilter implements Filter { - - private static Logger log = LoggerFactory.getLogger(RequestResponseDbLoggingFilter.class); - - public static final String REQUEST_ID = "X-ECOMP-RequestID"; - - private static class ByteArrayServletStream extends ServletOutputStream { - - ByteArrayOutputStream baos; - - ByteArrayServletStream(ByteArrayOutputStream baos) { - this.baos = baos; - } - - @Override - public void write(int param) throws IOException { - baos.write(param); - } - } - - private static class ByteArrayPrintWriter { - - private ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - private PrintWriter pw = new PrintWriter(baos); - - private ServletOutputStream sos = new ByteArrayServletStream(baos); - - public PrintWriter getWriter() { - return pw; - } - - public ServletOutputStream getStream() { - return sos; - } - - byte[] toByteArray() { - return baos.toByteArray(); - } - } - - private class BufferedServletInputStream extends ServletInputStream { - - ByteArrayInputStream bais; - - public BufferedServletInputStream(ByteArrayInputStream bais) { - this.bais = bais; - } - - @Override - public int available() { - return bais.available(); - } - - @Override - public int read() { - return bais.read(); - } - - @Override - public int read(byte[] buf, int off, int len) { - return bais.read(buf, off, len); - } - - } - - private class BufferedRequestWrapper extends HttpServletRequestWrapper { - - ByteArrayInputStream bais; - - ByteArrayOutputStream baos; - - BufferedServletInputStream bsis; - - byte[] buffer; - - public BufferedRequestWrapper(HttpServletRequest req) throws IOException { - super(req); - - InputStream is = req.getInputStream(); - baos = new ByteArrayOutputStream(); - byte buf[] = new byte[1024]; - int letti; - while ((letti = is.read(buf)) > 0) { - baos.write(buf, 0, letti); - } - buffer = baos.toByteArray(); - - } - - @Override - public ServletInputStream getInputStream() { - try { - bais = new ByteArrayInputStream(buffer); - bsis = new BufferedServletInputStream(bais); - } catch (Exception ex) { - ex.printStackTrace(); - } - - return bsis; - } - - public byte[] getBuffer() { - return buffer; - } - - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } - - @Override - public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain) - throws IOException, ServletException { - - if (request == null || !(request instanceof HttpServletRequest)) { - filterChain.doFilter(request, response); - return; - } - - long t1 = System.currentTimeMillis(); - - final HttpServletRequest httpRequest = (HttpServletRequest) request; - BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); - - String requestId = httpRequest.getHeader(REQUEST_ID); - if (requestId == null || requestId.trim().length() == 0) { - log.warn("Could not write request in DB: " + REQUEST_ID + " is missing in the HTTP headers."); - return; - } - - String requestHost = request.getRemoteHost(); - if (requestHost == null) - requestHost = request.getRemoteAddr(); - - String requestStr = new String(bufferedRequest.getBuffer()); - - MessageWriter.saveIncomingRequest(requestId, null, requestHost, requestStr); - - long t2 = System.currentTimeMillis(); - - log.info("Request saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1)); - - final HttpServletResponse httpResponse = (HttpServletResponse) response; - - final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(); - HttpServletResponse wrappedResp = new HttpServletResponseWrapper(httpResponse) { - - @Override - public PrintWriter getWriter() { - return pw.getWriter(); - } - - @Override - public ServletOutputStream getOutputStream() { - return pw.getStream(); - } - }; - - try { - - filterChain.doFilter(bufferedRequest, wrappedResp); - - } finally { - - if (request != null && request instanceof HttpServletRequest) { - - t1 = System.currentTimeMillis(); - - byte[] bytes = pw.toByteArray(); - response.getOutputStream().write(bytes); - response.getOutputStream().flush(); - - String responseStr = null; - if ("gzip".equals(httpResponse.getHeader("Content-Encoding"))) { - responseStr = decompressGZIPByteArray(bytes); - } else { - responseStr = new String(bytes); - } - - MessageWriter.saveIncomingResponse(requestId, httpResponse.getStatus(), responseStr); - - t2 = System.currentTimeMillis(); - - log.info("Response saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1)); - } - } - - } - - @Override - public void destroy() { - } - - private String decompressGZIPByteArray(byte[] bytes) { - - BufferedReader in = null; - InputStreamReader inR = null; - ByteArrayInputStream byteS = null; - GZIPInputStream gzS = null; - StringBuilder str = new StringBuilder(); - try { - byteS = new ByteArrayInputStream(bytes); - gzS = new GZIPInputStream(byteS); - inR = new InputStreamReader(gzS); - in = new BufferedReader(inR); - - if (in != null) { - - String content; - - while ((content = in.readLine()) != null) { - str.append(content); - } - } - - } catch (Exception e) { - log.error("Failed get read GZIPInputStream", e); - } finally { - - if (byteS != null) - try { - byteS.close(); - } catch (IOException e1) { - log.error("Failed to close ByteStream", e1); - } - if (gzS != null) - try { - gzS.close(); - } catch (IOException e2) { - log.error("Failed to close GZStream", e2); - } - if (inR != null) - try { - inR.close(); - } catch (IOException e3) { - log.error("Failed to close InputReader", e3); - } - if (in != null) - try { - in.close(); - } catch (IOException e) { - log.error("Failed to close BufferedReader", e); - } - } - return str.toString(); - } -} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java index 440aa41bd..ffe6d71d6 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -34,11 +34,13 @@ import java.util.zip.GZIPInputStream; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; +import javax.servlet.ReadListener; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.ServletOutputStream; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.WriteListener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; @@ -60,6 +62,17 @@ public class RequestResponseLoggingFilter implements Filter { public void write(int param) throws IOException { baos.write(param); } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener arg0) { + + + } } private static class ByteArrayPrintWriter { @@ -106,6 +119,21 @@ public class RequestResponseLoggingFilter implements Filter { return bais.read(buf, off, len); } + @Override + public boolean isFinished() { + return available() < 1; + } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setReadListener(ReadListener arg0) { + + } + } private class BufferedRequestWrapper extends HttpServletRequestWrapper { diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java index 9f36fe11e..7ce856e68 100644 --- a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java +++ b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java @@ -18,9 +18,11 @@ import java.util.LinkedList; import java.util.UUID; import java.util.Vector; import javax.servlet.FilterChain; +import javax.servlet.ReadListener; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.ServletOutputStream; +import javax.servlet.WriteListener; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.codec.binary.Base64; @@ -58,6 +60,30 @@ public class TestRequestResponseLoggingFilter { } + @Override + public boolean isFinished() { + try { + return stream.available() < 1; + } catch (IOException e) { + return true; + } + } + + + @Override + public boolean isReady() { + // TODO Auto-generated method stub + return true; + } + + + @Override + public void setReadListener(ReadListener arg0) { + // TODO Auto-generated method stub + + } + + } @@ -74,6 +100,16 @@ public class TestRequestResponseLoggingFilter { ostr.write(b); } + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(WriteListener arg0) { + + } + } /** diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 7f5ac8074..ebb4f0953 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -24,50 +24,36 @@ - - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - + org.apache.derby derby - 10.11.1.1 test org.antlr antlr4-runtime - ${antlr.version} org.slf4j slf4j-api - ${slf4j.version} org.slf4j slf4j-simple - 1.7.5 compile org.apache.commons commons-lang3 - ${commons.lang3.version} - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} + + org.osgi + org.osgi.core + ${osgi.core.version} + provided + org.mariadb.jdbc mariadb-java-client @@ -128,7 +114,6 @@ org.antlr antlr4-maven-plugin - ${antlr.version} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 4d0143664..f108726da 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 @@ -19,19 +21,20 @@ - org.opendaylight.mdsal.model - mdsal-model-artifacts - 0.11.1 + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} pom import - org.opendaylight.controller - mdsal-artifacts - 1.6.1 + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} pom import + @@ -73,17 +76,7 @@ xml features - - org.opendaylight.controller - odl-mdsal-broker - xml - features - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - provided - + + diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index ebba283d2..aed348303 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -1,109 +1,97 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.1.0-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.1.0-SNAPSHOT + + - org.onap.ccsdk.sli.core - sli-provider - 0.3.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sli-provider + 0.3.0-SNAPSHOT + bundle - ccsdk-sli-core :: sli :: ${project.artifactId} - SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. - - UTF-8 - + + UTF-8 + - - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - - - - org.onap.ccsdk.sli.core - sli-model - ${project.version} - test - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - compile - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - commons-lang - commons-lang - ${commons.lang.version} - compile - + + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + compile + - - org.opendaylight.controller - sal-binding-api - + + org.slf4j + slf4j-api + + + commons-lang + commons-lang + compile + - - - junit - junit - test - + + org.osgi + org.osgi.core + provided + + + org.opendaylight.controller + sal-binding-api + - - org.mockito - mockito-core - test - - - org.apache.derby - derby - 10.11.1.1 - test - - + + + junit + junit + test + - - - - org.apache.felix - maven-bundle-plugin - true - - - * - - + + org.mockito + mockito-core + test + + + org.apache.derby + derby + test + + - - + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + - + + + + diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index a13ed13ea..038381d58 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -1,84 +1,73 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.1.0-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.1.0-SNAPSHOT + + - org.onap.ccsdk.sli.core - sli-recording - 0.3.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sli-recording + 0.3.0-SNAPSHOT + bundle - ccsdk-sli-core :: sli :: ${project.artifactId} - SLI Recording is an OSGi bundle that implements recording service for the service logic record node. + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Recording is an OSGi bundle that implements recording service for the service logic record node. - - UTF-8 - + + UTF-8 + - - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - - - + + + org.onap.ccsdk.sli.core sli-common ${project.version} compile - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} + org.osgi + org.osgi.core + provided org.slf4j slf4j-api - ${slf4j.version} org.slf4j jcl-over-slf4j - ${slf4j.version} commons-lang commons-lang - ${commons.lang.version} compile - - org.opendaylight.controller - sal-binding-api - + + org.opendaylight.controller + sal-binding-api + - - - junit - junit - test - + + + junit + junit + test + - - org.mockito - mockito-core - test - + + org.mockito + mockito-core + test + - + diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 3737f9e73..78f5f1e1c 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -21,26 +21,20 @@ org.opendaylight.mdsal.model mdsal-model-artifacts - 0.11.1 + ${odl.mdsal.model.version} pom import org.opendaylight.controller mdsal-artifacts - 1.6.1 + ${odl.mdsal.version} pom import
    - - org.opendaylight.controller - odl-mdsal-broker - xml - features - ${project.groupId} @@ -55,11 +49,6 @@ sliPluginUtils-provider ${project.version} - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - provided - + diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index ae7506361..411c1453c 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -33,10 +33,7 @@ ${project.version} compile - - equinoxSDK381 - org.eclipse.osgi - + org.slf4j slf4j-api diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index f868f3453..f4f63948d 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -16,31 +16,26 @@ ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - + + + org.opendaylight.mdsal.model mdsal-model-artifacts - 0.11.1 + ${odl.mdsal.model.version} pom import org.opendaylight.controller mdsal-artifacts - 1.6.1 + ${odl.mdsal.version} pom import - - + + + - - org.opendaylight.controller - odl-mdsal-broker - xml - features - ${project.groupId} diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 3be16f42d..994557a5a 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -17,17 +17,7 @@ ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - - + org.onap.ccsdk.sli.core @@ -39,16 +29,19 @@ org.opendaylight.controller sal-binding-config + ${odl.mdsal.version} org.opendaylight.controller sal-binding-api + ${odl.mdsal.version} org.opendaylight.controller sal-common-util + ${odl.mdsal.version} @@ -65,10 +58,12 @@ org.opendaylight.controller sal-core-api + ${odl.mdsal.version} org.opendaylight.yangtools yang-data-impl + 2.0.3 @@ -87,7 +82,6 @@ org.apache.derby derby - 10.11.1.1 test diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 2ecea40e8..2698b39c9 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -27,12 +27,11 @@ com.google.guava guava - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - provided - + + org.osgi + org.osgi.core + provided + -- cgit 1.2.3-korg From 784e3ef65f03017ea82055dcedab73a5b04e4972 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Mon, 18 Jun 2018 17:11:56 -0400 Subject: Update sli/core/utils version Update sli/core/utils features versions to ODL Oxygen Change-Id: Icef6bd776bf489b3991dc2406bccfea4104b1299 Issue-ID: CCSDK-280 Signed-off-by: Timoney, Dan (dt5972) --- .../installer/src/main/resources/scripts/install-feature.sh | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh b/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh index 74b95b5c8..638c73394 100644 --- a/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh +++ b/sliPluginUtils/installer/src/main/resources/scripts/install-feature.sh @@ -29,7 +29,7 @@ REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip if [ -f ${REPOZIP} ] then - unzip -d ${ODL_HOME} ${REPOZIP} + unzip -nd ${ODL_HOME} ${REPOZIP} else echo "ERROR : repo zip ($REPOZIP) not found" exit 1 diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml index 8ff1d4cff..952e4ab1c 100644 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ b/utils/features/sdnc-slicore-utils/pom.xml @@ -21,26 +21,21 @@ org.opendaylight.mdsal.model mdsal-model-artifacts - 0.11.1 + ${odl.mdsal.model.version} pom import org.opendaylight.controller mdsal-artifacts - 1.6.1 + ${odl.mdsal.version} pom import - - org.opendaylight.controller - odl-mdsal-broker - xml - features - + ${project.groupId} -- cgit 1.2.3-korg From ed8a53f82d780d3c8409e286bff238dc93e43e2b Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 21 Jun 2018 14:40:27 +0000 Subject: additional dme2 improvements add back convenience method to support legacy callers that don't want to switch to new function signature and additional small changes Change-Id: Idebc992c4ddf70feb11fc7faebb0f050c353a4a7 Issue-ID: CCSDK-308 Signed-off-by: Smokowski, Kevin (ks6305) --- .../onap/ccsdk/sli/core/slipluginutils/DME2.java | 319 +++++++------- .../ccsdk/sli/core/slipluginutils/Dme2Test.java | 466 +++++++++++++-------- 2 files changed, 451 insertions(+), 334 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java index 422470b8f..7bc1a4118 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java @@ -1,150 +1,169 @@ -/*- - * ============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.slipluginutils; - -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A SvcLogicJavaPlugin that generates DME2 proxy urls (for calling the DME2 ingress proxy) using - * parameters from context memory. - */ -public class DME2 implements SvcLogicJavaPlugin { - - private static final Logger LOG = LoggerFactory.getLogger(DME2.class); - // the key for proxyUrl, which represents a CSV list of urls - static final String PROXY_URL_KEY = "proxyUrl"; - static final String PROXY_URLS_VALUE_SEPARATOR = ","; - static final String AAF_USERNAME_KEY = "aafUserName"; - static final String AAF_PASSWORD_KEY = "aafPassword"; - static final String ENV_CONTEXT_KEY = "envContext"; - static final String ROUTE_OFFER_KEY = "routeOffer"; - static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; - static final String PARTNER_KEY = "partner"; - static final String VERSION_KEY = "version"; - static final String SERVICE_KEY = "service"; - static final String SUBCONTEXT_KEY = "subContext"; - static final String ENDPOINT_READ_TIMEOUT_KEY = "endpointReadTimeout"; - static final String OUTPUT_PATH_KEY = "outputPath"; - - final String aafUserName; - final String aafPassword; - final String envContext; - final String routeOffer; - final String[] proxyUrls; - final String commonServiceVersion; - final String partner; - final String endpointReadTimeout; - Integer index; - - public DME2(Properties properties) { - Iterator> it = properties.entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); - if (entry.getValue() == null || entry.getValue().toString().length() < 1) { - it.remove(); - } - } - this.aafUserName = properties.getProperty(AAF_USERNAME_KEY, null); - this.aafPassword = properties.getProperty(AAF_PASSWORD_KEY, null); - this.envContext = properties.getProperty(ENV_CONTEXT_KEY, null); - this.routeOffer = properties.getProperty(ROUTE_OFFER_KEY, null); - this.commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY, null); - this.partner = properties.getProperty(PARTNER_KEY, null); - this.endpointReadTimeout = properties.getProperty(ENDPOINT_READ_TIMEOUT_KEY, null); - String proxyUrlString = properties.getProperty(PROXY_URL_KEY, null); - if (proxyUrlString != null && proxyUrlString.length() > 0) { - this.proxyUrls = proxyUrlString.split(PROXY_URLS_VALUE_SEPARATOR); - } else { - String[] local = {"http://localhost:5000"}; - this.proxyUrls = local; - } - this.index = 0; - } - - // constructs a URL to contact the proxy which contacts a DME2 service - public String constructUrl(Map parameters) { - StringBuilder sb = new StringBuilder(); - - // The hostname is assigned in a round robin fashion - sb.append(acquireHostName()); - sb.append("/service=" + parameters.get(SERVICE_KEY)); - - // If the directedGraph passes an explicit version use that, if not use the commonServiceVersion - // found in the properties file - String version = parameters.getOrDefault(VERSION_KEY, this.commonServiceVersion); - sb.append("/version=" + version); - String envContext = parameters.getOrDefault(ENV_CONTEXT_KEY, this.envContext); - sb.append("/envContext=" + envContext); - String routeOffer = parameters.getOrDefault(ROUTE_OFFER_KEY, this.routeOffer); - sb.append("/routeOffer=" + routeOffer); - - String subContext = parameters.get(SUBCONTEXT_KEY); - if (subContext != null && subContext.length() > 0) { - sb.append("/subContext=" + subContext); - } - sb.append("?dme2.password=" + this.aafPassword); - sb.append("&dme2.username=" + this.aafUserName); - if (this.partner != null) { - sb.append("&partner=" + this.partner); - } - sb.append("&dme2.allowhttpcode=true"); - String endpointReadTimeout = parameters.getOrDefault(ENDPOINT_READ_TIMEOUT_KEY, this.endpointReadTimeout); - if (endpointReadTimeout != null) { - sb.append("&dme2.endpointReadTimeout=" + endpointReadTimeout); - } - String incompleteUrl = sb.toString(); - - // Support optional parameters in a flexible way - for (Entry param : parameters.entrySet()) { - if (!incompleteUrl.contains(param.getKey() + "=") && param.getValue() != null - && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey())) { - sb.append("&" + param.getKey() + "=" + param.getValue()); - } - } - return sb.toString(); - } - - public synchronized String acquireHostName() { - String retVal = proxyUrls[index]; - index++; - if (index == this.proxyUrls.length) { - index = 0; - } - return retVal; - } - - // Node entry point - public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[] {SERVICE_KEY, OUTPUT_PATH_KEY}, LOG); - String completeProxyUrl = constructUrl(parameters); - ctx.setAttribute(parameters.get(OUTPUT_PATH_KEY), completeProxyUrl); - } - -} +/*- + * ============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.slipluginutils; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A SvcLogicJavaPlugin that generates DME2 proxy urls (for calling the DME2 ingress proxy) using + * parameters from context memory. + */ +public class DME2 implements SvcLogicJavaPlugin { + + private static final Logger LOG = LoggerFactory.getLogger(DME2.class); + // the key for proxyUrl, which represents a CSV list of urls + static final String PROXY_URL_KEY = "proxyUrl"; + static final String PROXY_URLS_VALUE_SEPARATOR = ","; + static final String AAF_USERNAME_KEY = "aafUserName"; + static final String AAF_PASSWORD_KEY = "aafPassword"; + static final String ENV_CONTEXT_KEY = "envContext"; + static final String ROUTE_OFFER_KEY = "routeOffer"; + static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; + static final String PARTNER_KEY = "partner"; + static final String VERSION_KEY = "version"; + static final String SERVICE_KEY = "service"; + static final String SUBCONTEXT_KEY = "subContext"; + static final String ENDPOINT_READ_TIMEOUT_KEY = "endpointReadTimeout"; + static final String OUTPUT_PATH_KEY = "outputPath"; + + final String aafUserName; + final String aafPassword; + final String envContext; + final String routeOffer; + final String[] proxyUrls; + final String commonServiceVersion; + final String partner; + final String endpointReadTimeout; + Integer index; + + public DME2(Properties properties) { + Iterator> it = properties.entrySet().iterator(); + while (it.hasNext()) { + Entry entry = it.next(); + if (entry.getValue() == null || entry.getValue().toString().length() < 1) { + it.remove(); + } + } + this.aafUserName = properties.getProperty(AAF_USERNAME_KEY, null); + this.aafPassword = properties.getProperty(AAF_PASSWORD_KEY, null); + this.envContext = properties.getProperty(ENV_CONTEXT_KEY, null); + this.routeOffer = properties.getProperty(ROUTE_OFFER_KEY, null); + this.commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY, null); + this.partner = properties.getProperty(PARTNER_KEY, null); + this.endpointReadTimeout = properties.getProperty(ENDPOINT_READ_TIMEOUT_KEY, null); + String proxyUrlString = properties.getProperty(PROXY_URL_KEY, null); + if (proxyUrlString != null && proxyUrlString.length() > 0) { + this.proxyUrls = proxyUrlString.split(PROXY_URLS_VALUE_SEPARATOR); + } else { + String[] local = {"http://localhost:5000"}; + this.proxyUrls = local; + } + this.index = 0; + } + + // constructs a URL to contact the proxy which contacts a DME2 service + public String constructUrl(Map parameters) { + StringBuilder sb = new StringBuilder(); + + // The hostname is assigned in a round robin fashion + sb.append(acquireHostName()); + sb.append("/service=" + parameters.get(SERVICE_KEY)); + + // If the directedGraph passes an explicit version use that, if not use the commonServiceVersion + // found in the properties file + String version = parameters.get(VERSION_KEY); + if (version != null && version.length() > 0) { + sb.append("/version=" + version); + }else { + sb.append("/version=" + this.commonServiceVersion); + } + String envContext = parameters.getOrDefault(ENV_CONTEXT_KEY, this.envContext); + sb.append("/envContext=" + envContext); + + String routeOffer = parameters.getOrDefault(ROUTE_OFFER_KEY, this.routeOffer); + if (routeOffer != null && routeOffer.length() > 0) { + sb.append("/routeOffer=" + routeOffer); + } + + String subContext = parameters.get(SUBCONTEXT_KEY); + if (subContext != null && subContext.length() > 0) { + sb.append("/subContext=" + subContext); + } + sb.append("?dme2.password=" + this.aafPassword); + sb.append("&dme2.username=" + this.aafUserName); + if (this.partner != null) { + sb.append("&partner=" + this.partner); + } + sb.append("&dme2.allowhttpcode=true"); + String endpointReadTimeout = parameters.getOrDefault(ENDPOINT_READ_TIMEOUT_KEY, this.endpointReadTimeout); + if (endpointReadTimeout != null) { + sb.append("&dme2.endpointReadTimeout=" + endpointReadTimeout); + } + String incompleteUrl = sb.toString(); + + // Support optional parameters in a flexible way + for (Entry param : parameters.entrySet()) { + if (!incompleteUrl.contains(param.getKey() + "=") && param.getValue() != null + && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey())) { + sb.append("&" + param.getKey() + "=" + param.getValue()); + } + } + return sb.toString(); + } + + public synchronized String acquireHostName() { + String retVal = proxyUrls[index]; + index++; + if (index == this.proxyUrls.length) { + index = 0; + } + return retVal; + } + + // Node entry point + public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] {SERVICE_KEY, OUTPUT_PATH_KEY}, LOG); + String completeProxyUrl = constructUrl(parameters); + ctx.setAttribute(parameters.get(OUTPUT_PATH_KEY), completeProxyUrl); + } + + // Support legacy direct java call + public String constructUrl(String service, String version, String subContext) { + Map parameters = new HashMap(); + parameters.put(SERVICE_KEY, service); + if (version != null) { + parameters.put(VERSION_KEY, version); + } + parameters.put(SUBCONTEXT_KEY, subContext); + return constructUrl(parameters); + } + +} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java index 662df75da..6cb6c8ba1 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java @@ -1,184 +1,282 @@ -/*- - * ============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.slipluginutils; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import org.junit.Assert; -import org.junit.Test; - -public class Dme2Test { - public Properties makesProperties(String aafUserName, String aafPassword, String envContext, String routeOffer, - String proxyUrls, String commonServiceVersion) { - Properties props = new Properties(); - props.put(DME2.AAF_USERNAME_KEY, aafUserName); - props.put(DME2.AAF_PASSWORD_KEY, aafPassword); - props.put(DME2.ENV_CONTEXT_KEY, envContext); - props.put(DME2.ROUTE_OFFER_KEY, routeOffer); - props.put(DME2.PROXY_URL_KEY, proxyUrls); - props.put(DME2.COMMON_SERVICE_VERSION_KEY, commonServiceVersion); - return props; - } - - @Test - public void createUrl() { - String instarUrl = - "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = - makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.VERSION_KEY, "1702.0"); - parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - parameters.put(DME2.OUTPUT_PATH_KEY, "tmp.test"); - - String constructedUrl = dme.constructUrl(parameters); - assertEquals(instarUrl, constructedUrl); - } - - @Test - public void createUrlNoSubContext() { - String instarUrl = - "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = - makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.VERSION_KEY, "1702.0"); - parameters.put(DME2.SUBCONTEXT_KEY, null); - String constructedUrl = dme.constructUrl(parameters); - assertEquals(instarUrl, constructedUrl); - } - - @Test - public void testRoundRobin() { - String[] proxyHostNames = new String[] {"http://one:25055", "http://two:25055", "http://three:25055"}; - String proxyHostNameString = proxyHostNames[0] + "," + proxyHostNames[1] + "," + proxyHostNames[2]; - - String urlSuffix = - "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNameString, "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.VERSION_KEY, "1702.0"); - parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - String constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - } - - @Test - public void createDme2EndtoEnd() throws FileNotFoundException, IOException { - Properties props = new Properties(); - props.load(new FileInputStream("src/test/resources/dme2.e2e.properties")); - DME2 dme2 = new DME2(props); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("UAT", dme2.envContext); - assertEquals("UAT", dme2.routeOffer); - Assert.assertArrayEquals( - "http://sample.com:25055,http://sample.com:25055".split(DME2.PROXY_URLS_VALUE_SEPARATOR), - dme2.proxyUrls); - assertEquals("1702.0", dme2.commonServiceVersion); - assertEquals(null, dme2.partner); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/restservices/instar/v1/assetSearch"); - parameters.put(DME2.VERSION_KEY, null); - parameters.put(DME2.SUBCONTEXT_KEY, "/mySubContext"); - String constructedUrl = dme2.constructUrl(parameters); - assertNotNull(constructedUrl); - } - - @Test - public void createDme2Prod() throws FileNotFoundException, IOException { - Properties props = new Properties(); - props.load(new FileInputStream("src/test/resources/dme2.prod.properties")); - DME2 dme2 = new DME2(props); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("PROD", dme2.envContext); - assertEquals(null, dme2.routeOffer); - Assert.assertArrayEquals( - "http://sample.com:25055,http://sample.com:25055".split(DME2.PROXY_URLS_VALUE_SEPARATOR), - dme2.proxyUrls); - assertEquals("1.0", dme2.commonServiceVersion); - assertEquals("LPP_PROD", dme2.partner); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.VERSION_KEY, "1702.0"); - parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - String constructedUrl = dme2.constructUrl(parameters); - assertNotNull(constructedUrl); - } - - @Test - public void blankProperties() throws Exception { - Properties props = new Properties(); - DME2 dme2 = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "easyService"); - parameters.put(DME2.VERSION_KEY, "3"); - parameters.put(DME2.SUBCONTEXT_KEY, "/sub"); - assertEquals( - "http://localhost:5000/service=easyService/version=3/envContext=null/routeOffer=null/subContext=/sub?dme2.password=null&dme2.username=null&dme2.allowhttpcode=true", - dme2.constructUrl(parameters)); - } - - @Test - public void optionalParameters() { - String instarUrl = - "http://localhost:25055/service=serv/version=4/envContext=TEST/routeOffer=DEFAULT/subContext=/sub?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true&test=123"; - Properties props = - makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "serv"); - parameters.put(DME2.VERSION_KEY, "4"); - parameters.put(DME2.SUBCONTEXT_KEY, "/sub"); - parameters.put("test", "123"); - - String constructedUrl = dme.constructUrl(parameters); - assertEquals(instarUrl, constructedUrl); - } - -} +/*- + * ============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.slipluginutils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import org.junit.Assert; +import org.junit.Test; + +public class Dme2Test { + public Properties makesProperties(String aafUserName, String aafPassword, String envContext, String routeOffer, + String proxyUrls, String commonServiceVersion) { + Properties props = new Properties(); + props.put(DME2.AAF_USERNAME_KEY, aafUserName); + props.put(DME2.AAF_PASSWORD_KEY, aafPassword); + props.put(DME2.ENV_CONTEXT_KEY, envContext); + props.put(DME2.ROUTE_OFFER_KEY, routeOffer); + props.put(DME2.PROXY_URL_KEY, proxyUrls); + props.put(DME2.COMMON_SERVICE_VERSION_KEY, commonServiceVersion); + return props; + } + + @Test + public void createUrl() { + String localUrl = + "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = + makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.VERSION_KEY, "1702.0"); + parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + parameters.put(DME2.OUTPUT_PATH_KEY, "tmp.test"); + + String constructedUrl = dme.constructUrl(parameters); + assertEquals(localUrl, constructedUrl); + } + + @Test + public void createUrlNoSubContext() { + String localUrl = + "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = + makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.VERSION_KEY, "1702.0"); + parameters.put(DME2.SUBCONTEXT_KEY, null); + String constructedUrl = dme.constructUrl(parameters); + assertEquals(localUrl, constructedUrl); + } + + @Test + public void testRoundRobin() { + String[] proxyHostNames = new String[] {"http://one:25055", "http://two:25055", "http://three:25055"}; + String proxyHostNameString = proxyHostNames[0] + "," + proxyHostNames[1] + "," + proxyHostNames[2]; + + String urlSuffix = + "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNameString, "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.VERSION_KEY, "1702.0"); + parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + String constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl(parameters); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + } + + @Test + public void createDme2EndtoEnd() throws FileNotFoundException, IOException { + Properties props = new Properties(); + props.load(new FileInputStream("src/test/resources/dme2.e2e.properties")); + DME2 dme2 = new DME2(props); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("UAT", dme2.envContext); + assertEquals("UAT", dme2.routeOffer); + Assert.assertArrayEquals( + "http://sample.com:25055,http://sample.com:25055".split(DME2.PROXY_URLS_VALUE_SEPARATOR), + dme2.proxyUrls); + assertEquals("1702.0", dme2.commonServiceVersion); + assertEquals(null, dme2.partner); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/restservices/sys/v1/assetSearch"); + parameters.put(DME2.VERSION_KEY, null); + parameters.put(DME2.SUBCONTEXT_KEY, "/mySubContext"); + String constructedUrl = dme2.constructUrl(parameters); + assertNotNull(constructedUrl); + String expected = + "http://sample.com:25055/service=sample.com/restservices/sys/v1/assetSearch/version=1702.0/envContext=UAT/routeOffer=UAT/subContext=/mySubContext?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + assertEquals(expected, constructedUrl); + } + + @Test + public void createDme2Prod() throws FileNotFoundException, IOException { + Properties props = new Properties(); + props.load(new FileInputStream("src/test/resources/dme2.prod.properties")); + DME2 dme2 = new DME2(props); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("PROD", dme2.envContext); + assertEquals(null, dme2.routeOffer); + Assert.assertArrayEquals( + "http://sample.com:25055,http://sample.com:25055".split(DME2.PROXY_URLS_VALUE_SEPARATOR), + dme2.proxyUrls); + assertEquals("1.0", dme2.commonServiceVersion); + assertEquals("LPP_PROD", dme2.partner); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.VERSION_KEY, "1702.0"); + parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + String constructedUrl = dme2.constructUrl(parameters); + assertNotNull(constructedUrl); + String expected = + "http://sample.com:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=PROD/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&partner=LPP_PROD&dme2.allowhttpcode=true"; + assertEquals(expected, constructedUrl); + } + + @Test + public void blankProperties() throws Exception { + Properties props = new Properties(); + DME2 dme2 = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "easyService"); + parameters.put(DME2.VERSION_KEY, "3"); + parameters.put(DME2.SUBCONTEXT_KEY, "/sub"); + assertEquals( + "http://localhost:5000/service=easyService/version=3/envContext=null/subContext=/sub?dme2.password=null&dme2.username=null&dme2.allowhttpcode=true", + dme2.constructUrl(parameters)); + } + + @Test + public void optionalParameters() { + String localUrl = + "http://localhost:25055/service=serv/version=4/envContext=TEST/routeOffer=DEFAULT/subContext=/sub?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true&test=123"; + Properties props = + makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + parameters.put(DME2.SERVICE_KEY, "serv"); + parameters.put(DME2.VERSION_KEY, "4"); + parameters.put(DME2.SUBCONTEXT_KEY, "/sub"); + parameters.put("test", "123"); + + String constructedUrl = dme.constructUrl(parameters); + assertEquals(localUrl, constructedUrl); + } + + @Test + public void createLocalUrlLegacy() { + String localUrl = + "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = + makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); + DME2 dme = new DME2(props); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", + "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(localUrl, constructedUrl); + } + + @Test + public void createLocalUrlNoSubContextLegacy() { + String localUrl = + "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = + makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); + DME2 dme = new DME2(props); + Map parameters = new HashMap(); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", parameters.get(null)); + assertEquals(localUrl, constructedUrl); + } + + @Test + public void testRoundRobinLegacy() { + String[] proxyHostNames = new String[] {"http://one:25055", "http://two:25055", "http://three:25055"}; + String urlSuffix = + "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + Properties props = makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", + "http://one:25055,http://two:25055,http://three:25055", "common"); + DME2 dme = new DME2(props); + String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", + "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", + "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", + "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", + "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", + "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", + "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); + constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", + "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); + assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); + } + + @Test + public void createDme2EndtoEndLegacy() throws Exception { + Properties props = new Properties(); + props.load(new FileInputStream("src/test/resources/dme2.e2e.properties")); + DME2 dme2 = new DME2(props); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("UAT", dme2.envContext); + assertEquals("UAT", dme2.routeOffer); + Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); + assertEquals("1702.0", dme2.commonServiceVersion); + assertEquals(null, dme2.partner); + String constructedUrl = dme2.constructUrl("sample.com/restservices/sys/v1/assetSearch", null, "/mySubContext"); + assertNotNull(constructedUrl); + String expected = + "http://sample.com:25055/service=sample.com/restservices/sys/v1/assetSearch/version=1702.0/envContext=UAT/routeOffer=UAT/subContext=/mySubContext?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; + assertEquals(expected, constructedUrl); + } + + @Test + public void createDme2ProdLegacy() throws Exception { + Properties props = new Properties(); + props.load(new FileInputStream("src/test/resources/dme2.prod.properties")); + DME2 dme2 = new DME2(props); + assertEquals("user@sample.com", dme2.aafUserName); + assertEquals("fake", dme2.aafPassword); + assertEquals("PROD", dme2.envContext); + assertEquals(null, dme2.routeOffer); + Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); + assertEquals("1.0", dme2.commonServiceVersion); + assertEquals("LPP_PROD", dme2.partner); + String constructedUrl = dme2.constructUrl("sample.com/restservices/sys/v1/assetSearch", null, "/mySubContext"); + assertNotNull(constructedUrl); + String expected = + "http://sample.com:25055/service=sample.com/restservices/sys/v1/assetSearch/version=1.0/envContext=PROD/subContext=/mySubContext?dme2.password=fake&dme2.username=user@sample.com&partner=LPP_PROD&dme2.allowhttpcode=true"; + assertEquals(expected, constructedUrl); + } + +} -- cgit 1.2.3-korg From 84eab50f627a1a8c1a4362d373986718eefcecbc Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 22 Jun 2018 15:48:39 -0400 Subject: Add feature aggregator Add feature aggregator ccsdk-sli-core-all to install all sli-core features. Change-Id: I11174fc693a9275d712312145c03abb0d4f88b41 Issue-ID: CCSDK-280 Signed-off-by: Timoney, Dan (dt5972) --- dblib/installer/pom.xml | 4 +- .../src/assembly/assemble_mvnrepo_zip.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 83 +++++++ features/features-sli-core/pom.xml | 29 +++ features/installer/pom.xml | 138 +++++++++++ .../src/assembly/assemble_installer_zip.xml | 39 ++++ .../src/assembly/assemble_mvnrepo_zip.xml | 29 +++ .../src/main/resources/scripts/install-feature.sh | 18 ++ features/pom.xml | 24 ++ filters/installer/pom.xml | 4 +- .../src/assembly/assemble_mvnrepo_zip.xml | 2 +- pom.xml | 1 + sli/installer/pom.xml | 4 +- .../src/assembly/assemble_mvnrepo_zip.xml | 2 +- sliPluginUtils/installer/pom.xml | 4 +- .../src/assembly/assemble_mvnrepo_zip.xml | 2 +- sliapi/installer/pom.xml | 4 +- .../src/assembly/assemble_mvnrepo_zip.xml | 2 +- utils/installer/pom.xml | 260 +++++++++++---------- .../src/assembly/assemble_mvnrepo_zip.xml | 2 +- 20 files changed, 508 insertions(+), 145 deletions(-) create mode 100644 features/ccsdk-sli-core-all/pom.xml create mode 100644 features/features-sli-core/pom.xml create mode 100755 features/installer/pom.xml create mode 100755 features/installer/src/assembly/assemble_installer_zip.xml create mode 100755 features/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 features/installer/src/main/resources/scripts/install-feature.sh create mode 100755 features/pom.xml diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index e0710b8fd..6544f20a5 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -70,12 +70,12 @@ package - false + true stage/${application.name}-${project.version} src/assembly/assemble_mvnrepo_zip.xml - false + true diff --git a/dblib/installer/src/assembly/assemble_mvnrepo_zip.xml b/dblib/installer/src/assembly/assemble_mvnrepo_zip.xml index d96c9f402..86b07f1f3 100755 --- a/dblib/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/dblib/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -4,7 +4,7 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - bin + repo zip diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml new file mode 100644 index 000000000..ef5da1200 --- /dev/null +++ b/features/ccsdk-sli-core-all/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-sli-core-all + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-core :: features :: ${project.artifactId} + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + + + + + ${project.groupId} + ccsdk-slicore-utils + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-dblib + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-filters + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sliapi + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sliPluginUtils + ${project.version} + xml + features + + + diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml new file mode 100644 index 000000000..843e27d9e --- /dev/null +++ b/features/features-sli-core/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + feature-repo-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + features-sli-core + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-core :: features :: ${project.artifactId} + + + + ${project.groupId} + ccsdk-sli-core-all + ${project.version} + xml + features + + + + diff --git a/features/installer/pom.xml b/features/installer/pom.xml new file mode 100755 index 000000000..eb6344bd3 --- /dev/null +++ b/features/installer/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + slicore-features-installer + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-core :: features :: ${project.artifactId} + + + ccsdk-sli-core-all + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.core + ${application.name} + ${project.version} + xml + features + + + * + * + + + + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.core,org.apache.tomcat,org.slf4j + utils-provider,slf4j-api + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + diff --git a/features/installer/src/assembly/assemble_installer_zip.xml b/features/installer/src/assembly/assemble_installer_zip.xml new file mode 100755 index 000000000..a6a22a9ba --- /dev/null +++ b/features/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,39 @@ + + + + bin + + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/features/installer/src/assembly/assemble_mvnrepo_zip.xml b/features/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100755 index 000000000..86b07f1f3 --- /dev/null +++ b/features/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,29 @@ + + + + repo + + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/features/installer/src/main/resources/scripts/install-feature.sh b/features/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..e16e79a12 --- /dev/null +++ b/features/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/features/pom.xml b/features/pom.xml new file mode 100755 index 000000000..f7ff3fdd4 --- /dev/null +++ b/features/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + slicore-feature-aggregator + 0.3.0-SNAPSHOT + pom + + ccsdk-sli-core :: features + + + ccsdk-sli-core-all + features-sli-core + installer + + diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index d03afaaa2..76e055def 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -60,12 +60,12 @@ package - false + true stage/${application.name}-${project.version} src/assembly/assemble_mvnrepo_zip.xml - false + true diff --git a/filters/installer/src/assembly/assemble_mvnrepo_zip.xml b/filters/installer/src/assembly/assemble_mvnrepo_zip.xml index f000fd074..69e9e2909 100644 --- a/filters/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/filters/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -25,7 +25,7 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - bin + repo zip diff --git a/pom.xml b/pom.xml index 9dc52969d..d2f9d39fe 100755 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ filters sliPluginUtils sliapi + features diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 83f059c54..4a3eeff74 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -87,12 +87,12 @@ package - false + true stage/${application.name}-${project.version} src/assembly/assemble_mvnrepo_zip.xml - false + true diff --git a/sli/installer/src/assembly/assemble_mvnrepo_zip.xml b/sli/installer/src/assembly/assemble_mvnrepo_zip.xml index a1be36792..6a21012dc 100644 --- a/sli/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/sli/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -19,7 +19,7 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - bin + repo zip diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index a1737a86d..5a22e4953 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -64,12 +64,12 @@ package - false + true stage/${application.name}-${project.version} src/assembly/assemble_mvnrepo_zip.xml - false + true diff --git a/sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml b/sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml index b8a6dde62..63ef515a0 100644 --- a/sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/sliPluginUtils/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -25,7 +25,7 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - bin + repo zip diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 145169ba0..de5c6a684 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -60,12 +60,12 @@ package - false + true stage/${application.name}-${project.version} src/assembly/assemble_mvnrepo_zip.xml - false + true diff --git a/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml b/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml index 5f3e3af31..c4eb9aa25 100644 --- a/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/sliapi/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -25,7 +25,7 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - bin + repo zip diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 4b445936a..389927256 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -1,143 +1,145 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.1.0-SNAPSHOT - - + + org.onap.ccsdk.parent + odlparent-lite + 1.1.0-SNAPSHOT + + - org.onap.ccsdk.sli.core - utils-installer - 0.3.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + utils-installer + 0.3.0-SNAPSHOT + pom - ccsdk-sli-core :: utils :: ${project.artifactId} + ccsdk-sli-core :: utils :: ${project.artifactId} - - ccsdk-slicore-utils - ${application.name} - mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features - false - + + ccsdk-slicore-utils + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features + false + - + - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.core + ${application.name} + ${project.version} + xml + features + + + * + * + + + - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + - + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - false - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - false - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli,org.apache.tomcat - sli-common,sli-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli,org.apache.tomcat + sli-common,sli-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/utils/installer/src/assembly/assemble_mvnrepo_zip.xml b/utils/installer/src/assembly/assemble_mvnrepo_zip.xml index d96c9f402..86b07f1f3 100755 --- a/utils/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/utils/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -4,7 +4,7 @@ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - bin + repo zip -- cgit 1.2.3-korg From dcf9e631063544fb44ac11491c717907165b9620 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 27 Jun 2018 20:15:40 +0000 Subject: filter partner out filter partner out Change-Id: Ia23d5f484c52aed94500bb0bf50ae2654d8aa14b Issue-ID: CCSDK-323 Signed-off-by: Smokowski, Kevin (ks6305) --- .../onap/ccsdk/sli/core/slipluginutils/DME2.java | 28 +++++++++++----------- .../ccsdk/sli/core/slipluginutils/Dme2Test.java | 1 + 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java index 7bc1a4118..5b3c2a623 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java @@ -40,19 +40,19 @@ public class DME2 implements SvcLogicJavaPlugin { private static final Logger LOG = LoggerFactory.getLogger(DME2.class); // the key for proxyUrl, which represents a CSV list of urls - static final String PROXY_URL_KEY = "proxyUrl"; - static final String PROXY_URLS_VALUE_SEPARATOR = ","; - static final String AAF_USERNAME_KEY = "aafUserName"; - static final String AAF_PASSWORD_KEY = "aafPassword"; - static final String ENV_CONTEXT_KEY = "envContext"; - static final String ROUTE_OFFER_KEY = "routeOffer"; - static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; - static final String PARTNER_KEY = "partner"; - static final String VERSION_KEY = "version"; - static final String SERVICE_KEY = "service"; - static final String SUBCONTEXT_KEY = "subContext"; - static final String ENDPOINT_READ_TIMEOUT_KEY = "endpointReadTimeout"; - static final String OUTPUT_PATH_KEY = "outputPath"; + public static final String PROXY_URL_KEY = "proxyUrl"; + public static final String PROXY_URLS_VALUE_SEPARATOR = ","; + public static final String AAF_USERNAME_KEY = "aafUserName"; + public static final String AAF_PASSWORD_KEY = "aafPassword"; + public static final String ENV_CONTEXT_KEY = "envContext"; + public static final String ROUTE_OFFER_KEY = "routeOffer"; + public static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; + public static final String PARTNER_KEY = "partner"; + public static final String VERSION_KEY = "version"; + public static final String SERVICE_KEY = "service"; + public static final String SUBCONTEXT_KEY = "subContext"; + public static final String ENDPOINT_READ_TIMEOUT_KEY = "endpointReadTimeout"; + public static final String OUTPUT_PATH_KEY = "outputPath"; final String aafUserName; final String aafPassword; @@ -132,7 +132,7 @@ public class DME2 implements SvcLogicJavaPlugin { // Support optional parameters in a flexible way for (Entry param : parameters.entrySet()) { if (!incompleteUrl.contains(param.getKey() + "=") && param.getValue() != null - && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey())) { + && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey()) && !"partner".equals(param.getKey())) { sb.append("&" + param.getKey() + "=" + param.getValue()); } } diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java index 6cb6c8ba1..9bff94835 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java @@ -121,6 +121,7 @@ public class Dme2Test { assertEquals("1702.0", dme2.commonServiceVersion); assertEquals(null, dme2.partner); Map parameters = new HashMap(); + parameters.put(DME2.PARTNER_KEY, "I SHOULD BE FILTERED NOW!"); parameters.put(DME2.SERVICE_KEY, "sample.com/restservices/sys/v1/assetSearch"); parameters.put(DME2.VERSION_KEY, null); parameters.put(DME2.SUBCONTEXT_KEY, "/mySubContext"); -- cgit 1.2.3-korg From 7636bbc1db457a7cff570b35c724e4253d0a1cd4 Mon Sep 17 00:00:00 2001 From: ONAP Date: Fri, 6 Jul 2018 18:57:23 +0900 Subject: sonar issue fix Issue-ID: CCSDK-332 Change-Id: Iec65b1ff600518b04ab13fb3508827864074a31b Signed-off-by: ONAP --- .../src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java index bcbe42a60..554927768 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java @@ -1346,8 +1346,8 @@ public class PrintYangToProp { } public static void main(String[] args){ - try{ - PrintStream ps = new PrintStream(new FileOutputStream(FileDescriptor.out)); + + try(PrintStream ps = new PrintStream(new FileOutputStream(FileDescriptor.out))){ PrintYangToProp printYangToProp = new PrintYangToProp(); String className = args[0]; //ClassLoader classLoader = PrintYangToProp.class.getClassLoader(); -- cgit 1.2.3-korg From cfabda23cb6dc6c98e3266228f3bd2f409591a2f Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 12 Jul 2018 12:29:42 -0400 Subject: Special handling for inet classes Add special handling for inet POJOs (which have different form then POJOs generated from Yang by yangtools) in toList method. Change-Id: Ie25527e6aacbf683965d7f24018fe066c74fb917 Issue-ID: CCSDK-362 Signed-off-by: Timoney, Dan (dt5972) --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 66 +++++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index b652c433c..e50b99742 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -528,24 +528,60 @@ public class MdsalHelper { String curBase = pfx + "[" + i + "]"; if (isYangGenerated(elemType)) { - String builderName = elemType.getName() + "Builder"; - try { - Class builderClass = Class.forName(builderName); - Object builderObj = builderClass.newInstance(); - Method buildMethod = builderClass.getMethod("build"); - builderObj = toBuilder(props, curBase, builderObj, true); - if (builderObj != null) { - LOG.trace("Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(builderObj); - toObj.add(builtObj); + + if (isIpAddress(elemType) || isIpv4Address(elemType) || isIpv6Address(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(IpAddressBuilder.getDefaultInstance(curValue)); foundValue = true; } + } else if (isIpPrefix(elemType)) { - } catch (ClassNotFoundException e) { - LOG.warn("Could not find builder class {}", builderName, e); - } catch (Exception e) { - LOG.error("Caught exception trying to populate list from {}", pfx, e); - } + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(IpPrefixBuilder.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isPortNumber(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(PortNumber.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isDscp(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(Dscp.getDefaultInstance(curValue)); + foundValue = true; + } + } else { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + LOG.trace( + "Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class {}", builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from {}", pfx, e); + } + } } else { // Must be a leaf list String curValue = props.getProperty(curBase, ""); -- cgit 1.2.3-korg From 47099b56dcecba622e574b37c0167a061d6f667b Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Tue, 24 Jul 2018 19:15:27 +0900 Subject: Fix sonar issues Fix sonar issues in ccsdk/sli/core Issue-ID: CCSDK-332 Change-Id: I2aee69cf410d8f9cb63f3a22aeb793a99e27d2c7 Signed-off-by: Parshad Patel --- .../java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java | 7 ++----- .../ccsdk/sli/core/filters/RequestResponseLoggingFilter.java | 2 +- .../onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java | 2 +- .../onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java | 2 +- .../org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 12 +++++++----- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 97380f58d..f3ecfa279 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -214,10 +214,8 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito throws SQLException { long time = System.currentTimeMillis(); - CachedRowSet data; - - try (PreparedStatement ps = conn.prepareStatement(statement)) { - data = RowSetProvider.newFactory().createCachedRowSet(); + try (PreparedStatement ps = conn.prepareStatement(statement); + CachedRowSet data = RowSetProvider.newFactory().createCachedRowSet()) { if (arguments != null) { prepareStatementForExecuteUpdate(arguments, ps); } @@ -227,7 +225,6 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito LOGGER.debug("SQL SUCCESS. rows returned: {}, time(ms): {}", data.size(), (System.currentTimeMillis() - time)); } - ps.close(); } catch (SQLException exc) { handleSqlExceptionForExecuteStatement(conn, statement, arguments, exc, time); } finally { diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java index ffe6d71d6..f5510b9ab 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -166,7 +166,7 @@ public class RequestResponseLoggingFilter implements Filter { bais = new ByteArrayInputStream(buffer); bsis = new BufferedServletInputStream(bais); } catch (Exception ex) { - ex.printStackTrace(); + log.error("Exception in getInputStream",ex); } return bsis; diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java index c229cf59f..d275e9703 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java @@ -93,7 +93,7 @@ public class SvcLogicExpressionFactory { try { SvcLogicExpressionFactory.parse(sbuff.toString()); } catch (IOException e) { - e.printStackTrace(); + LOG.error("Exception in SvcLogicExpressionFactory.parse",e); } } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java index 6c6b4ca27..a73fadcfc 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java @@ -101,7 +101,7 @@ public class ForNodeExecutor extends SvcLogicNodeExecutor { } } } catch (BreakNodeException br) { - LOG.debug("ForNodeExecutor caught break"); + LOG.error("ForNodeExecutor caught break",br); } return (null); } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index e50b99742..f7a229d5d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -1117,8 +1117,11 @@ public class MdsalHelper { Class returnClass = m.getReturnType(); String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - + if(fieldName!=null) { + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + }else { + fieldName=""; + } String propName = propNamePfx + "." + fieldName; // Is the return type a yang generated class? @@ -1182,11 +1185,10 @@ public class MdsalHelper { } public static boolean isYangGenerated(Class c) { - if (c == null) { - return (false); - } else { + if (c != null) { return (c.getName().startsWith("org.opendaylight.yang.gen.")); } + return false; } public static boolean isIpPrefix(Class c) { -- cgit 1.2.3-korg From 3c74f62d1b4892560554e52e709e87769bd26ba0 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 24 Jul 2018 21:08:01 +0000 Subject: support legacy enumeration mapping support legacy enumeration mapping in MdsalHelper Change-Id: I637f5dc368da75e24fb8cc3ebdebd002aae3f025 Issue-ID: CCSDK-396 Signed-off-by: Smokowski, Kevin (ks6305) --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 19 ++++++-- .../sli/core/sli/provider/MdsalHelperTest.java | 30 +++++++++++++ .../yang/gen/v1/test/CosModelType.java | 51 ++++++++++++++++++++++ .../opendaylight/yang/gen/v1/test/WrapperObj.java | 10 +++++ .../test/resources/EnumerationMapping.properties | 1 + 5 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/CosModelType.java create mode 100644 sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/WrapperObj.java create mode 100644 sli/provider/src/test/resources/EnumerationMapping.properties diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index e50b99742..10478ddd1 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -50,7 +50,12 @@ public class MdsalHelper { private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); private static Properties yangMappingProperties = new Properties(); - + protected static boolean useLegacyEnumerationMapping = false; + + public static void useLegacyEnumerationMapping(Boolean bool) { + useLegacyEnumerationMapping = bool; + } + @Deprecated public static void setProperties(Properties input) { setYangMappingProperties(input); @@ -188,9 +193,15 @@ public class MdsalHelper { } if (retValue != null) { String propName = propNamePfx + "." + fieldName; - Method method = retValue.getClass().getMethod("getName"); - String yangValue = (String) method.invoke(retValue); - props.setProperty(propName, yangValue); + if(useLegacyEnumerationMapping) { + propVal = retValue.toString(); + props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); + }else { + Method method = retValue.getClass().getMethod("getName"); + String yangValue = (String) method.invoke(retValue); + props.setProperty(propName, yangValue); + } + } } catch (Exception e) { LOG.error( diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index e7f1e18b9..d5ca04d75 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -36,6 +36,8 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.opendaylight.yang.gen.v1.test.CosModelType; +import org.opendaylight.yang.gen.v1.test.WrapperObj; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -141,4 +143,32 @@ public class MdsalHelperTest extends TestCase { assertEquals("SomethingElse",MdsalHelper.toJavaEnum("Something.Else")); assertEquals("MyTestString",MdsalHelper.toJavaEnum("my-test-string")); } + + // During the default enumeration mapping no properties file is needed, the yang value is returned + // by the java object + public void testDefaultEnumerationMapping() throws Exception { + MdsalHelper.useLegacyEnumerationMapping(false); + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj()); + assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type")); + } + + // When no properties file exists the default java value will be returned if legacy enumeration + // mapping is enabled + public void testLegacyEnumerationMappingNoProperties() throws Exception { + MdsalHelper.useLegacyEnumerationMapping(true); + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj()); + assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type")); + } + + // When a properties file exists & legacy enumeration mapping is enabled the value from the + // properties file should be returned + public void testLegacyEnumerationMappingWithProperties() throws Exception { + MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties"); + MdsalHelper.useLegacyEnumerationMapping(true); + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj()); + assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type")); + } } diff --git a/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/CosModelType.java b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/CosModelType.java new file mode 100644 index 000000000..2aaaf8aa3 --- /dev/null +++ b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/CosModelType.java @@ -0,0 +1,51 @@ +package org.opendaylight.yang.gen.v1.test; + +public enum CosModelType { + _4COS(0, "4COS"), + + _6COS(1, "6COS") + ; + + private static final java.util.Map VALUE_MAP; + + static { + final com.google.common.collect.ImmutableMap.Builder b = com.google.common.collect.ImmutableMap.builder(); + for (CosModelType enumItem : CosModelType.values()) { + b.put(enumItem.value, enumItem); + } + + VALUE_MAP = b.build(); + } + + private final java.lang.String name; + private final int value; + + private CosModelType(int value, java.lang.String name) { + this.value = value; + this.name = name; + } + + /** + * Returns the name of the enumeration item as it is specified in the input yang. + * + * @return the name of the enumeration item as it is specified in the input yang + */ + public java.lang.String getName() { + return name; + } + + /** + * @return integer value + */ + public int getIntValue() { + return value; + } + + /** + * @param valueArg integer value + * @return corresponding CosModelType item + */ + public static CosModelType forValue(int valueArg) { + return VALUE_MAP.get(valueArg); + } +} \ No newline at end of file diff --git a/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/WrapperObj.java b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/WrapperObj.java new file mode 100644 index 000000000..bae0bdb1c --- /dev/null +++ b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/WrapperObj.java @@ -0,0 +1,10 @@ +package org.opendaylight.yang.gen.v1.test; + +public class WrapperObj { + + CosModelType cosModel = CosModelType._4COS; + + public CosModelType getCosModelType() { + return cosModel; + } +} diff --git a/sli/provider/src/test/resources/EnumerationMapping.properties b/sli/provider/src/test/resources/EnumerationMapping.properties new file mode 100644 index 000000000..d0fb29710 --- /dev/null +++ b/sli/provider/src/test/resources/EnumerationMapping.properties @@ -0,0 +1 @@ +yang.cos-model-type._4COS=HelloWorld \ No newline at end of file -- cgit 1.2.3-korg From de9fb16753eefa333dc3e44330062621b17b2ac2 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 1 Aug 2018 18:04:04 +0000 Subject: remove static bool Don't use static boolean for legacy enumeration mapping, add additional parameter to the function Change-Id: I5d8963a208f3ffdd3af83216aa55f7d34ee39eb9 Issue-ID: CCSDK-396 Signed-off-by: Smokowski, Kevin (ks6305) --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 27 ++++++++++++++-------- .../sli/core/sli/provider/MdsalHelperTest.java | 7 ++---- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index e8f73e8c3..f87b7d3c3 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -50,11 +50,6 @@ public class MdsalHelper { private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); private static Properties yangMappingProperties = new Properties(); - protected static boolean useLegacyEnumerationMapping = false; - - public static void useLegacyEnumerationMapping(Boolean bool) { - useLegacyEnumerationMapping = bool; - } @Deprecated public static void setProperties(Properties input) { @@ -88,25 +83,37 @@ public class MdsalHelper { } public static Properties toProperties(Properties props, Object fromObj) { + return toProperties(props, fromObj, false); + } + + public static Properties toProperties(Properties props, Object fromObj, Boolean useLegacyEnumerationMapping) { Class fromClass = null; if (fromObj != null) { fromClass = fromObj.getClass(); } - return toProperties(props, "", fromObj, fromClass); + return toProperties(props, "", fromObj, fromClass,useLegacyEnumerationMapping ); } public static Properties toProperties(Properties props, String pfx, Object fromObj) { + return toProperties(props, pfx, fromObj, false); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj, Boolean useLegacyEnumerationMapping) { Class fromClass = null; if (fromObj != null) { fromClass = fromObj.getClass(); } - return toProperties(props, pfx, fromObj, fromClass); + return toProperties(props, pfx, fromObj, fromClass, useLegacyEnumerationMapping); } public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { + return toProperties(props, pfx, fromObj, fromClass, false); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass, Boolean useLegacyEnumerationMapping) { if (fromObj == null) { return props; @@ -121,7 +128,7 @@ public class MdsalHelper { List fromList = (List) fromObj; for (int i = 0; i < fromList.size(); i++) { - toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass, useLegacyEnumerationMapping); } props.setProperty(pfx + "_length", Integer.toString(fromList.size())); @@ -365,7 +372,7 @@ public class MdsalHelper { m.setAccessible(isAccessible); } if (retValue != null) { - toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); + toProperties(props, propNamePfx + "." + fieldName, retValue, returnType, useLegacyEnumerationMapping); } } catch (Exception e) { @@ -398,7 +405,7 @@ public class MdsalHelper { // this array. Type paramType = m.getGenericReturnType(); Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; - toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType); + toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType, useLegacyEnumerationMapping); } catch (Exception e) { LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index d5ca04d75..307c69c7d 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -147,7 +147,6 @@ public class MdsalHelperTest extends TestCase { // During the default enumeration mapping no properties file is needed, the yang value is returned // by the java object public void testDefaultEnumerationMapping() throws Exception { - MdsalHelper.useLegacyEnumerationMapping(false); Properties props = new Properties(); MdsalHelper.toProperties(props, new WrapperObj()); assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type")); @@ -156,9 +155,8 @@ public class MdsalHelperTest extends TestCase { // When no properties file exists the default java value will be returned if legacy enumeration // mapping is enabled public void testLegacyEnumerationMappingNoProperties() throws Exception { - MdsalHelper.useLegacyEnumerationMapping(true); Properties props = new Properties(); - MdsalHelper.toProperties(props, new WrapperObj()); + MdsalHelper.toProperties(props, new WrapperObj(), true); assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type")); } @@ -166,9 +164,8 @@ public class MdsalHelperTest extends TestCase { // properties file should be returned public void testLegacyEnumerationMappingWithProperties() throws Exception { MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties"); - MdsalHelper.useLegacyEnumerationMapping(true); Properties props = new Properties(); - MdsalHelper.toProperties(props, new WrapperObj()); + MdsalHelper.toProperties(props, new WrapperObj(), true); assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type")); } } -- cgit 1.2.3-korg From 1ff267b4fc1d964d6a0f283f22b07237bb6a1163 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 2 Aug 2018 14:37:21 +0000 Subject: add null check to format string add null check to format string Change-Id: If82f751ec679189620e02fafdcd2e1af9258268f Issue-ID: CCSDK-424 Signed-off-by: Smokowski, Kevin (ks6305) --- .../main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java | 8 +++++--- .../java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java | 11 +++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 9d263456c..b4bd2017e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -300,9 +300,11 @@ public class MetricLogger { } protected String formatString(String str) { - str = str.replaceAll("\\R",""); // this will strip all new line characters - str = str.replaceAll("\\|","%7C"); //log records should not contain a pipe, encode the pipe character - return str; + if (str != null) { + str = str.replaceAll("\\R", ""); // this will strip all new line characters + str = str.replaceAll("\\|", "%7C"); // log records should not contain a pipe, encode the pipe character + } + return str; } public static void resetContext() { diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java index 31a419bb1..971a700f5 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java @@ -129,7 +129,14 @@ public class TestMetricLogger { logger.asIso8601(System.currentTimeMillis()); } - - + @Test + public void formatString() { + String output = logger.formatString("\n"); + assertEquals("",output); + output = logger.formatString("|"); + assertEquals("%7C",output); + output = logger.formatString(null); + assertEquals(null,output); + } } -- cgit 1.2.3-korg From 3f8e0f20d346ec01dfa216f2c594064a27d7d61b Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 8 Aug 2018 17:46:34 +0000 Subject: remove dependency remove eelf dependency from sli-common, it isn't being used Change-Id: Ic8cbb8d833137a0d32707b814dec56450b7129b3 Issue-ID: CCSDK-450 Signed-off-by: Smokowski, Kevin (ks6305) --- sli/common/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index ebb4f0953..5007bedfd 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -90,11 +90,6 @@ sal-binding-api - - com.att.eelf - eelf-core - - junit -- cgit 1.2.3-korg From 0d5be9d94c13f19030a373d74efe7c2dc97367b5 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Mon, 13 Aug 2018 14:55:59 -0400 Subject: Add site definition in distributionManagement Define site in distributionManagement to allow javadoc to be published to ONAP nexus site. Change-Id: I3f0ed9df6016cd8e9c3486fa92dea9132da7d63d Issue-ID: CCSDK-455 Signed-off-by: Timoney, Dan (dt5972) --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index d2f9d39fe..3e2319bcc 100755 --- a/pom.xml +++ b/pom.xml @@ -20,6 +20,10 @@ ONAP + + + content/sites/site/org/onap/ccsdk/sli/core/${project.version}/ + utils @@ -77,4 +81,10 @@ + + + ecomp-site + dav:${onap.nexus.url}/${sitePath} + + -- cgit 1.2.3-korg From b5dfc03248533fb70c9989ac378d94b88934e399 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 15 Aug 2018 11:22:55 -0400 Subject: Update sli/core for Oxygen SR3 Removed version for yangtools dependency in sliapi so that it is controlled by parent pom to resolve issue caused in Oxygen SR3 upgrade due to hard-coded SR1 version. Also, updated name of utils features directory to match name of artifact (sdnc-slicore-utils renamed to ccsdk-slicore-utils). Change-Id: I32b3822e4ae0fdd4c07d5912e4674b19c8615d54 Issue-ID: CCSDK-453 Signed-off-by: Timoney, Dan (dt5972) --- .gitignore | 2 +- sliapi/provider/pom.xml | 8 ----- utils/features/ccsdk-slicore-utils/pom.xml | 47 ++++++++++++++++++++++++++++++ utils/features/pom.xml | 2 +- utils/features/sdnc-slicore-utils/pom.xml | 47 ------------------------------ 5 files changed, 49 insertions(+), 57 deletions(-) create mode 100644 utils/features/ccsdk-slicore-utils/pom.xml delete mode 100644 utils/features/sdnc-slicore-utils/pom.xml diff --git a/.gitignore b/.gitignore index a5a0d80e3..b45dfca41 100755 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ ExprGrammar.tokens ExprGrammarLexer.tokens # BlackDuck generated file -sdnc-core_bdio.jsonld +*.jsonld blackDuckHubProjectName.txt blackDuckHubProjectVersionName.txt diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 994557a5a..bcd585323 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -29,47 +29,39 @@ org.opendaylight.controller sal-binding-config - ${odl.mdsal.version} org.opendaylight.controller sal-binding-api - ${odl.mdsal.version} org.opendaylight.controller sal-common-util - ${odl.mdsal.version} org.onap.ccsdk.sli.core sli-common - ${project.version} org.onap.ccsdk.sli.core sli-provider - ${project.version} org.opendaylight.controller sal-core-api - ${odl.mdsal.version} org.opendaylight.yangtools yang-data-impl - 2.0.3 junit junit - ${junit.version} test diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml new file mode 100644 index 000000000..952e4ab1c --- /dev/null +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.1.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-slicore-utils + 0.3.0-SNAPSHOT + feature + + ccsdk-sli-core :: utils :: ${project.artifactId} + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + + + + + + ${project.groupId} + utils-provider + ${project.version} + + + + diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 4f3be1b86..bac928ab8 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -17,6 +17,6 @@ features-util - sdnc-slicore-utils + ccsdk-slicore-utils diff --git a/utils/features/sdnc-slicore-utils/pom.xml b/utils/features/sdnc-slicore-utils/pom.xml deleted file mode 100644 index 952e4ab1c..000000000 --- a/utils/features/sdnc-slicore-utils/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.1.0-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-slicore-utils - 0.3.0-SNAPSHOT - feature - - ccsdk-sli-core :: utils :: ${project.artifactId} - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - - - - - - ${project.groupId} - utils-provider - ${project.version} - - - - -- cgit 1.2.3-korg From 93833b4e67713c094025648b2a7b7673a8b58de9 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Fri, 17 Aug 2018 16:58:44 +0900 Subject: breaknode executor tests added Issue-ID: CCSDK-471 Change-Id: Ice1582299950332292c1fba6052ec85489477ab7 Signed-off-by: Ganesh Chandrasekaran --- .../onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 0a8bf71ac..d8698860f 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -57,6 +57,7 @@ public class ITCaseSvcLogicGraphExecutor { private static final Map BUILTIN_NODES = new HashMap() { { put("block", new BlockNodeExecutor()); + put("break", new BreakNodeExecutor()); put("call", new CallNodeExecutor()); put("configure", new ConfigureNodeExecutor()); put("delete", new DeleteNodeExecutor()); -- cgit 1.2.3-korg From 5a0f5957372e75b1bf5835738a23906f1bf4d8ba Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Mon, 20 Aug 2018 13:00:07 -0400 Subject: Update swagger documentation Re-generated converted swagger doc. Note: ideally, it would be good to generate this on the fly based on Yang model. However, ODL yangtools generates swagger 1.2, and readthedocs needs version 2. Currently we convert this using api-spec-converter tool and store converted version. Tried automating this conversion, which works fine in local compiles but does not work on ONAP Jenkins (tool is node.js based). Change-Id: Ic607bcdcc218489a45d616bb1d280675511a760d Issue-ID: CCSDK-476 Signed-off-by: Timoney, Dan (dt5972) --- .../model/src/main/resources/sli-api.20161110.json | 93 ++++++++++++++++------ 1 file changed, 67 insertions(+), 26 deletions(-) diff --git a/sliapi/model/src/main/resources/sli-api.20161110.json b/sliapi/model/src/main/resources/sli-api.20161110.json index da966e1e7..1c6cdabfe 100644 --- a/sliapi/model/src/main/resources/sli-api.20161110.json +++ b/sliapi/model/src/main/resources/sli-api.20161110.json @@ -274,6 +274,23 @@ }, "operationId": "healthcheck" } + }, + "/operations/SLI-API:vlbcheck": { + "post": { + "produces": [ + "application/json", + "application/xml" + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(vlbcheck)output-TOP" + } + } + }, + "operationId": "vlbcheck" + } } }, "definitions": { @@ -291,17 +308,17 @@ "(config)sli-parameterPOST": { "properties": { "boolean-value": { - "$ref": "#/definitions/true" + "$ref": "#/definitions/Optional.empty" }, "int-value": { - "$ref": "#/definitions/-2147483648" + "$ref": "#/definitions/Optional.empty" }, "parameter-name": { - "$ref": "#/definitions/Some parameter-name", + "$ref": "#/definitions/Optional.empty", "description": "Parameter name" }, "string-value": { - "$ref": "#/definitions/Some string-value" + "$ref": "#/definitions/Optional.empty" } }, "type": "object" @@ -309,7 +326,7 @@ "(config)test-resultPOST": { "properties": { "test-identifier": { - "$ref": "#/definitions/Some test-identifier" + "$ref": "#/definitions/Optional.empty" } }, "type": "object" @@ -328,17 +345,13 @@ "(execute-graph)input": { "properties": { "SLI-API:mode": { - "$ref": "#/definitions/sync", - "enum": [ - "sync", - "async" - ] + "$ref": "#/definitions/Optional.empty" }, "SLI-API:module-name": { - "$ref": "#/definitions/Some module-name" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:rpc-name": { - "$ref": "#/definitions/Some rpc-name" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:sli-parameter": { "items": { @@ -363,16 +376,16 @@ "(execute-graph)output": { "properties": { "SLI-API:ack-final-indicator": { - "$ref": "#/definitions/Some ack-final-indicator" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:context-memory-json": { - "$ref": "#/definitions/Some context-memory-json" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:response-code": { - "$ref": "#/definitions/Some response-code" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:response-message": { - "$ref": "#/definitions/Some response-message" + "$ref": "#/definitions/Optional.empty" } }, "type": "object" @@ -391,16 +404,16 @@ "(healthcheck)output": { "properties": { "SLI-API:ack-final-indicator": { - "$ref": "#/definitions/Some ack-final-indicator" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:context-memory-json": { - "$ref": "#/definitions/Some context-memory-json" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:response-code": { - "$ref": "#/definitions/Some response-code" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:response-message": { - "$ref": "#/definitions/Some response-message" + "$ref": "#/definitions/Optional.empty" } }, "type": "object" @@ -416,20 +429,48 @@ }, "type": "object" }, + "(vlbcheck)output": { + "properties": { + "SLI-API:ack-final-indicator": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:context-memory-json": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:response-code": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:response-message": { + "$ref": "#/definitions/Optional.empty" + } + }, + "type": "object" + }, + "(vlbcheck)output-TOP": { + "properties": { + "SLI-API:output": { + "items": { + "$ref": "#/definitions/(vlbcheck)output" + }, + "type": "object" + } + }, + "type": "object" + }, "SLI-API(config)sli-parameter": { "properties": { "SLI-API:boolean-value": { - "$ref": "#/definitions/true" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:int-value": { - "$ref": "#/definitions/-2147483648" + "$ref": "#/definitions/Optional.empty" }, "SLI-API:parameter-name": { - "$ref": "#/definitions/Some parameter-name", + "$ref": "#/definitions/Optional.empty", "description": "Parameter name" }, "SLI-API:string-value": { - "$ref": "#/definitions/Some string-value" + "$ref": "#/definitions/Optional.empty" } }, "type": "object" @@ -487,12 +528,12 @@ "properties": { "SLI-API:results": { "items": { - "$ref": "#/definitions/Some results" + "$ref": "#/definitions/Optional.empty" }, "type": "array" }, "SLI-API:test-identifier": { - "$ref": "#/definitions/Some test-identifier" + "$ref": "#/definitions/Optional.empty" } }, "type": "object" -- cgit 1.2.3-korg From 307740b66b73b55fd818f0c4c01edc0c5f0d05ec Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Fri, 24 Aug 2018 15:17:40 -0700 Subject: Use managed guava version Use centrally managed guava version specified in oparent. Includes upgrade to oparent 1.2.0. This change was submitted by script and may include additional whitespace or formatting changes. Change-Id: I803cc7ebf2b9368f276e15af7153fa2bfa90ee40 Issue-ID: INT-619 Signed-off-by: Gary Wu --- dblib/provider/pom.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 78e701654..66b1fcd7c 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -1,14 +1,12 @@ - + 4.0.0 org.onap.ccsdk.parent binding-parent 1.1.0-SNAPSHOT - + org.onap.ccsdk.sli.core -- cgit 1.2.3-korg From f3965529b82a2aa6cf49460a9bf1d00e17af27b3 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 4 Sep 2018 20:10:42 +0000 Subject: Restore registering break node Restore registering break node, it was removed by accident Change-Id: Ifd7fa68fae39c83e397105d84435be91cebada35 Issue-ID: CCSDK-513 Signed-off-by: Smokowski, Kevin (ks6305) --- .../java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 05698864e..d83bfebcf 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -68,8 +68,8 @@ public class SvcLogicServiceImpl implements SvcLogicService { put("set", new SetNodeExecutor()); put("switch", new SwitchNodeExecutor()); put("update", new UpdateNodeExecutor()); + put("break", new BreakNodeExecutor()); put("while", new WhileNodeExecutor()); - } }; -- cgit 1.2.3-korg From edf288e1c79c58b2d7066b8ad27cb578d8dd5483 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 17 Aug 2018 19:36:54 +0000 Subject: SvcLogicLoader Improvements restore storing md5sum and add bulkActivate Change-Id: I27ea86c667d61f435bd2f0a77934d00db57bc218 Issue-ID: CCSDK-473 Signed-off-by: Smokowski, Kevin (ks6305) --- .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 39 +++++++-------------- .../onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 40 +++++----------------- .../onap/ccsdk/sli/core/sli/SvcLogicLoader.java | 8 +++++ .../onap/ccsdk/sli/core/sli/SvcLogicParser.java | 13 ++++++- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 4 ++- 5 files changed, 44 insertions(+), 60 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 864652b40..3ade88f4f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -34,9 +34,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Properties; - import javax.sql.rowset.CachedRowSet; - import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.osgi.framework.Bundle; @@ -98,9 +96,6 @@ public class SvcLogicDblibStore implements SvcLogicStore { @Override public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - - - boolean retval = false; CachedRowSet results = null; String hasVersionGraphSql = "SELECT count(*) FROM SVC_LOGIC" @@ -236,8 +231,8 @@ public class SvcLogicDblibStore implements SvcLogicStore { - String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph)" - + " VALUES(?, ?, ?, ?, ?, ?)"; + String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph, md5sum)" + + " VALUES(?, ?, ?, ?, ?, ?, ?)"; if (graph == null) { throw new SvcLogicException("graph cannot be null"); @@ -264,23 +259,22 @@ public class SvcLogicDblibStore implements SvcLogicStore { } Connection dbConn = null; - PreparedStatement storeGraphStmt = null; + PreparedStatement storeGraphStmt = null; try { - dbConn = dbSvc.getConnection(); - boolean oldAutoCommit = dbConn.getAutoCommit(); + dbConn = dbSvc.getConnection(); + boolean oldAutoCommit = dbConn.getAutoCommit(); dbConn.setAutoCommit(false); - storeGraphStmt = dbConn.prepareStatement(storeGraphSql); + storeGraphStmt = dbConn.prepareStatement(storeGraphSql); storeGraphStmt.setString(1, graph.getModule()); storeGraphStmt.setString(2, graph.getRpc()); storeGraphStmt.setString(3, graph.getVersion()); storeGraphStmt.setString(4, graph.getMode()); storeGraphStmt.setString(5, "N"); storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); - + storeGraphStmt.setString(7, graph.getMd5sum()); storeGraphStmt.executeUpdate(); dbConn.commit(); - - dbConn.setAutoCommit(oldAutoCommit); + dbConn.setAutoCommit(oldAutoCommit); } catch (Exception e) { throw new SvcLogicException("Could not write object to database", e); } finally { @@ -306,12 +300,9 @@ public class SvcLogicDblibStore implements SvcLogicStore { public void delete(String module, String rpc, String version, String mode) throws SvcLogicException { - - - String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - ArrayList args = new ArrayList<>(); + ArrayList args = new ArrayList(); args.add(module); args.add(rpc); @@ -326,25 +317,19 @@ public class SvcLogicDblibStore implements SvcLogicStore { } public void activate(SvcLogicGraph graph) throws SvcLogicException { - - String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; - String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - ArrayList args = new ArrayList<>(); + ArrayList args = new ArrayList(); args.add(graph.getModule()); args.add(graph.getRpc()); args.add(graph.getMode()); try { - dbSvc.writeData(deactivateSql, args, null); - args.add(graph.getVersion()); dbSvc.writeData(activateSql, args, null); - } catch (Exception e) { throw new SvcLogicException("Could not activate graph", e); } @@ -444,10 +429,10 @@ public class SvcLogicDblibStore implements SvcLogicStore { } } + @Override public void activate(String module, String rpc, String version, String mode) throws SvcLogicException { - String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; @@ -467,7 +452,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { } catch (Exception e) { throw new SvcLogicException("Could not activate graph", e); - } + } } } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index 0e7d05a6e..5db2a8c91 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -58,10 +58,6 @@ public class SvcLogicJdbcStore implements SvcLogicStore { private PreparedStatement deactivateStmt = null; private PreparedStatement activateStmt = null; - private PreparedStatement registerNodeStmt = null; - private PreparedStatement unregisterNodeStmt = null; - private PreparedStatement validateNodeStmt = null; - private void getConnection() throws ConfigurationException { Properties jdbcProps = new Properties(); @@ -109,7 +105,9 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } else { String crTableCmd = "CREATE TABLE " + dbName + ".SVC_LOGIC (" + "module varchar(80) NOT NULL," + "rpc varchar(80) NOT NULL," + "version varchar(40) NOT NULL," + "mode varchar(5) NOT NULL," - + "active varchar(1) NOT NULL," + "graph BLOB," + + "active varchar(1) NOT NULL,graph BLOB," + + "modified_timestamp timestamp DEFAULT NULL," + + "md5sum varchar(128) DEFAULT NULL," + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; stmt = dbConn.createStatement(); @@ -199,7 +197,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } String storeGraphSql = CommonConstants.JDBC_INSERT + dbName - + ".SVC_LOGIC (module, rpc, version, mode, active, graph) VALUES(?, ?, ?, ?, ?, ?)"; + + ".SVC_LOGIC (module, rpc, version, mode, active, graph, md5sum) VALUES(?, ?, ?, ?, ?, ?, ?)"; try { storeGraphStmt = dbConn.prepareStatement(storeGraphSql); @@ -233,27 +231,6 @@ public class SvcLogicJdbcStore implements SvcLogicStore { } catch (Exception e) { throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + activateSql, e); } - - String registerNodeSql = CommonConstants.JDBC_INSERT + dbName + ".NODE_TYPES (nodetype) VALUES(?)"; - try { - registerNodeStmt = dbConn.prepareStatement(registerNodeSql); - } catch (Exception e) { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + registerNodeSql, e); - } - - String unregisterNodeSql = CommonConstants.JDBC_DELETE + dbName + ".NODE_TYPES WHERE nodetype = ?"; - try { - unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql); - } catch (Exception e) { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + unregisterNodeSql, e); - } - - String validateNodeSql = CommonConstants.JDBC_SELECT_COUNT + dbName + ".NODE_TYPES WHERE nodetype = ?"; - try { - validateNodeStmt = dbConn.prepareStatement(validateNodeSql); - } catch (Exception e) { - throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + validateNodeSql, e); - } } private void initDbResources() throws ConfigurationException { @@ -489,16 +466,17 @@ public class SvcLogicJdbcStore implements SvcLogicStore { try { boolean oldAutoCommit = dbConn.getAutoCommit(); dbConn.setAutoCommit(false); - storeGraphStmt.setString(1, graph.getModule()); - storeGraphStmt.setString(2, graph.getRpc()); + storeGraphStmt.setString(1, graph.getModule()); + storeGraphStmt.setString(2, graph.getRpc()); storeGraphStmt.setString(3, graph.getVersion()); storeGraphStmt.setString(4, graph.getMode()); storeGraphStmt.setString(5, "N"); - storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); + storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes)); + storeGraphStmt.setString(7, graph.getMd5sum()); storeGraphStmt.executeUpdate(); dbConn.commit(); - + dbConn.setAutoCommit(oldAutoCommit); } catch (Exception e) { throw new SvcLogicException("Could not write object to database", e); diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java index 37d7faae0..d50c371c0 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java @@ -164,5 +164,13 @@ public class SvcLogicLoader { } return raw; } + + public void bulkActivate() { + Path activationFile = Paths.get(directoryRoot); + List pathList = new ArrayList(1); + pathList.add(activationFile); + List activationEntries = processActivationFiles(pathList); + activateGraphs(activationEntries); + } } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 2804f6205..5cb7ac5e2 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -417,6 +417,17 @@ public class SvcLogicParser { } else { SvcLogicParser.usage(); } + } else if ("bulkActivate".equalsIgnoreCase(argv[0])) { + if (argv.length == 3) { + SvcLogicLoader loader = new SvcLogicLoader(argv[1], argv[2]); + try { + loader.bulkActivate(); + } catch (Exception e) { + LOGGER.error(e.getMessage(), e); + } + } else { + SvcLogicParser.usage(); + } } System.exit(0); @@ -557,7 +568,7 @@ public class SvcLogicParser { System.err.println(" OR SvcLogicParser activate "); System.err.println(" OR SvcLogicParser validate "); System.err.println(" OR SvcLogicParser install "); - + System.err.println(" OR SvcLogicParser bulkActivate "); System.exit(1); } diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 6ee18e922..f5cbf50b0 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -165,7 +165,9 @@ public class ITCaseSvcLogicParser { } else { String crTableCmd = "CREATE TABLE " + dbName + ".SVC_LOGIC (" + "module varchar(80) NOT NULL," + "rpc varchar(80) NOT NULL," + "version varchar(40) NOT NULL," + "mode varchar(5) NOT NULL," - + "active varchar(1) NOT NULL," + "graph BLOB," + + "active varchar(1) NOT NULL,graph BLOB," + + "modified_timestamp timestamp DEFAULT NULL," + + "md5sum varchar(128) DEFAULT NULL," + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; stmt = dbConn.createStatement(); -- cgit 1.2.3-korg From 9e8138f54edbf4cc8a0309f9e149953e08d3280e Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 14 Sep 2018 10:10:26 -0400 Subject: Fix version of sli/core Fix version.properties to set version 0.3.0 Change-Id: I81dbfa0a50ad01573e0af7f753c3dcdd0460536f Issue-ID: CCSDK-571 Signed-off-by: Timoney, Dan (dt5972) --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 57f71d583..4c1c6c69a 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=3 -feature_revision=9 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From f029e358bf9318ac03ba1be27912f52d296feacd Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 24 Sep 2018 01:03:37 +0530 Subject: formatted code and added test case to increase code coverage in CachedDataSourceTest Issue-ID: CCSDK-595 Change-Id: I10c2fec758bfb93587b4f5b096828a43a64039b0 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/dblib/CachedDataSourceTest.java | 159 +++++++++++---------- 1 file changed, 81 insertions(+), 78 deletions(-) diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java index 6385c1b57..c463f38bb 100644 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java @@ -1,6 +1,9 @@ package org.onap.ccsdk.sli.core.dblib; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; @@ -14,81 +17,81 @@ import org.slf4j.LoggerFactory; public class CachedDataSourceTest { - private static final Properties props = new Properties(); - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - props.setProperty("org.onap.ccsdk.sli.dbtype", "jdbc"); - props.setProperty("org.onap.ccsdk.sli.jdbc.hosts", "localhost"); - props.setProperty("org.onap.ccsdk.sli.jdbc.url", "jdbc:mysql://dbhost:3306/test"); - props.setProperty("org.onap.ccsdk.sli.jdbc.driver", "org.mariadb.jdbc.Driver"); - props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); - props.setProperty("org.onap.ccsdk.sli.jdbc.user", "dbuser"); - props.setProperty("org.onap.ccsdk.sli.jdbc.password", "passw0rd"); - props.setProperty("org.onap.ccsdk.sli.jdbc.connection.name", "testdb01"); - props.setProperty("org.onap.ccsdk.sli.jdbc.connection.timeout", "50"); - props.setProperty("org.onap.ccsdk.sli.jdbc.request.timeout", "100"); - props.setProperty("org.onap.ccsdk.sli.jdbc.limit.init", "10"); - props.setProperty("org.onap.ccsdk.sli.jdbc.limit.min", "10"); - props.setProperty("org.onap.ccsdk.sli.jdbc.limit.max", "20"); - props.setProperty("org.onap.dblib.connection.recovery", "false"); - } - - @Test - public void testCachedDataSource() { - BaseDBConfiguration config = new JDBCConfiguration(props); - CachedDataSource ds = new JdbcDBCachedDataSource(config); - assertNotNull(ds); - } - - @Test - public void testConfigure() { - BaseDBConfiguration config = new JDBCConfiguration(props); - - CachedDataSource ds = new JdbcDBCachedDataSource(config); - assertNotNull(ds.configure(config)); - } - - @Test - public void testSetInitialDelay() { - BaseDBConfiguration config = new JDBCConfiguration(props); - CachedDataSource ds = new JdbcDBCachedDataSource(config); - ds.setInitialDelay(1000L); - assertTrue(ds.getInitialDelay() == 1000L); - } - - @Test - public void testSetInterval() { - BaseDBConfiguration config = new JDBCConfiguration(props); - CachedDataSource ds = new JdbcDBCachedDataSource(config); - ds.setInterval(1000L); - assertTrue(ds.getInterval() == 1000L); - } - - @Test - public void testSetExpectedCompletionTime() { - BaseDBConfiguration config = new JDBCConfiguration(props); - CachedDataSource ds = new JdbcDBCachedDataSource(config); - ds.setExpectedCompletionTime(100L); - assertTrue(ds.getExpectedCompletionTime() == 100L); - } - - @Test - public void testSetUnprocessedFailoverThreshold() { - BaseDBConfiguration config = new JDBCConfiguration(props); - CachedDataSource ds = new JdbcDBCachedDataSource(config); - ds.setUnprocessedFailoverThreshold(100L); - assertTrue(ds.getUnprocessedFailoverThreshold() == 100L); - } - - @Test - public void testGetParentLogger() { - BaseDBConfiguration config = new JDBCConfiguration(props); - CachedDataSource ds = new JdbcDBCachedDataSource(config); - try { - assertNull(ds.getParentLogger()); - } catch (SQLFeatureNotSupportedException e) { - LoggerFactory.getLogger(CachedDataSourceTest.class).warn("Test Failure", e); - } - } + private static final Properties props = new Properties(); + private static BaseDBConfiguration config; + private static CachedDataSource ds; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + props.setProperty("org.onap.ccsdk.sli.dbtype", "jdbc"); + props.setProperty("org.onap.ccsdk.sli.jdbc.hosts", "localhost"); + props.setProperty("org.onap.ccsdk.sli.jdbc.url", "jdbc:mysql://dbhost:3306/test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.driver", "org.mariadb.jdbc.Driver"); + props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.user", "dbuser"); + props.setProperty("org.onap.ccsdk.sli.jdbc.password", "passw0rd"); + props.setProperty("org.onap.ccsdk.sli.jdbc.connection.name", "testdb01"); + props.setProperty("org.onap.ccsdk.sli.jdbc.connection.timeout", "50"); + props.setProperty("org.onap.ccsdk.sli.jdbc.request.timeout", "100"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.init", "10"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.min", "10"); + props.setProperty("org.onap.ccsdk.sli.jdbc.limit.max", "20"); + props.setProperty("org.onap.dblib.connection.recovery", "false"); + + config = new JDBCConfiguration(props); + ds = new JdbcDBCachedDataSource(config); + } + + @Test + public void testCachedDataSource() { + assertNotNull(ds); + } + + @Test + public void testConfigure() { + + assertNotNull(ds.configure(config)); + } + + @Test + public void testSetInitialDelay() { + ds.setInitialDelay(1000L); + assertTrue(ds.getInitialDelay() == 1000L); + } + + @Test + public void testSetInterval() { + ds.setInterval(1000L); + assertTrue(ds.getInterval() == 1000L); + } + + @Test + public void testSetExpectedCompletionTime() { + ds.setExpectedCompletionTime(100L); + assertTrue(ds.getExpectedCompletionTime() == 100L); + } + + @Test + public void testSetUnprocessedFailoverThreshold() { + ds.setUnprocessedFailoverThreshold(100L); + assertTrue(ds.getUnprocessedFailoverThreshold() == 100L); + } + + @Test + public void testGetParentLogger() { + try { + assertNull(ds.getParentLogger()); + } catch (SQLFeatureNotSupportedException e) { + LoggerFactory.getLogger(CachedDataSourceTest.class).warn("Test Failure", e); + } + } + + @Test + public void testGettersForJdbcDBCachedDataSource() { + + assertEquals("jdbc:mysql://dbhost:3306/test", ((JdbcDBCachedDataSource) ds).getDbUrl()); + assertEquals("dbuser", ((JdbcDBCachedDataSource) ds).getDbUserId()); + assertEquals("passw0rd", ((JdbcDBCachedDataSource) ds).getDbPasswd()); + assertEquals("testdb01", ((JdbcDBCachedDataSource) ds).toString()); + } } \ No newline at end of file -- cgit 1.2.3-korg From cdd9c11b89444735350eed52d412caf3f6d85c16 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 24 Sep 2018 01:28:16 +0530 Subject: added test cases to TestDBResourceManager to increase code coverage Issue-ID: CCSDK-595 Change-Id: I8def1aa2e4108f48bc549e63e533f8a63e7a0377 Signed-off-by: Sandeep J --- .../sli/core/dblib/TestDBResourceManager.java | 63 +++++++++++++--------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java index dca07921b..8d7d34324 100644 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java @@ -4,6 +4,7 @@ import static org.junit.Assert.*; import java.io.InputStream; import java.net.URL; +import java.sql.SQLException; import java.util.Properties; import org.junit.Before; @@ -14,42 +15,56 @@ import ch.vorburger.mariadb4j.DBConfigurationBuilder; public class TestDBResourceManager { - DbLibService dblibSvc; + DbLibService dblibSvc; + DBResourceManager dbm; - @Before - public void setUp() throws Exception { - URL propUrl = getClass().getResource("/dblib.properties"); + @Before + public void setUp() throws Exception { + URL propUrl = getClass().getResource("/dblib.properties"); - InputStream propStr = getClass().getResourceAsStream("/dblib.properties"); + InputStream propStr = getClass().getResourceAsStream("/dblib.properties"); - Properties props = new Properties(); + Properties props = new Properties(); - props.load(propStr); + props.load(propStr); + // Start MariaDB4j database + DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); + config.setPort(0); // 0 => autom. detect free port + DB db = DB.newEmbeddedDB(config.build()); + db.start(); - // Start MariaDB4j database - DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); - config.setPort(0); // 0 => autom. detect free port - DB db = DB.newEmbeddedDB(config.build()); - db.start(); + // Override jdbc URL and database name + props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + dblibSvc = new DBResourceManager(props); + dbm = new DBResourceManager(props); + dblibSvc.writeData("CREATE TABLE DBLIB_TEST (name varchar(20));", null, null); + dblibSvc.getData("SELECT * FROM DBLIB_TEST", null, null); - // Override jdbc URL and database name - props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); - props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + } + @Test + public void testForceRecovery() { + dbm.testForceRecovery(); + } - dblibSvc = new DBResourceManager(props); + @Test + public void testGetConnection() throws SQLException { + assertNotNull(dbm.getConnection()); + assertNotNull(dbm.getConnection("testUser", "testPaswd")); + } - dblibSvc.writeData("CREATE TABLE DBLIB_TEST (name varchar(20));", null, null); - dblibSvc.getData("SELECT * FROM DBLIB_TEST", null, null); + @Test + public void testCleanup() { + dbm.cleanUp(); - } + } - @Test - public void test() { - - - } + @Test + public void testGetLogWriter() throws SQLException { + assertNull(dbm.getLogWriter()); + } } -- cgit 1.2.3-korg From d13f91c223d2cd6b8c6d02766f386bd22991396a Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 24 Sep 2018 02:31:45 +0530 Subject: added test cases to CheckParametersTest to increase code coverage Issue-ID: CCSDK-595 Change-Id: Ief8154612aff27cda10f57623b1cca6baac9a7a7 Signed-off-by: Sandeep J --- .../core/slipluginutils/CheckParametersTest.java | 201 ++++++++++++--------- 1 file changed, 119 insertions(+), 82 deletions(-) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java index 166a60e90..266603d1d 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java @@ -3,7 +3,9 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * 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. @@ -21,6 +23,9 @@ package org.onap.ccsdk.sli.core.slipluginutils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.util.HashMap; import java.util.Map; @@ -32,85 +37,117 @@ import org.slf4j.LoggerFactory; public class CheckParametersTest { - @Test - public void nullRequiredParameters() throws Exception { - Map parametersMap = new HashMap(); - String[] requiredParams = null; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test(expected = SvcLogicException.class) - public void emptyParametersMap() throws Exception { - Map parametersMap = new HashMap(); - String[] requiredParams = new String[] { "param1", "param2", "param3" }; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test(expected = SvcLogicException.class) - public void paramNotFound() throws Exception { - Map parametersMap = new HashMap(); - parametersMap.put("tst", "me"); - String[] requiredParams = new String[] { "param1", "parm2", "param3" }; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test - public void testSunnyRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param2", "world"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - parameters.put("param1", "dog"); - parameters.put("param2", "cat"); - parameters.put("param3", "fish"); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test - public void testSunnyRequiredParametersWithPrefix() throws Exception { - String prefixValue = "my.unique.path."; - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute(prefixValue + "param1", "hello"); - ctx.setAttribute(prefixValue + "param2", "world"); - ctx.setAttribute(prefixValue + "param3", "!"); - - Map parameters = new HashMap(); - parameters.put("prefix", prefixValue); - parameters.put("param1", "dog"); - parameters.put("param2", "cat"); - parameters.put("param3", "fish"); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testRainyMissingRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - parameters.put("param1", null); - parameters.put("param2", null); - parameters.put("param3", null); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testEmptyRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - - SliPluginUtils.requiredParameters(parameters, ctx); - } + @Test + public void nullRequiredParameters() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = null; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void emptyParametersMap() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = new String[] { "param1", "param2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void paramNotFound() throws Exception { + Map parametersMap = new HashMap(); + parametersMap.put("tst", "me"); + String[] requiredParams = new String[] { "param1", "parm2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test + public void testSunnyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param2", "world"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test + public void testSunnyRequiredParametersWithPrefix() throws Exception { + String prefixValue = "my.unique.path."; + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(prefixValue + "param1", "hello"); + ctx.setAttribute(prefixValue + "param2", "world"); + ctx.setAttribute(prefixValue + "param3", "!"); + + Map parameters = new HashMap(); + parameters.put("prefix", prefixValue); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testRainyMissingRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", null); + parameters.put("param2", null); + parameters.put("param3", null); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testEmptyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testJsonStringToCtx() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "true"); + parameters.put("source", "//{/name1/:value1/}//"); + SliPluginUtils.jsonStringToCtx(parameters, ctx); + } + + @Test + public void testGetAttributeValue() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("source", "testSource"); + SliPluginUtils.getAttributeValue(parameters, ctx); + assertNull(ctx.getAttribute(parameters.get("outputPath"))); + } + + @Test + public void testCtxListContains() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters = new HashMap(); + parameters.put("list", "10_length"); + parameters.put("keyName", "testName"); + parameters.put("keyValue", "testValue"); + ctx.setAttribute("10_length", "10"); + assertEquals("false", SliPluginUtils.ctxListContains(parameters, ctx)); + + } } -- cgit 1.2.3-korg From dd40efb6c50b80695a4bc645b3227e73ddc4c67d Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 24 Sep 2018 02:43:20 +0530 Subject: added test case to Dme2Test.java to increase code coverage Issue-ID: CCSDK-595 Change-Id: Id3ae2ba9045d1308af2fb09f0c8aacdf5e40605b Signed-off-by: Sandeep J --- .../ccsdk/sli/core/slipluginutils/Dme2Test.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java index 9bff94835..a06def652 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java @@ -3,7 +3,9 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * 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. @@ -31,6 +33,8 @@ import java.util.Map; import java.util.Properties; import org.junit.Assert; import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; public class Dme2Test { public Properties makesProperties(String aafUserName, String aafPassword, String envContext, String routeOffer, @@ -279,5 +283,20 @@ public class Dme2Test { "http://sample.com:25055/service=sample.com/restservices/sys/v1/assetSearch/version=1.0/envContext=PROD/subContext=/mySubContext?dme2.password=fake&dme2.username=user@sample.com&partner=LPP_PROD&dme2.allowhttpcode=true"; assertEquals(expected, constructedUrl); } + + @Test + public void testConstructUrl() throws FileNotFoundException, IOException, SvcLogicException + { + Properties props = new Properties(); + props.load(new FileInputStream("src/test/resources/dme2.prod.properties")); + DME2 dme2 = new DME2(props); + Map parameters= new HashMap<>(); + SvcLogicContext ctx= new SvcLogicContext(); + parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); + parameters.put(DME2.OUTPUT_PATH_KEY, "tmp.test"); + dme2.constructUrl(parameters,ctx); + String expected= "http://sample.com:25055/service=sample.com/services/eim/v1/rest/version=1.0/envContext=PROD?dme2.password=fake&dme2.username=user@sample.com&partner=LPP_PROD&dme2.allowhttpcode=true"; + assertEquals(expected,ctx.getAttribute(parameters.get(DME2.OUTPUT_PATH_KEY))); + } } -- cgit 1.2.3-korg From 31e5da15c8247d2b98fc3a52fcf3c096e45933ce Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 25 Sep 2018 17:29:03 +0530 Subject: added test cases to CheckParametersTest.java to increase code coverage Issue-ID: CCSDK-595 Change-Id: I182eac676dd65c4ef68dd8a479d288615471c712 Signed-off-by: Sandeep J --- .../core/slipluginutils/CheckParametersTest.java | 259 ++++++++++++--------- 1 file changed, 146 insertions(+), 113 deletions(-) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java index 266603d1d..a7cc1bde5 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java @@ -35,119 +35,152 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.gson.JsonObject; + public class CheckParametersTest { - @Test - public void nullRequiredParameters() throws Exception { - Map parametersMap = new HashMap(); - String[] requiredParams = null; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test(expected = SvcLogicException.class) - public void emptyParametersMap() throws Exception { - Map parametersMap = new HashMap(); - String[] requiredParams = new String[] { "param1", "param2", "param3" }; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test(expected = SvcLogicException.class) - public void paramNotFound() throws Exception { - Map parametersMap = new HashMap(); - parametersMap.put("tst", "me"); - String[] requiredParams = new String[] { "param1", "parm2", "param3" }; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test - public void testSunnyRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param2", "world"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - parameters.put("param1", "dog"); - parameters.put("param2", "cat"); - parameters.put("param3", "fish"); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test - public void testSunnyRequiredParametersWithPrefix() throws Exception { - String prefixValue = "my.unique.path."; - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute(prefixValue + "param1", "hello"); - ctx.setAttribute(prefixValue + "param2", "world"); - ctx.setAttribute(prefixValue + "param3", "!"); - - Map parameters = new HashMap(); - parameters.put("prefix", prefixValue); - parameters.put("param1", "dog"); - parameters.put("param2", "cat"); - parameters.put("param3", "fish"); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testRainyMissingRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - parameters.put("param1", null); - parameters.put("param2", null); - parameters.put("param3", null); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testEmptyRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testJsonStringToCtx() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters = new HashMap(); - parameters.put("outputPath", "testPath"); - parameters.put("isEscaped", "true"); - parameters.put("source", "//{/name1/:value1/}//"); - SliPluginUtils.jsonStringToCtx(parameters, ctx); - } - - @Test - public void testGetAttributeValue() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters = new HashMap(); - parameters.put("outputPath", "testPath"); - parameters.put("source", "testSource"); - SliPluginUtils.getAttributeValue(parameters, ctx); - assertNull(ctx.getAttribute(parameters.get("outputPath"))); - } - - @Test - public void testCtxListContains() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters = new HashMap(); - parameters.put("list", "10_length"); - parameters.put("keyName", "testName"); - parameters.put("keyValue", "testValue"); - ctx.setAttribute("10_length", "10"); - assertEquals("false", SliPluginUtils.ctxListContains(parameters, ctx)); - - } + @Test + public void nullRequiredParameters() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = null; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void emptyParametersMap() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = new String[] { "param1", "param2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void paramNotFound() throws Exception { + Map parametersMap = new HashMap(); + parametersMap.put("tst", "me"); + String[] requiredParams = new String[] { "param1", "parm2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test + public void testSunnyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param2", "world"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test + public void testSunnyRequiredParametersWithPrefix() throws Exception { + String prefixValue = "my.unique.path."; + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(prefixValue + "param1", "hello"); + ctx.setAttribute(prefixValue + "param2", "world"); + ctx.setAttribute(prefixValue + "param3", "!"); + + Map parameters = new HashMap(); + parameters.put("prefix", prefixValue); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testRainyMissingRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", null); + parameters.put("param2", null); + parameters.put("param3", null); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testEmptyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testJsonStringToCtx() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "true"); + parameters.put("source", "//{/name1/:value1/}//"); + SliPluginUtils.jsonStringToCtx(parameters, ctx); + } + + @Test + public void testGetAttributeValue() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("source", "testSource"); + SliPluginUtils.getAttributeValue(parameters, ctx); + assertNull(ctx.getAttribute(parameters.get("outputPath"))); + } + + @Test + public void testCtxListContains() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters = new HashMap(); + parameters.put("list", "10_length"); + parameters.put("keyName", "testName"); + parameters.put("keyValue", "testValue"); + ctx.setAttribute("10_length", "10"); + assertEquals("false", SliPluginUtils.ctxListContains(parameters, ctx)); + + } + + @Test(expected= SvcLogicException.class) + public void testPrintContextForNullParameters() throws SvcLogicException + { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters = new HashMap(); + SliPluginUtils.printContext(parameters, ctx); + } + + @Test + public void testPrintContext() throws SvcLogicException + { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters = new HashMap(); + parameters.put("filename","testFileName"); + SliPluginUtils.printContext(parameters, ctx); + } + + @Test + public void testWriteJsonObject() throws SvcLogicException + { + JsonObject obj=new JsonObject(); + obj.addProperty("name","testName"); + obj.addProperty("age",27); + obj.addProperty("salary",600000); + SvcLogicContext ctx = new SvcLogicContext(); + SliPluginUtils.writeJsonObject(obj, ctx,"root"); + assertEquals("testName", ctx.getAttribute("root.name")); + assertEquals("27", ctx.getAttribute("root.age")); + assertEquals("600000", ctx.getAttribute("root.salary")); + } } -- cgit 1.2.3-korg From 7f5b3567cf9945a230b1a07373cce943f13bc1ac Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 25 Sep 2018 16:56:10 -0400 Subject: Create release version Update sli/core to create release version Change-Id: I0680e7b4c8bc08f7954b7b87ffc701289acd7893 Issue-ID: CCSDK-597 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 19 ++++++++++++++++- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 24 ++++++++++++++++++++-- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 24 +++++++++++++++++++++- filters/pom.xml | 2 +- filters/provider/pom.xml | 24 +++++++++++++++++++++- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 14 +++++++++++-- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider/pom.xml | 13 ++++++++++-- sli/recording/pom.xml | 13 ++++++++++-- .../features/ccsdk-sliPluginUtils/pom.xml | 17 ++++++++++++++- .../features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 23 ++++++++++++++++++++- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 12 +++++++++-- sliapi/features/ccsdk-sliapi/pom.xml | 18 +++++++++++++++- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 24 ++++++++++++++++++++-- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 15 ++++++++++++-- utils/features/ccsdk-slicore-utils/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- version.properties | 2 +- 46 files changed, 253 insertions(+), 53 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 5d05f84b3..8eb6469a3 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index ce31373ce..0bbab0390 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index a24c558cc..210d95c47 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 6544f20a5..d99034578 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/dblib/pom.xml b/dblib/pom.xml index f34ee2041..e239c5d4f 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 66b1fcd7c..a70599656 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index ef5da1200..dc40f40fa 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -17,6 +17,8 @@ feature ccsdk-sli-core :: features :: ${project.artifactId} + + @@ -33,6 +35,21 @@ pom import + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 843e27d9e..85daa50d2 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index eb6344bd3..e04bd4477 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/features/pom.xml b/features/pom.xml index f7ff3fdd4..2783b64fe 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index a995790d5..663f14bb3 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -16,7 +16,27 @@ feature ccsdk-sli-core :: filters :: ${project.artifactId} - + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 810d40ab4..cb8a5c244 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 73192fa8a..c85339349 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 76e055def..1bf9d5949 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 @@ -23,6 +23,28 @@ false + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + diff --git a/filters/pom.xml b/filters/pom.xml index 319c4a7ff..9f4f6fb9b 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index c7d356ba3..84da7164e 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -23,6 +23,28 @@ **/RequestResponseDbLoggingFilter.java + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + junit diff --git a/pom.xml b/pom.xml index 3e2319bcc..a841167e9 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 5007bedfd..15c9a4de5 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 7193b2b21..bf3ca4385 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index f108726da..56399bc69 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 9a75ad709..b351e1dd3 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 4a3eeff74..2a0898160 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 @@ -23,7 +23,17 @@ mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false - + + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + diff --git a/sli/model/pom.xml b/sli/model/pom.xml index d074e2501..b9a154760 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sli/pom.xml b/sli/pom.xml index d608e341a..14c14a8f6 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index aed348303..336e82561 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -24,8 +24,17 @@ + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + - org.onap.ccsdk.sli.core sli-model diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 038381d58..9ff69c1b0 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -23,7 +23,16 @@ UTF-8 - + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + org.onap.ccsdk.sli.core diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 78f5f1e1c..3c1cebac2 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -32,6 +32,21 @@ pom import + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 23e54fe5d..b73c980b3 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 5b4b70fd8..d68a908e0 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 5a22e4953..89ad6c890 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 @@ -23,6 +23,27 @@ false + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 8ecdf3972..d6cec7707 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 411c1453c..7737d9c22 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -20,7 +20,15 @@ UTF-8 - + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + junit diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index f4f63948d..d7e29d6ec 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -32,6 +32,22 @@ pom import + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 8b0ffecd9..4d8bc0c75 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index dd0c3bd7d..1f994278d 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index de5c6a684..78886afa6 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 @@ -22,7 +22,27 @@ mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false - + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 594a6dbf4..e2fed13a9 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index d59e72aea..7767174ea 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index bcd585323..1fbc8fba0 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 @@ -16,7 +16,16 @@ bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} - + + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + @@ -45,10 +54,12 @@ org.onap.ccsdk.sli.core sli-common + ${project.version} org.onap.ccsdk.sli.core sli-provider + ${project.version} org.opendaylight.controller diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 952e4ab1c..59c46b16a 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 8f8748a57..c6b06283d 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/utils/features/pom.xml b/utils/features/pom.xml index bac928ab8..dca1b801f 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 389927256..1989e31b0 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/utils/pom.xml b/utils/pom.xml index 85206f8ad..44b28ee7e 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 2698b39c9..7258df209 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0-SNAPSHOT + 1.1.0 diff --git a/version.properties b/version.properties index 4c1c6c69a..31723e3ff 100644 --- a/version.properties +++ b/version.properties @@ -10,6 +10,6 @@ feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version}-STAGING +release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg From 5b83cd33196edc26bf8eaa7ae3742760d542455a Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 25 Sep 2018 19:09:31 -0400 Subject: Roll to 0.3.1-SNAPSHOT Roll to next snapshot version Change-Id: I58ead1293d517f94bacca69407b22533840b0ee6 Issue-ID: CCSDK-597 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/ccsdk-slicore-utils/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- version.properties | 4 ++-- 44 files changed, 45 insertions(+), 45 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 8eb6469a3..7cf80043d 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -12,7 +12,7 @@ org.onap.ccsdk.sli.core ccsdk-dblib - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 0bbab0390..4a5b50f3d 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core features-dblib - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 210d95c47..73464775b 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index d99034578..39730f925 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -12,7 +12,7 @@ org.onap.ccsdk.sli.core dblib-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index e239c5d4f..21c805360 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core dblib - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index a70599656..4e785a10c 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core dblib-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index dc40f40fa..f67c7c052 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 85daa50d2..7e6243faa 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core features-sli-core - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index e04bd4477..6a341d9a9 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -12,7 +12,7 @@ org.onap.ccsdk.sli.core slicore-features-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 2783b64fe..0cb15b3ad 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 663f14bb3..b38b348bd 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -12,7 +12,7 @@ org.onap.ccsdk.sli.core ccsdk-filters - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index cb8a5c244..d82911f27 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core features-filters - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 1bf9d5949..c34fc2585 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core filters-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 9f4f6fb9b..2d6f1611a 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core filters - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 84da7164e..b6ae79739 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core filters-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index a841167e9..78136b22c 100755 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 15c9a4de5..d16ce033b 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -12,7 +12,7 @@ org.onap.ccsdk.sli.core sli-common - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index bf3ca4385..729e24ea5 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core features-sli - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 56399bc69..0e0265efa 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.sli.core ccsdk-sli - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index b351e1dd3..734c342c0 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli-feature-aggregator - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 2a0898160..0a70cf9fe 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -12,7 +12,7 @@ org.onap.ccsdk.sli.core sli-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index b9a154760..bfb4c2492 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli-model - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 14c14a8f6..c03e1dadd 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 336e82561..0e343c804 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.sli.core sli-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 9ff69c1b0..7c1682e17 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.sli.core sli-recording - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 3c1cebac2..3e15fa449 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index b73c980b3..60d563f72 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core features-sliPluginUtils - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index d68a908e0..2194f8ec5 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliPluginUtils-features - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 89ad6c890..e30e9d26e 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index d6cec7707..da646177e 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 7737d9c22..4b7fe9520 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index d7e29d6ec..99d5973e0 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sliapi - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 4d8bc0c75..f907d54d9 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core features-sliapi - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 1f994278d..0f5772398 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 78886afa6..5a60f1b09 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index e2fed13a9..5a0c5e238 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi-model - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 7767174ea..60dc94aaf 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 1fbc8fba0..280b2131e 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -12,7 +12,7 @@ org.onap.ccsdk.sli.core sliapi-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 59c46b16a..e530cdc5c 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index c6b06283d..713ba4da3 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core features-util - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 1989e31b0..473c4a571 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -13,7 +13,7 @@ org.onap.ccsdk.sli.core utils-installer - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 44b28ee7e..cbdcdad7d 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core utils - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 7258df209..678ce1bb3 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core utils-provider - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 31723e3ff..407a30cd3 100644 --- a/version.properties +++ b/version.properties @@ -6,10 +6,10 @@ release_name=0 sprint_number=3 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version} +release_version=${base_version}-STAGING snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg From c8c30742003324f8d4b56ac5efb4de0d182bd1a0 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 26 Sep 2018 02:59:01 +0530 Subject: added test case to SliPluginUtils_ctxSortList to increase code coverage Issue-ID: CCSDK-595 Change-Id: I0cfaac418d169542b92b6f60eb1b8c32a1a95f37 Signed-off-by: Sandeep J --- .../slipluginutils/SliPluginUtils_ctxSortList.java | 167 +++++++++++++-------- 1 file changed, 106 insertions(+), 61 deletions(-) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java index f9d70f2fb..bfd19bc6a 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java @@ -3,7 +3,9 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * 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. @@ -17,15 +19,16 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - */ + */ package org.onap.ccsdk.sli.core.slipluginutils; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.HashMap; import java.util.Random; - + import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -35,62 +38,104 @@ import org.slf4j.LoggerFactory; @SuppressWarnings("unused") public class SliPluginUtils_ctxSortList { - private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class); - SliPluginUtils utils = new SliPluginUtils(); - SvcLogicContext ctx; - HashMap parameters; - Random rand = new Random(); - - @Before - public void setUp() throws Exception { - this.ctx = new SvcLogicContext(); - this.parameters = new HashMap(); - } - - @Test - public final void list_of_containers() throws SvcLogicException { - this.parameters.put("list", "input.list"); - this.parameters.put("sort-fields", "sort-key"); - this.parameters.put("delimiter",","); - - ctx.setAttribute("input.list_length", "10"); - for( int i = 0; i < 10; i++ ) { - this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString( rand.nextInt(10) )); - this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString( rand.nextInt(10) )); - } - - LOG.trace("BEFORE SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - utils.ctxSortList(this.parameters, this.ctx); - - LOG.trace("AFTER SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - for( int i = 0; i < 9; i++ ) { - assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i+1) + "].sort-key")) < 1 ); - } - } - - @Test public final void list_of_elements() throws SvcLogicException { - this.parameters.put("list", "input.list"); - this.parameters.put("delimiter",","); - - this.ctx.setAttribute("input.list_length", "10"); - for( int i = 0; i < 10; i++ ) { - this.ctx.setAttribute("input.list[" + i + ']', Integer.toString( rand.nextInt(10) )); - } - - LOG.trace("BEFORE SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - utils.ctxSortList(this.parameters, this.ctx); - - LOG.trace("AFTER SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - for( int i = 0; i < 9; i++ ) { - assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i+1) + ']')) < 1 ); - } - } + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class); + SliPluginUtils utils = new SliPluginUtils(); + SvcLogicContext ctx; + HashMap parameters; + Random rand = new Random(); + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + this.parameters = new HashMap(); + } + + @Test + public final void list_of_containers() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("sort-fields", "sort-key"); + this.parameters.put("delimiter",","); + + ctx.setAttribute("input.list_length", "10"); + for( int i = 0; i < 10; i++ ) { + this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString( rand.nextInt(10) )); + this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString( rand.nextInt(10) )); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for( int i = 0; i < 9; i++ ) { + assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i+1) + "].sort-key")) < 1 ); + } + } + + @Test + public final void list_of_elements() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("delimiter",","); + + this.ctx.setAttribute("input.list_length", "10"); + for( int i = 0; i < 10; i++ ) { + this.ctx.setAttribute("input.list[" + i + ']', Integer.toString( rand.nextInt(10) )); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for( int i = 0; i < 9; i++ ) { + assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i+1) + ']')) < 1 ); + } + } + + @Test + public void testGenerateUUID() throws SvcLogicException + { + SliPluginUtils utils= new SliPluginUtils(); + this.parameters.put("ctx-destination", "testDestination"); + utils.generateUUID(this.parameters, ctx); + } + + @Test + public void testSubstring() throws SvcLogicException + { + SliPluginUtils utils= new SliPluginUtils(); + this.parameters.put("string", "testString"); + this.parameters.put("begin-index", "1"); + this.parameters.put("result", "testResult"); + this.parameters.put("end-index", "5"); + utils.substring(this.parameters, ctx); + assertEquals("estS",ctx.getAttribute("testResult")); + } + + @Test + public void testSubstringForNullEndIndex() throws SvcLogicException + { + SliPluginUtils utils= new SliPluginUtils(); + this.parameters.put("string", "testString"); + this.parameters.put("begin-index", "1"); + this.parameters.put("result", "testResult"); + utils.substring(this.parameters, ctx); + assertEquals("estString",ctx.getAttribute("testResult")); + } + + @Test + public void testCtxBulkCopy() + { + ctx.setAttribute("Mykey1", "MyValue1"); + ctx.setAttribute("Mykey2", "MyValue2"); + SliPluginUtils.ctxBulkCopy(ctx, "Mykey", "test."); + assertEquals("MyValue1",ctx.getAttribute("test.1")); + assertEquals("MyValue2",ctx.getAttribute("test.2")); + } } -- cgit 1.2.3-korg From c3e894237d04ca28c5506c5f0f6783d54add8ebf Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 26 Sep 2018 03:11:22 +0530 Subject: added test case to SliStringUtilsTest to increase code coverage Issue-ID: CCSDK-595 Change-Id: I3cc31ab404fa5ee26bcecd1a5617b2423a10a96c Signed-off-by: Sandeep J --- .../sli/core/slipluginutils/SliStringUtilsTest.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index 4c665121c..9bf851d5d 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -3,7 +3,9 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * 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. @@ -19,9 +21,6 @@ * ============LICENSE_END========================================================= */ -/** - * - */ package org.onap.ccsdk.sli.core.slipluginutils; import static org.hamcrest.Matchers.equalTo; @@ -30,7 +29,7 @@ import static org.junit.Assert.assertThat; import java.util.HashMap; import java.util.Map; - + import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -273,5 +272,14 @@ public class SliStringUtilsTest { SliStringUtils.urlEncode(param, ctx); assertEquals("102%2FGE100%2FSNJSCAMCJP8%2FSNJSCAMCJT4", ctx.getAttribute(outputPath)); } + + @Test + public void testXmlEscapeText() + { + param.put("source", "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"); + param.put("target", "target"); + SliStringUtils.xmlEscapeText(param,ctx); + assertEquals("102/GE100/SNJSCAMCJP8/SNJSCAMCJT4",ctx.getAttribute("target")); + } } -- cgit 1.2.3-korg From 2f5bc084af648187c9fcffb8ff6472f8755c034d Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 2 Oct 2018 01:10:21 +0530 Subject: added test cases to CachedDataSource to increase code coverage Issue-ID: CCSDK-595 Change-Id: I7d5a5ed59538e7d6e1a7d00dfba690eedc7c2e22 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/dblib/CachedDataSourceTest.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java index c463f38bb..45268107e 100644 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java @@ -1,10 +1,12 @@ package org.onap.ccsdk.sli.core.dblib; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; @@ -94,4 +96,26 @@ public class CachedDataSourceTest { assertEquals("passw0rd", ((JdbcDBCachedDataSource) ds).getDbPasswd()); assertEquals("testdb01", ((JdbcDBCachedDataSource) ds).toString()); } + + @Test + public void testIsInitialised() { + assertTrue(ds.isInitialized()); + } + + @Test + public void testIsWrapperFor() throws SQLException { + assertFalse(ds.isWrapperFor(CachedDataSource.class)); + } + + @Test + public void testGetSetNextErrorReportTime() throws SQLException { + ds.setNextErrorReportTime(1L); + assertEquals(1L, ds.getNextErrorReportTime()); + } + + @Test + public void testGetSetGlobalHostName() throws SQLException { + ds.setGlobalHostName("hostName"); + assertEquals("hostName", ds.getGlobalHostName()); + } } \ No newline at end of file -- cgit 1.2.3-korg From 4f6fbb98b4775a6ec181cbfc1992c2ea4a94b30f Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 2 Oct 2018 01:42:18 +0530 Subject: added test cases to MdsalHelperTest to increase code coverage Issue-ID: CCSDK-552 Change-Id: I9d5ba40bc0039ef335642a0c66d8680c704b2d40 Signed-off-by: Sandeep J --- .../sli/core/sli/provider/MdsalHelperTest.java | 160 +++++++++++---------- 1 file changed, 86 insertions(+), 74 deletions(-) diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index 307c69c7d..d0ea4f551 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -3,7 +3,9 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * 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. @@ -21,33 +23,26 @@ package org.onap.ccsdk.sli.core.sli.provider; -import java.io.File; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; -import static org.junit.Assert.*; - import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; -import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; -import org.opendaylight.yang.gen.v1.test.CosModelType; import org.opendaylight.yang.gen.v1.test.WrapperObj; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import junit.framework.TestCase; - public class MdsalHelperTest extends TestCase { - private static final Logger LOG = LoggerFactory - .getLogger(MdsalHelperTest.class); + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTest.class); public static final String pathToSdnPropertiesFile = "src/test/resources/l3sdn.properties"; public void testSdnProperties() { @@ -56,8 +51,8 @@ public class MdsalHelperTest extends TestCase { assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "synccomplete")); assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete")); - assertEquals("service-configuration-operation", MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", - "service-configuration-operation")); + assertEquals("service-configuration-operation", + MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", "service-configuration-operation")); } public void testNegativeSdnProperties() { @@ -66,85 +61,82 @@ public class MdsalHelperTest extends TestCase { public void testToProperties() { - ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); - SliParameterBuilder parmBuilder = new SliParameterBuilder(); - List params = new LinkedList(); - - parmBuilder.setParameterName("boolean-parm"); - parmBuilder.setBooleanValue(Boolean.TRUE); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("int-parm"); - parmBuilder.setBooleanValue(null); - parmBuilder.setIntValue(1); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("str-parm"); - parmBuilder.setIntValue(null); - parmBuilder.setStringValue("hello"); - params.add(parmBuilder.build()); + ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); + SliParameterBuilder parmBuilder = new SliParameterBuilder(); + List params = new LinkedList(); - parmBuilder.setParameterName("ipaddress4-parm"); - parmBuilder.setStringValue(null); - parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); - params.add(parmBuilder.build()); + parmBuilder.setParameterName("boolean-parm"); + parmBuilder.setBooleanValue(Boolean.TRUE); + params.add(parmBuilder.build()); - parmBuilder.setParameterName("ipaddress6-parm"); - parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1")); - params.add(parmBuilder.build()); + parmBuilder.setParameterName("int-parm"); + parmBuilder.setBooleanValue(null); + parmBuilder.setIntValue(1); + params.add(parmBuilder.build()); + parmBuilder.setParameterName("str-parm"); + parmBuilder.setIntValue(null); + parmBuilder.setStringValue("hello"); + params.add(parmBuilder.build()); - execBuilder.setMode(Mode.Sync); - execBuilder.setModuleName("my-module"); - execBuilder.setRpcName("do-it-now"); - execBuilder.setSliParameter(params); + parmBuilder.setParameterName("ipaddress4-parm"); + parmBuilder.setStringValue(null); + parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); + params.add(parmBuilder.build()); + parmBuilder.setParameterName("ipaddress6-parm"); + parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1")); + params.add(parmBuilder.build()); - Properties props = new Properties(); + execBuilder.setMode(Mode.Sync); + execBuilder.setModuleName("my-module"); + execBuilder.setRpcName("do-it-now"); + execBuilder.setSliParameter(params); - MdsalHelperTesterUtil.toProperties(props, execBuilder); + Properties props = new Properties(); - LOG.info("Converted to properties"); - for (Map.Entry e : props.entrySet()) { - LOG.info(e.getKey().toString() + " = "+e.getValue().toString()); + MdsalHelperTesterUtil.toProperties(props, execBuilder); + MdsalHelperTesterUtil.toProperties(props, "", execBuilder); - } + LOG.info("Converted to properties"); + for (Map.Entry e : props.entrySet()) { + LOG.info(e.getKey().toString() + " = " + e.getValue().toString()); + } } public void testToBuilder() { - Properties props = new Properties(); - - props.setProperty("execute-graph-input.mode", "Sync"); - props.setProperty("execute-graph-input.module", "my-module"); - props.setProperty("execute-graph-input.rpc", "do-it-now"); - props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm"); - props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true"); - props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param"); - props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1"); - props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param"); - props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello"); - props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param"); - props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1"); - props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param"); - props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1"); - ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); - - MdsalHelperTesterUtil.toBuilder(props, execBuilder); - + Properties props = new Properties(); + props.setProperty("execute-graph-input.mode", "Sync"); + props.setProperty("execute-graph-input.module", "my-module"); + props.setProperty("execute-graph-input.rpc", "do-it-now"); + props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm"); + props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true"); + props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param"); + props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1"); + props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param"); + props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello"); + props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param"); + props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1"); + props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param"); + props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1"); + ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); + + MdsalHelperTesterUtil.toBuilder(props, execBuilder); } - public void testToJavaEnum() throws Exception{ - assertEquals("_2018HelloWorld",MdsalHelper.toJavaEnum("2018Hello World")); - assertEquals("SomethingElse",MdsalHelper.toJavaEnum("Something.Else")); - assertEquals("MyTestString",MdsalHelper.toJavaEnum("my-test-string")); + public void testToJavaEnum() throws Exception { + assertEquals("_2018HelloWorld", MdsalHelper.toJavaEnum("2018Hello World")); + assertEquals("SomethingElse", MdsalHelper.toJavaEnum("Something.Else")); + assertEquals("MyTestString", MdsalHelper.toJavaEnum("my-test-string")); } - - // During the default enumeration mapping no properties file is needed, the yang value is returned + + // During the default enumeration mapping no properties file is needed, the + // yang value is returned // by the java object public void testDefaultEnumerationMapping() throws Exception { Properties props = new Properties(); @@ -152,7 +144,8 @@ public class MdsalHelperTest extends TestCase { assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type")); } - // When no properties file exists the default java value will be returned if legacy enumeration + // When no properties file exists the default java value will be returned if + // legacy enumeration // mapping is enabled public void testLegacyEnumerationMappingNoProperties() throws Exception { Properties props = new Properties(); @@ -160,7 +153,8 @@ public class MdsalHelperTest extends TestCase { assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type")); } - // When a properties file exists & legacy enumeration mapping is enabled the value from the + // When a properties file exists & legacy enumeration mapping is enabled the + // value from the // properties file should be returned public void testLegacyEnumerationMappingWithProperties() throws Exception { MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties"); @@ -168,4 +162,22 @@ public class MdsalHelperTest extends TestCase { MdsalHelper.toProperties(props, new WrapperObj(), true); assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type")); } + + public void testGetFullPropertiesPath() { + String fullPath = MdsalHelper.getFullPropertiesPath("testFile"); + assertEquals("/opt/bvc/controller/configuration/testFile", fullPath); + + } + + public void testIsDscp() { + + assertTrue(MdsalHelper.isDscp(Dscp.class)); + + } + + public void testIsPortNumber() { + + assertTrue(MdsalHelper.isPortNumber(PortNumber.class)); + + } } -- cgit 1.2.3-korg From 1cb3e7a33caebb6bc61a7766c00e30ee6b9f2d3b Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 2 Oct 2018 01:58:59 +0530 Subject: added test case to TestFileRecorder to increase code coverage Issue-ID: CCSDK-595 Change-Id: Idf00ada3253593a8a5cc2096b927b4bcad457b3c Signed-off-by: Sandeep J --- .../sli/core/sli/recording/TestFileRecorder.java | 50 ++++++++++++++-------- 1 file changed, 32 insertions(+), 18 deletions(-) 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 index c879d8f62..d0cc83182 100644 --- 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 @@ -3,8 +3,11 @@ */ package org.onap.ccsdk.sli.core.sli.recording; -import static org.junit.Assert.*; +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; @@ -13,23 +16,34 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; * */ 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 method for {@link org.onap.ccsdk.sli.core.sli.recording.FileRecorder#record(java.util.Map)}. - */ - @Test - public void testRecord() { - - FileRecorder recorder = new FileRecorder(); - - 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); + } } -- cgit 1.2.3-korg From 1b12d57f0da5566ff2c2d6c6d21300089ae538fb Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 2 Oct 2018 02:08:36 +0530 Subject: added tes file to cover SliapiHelper to incrase code coverage Issue-ID: CCSDK-595 Change-Id: I5c15bb14e8d101873e70dcd057e2e8fc7bead344 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/sliapi/SliapiHelperTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelperTest.java diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelperTest.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelperTest.java new file mode 100644 index 000000000..228f6127e --- /dev/null +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelperTest.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2018 IBM. 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.sliapi; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class SliapiHelperTest { + + @Test + public void TestSliapiHelper() + { + SliapiHelper sliapiHelper= new SliapiHelper(); + assertNotNull(sliapiHelper); + } +} -- cgit 1.2.3-korg From e679025082286f86e983d999084605326c540547 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 2 Oct 2018 02:24:14 +0530 Subject: added test case to TestSlipapiprovider to increase code coverage Issue-ID: CCSDK-595 Change-Id: If835e05bfd08db9c60ae15e924a9750c78d67763 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index 38cbd40c9..287f2f206 100644 --- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -4,8 +4,12 @@ package org.onap.ccsdk.sli.core.sliapi; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Mockito.*; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.io.InputStream; import java.net.URL; import java.util.HashMap; @@ -13,6 +17,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.concurrent.Future; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -86,7 +92,6 @@ public class TestSliapiProvider { } }; - /** * @throws java.lang.Exception */ @@ -95,10 +100,10 @@ public class TestSliapiProvider { DataBroker dataBroker = mock(DataBroker.class); NotificationPublishService notifyService = mock(NotificationPublishService.class); RpcProviderRegistry rpcRegistry = mock(RpcProviderRegistry.class); - BindingAwareBroker.RpcRegistration rpcRegistration = (BindingAwareBroker.RpcRegistration) mock(BindingAwareBroker.RpcRegistration.class); + BindingAwareBroker.RpcRegistration rpcRegistration = (BindingAwareBroker.RpcRegistration) mock( + BindingAwareBroker.RpcRegistration.class); when(rpcRegistry.addRpcImplementation(any(Class.class), any(SLIAPIService.class))).thenReturn(rpcRegistration); - // Load svclogic.properties and get a SvcLogicStore InputStream propStr = TestSliapiProvider.class.getResourceAsStream("/svclogic.properties"); Properties svcprops = new Properties(); @@ -111,7 +116,7 @@ public class TestSliapiProvider { // Load the DG for the healthcheck api URL testCaseUrl = TestSliapiProvider.class.getClassLoader().getResource(HEALTHCHECK_DG); if (testCaseUrl == null) { - fail("Cannot find "+HEALTHCHECK_DG); + fail("Cannot find " + HEALTHCHECK_DG); } SvcLogicParser.load(testCaseUrl.getPath(), store); SvcLogicParser.activate("sli", "healthcheck", "1.0.0", "sync", store); @@ -138,7 +143,8 @@ public class TestSliapiProvider { } /** - * Test method for {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#executeGraph(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)}. + * Test method for + * {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#executeGraph(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)}. */ @Test public void testExecuteGraph() { @@ -154,14 +160,13 @@ public class TestSliapiProvider { pList.add(pBuilder.build()); inputBuilder.setSliParameter(pList); - - - provider.executeGraph(inputBuilder.build()); + assertTrue(provider.vlbcheck() instanceof Future); } /** - * Test method for {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#healthcheck()}. + * Test method for + * {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#healthcheck()}. */ @Test public void testHealthcheck() { -- cgit 1.2.3-korg From 5840e02a1eb4800be92ad632f1dd02469d64234d Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 2 Oct 2018 18:42:38 +0530 Subject: added test cases to CheckParametersTest to increase code coverage Issue-ID: CCSDK-595 Change-Id: Ibf5316cc567cacf52806ef57e69749006fe8b204 Signed-off-by: Sandeep J --- .../core/slipluginutils/CheckParametersTest.java | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java index a7cc1bde5..21aa4a356 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java @@ -19,12 +19,13 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - */ + */ package org.onap.ccsdk.sli.core.slipluginutils; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.util.HashMap; import java.util.Map; @@ -32,8 +33,10 @@ import java.util.Map; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils.LogLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.Marker; import com.google.gson.JsonObject; @@ -183,4 +186,31 @@ public class CheckParametersTest { assertEquals("27", ctx.getAttribute("root.age")); assertEquals("600000", ctx.getAttribute("root.salary")); } + + @Test + public void testCtxKeyEmpty() + { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("key", ""); + assertTrue(SliPluginUtils.ctxKeyEmpty(ctx, "key")); + } + + @Test + public void testGetArrayLength() + { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("key_length", "test"); + Logger log = LoggerFactory.getLogger(getClass()); + SliPluginUtils.getArrayLength(ctx, "key", log , LogLevel.INFO, "invalid input"); + } + + @Test + public void testSetPropertiesForRoot() + { + SvcLogicContext ctx = new SvcLogicContext(); + Map parameters= new HashMap<>(); + parameters.put("root","RootVal"); + parameters.put("valueRoot", "ValueRootVal"); + assertEquals("success",SliPluginUtils.setPropertiesForRoot(parameters,ctx)); + } } -- cgit 1.2.3-korg From 793c4bf4f51f6d90531b6d8928a4680658cd6f08 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 2 Oct 2018 18:52:48 +0530 Subject: added test case to SliPluginUtils_ctxSortList to increase code coverage Issue-ID: CCSDK-595 Change-Id: Idb51b525279916e5f7b6fe26dc9b4372243d163a Signed-off-by: Sandeep J --- .../slipluginutils/SliPluginUtils_ctxSortList.java | 215 +++++++++++---------- 1 file changed, 112 insertions(+), 103 deletions(-) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java index bfd19bc6a..78e846aef 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java @@ -19,8 +19,8 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - */ - + */ + package org.onap.ccsdk.sli.core.slipluginutils; import static org.junit.Assert.assertEquals; @@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue; import java.util.HashMap; import java.util.Random; - + import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -38,104 +38,113 @@ import org.slf4j.LoggerFactory; @SuppressWarnings("unused") public class SliPluginUtils_ctxSortList { - private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class); - SliPluginUtils utils = new SliPluginUtils(); - SvcLogicContext ctx; - HashMap parameters; - Random rand = new Random(); - - @Before - public void setUp() throws Exception { - this.ctx = new SvcLogicContext(); - this.parameters = new HashMap(); - } - - @Test - public final void list_of_containers() throws SvcLogicException { - this.parameters.put("list", "input.list"); - this.parameters.put("sort-fields", "sort-key"); - this.parameters.put("delimiter",","); - - ctx.setAttribute("input.list_length", "10"); - for( int i = 0; i < 10; i++ ) { - this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString( rand.nextInt(10) )); - this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString( rand.nextInt(10) )); - } - - LOG.trace("BEFORE SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - utils.ctxSortList(this.parameters, this.ctx); - - LOG.trace("AFTER SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - for( int i = 0; i < 9; i++ ) { - assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key").compareTo(this.ctx.getAttribute("input.list[" + (i+1) + "].sort-key")) < 1 ); - } - } - - @Test - public final void list_of_elements() throws SvcLogicException { - this.parameters.put("list", "input.list"); - this.parameters.put("delimiter",","); - - this.ctx.setAttribute("input.list_length", "10"); - for( int i = 0; i < 10; i++ ) { - this.ctx.setAttribute("input.list[" + i + ']', Integer.toString( rand.nextInt(10) )); - } - - LOG.trace("BEFORE SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - utils.ctxSortList(this.parameters, this.ctx); - - LOG.trace("AFTER SORT:"); - SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); - - for( int i = 0; i < 9; i++ ) { - assertTrue(this.ctx.getAttribute("input.list[" + i + ']').compareTo(this.ctx.getAttribute("input.list[" + (i+1) + ']')) < 1 ); - } - } - - @Test - public void testGenerateUUID() throws SvcLogicException - { - SliPluginUtils utils= new SliPluginUtils(); - this.parameters.put("ctx-destination", "testDestination"); - utils.generateUUID(this.parameters, ctx); - } - - @Test - public void testSubstring() throws SvcLogicException - { - SliPluginUtils utils= new SliPluginUtils(); - this.parameters.put("string", "testString"); - this.parameters.put("begin-index", "1"); - this.parameters.put("result", "testResult"); - this.parameters.put("end-index", "5"); - utils.substring(this.parameters, ctx); - assertEquals("estS",ctx.getAttribute("testResult")); - } - - @Test - public void testSubstringForNullEndIndex() throws SvcLogicException - { - SliPluginUtils utils= new SliPluginUtils(); - this.parameters.put("string", "testString"); - this.parameters.put("begin-index", "1"); - this.parameters.put("result", "testResult"); - utils.substring(this.parameters, ctx); - assertEquals("estString",ctx.getAttribute("testResult")); - } - - @Test - public void testCtxBulkCopy() - { - ctx.setAttribute("Mykey1", "MyValue1"); - ctx.setAttribute("Mykey2", "MyValue2"); - SliPluginUtils.ctxBulkCopy(ctx, "Mykey", "test."); - assertEquals("MyValue1",ctx.getAttribute("test.1")); - assertEquals("MyValue2",ctx.getAttribute("test.2")); - } + private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_ctxSortList.class); + SliPluginUtils utils = new SliPluginUtils(); + SvcLogicContext ctx; + HashMap parameters; + Random rand = new Random(); + + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + this.parameters = new HashMap(); + } + + @Test + public final void list_of_containers() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("sort-fields", "sort-key"); + this.parameters.put("delimiter", ","); + + ctx.setAttribute("input.list_length", "10"); + for (int i = 0; i < 10; i++) { + this.ctx.setAttribute("input.list[" + i + "].sort-key", Integer.toString(rand.nextInt(10))); + this.ctx.setAttribute("input.list[" + i + "].value", Integer.toString(rand.nextInt(10))); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for (int i = 0; i < 9; i++) { + assertTrue(this.ctx.getAttribute("input.list[" + i + "].sort-key") + .compareTo(this.ctx.getAttribute("input.list[" + (i + 1) + "].sort-key")) < 1); + } + } + + @Test + public final void list_of_elements() throws SvcLogicException { + this.parameters.put("list", "input.list"); + this.parameters.put("delimiter", ","); + + this.ctx.setAttribute("input.list_length", "10"); + for (int i = 0; i < 10; i++) { + this.ctx.setAttribute("input.list[" + i + ']', Integer.toString(rand.nextInt(10))); + } + + LOG.trace("BEFORE SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + utils.ctxSortList(this.parameters, this.ctx); + + LOG.trace("AFTER SORT:"); + SliPluginUtils.logContextMemory(ctx, LOG, SliPluginUtils.LogLevel.TRACE); + + for (int i = 0; i < 9; i++) { + assertTrue(this.ctx.getAttribute("input.list[" + i + ']') + .compareTo(this.ctx.getAttribute("input.list[" + (i + 1) + ']')) < 1); + } + } + + @Test + public void testGenerateUUID() throws SvcLogicException { + SliPluginUtils utils = new SliPluginUtils(); + this.parameters.put("ctx-destination", "testDestination"); + utils.generateUUID(this.parameters, ctx); + } + + @Test + public void testSubstring() throws SvcLogicException { + SliPluginUtils utils = new SliPluginUtils(); + this.parameters.put("string", "testString"); + this.parameters.put("begin-index", "1"); + this.parameters.put("result", "testResult"); + this.parameters.put("end-index", "5"); + utils.substring(this.parameters, ctx); + assertEquals("estS", ctx.getAttribute("testResult")); + } + + @Test + public void testSubstringForNullEndIndex() throws SvcLogicException { + SliPluginUtils utils = new SliPluginUtils(); + this.parameters.put("string", "testString"); + this.parameters.put("begin-index", "1"); + this.parameters.put("result", "testResult"); + utils.substring(this.parameters, ctx); + assertEquals("estString", ctx.getAttribute("testResult")); + } + + @Test + public void testCtxBulkCopy() { + ctx.setAttribute("Mykey1", "MyValue1"); + ctx.setAttribute("Mykey2", "MyValue2"); + SliPluginUtils.ctxBulkCopy(ctx, "Mykey", "test."); + assertEquals("MyValue1", ctx.getAttribute("test.1")); + assertEquals("MyValue2", ctx.getAttribute("test.2")); + } + + @Test + public void testSetPropertiesForList() { + parameters.put("prefixKey", "testPrefixKey"); + parameters.put("valuePrefixKey", "testPrefixValue"); + parameters.put("keyName", "testKey"); + parameters.put("keyValue", "testValue"); + + assertEquals("success", SliPluginUtils.setPropertiesForList(parameters, ctx)); + + } } -- cgit 1.2.3-korg From 5b1e8ed247b7e23b1606908e38ee83858bec6082 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 2 Oct 2018 19:02:39 +0530 Subject: added test cases to SliStringUtilsTest to increase code coverage Issue-ID: CCSDK-595 Change-Id: Ice4f938166ab65ea316b683c3865dffc0483738c Signed-off-by: Sandeep J --- .../core/slipluginutils/SliStringUtilsTest.java | 501 +++++++++++---------- 1 file changed, 258 insertions(+), 243 deletions(-) diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index 9bf851d5d..085d46ef7 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -19,7 +19,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - */ + */ package org.onap.ccsdk.sli.core.slipluginutils; @@ -29,7 +29,7 @@ import static org.junit.Assert.assertThat; import java.util.HashMap; import java.util.Map; - + import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -40,246 +40,261 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; * */ public class SliStringUtilsTest { - private SvcLogicContext ctx; - private HashMap param; - private SliStringUtils stringUtils = new SliStringUtils(); - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - this.ctx = new SvcLogicContext(); - param = new HashMap(); - } - - /** - * @throws SvcLogicException - * @see SliStringUtils#split(Map, SvcLogicContext) - */ - @Test - public final void testSplit() throws SvcLogicException { - param.put("original_string", "one ## two ## three"); - param.put("regex", " ## "); - param.put("ctx_memory_result_key", "result"); - - stringUtils.split(param, ctx); - - assertThat(ctx.getAttribute("result[0]"), equalTo("one")); - assertThat(ctx.getAttribute("result[1]"), equalTo("two")); - assertThat(ctx.getAttribute("result[2]"), equalTo("three")); - assertThat(ctx.getAttribute("result_length"), equalTo("3")); - } - - /** - * @throws SvcLogicException - * @see SliStringUtils#split(Map, SvcLogicContext) - */ - @Test - public final void testSplit_limit() throws SvcLogicException { - param.put("original_string", "one ## two ## three"); - param.put("regex", " ## "); - param.put("limit", "2"); - param.put("ctx_memory_result_key", "result"); - - stringUtils.split(param, ctx); - - assertThat(ctx.getAttribute("result[0]"), equalTo("one")); - assertThat(ctx.getAttribute("result[1]"), equalTo("two ## three")); - assertThat(ctx.getAttribute("result_length"), equalTo("2")); - } - - @Test - public final void testSubString() throws SvcLogicException { - param.put("string","splitatgivenindex"); - param.put("begin-index","0"); - param.put("end-index","5"); - param.put("result","result"); - - stringUtils.substring(param, ctx); - - assertEquals("split", ctx.getAttribute("result")); - } - - @Test - public final void testQuotedOrNull() throws SvcLogicException { - //param.put("nullString",null); - assertEquals("NULL",SliStringUtils.quotedOrNULL(null)); - } - - @Test - public void equalsIgnoreCaseTrue() throws SvcLogicException { - String sourceString = "HeLlOwORLD"; - String targetSTring = "HELLOWORLD"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("true", SliStringUtils.equalsIgnoreCase(param, ctx)); - } - - @Test - public void equalsIgnoreCaseFalse() throws SvcLogicException { - String sourceString = "HeLlOwORLD"; - String targetSTring = "goodbyeWORLD"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("false", SliStringUtils.equalsIgnoreCase(param, ctx)); - } - - @Test - public void toUpper() throws SvcLogicException { - String sourceString = "HeLlOwORLD"; - param.put("source", sourceString); - String path = "my.unique.path."; - param.put("outputPath", path); - SliStringUtils.toUpper(param, ctx); - assertEquals(sourceString.toUpperCase(), ctx.getAttribute(path)); - } - - @Test - public void toLower() throws SvcLogicException { - String sourceString = "HeLlOwORLD"; - param.put("source", sourceString); - String path = "my.unique.path."; - param.put("outputPath", path); - SliStringUtils.toLower(param, ctx); - assertEquals(sourceString.toLowerCase(), ctx.getAttribute(path)); - } - - @Test - public void containsTrue() throws SvcLogicException { - String sourceString = "Pizza"; - String targetSTring = "izza"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("true", SliStringUtils.contains(param, ctx)); - } - - @Test - public void containsFalse() throws SvcLogicException { - String sourceString = "Pizza"; - String targetSTring = "muffin"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("false", SliStringUtils.contains(param, ctx)); - } - - @Test - public void endsWithTrue() throws SvcLogicException { - String sourceString = "Pizza"; - String targetSTring = "za"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("true", SliStringUtils.endsWith(param, ctx)); - } - - @Test - public void endsWithFalse() throws SvcLogicException { - String sourceString = "Pizza"; - String targetSTring = "muffin"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("false", SliStringUtils.endsWith(param, ctx)); - } - - @Test - public void trim() throws SvcLogicException { - String sourceString = " H E L L O W O R L D"; - String outputPath = "muffin"; - param.put("source", sourceString); - param.put("outputPath", outputPath); - SliStringUtils.trim(param, ctx); - assertEquals(sourceString.trim(), ctx.getAttribute(outputPath)); - } - - @Test - public void getLength() throws SvcLogicException { - String sourceString = "SomeRandomString"; - String outputPath = "muffin"; - param.put("source", sourceString); - param.put("outputPath", outputPath); - SliStringUtils.getLength(param, ctx); - assertEquals(String.valueOf(sourceString.length()), ctx.getAttribute(outputPath)); - } - - @Test - public void startsWithFalse() throws SvcLogicException { - String sourceString = "Java"; - String targetSTring = "DG"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("false", SliStringUtils.startsWith(param, ctx)); - } - - @Test - public void startsWithTrue() throws SvcLogicException { - String sourceString = "Java"; - String targetSTring = "Ja"; - param.put("source", sourceString); - param.put("target", targetSTring); - assertEquals("true", SliStringUtils.startsWith(param, ctx)); - } - - @Test - public void replace() throws SvcLogicException { - String sourceString = "cat Hello World cat"; - String old = "cat"; - String neww = "dog"; - String outputPath = "out"; - - param.put("source", sourceString); - param.put("target", old); - param.put("replacement", neww); - param.put("outputPath", outputPath); - SliStringUtils.replace(param, ctx); - assertEquals(sourceString.replace(old, neww), ctx.getAttribute(outputPath)); - } - - @Test - public void replaceAll() throws SvcLogicException { - String source = "cat Hello World cat"; - String target = "\\s"; - String replacement = ""; - String outputPath = "out"; - - param.put("source", source); - param.put("target", target); - param.put("replacement", replacement); - param.put("outputPath", outputPath); - SliStringUtils.replaceAll(param, ctx); - assertEquals(source.replaceAll(target, replacement), ctx.getAttribute(outputPath)); - } - - @Test - public void concat() throws SvcLogicException { - String sourceString = "cat"; - String targetString = "dog"; - String outputPath = "out"; - - param.put("source", sourceString); - param.put("target", targetString); - param.put("outputPath", outputPath); - SliStringUtils.concat(param, ctx); - assertEquals(sourceString + targetString, ctx.getAttribute(outputPath)); - } - - @Test - public void urlEncode() throws SvcLogicException { - String sourceString = "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"; - String outputPath = "out"; - - param.put("source", sourceString); - param.put("outputPath", outputPath); - SliStringUtils.urlEncode(param, ctx); - assertEquals("102%2FGE100%2FSNJSCAMCJP8%2FSNJSCAMCJT4", ctx.getAttribute(outputPath)); - } - - @Test - public void testXmlEscapeText() - { - param.put("source", "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"); - param.put("target", "target"); - SliStringUtils.xmlEscapeText(param,ctx); - assertEquals("102/GE100/SNJSCAMCJP8/SNJSCAMCJT4",ctx.getAttribute("target")); - } + private SvcLogicContext ctx; + private HashMap param; + private SliStringUtils stringUtils = new SliStringUtils(); + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + this.ctx = new SvcLogicContext(); + param = new HashMap(); + } + + /** + * @throws SvcLogicException + * @see SliStringUtils#split(Map, SvcLogicContext) + */ + @Test + public final void testSplit() throws SvcLogicException { + param.put("original_string", "one ## two ## three"); + param.put("regex", " ## "); + param.put("ctx_memory_result_key", "result"); + + stringUtils.split(param, ctx); + + assertThat(ctx.getAttribute("result[0]"), equalTo("one")); + assertThat(ctx.getAttribute("result[1]"), equalTo("two")); + assertThat(ctx.getAttribute("result[2]"), equalTo("three")); + assertThat(ctx.getAttribute("result_length"), equalTo("3")); + } + + /** + * @throws SvcLogicException + * @see SliStringUtils#split(Map, SvcLogicContext) + */ + @Test + public final void testSplit_limit() throws SvcLogicException { + param.put("original_string", "one ## two ## three"); + param.put("regex", " ## "); + param.put("limit", "2"); + param.put("ctx_memory_result_key", "result"); + + stringUtils.split(param, ctx); + + assertThat(ctx.getAttribute("result[0]"), equalTo("one")); + assertThat(ctx.getAttribute("result[1]"), equalTo("two ## three")); + assertThat(ctx.getAttribute("result_length"), equalTo("2")); + } + + @Test + public final void testSubString() throws SvcLogicException { + param.put("string", "splitatgivenindex"); + param.put("begin-index", "0"); + param.put("end-index", "5"); + param.put("result", "result"); + + stringUtils.substring(param, ctx); + + assertEquals("split", ctx.getAttribute("result")); + } + + @Test + public final void testQuotedOrNull() throws SvcLogicException { + // param.put("nullString",null); + assertEquals("NULL", SliStringUtils.quotedOrNULL(null)); + } + + @Test + public void equalsIgnoreCaseTrue() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + String targetSTring = "HELLOWORLD"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.equalsIgnoreCase(param, ctx)); + } + + @Test + public void equalsIgnoreCaseFalse() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + String targetSTring = "goodbyeWORLD"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.equalsIgnoreCase(param, ctx)); + } + + @Test + public void toUpper() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + param.put("source", sourceString); + String path = "my.unique.path."; + param.put("outputPath", path); + SliStringUtils.toUpper(param, ctx); + assertEquals(sourceString.toUpperCase(), ctx.getAttribute(path)); + } + + @Test + public void toLower() throws SvcLogicException { + String sourceString = "HeLlOwORLD"; + param.put("source", sourceString); + String path = "my.unique.path."; + param.put("outputPath", path); + SliStringUtils.toLower(param, ctx); + assertEquals(sourceString.toLowerCase(), ctx.getAttribute(path)); + } + + @Test + public void containsTrue() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "izza"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.contains(param, ctx)); + } + + @Test + public void containsFalse() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "muffin"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.contains(param, ctx)); + } + + @Test + public void endsWithTrue() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "za"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.endsWith(param, ctx)); + } + + @Test + public void endsWithFalse() throws SvcLogicException { + String sourceString = "Pizza"; + String targetSTring = "muffin"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.endsWith(param, ctx)); + } + + @Test + public void trim() throws SvcLogicException { + String sourceString = " H E L L O W O R L D"; + String outputPath = "muffin"; + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.trim(param, ctx); + assertEquals(sourceString.trim(), ctx.getAttribute(outputPath)); + } + + @Test + public void getLength() throws SvcLogicException { + String sourceString = "SomeRandomString"; + String outputPath = "muffin"; + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.getLength(param, ctx); + assertEquals(String.valueOf(sourceString.length()), ctx.getAttribute(outputPath)); + } + + @Test + public void startsWithFalse() throws SvcLogicException { + String sourceString = "Java"; + String targetSTring = "DG"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("false", SliStringUtils.startsWith(param, ctx)); + } + + @Test + public void startsWithTrue() throws SvcLogicException { + String sourceString = "Java"; + String targetSTring = "Ja"; + param.put("source", sourceString); + param.put("target", targetSTring); + assertEquals("true", SliStringUtils.startsWith(param, ctx)); + } + + @Test + public void replace() throws SvcLogicException { + String sourceString = "cat Hello World cat"; + String old = "cat"; + String neww = "dog"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("target", old); + param.put("replacement", neww); + param.put("outputPath", outputPath); + SliStringUtils.replace(param, ctx); + assertEquals(sourceString.replace(old, neww), ctx.getAttribute(outputPath)); + } + + @Test + public void replaceAll() throws SvcLogicException { + String source = "cat Hello World cat"; + String target = "\\s"; + String replacement = ""; + String outputPath = "out"; + + param.put("source", source); + param.put("target", target); + param.put("replacement", replacement); + param.put("outputPath", outputPath); + SliStringUtils.replaceAll(param, ctx); + assertEquals(source.replaceAll(target, replacement), ctx.getAttribute(outputPath)); + } + + @Test + public void concat() throws SvcLogicException { + String sourceString = "cat"; + String targetString = "dog"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("target", targetString); + param.put("outputPath", outputPath); + SliStringUtils.concat(param, ctx); + assertEquals(sourceString + targetString, ctx.getAttribute(outputPath)); + } + + @Test + public void urlEncode() throws SvcLogicException { + String sourceString = "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.urlEncode(param, ctx); + assertEquals("102%2FGE100%2FSNJSCAMCJP8%2FSNJSCAMCJT4", ctx.getAttribute(outputPath)); + } + + @Test + public void testXmlEscapeText() { + param.put("source", "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"); + param.put("target", "target"); + SliStringUtils.xmlEscapeText(param, ctx); + assertEquals("102/GE100/SNJSCAMCJP8/SNJSCAMCJT4", ctx.getAttribute("target")); + } + + @Test(expected = Exception.class) + public void testSplitForEmptyParams() throws Exception { + SliStringUtils utils = new SliStringUtils(); + ctx = new SvcLogicContext(); + param = new HashMap<>(); + utils.split(param, ctx); + } + + @Test(expected = Exception.class) + public void testSubstringForEmptyParams() throws Exception { + SliStringUtils utils = new SliStringUtils(); + ctx = new SvcLogicContext(); + param = new HashMap<>(); + utils.substring(param, ctx); + } } -- cgit 1.2.3-korg From a68b1d51bdb4b5fb8575b7029b86d2d1abbfdace Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 4 Oct 2018 19:18:28 +0000 Subject: throw an exception if an executor is missing If trying to execute a node of a type which has no registered executor throw an exception instead of continuing to execute Change-Id: Ic0a785e97ad85eb886f822e87a78347d9ea6563a Issue-ID: CCSDK-610 Signed-off-by: Smokowski, Kevin (ks6305) --- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 24 ++-------------------- 1 file changed, 2 insertions(+), 22 deletions(-) mode change 100644 => 100755 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java old mode 100644 new mode 100755 index d83bfebcf..000c2872d --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -70,6 +70,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { put("update", new UpdateNodeExecutor()); put("break", new BreakNodeExecutor()); put("while", new WhileNodeExecutor()); + } }; @@ -180,28 +181,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { executor.getClass().getName()); return (executor.execute(this, node, ctx)); } else { - if (LOG.isDebugEnabled()) { - LOG.debug("{} node not implemented", node.getNodeType()); - } - SvcLogicNode nextNode = node.getOutcomeValue("failure"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute failure branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no failure or Other branch found"); - } - } - return (nextNode); + throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type"); } } -- cgit 1.2.3-korg From 86e489058f5a8f75f0b8fbcbd0a3eca2dbcb4470 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 4 Oct 2018 20:12:40 +0000 Subject: implement exit node exit node functions similar to a return statement in most programming languages Change-Id: I2991590fb700b03a9f3d72ae0bc7b5dd9bb25f74 Issue-ID: CCSDK-611 Signed-off-by: Smokowski, Kevin (ks6305) --- .../onap/ccsdk/sli/core/sli/ExitNodeException.java | 46 ++ sli/common/src/main/resources/svclogic.xsd | 673 +++++++++++---------- sli/common/src/test/resources/svclogic.xsd | 71 ++- .../sli/core/sli/provider/ExitNodeExecutor.java | 42 ++ .../sli/core/sli/provider/SvcLogicServiceImpl.java | 45 +- 5 files changed, 500 insertions(+), 377 deletions(-) create mode 100755 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ExitNodeException.java create mode 100755 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ExitNodeException.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ExitNodeException.java new file mode 100755 index 000000000..f119c1812 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ExitNodeException.java @@ -0,0 +1,46 @@ +/*- + * ============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; + +public class ExitNodeException extends SvcLogicException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public ExitNodeException() + { + super(); + } + + public ExitNodeException(String message) + { + super(message); + } + + public ExitNodeException(String message, Throwable t) + { + super(message, t); + } + +} diff --git a/sli/common/src/main/resources/svclogic.xsd b/sli/common/src/main/resources/svclogic.xsd index 2704de88e..c9beae83e 100755 --- a/sli/common/src/main/resources/svclogic.xsd +++ b/sli/common/src/main/resources/svclogic.xsd @@ -1,334 +1,339 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sli/common/src/test/resources/svclogic.xsd b/sli/common/src/test/resources/svclogic.xsd index 2704de88e..3e109c7c2 100755 --- a/sli/common/src/test/resources/svclogic.xsd +++ b/sli/common/src/test/resources/svclogic.xsd @@ -31,13 +31,14 @@ + - + @@ -47,7 +48,7 @@ - + @@ -57,7 +58,7 @@ - + @@ -66,7 +67,7 @@ - + @@ -78,7 +79,7 @@ - + @@ -90,7 +91,7 @@ - + @@ -101,8 +102,8 @@ - - + + @@ -115,7 +116,7 @@ - + @@ -127,8 +128,8 @@ - - + + @@ -138,8 +139,8 @@ - - + + @@ -152,8 +153,8 @@ - - + + @@ -169,8 +170,8 @@ - - + + @@ -190,7 +191,7 @@ - + @@ -199,7 +200,7 @@ - + @@ -208,8 +209,8 @@ - - + + @@ -224,8 +225,8 @@ - - + + @@ -242,7 +243,7 @@ - + @@ -255,7 +256,7 @@ - + @@ -265,8 +266,8 @@ - - + + @@ -277,8 +278,8 @@ - - + + @@ -293,8 +294,8 @@ - - + + @@ -306,7 +307,7 @@ - + @@ -321,10 +322,14 @@ + + + + - + diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java new file mode 100755 index 000000000..fc667f40b --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java @@ -0,0 +1,42 @@ +/*- + * ============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.provider; + +import org.onap.ccsdk.sli.core.sli.ExitNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExitNodeExecutor extends SvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(ExitNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + String message = "ExitNodeExecutor encountered exit with nodeId " + node.getNodeId(); + LOG.debug(message); + throw new ExitNodeException(message); + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 000c2872d..0a2869580 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Properties; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.ExitNodeException; import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; @@ -70,7 +71,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { put("update", new UpdateNodeExecutor()); put("break", new BreakNodeExecutor()); put("while", new WhileNodeExecutor()); - + put("exit", new ExitNodeExecutor()); } }; @@ -151,14 +152,17 @@ public class SvcLogicServiceImpl implements SvcLogicService { SvcLogicNode curNode = graph.getRootNode(); LOG.info("About to execute graph {}", graph.toString()); - - while (curNode != null) { - MDC.put("nodeId", curNode.getNodeId() + " (" + curNode.getNodeType() + ")"); - LOG.info("About to execute node # {} ({})", curNode.getNodeId(), curNode.getNodeType()); - - SvcLogicNode nextNode = executeNode(curNode, ctx); - curNode = nextNode; - } + try { + while (curNode != null) { + MDC.put("nodeId", curNode.getNodeId() + " (" + curNode.getNodeType() + ")"); + LOG.info("About to execute node # {} ({})", curNode.getNodeId(), curNode.getNodeType()); + + SvcLogicNode nextNode = executeNode(curNode, ctx); + curNode = nextNode; + } + } catch (ExitNodeException e) { + LOG.debug("SvcLogicServiceImpl caught ExitNodeException"); + } MDC.remove("nodeId"); MDC.remove("currentGraph"); @@ -181,7 +185,28 @@ public class SvcLogicServiceImpl implements SvcLogicService { executor.getClass().getName()); return (executor.execute(this, node, ctx)); } else { - throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type"); + if (LOG.isDebugEnabled()) { + LOG.debug("{} node not implemented", node.getNodeType()); + } + SvcLogicNode nextNode = node.getOutcomeValue("failure"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute failure branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no failure or Other branch found"); + } + } + return (nextNode); } } -- cgit 1.2.3-korg From c153dbc5e9583b79d67a20522b2a4664644df62c Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 4 Oct 2018 18:55:57 +0000 Subject: callnode handling updates throw an exception if graph isnt found when executing a call node Change-Id: I10158cbcd5ba5787e710bfb6161e7e04cbf46577 Issue-ID: CCSDK-609 Signed-off-by: Smokowski, Kevin (ks6305) --- .../sli/core/sli/provider/CallNodeExecutor.java | 21 +++++++++++++---- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 23 +------------------ .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 26 ++++++++++++++++------ 3 files changed, 37 insertions(+), 33 deletions(-) mode change 100644 => 100755 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java old mode 100644 new mode 100755 index 6036c38ac..c8e6548fd --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java @@ -118,16 +118,18 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { ctx.setAttribute("parentGraph", parentGraph); SvcLogicStore store = svc.getStore(); - - if (store != null) { + String errorMessage = "Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found"; + boolean graphWasCalled = false; + if (store != null) { SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); if (calledGraph != null) { LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); ctx.setAttribute("currentGraph", calledGraph.toString()); svc.execute(calledGraph, ctx); outValue = ctx.getStatus(); + graphWasCalled = true; } else { - LOG.debug("Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found"); + LOG.debug(errorMessage); } } else { LOG.debug("Could not get SvcLogicStore reference"); @@ -152,7 +154,18 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor { LOG.debug("no " + outValue + " or Other branch found"); } } - ctx.setAttribute("currentGraph", parentGraph); + + if (graphWasCalled == false) { + if (node.getOutcomeValue("catch") != null) { + nextNode = node.getOutcomeValue("catch"); + LOG.debug("graph could not be called, but catch node was found and will be executed"); + } else { + LOG.debug("graph could not be called and no catch node was found, throwing exception"); + throw new SvcLogicException(errorMessage); + } + } + + ctx.setAttribute("currentGraph", parentGraph); ctx.setAttribute("parentGraph", null); return (nextNode); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index d83bfebcf..15c447866 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -180,28 +180,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { executor.getClass().getName()); return (executor.execute(this, node, ctx)); } else { - if (LOG.isDebugEnabled()) { - LOG.debug("{} node not implemented", node.getNodeType()); - } - SvcLogicNode nextNode = node.getOutcomeValue("failure"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute failure branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no failure or Other branch found"); - } - } - return (nextNode); + throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type"); } } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index d8698860f..445df36f6 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -136,19 +136,21 @@ public class ITCaseSvcLogicGraphExecutor { Properties svcprops = new Properties(); svcprops.load(propStr); - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); - assertNotNull(store); - SvcLogicParser parser = new SvcLogicParser(); // Loop through executor tests - SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl(); - + SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider() { + @Override + public Properties getProperties() { + return svcprops; + } + }; SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); - + SvcLogicStore store = svc.getStore(); + assertNotNull(store); for (String nodeType : BUILTIN_NODES.keySet()) { LOG.info("SLI - registering node executor for node type {}", nodeType); @@ -203,7 +205,17 @@ public class ITCaseSvcLogicGraphExecutor { assertNotNull(graphs); // Load grqphs into db to support call node - parser.load(testCaseUrl.getPath(), store); + SvcLogicParser.load(testCaseUrl.getPath(), store); + SvcLogicParser.activate("neutron", "canCreateNetwork", "1.0.0", "sync", store); + SvcLogicParser.activate("neutron", "switchTester", "1.0.0", "sync", store); + SvcLogicParser.activate("neutron", "forRecordTester", "1.0.0", "sync", store); + SvcLogicParser.activate("neutron", "whileNodeTester", "1.0.0", "sync", store); + SvcLogicParser.activate("neutron", "resourceTester", "1.0.0", "sync", store); + SvcLogicParser.activate("neutron", "configureTester", "1.0.0", "sync", store); + SvcLogicParser.activate("neutron", "javaPluginTester", "1.0.0", "sync", store); + SvcLogicParser.activate("neutron", "allNodesTester", "1.0.0", "sync", store); + SvcLogicParser.activate("neutron", "networkCreated", "1.0.0", "sync", store); + for (SvcLogicGraph graph : graphs) { if (graph.getRpc().equals(testCaseMethod)) { Properties props = ctx.toProperties(); -- cgit 1.2.3-korg From 7c523d1f7011e84fd7a473af1a89df02f41cd5fa Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 10 Oct 2018 16:20:50 -0400 Subject: Prepare sli/core for RC0 release Remove -STAGING tag and update parent poms to correct release version (1.1.1) Change-Id: I16d4a5c07fe6e3e2bf997fff417242aa6184f89e Issue-ID: CCSDK-617 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliPluginUtils/provider/testFileName | 1 + sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/ccsdk-slicore-utils/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- version.properties | 2 +- 47 files changed, 47 insertions(+), 46 deletions(-) create mode 100644 sliPluginUtils/provider/testFileName diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 7cf80043d..b81545183 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1 diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 4a5b50f3d..ed5faf2cc 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1 diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 73464775b..fa3e7579a 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 39730f925..40e5babf0 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/dblib/pom.xml b/dblib/pom.xml index 21c805360..7f9de4b75 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 4e785a10c..6dd36bd60 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index f67c7c052..8323cb953 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1 diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 7e6243faa..5e2e95d93 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 6a341d9a9..74662d598 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/features/pom.xml b/features/pom.xml index 0cb15b3ad..37f1d9c1e 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index b38b348bd..b5f8bc6ed 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1 diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index d82911f27..4d1daffce 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1 diff --git a/filters/features/pom.xml b/filters/features/pom.xml index c85339349..d36a70f7c 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index c34fc2585..79dc8c899 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/filters/pom.xml b/filters/pom.xml index 2d6f1611a..23ff23f1a 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index b6ae79739..a71abf67f 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/pom.xml b/pom.xml index 78136b22c..efaeed723 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index d16ce033b..2ecc0f10a 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 729e24ea5..ea91056f7 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1 diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 0e0265efa..a40091abe 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 734c342c0..9d0ae7377 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 0a70cf9fe..0bce34623 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index bfb4c2492..dc6d2d286 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/sli/pom.xml b/sli/pom.xml index c03e1dadd..bc90782ac 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 0e343c804..0a0ba4a1e 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 7c1682e17..dab91e959 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 3e15fa449..b47e9c655 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1 diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 60d563f72..349670345 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1 diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 2194f8ec5..09d231fdf 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index e30e9d26e..3d62120a0 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index da646177e..c66e60556 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 4b7fe9520..d6bff022d 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/sliPluginUtils/provider/testFileName b/sliPluginUtils/provider/testFileName new file mode 100644 index 000000000..674e20cc7 --- /dev/null +++ b/sliPluginUtils/provider/testFileName @@ -0,0 +1 @@ +####################################### diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 99d5973e0..90f5a35e7 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1 diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index f907d54d9..58e344add 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1 diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 0f5772398..d4bf94653 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 5a60f1b09..4c1361aec 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 5a0c5e238..37055c0d8 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 60dc94aaf..29fb9bdbf 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 280b2131e..157af5fca 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index e530cdc5c..b06c9b5b3 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.0 + 1.1.1 diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 713ba4da3..ac2711c29 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.0 + 1.1.1 diff --git a/utils/features/pom.xml b/utils/features/pom.xml index dca1b801f..c644defa0 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 473c4a571..a6d4356b8 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -7,7 +7,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/utils/pom.xml b/utils/pom.xml index cbdcdad7d..a5131db42 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.0 + 1.1.1 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 678ce1bb3..31d3f21e4 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.1.0 + 1.1.1 diff --git a/version.properties b/version.properties index 407a30cd3..e5ea9c747 100644 --- a/version.properties +++ b/version.properties @@ -10,6 +10,6 @@ feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version}-STAGING +release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg From da6f11333d8a7d0abafe780e4d1b86cf5ab87618 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Mon, 22 Oct 2018 09:32:19 -0400 Subject: Roll to first Dublin snapshot Roll to first Dublin snapshot Change-Id: I7066b4c4359f6c700c2b8036fd67a1a3bd66cf1e Issue-ID: CCSDK-617 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/ccsdk-slicore-utils/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 6 +++--- 46 files changed, 91 insertions(+), 91 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index b81545183..23bf11704 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index ed5faf2cc..456822ca0 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index fa3e7579a..738fdb08b 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 40e5babf0..78099e730 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 7f9de4b75..d71f35a89 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 6dd36bd60..55e5619c6 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 8323cb953..447b2034c 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 5e2e95d93..38d2715e1 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 74662d598..3eb283378 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 37f1d9c1e..2c098434a 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index b5f8bc6ed..a56f27341 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 4d1daffce..a8c0e7550 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index d36a70f7c..d3f9ecd8d 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 79dc8c899..7fe64220e 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 23ff23f1a..1182f2bd7 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index a71abf67f..76898e2f9 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index efaeed723..aa05c6481 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 2ecc0f10a..a8bb2f6b9 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index ea91056f7..2d29070ea 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index a40091abe..8d50d8b84 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 9d0ae7377..445e917f5 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 0bce34623..99b4a400c 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index dc6d2d286..5a60ce2bd 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index bc90782ac..7b1fd9d2b 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 0a0ba4a1e..3bf931a7e 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index dab91e959..593db5b87 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index b47e9c655..18fd8c3ca 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 349670345..7aaa53e02 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 09d231fdf..fb90b9ec9 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 3d62120a0..5d38c0283 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index c66e60556..244767d7e 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index d6bff022d..5f7be7605 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 90f5a35e7..fe7625a04 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 58e344add..2cf38447b 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index d4bf94653..fb267583d 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 4c1361aec..d8a56b8dd 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 37055c0d8..bb84b87db 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 29fb9bdbf..eb02ee850 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 157af5fca..e6ffaa9d5 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -6,13 +6,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index b06c9b5b3..c019687d2 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index ac2711c29..5b038695b 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index c644defa0..301173993 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index a6d4356b8..902120ae3 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -7,13 +7,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index a5131db42..68f20cb7a 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 31d3f21e4..e4c446b59 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.1.1 + 1.2.0-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index e5ea9c747..aa6328e0e 100644 --- a/version.properties +++ b/version.properties @@ -5,11 +5,11 @@ release_name=0 -sprint_number=3 -feature_revision=1 +sprint_number=4 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version} +release_version=${base_version}-STAGING snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg From 1537af8ec53887628f82b118b782a122046bc5ed Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 24 Oct 2018 21:26:12 +0000 Subject: mdsalhelper patch fix mdsalhelper handling of certain types when calling to builder Change-Id: I01c1df75ad71426a891ea885ac3f7631d1b28c1b Issue-ID: CCSDK-626 Signed-off-by: Smokowski, Kevin (ks6305) --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 2530 ++++++++++---------- .../sli/core/sli/provider/MdsalHelperTest.java | 438 ++-- .../opendaylight/yang/gen/v1/test/TestObject.java | 17 + .../yang/gen/v1/test/TestObjectBuilder.java | 134 ++ 4 files changed, 1669 insertions(+), 1450 deletions(-) mode change 100644 => 100755 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java mode change 100644 => 100755 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java create mode 100755 sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObject.java create mode 100755 sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObjectBuilder.java diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java old mode 100644 new mode 100755 index f87b7d3c3..bfbe9f974 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -48,537 +48,441 @@ import org.slf4j.LoggerFactory; public class MdsalHelper { - private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); - private static Properties yangMappingProperties = new Properties(); - - @Deprecated - public static void setProperties(Properties input) { - setYangMappingProperties(input); - } - - @Deprecated - public static void setYangMappingProperties(Properties properties) { - for (Object propNameObj : properties.keySet()) { - String propName = (String) propNameObj; - MdsalHelper.yangMappingProperties.setProperty(propName, properties.getProperty(propName)); - } - } - - @Deprecated - public static void loadProperties(String propertiesFile) { - File file = new File(propertiesFile); - Properties properties = new Properties(); - if (file.isFile() && file.canRead()) { - try (InputStream input = new FileInputStream(file)) { - properties.load(input); - MdsalHelper.setYangMappingProperties(properties); - LOG.info("Loaded properties from " + propertiesFile); - } catch (Exception e) { - LOG.error("Failed to load properties " + propertiesFile + "\n", e); - } - } else { - LOG.error("Failed to load the properties file " + propertiesFile + "\n"); - LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); - } - } - - public static Properties toProperties(Properties props, Object fromObj) { - return toProperties(props, fromObj, false); - } - - public static Properties toProperties(Properties props, Object fromObj, Boolean useLegacyEnumerationMapping) { - Class fromClass = null; - - if (fromObj != null) { - fromClass = fromObj.getClass(); - } - return toProperties(props, "", fromObj, fromClass,useLegacyEnumerationMapping ); - } - - public static Properties toProperties(Properties props, String pfx, Object fromObj) { - return toProperties(props, pfx, fromObj, false); - } - + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); + private static Properties yangMappingProperties = new Properties(); + + @Deprecated + public static void setProperties(Properties input) { + setYangMappingProperties(input); + } + + @Deprecated + public static void setYangMappingProperties(Properties properties) { + for (Object propNameObj : properties.keySet()) { + String propName = (String) propNameObj; + MdsalHelper.yangMappingProperties.setProperty(propName, properties.getProperty(propName)); + } + } + + @Deprecated + public static void loadProperties(String propertiesFile) { + File file = new File(propertiesFile); + Properties properties = new Properties(); + if (file.isFile() && file.canRead()) { + try (InputStream input = new FileInputStream(file)) { + properties.load(input); + MdsalHelper.setYangMappingProperties(properties); + LOG.info("Loaded properties from " + propertiesFile); + } catch (Exception e) { + LOG.error("Failed to load properties " + propertiesFile + "\n", e); + } + } else { + LOG.error("Failed to load the properties file " + propertiesFile + "\n"); + LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); + } + } + + public static Properties toProperties(Properties props, Object fromObj) { + return toProperties(props, fromObj, false); + } + + public static Properties toProperties(Properties props, Object fromObj, Boolean useLegacyEnumerationMapping) { + Class fromClass = null; + + if (fromObj != null) { + fromClass = fromObj.getClass(); + } + return toProperties(props, "", fromObj, fromClass, useLegacyEnumerationMapping); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj) { + return toProperties(props, pfx, fromObj, false); + } + public static Properties toProperties(Properties props, String pfx, Object fromObj, Boolean useLegacyEnumerationMapping) { - Class fromClass = null; + Class fromClass = null; + + if (fromObj != null) { + fromClass = fromObj.getClass(); + } - if (fromObj != null) { - fromClass = fromObj.getClass(); - } + return toProperties(props, pfx, fromObj, fromClass, useLegacyEnumerationMapping); + } - return toProperties(props, pfx, fromObj, fromClass, useLegacyEnumerationMapping); - } + public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { + return toProperties(props, pfx, fromObj, fromClass, false); + } - public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { - return toProperties(props, pfx, fromObj, fromClass, false); - } - public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass, Boolean useLegacyEnumerationMapping) { - if (fromObj == null) { - return props; - } - - LOG.trace("Extracting properties from " + fromClass.getName() + " class"); - if (fromObj instanceof List) { - - // Class is a List. List should contain yang-generated classes. - LOG.trace(fromClass.getName() + " is a List"); - - List fromList = (List) fromObj; - - for (int i = 0; i < fromList.size(); i++) { - toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass, useLegacyEnumerationMapping); - } - props.setProperty(pfx + "_length", Integer.toString(fromList.size())); - - } else if (isYangGenerated(fromClass)) { - // Class is yang generated. - LOG.trace(fromClass.getName() + " is a Yang-generated class"); - - String propNamePfx = null; - - // If called from a list (so prefix ends in ']'), don't - // add class name again - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx; - } else { - propNamePfx = toLowerHyphen(fromClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - // Iterate through getter methods to figure out values we need to - // save from - - int numGetters = 0; - String lastGetterName = null; - String propVal = null; - - for (Method m : fromClass.getMethods()) { - if (isGetter(m)) { - - numGetters++; - lastGetterName = m.getName(); - - Class returnType = m.getReturnType(); - String fieldName; - if (m.getName().startsWith("get")) { - fieldName = toLowerHyphen(m.getName().substring(3)); - } else { - - fieldName = toLowerHyphen(m.getName().substring(2)); - } - - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - // Is the return type a yang generated class? - if (isYangGenerated(returnType)) { - // Is it an enum? - if (returnType.isEnum()) { - // Return type is a typedef. Save its value. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - Object retValue = m.invoke(fromObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - String propName = propNamePfx + "." + fieldName; - if(useLegacyEnumerationMapping) { - propVal = retValue.toString(); - props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); - }else { - Method method = retValue.getClass().getMethod("getName"); - String yangValue = (String) method.invoke(retValue); - props.setProperty(propName, yangValue); - } - - } - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert Yang-generated enum returned by " - + fromClass.getName() + "." + m.getName() + "() to Properties entry", - e); - } - } else if (isIpv4Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = retValue.getValue().toString(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpv6Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = retValue.getValue().toString(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpAddress(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - IpAddress retValue = (IpAddress) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = new String(retValue.getValue()); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } else if (isIpPrefix(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - IpPrefix retValue = (IpPrefix) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = new String(retValue.getValue()); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } else if (isPortNumber(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - PortNumber retValue = (PortNumber) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = "" + retValue.getValue(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } else if (isDscp(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Dscp retValue = (Dscp) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - propVal = "" + retValue.getValue(); - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retValue = m.invoke(fromObj); - - if (retValue instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); - retValue = new String((byte[]) retValue, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " - + retValue); - } - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { + if (fromObj == null) { + return props; + } + String simpleTypeName = fromObj.getClass().getTypeName(); + simpleTypeName = simpleTypeName.substring(simpleTypeName.lastIndexOf(".") + 1); + LOG.trace("Extracting properties from " + fromClass.getName() + " class"); + if (classHasSpecialHandling(simpleTypeName)) { + try { + Method m = fromClass.getMethod("getValue", null); + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + if (retValue != null) { + String propVal = null; + if ("IpAddress".equals(simpleTypeName) || "IpPrefix".equals(simpleTypeName)) { + propVal = String.valueOf((char[]) retValue); + } else if ("Ipv4Address".equals(simpleTypeName) || "Ipv6Address".equals(simpleTypeName)) { + propVal = (String) retValue; + } else if ("Dscp".equals(simpleTypeName)) { + propVal = String.valueOf((short) retValue); + } else if ("PortNumber".equals(simpleTypeName)) { + propVal = String.valueOf((Integer) retValue); + } + LOG.debug("Setting property " + pfx + " to " + propVal); + props.setProperty(pfx, propVal); + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + ".getValue() to Properties entry", e); + } + } else if (fromObj instanceof List) { + + // Class is a List. List should contain yang-generated classes. + LOG.trace(fromClass.getName() + " is a List"); + + List fromList = (List) fromObj; + + for (int i = 0; i < fromList.size(); i++) { + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass, useLegacyEnumerationMapping); + } + props.setProperty(pfx + "_length", Integer.toString(fromList.size())); + + } else if (isYangGenerated(fromClass)) { + // Class is yang generated. + LOG.trace(fromClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + + // If called from a list (so prefix ends in ']'), don't + // add class name again + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx; + } else { + propNamePfx = toLowerHyphen(fromClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // save from + + int numGetters = 0; + String lastGetterName = null; + String propVal = null; + + for (Method m : fromClass.getMethods()) { + if (isGetter(m)) { + + numGetters++; + lastGetterName = m.getName(); + + Class returnType = m.getReturnType(); + String fieldName; + if (m.getName().startsWith("get")) { + fieldName = toLowerHyphen(m.getName().substring(3)); + } else { + + fieldName = toLowerHyphen(m.getName().substring(2)); + } + + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + // Is the return type a yang generated class? + if (isYangGenerated(returnType)) { + // Is it an enum? + if (returnType.isEnum()) { + // Return type is a typedef. Save its value. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + Object retValue = m.invoke(fromObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + String propName = propNamePfx + "." + fieldName; + if (useLegacyEnumerationMapping) { + propVal = retValue.toString(); + props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); + } else { + Method method = retValue.getClass().getMethod("getName"); + String yangValue = (String) method.invoke(retValue); + props.setProperty(propName, yangValue); + } + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated enum returned by " + + fromClass.getName() + "." + m.getName() + "() to Properties entry", + e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + + if (retValue instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + retValue = new String((byte[]) retValue, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + + retValue); + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { toProperties(props, propNamePfx + "." + fieldName, retValue, returnType, useLegacyEnumerationMapping); - } - } catch (Exception e) { - - if (m.getName().equals("getKey")) { - LOG.trace("Caught " + e.getClass().getName() - + " exception trying to convert results from getKey() - ignoring"); - } else { - LOG.error("Caught exception trying to convert Yang-generated class returned by" - + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - } else if (returnType.equals(Class.class)) { - - LOG.trace(m.getName() + " returns a Class object - not interested"); - - } else if (List.class.isAssignableFrom(returnType)) { - - // This getter method returns a list. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retList = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - // Figure out what type of elements are stored in - // this array. - Type paramType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + } + } catch (Exception e) { + + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert Yang-generated class returned by" + + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } else if (returnType.equals(Class.class)) { + + LOG.trace(m.getName() + " returns a Class object - not interested"); + + } else if (List.class.isAssignableFrom(returnType)) { + + // This getter method returns a list. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retList = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + // Figure out what type of elements are stored in + // this array. + Type paramType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType, useLegacyEnumerationMapping); - } catch (Exception e) { - LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." - + m.getName() + "() to Properties entry", e); - } - - } else { - - // Method returns something that is not a List and not - // yang-generated. - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object propValObj = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (propValObj != null) { - if (propValObj instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); - propVal = new String((byte[]) propValObj, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " - + propVal); - - } else { - propVal = propValObj.toString(); - } - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - if (m.getName().equals("getKey")) { - LOG.trace("Caught " + e.getClass().getName() - + " exception trying to convert results from getKey() - ignoring"); - } else { - LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } - } - - } - } - - // End of method loop. If there was only one getter, named - // "getValue", then - // set value identified by "prefix" to that one value. - if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { - LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx - + " = " + propVal); - props.setProperty(propNamePfx, propVal); - } else { - LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " - + lastGetterName); - - } - - } else { - // Class is not yang generated and not a list - // It must be an element of a leaf list - set "prefix" to value - String fromVal = null; - if (fromObj instanceof byte[]) { - try { - fromVal = new String((byte[]) fromObj, "UTF-8"); - LOG.trace("Converted byte array " + pfx + "to string " + fromVal); - } catch (Exception e) { - LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); - fromVal = fromObj.toString(); - } - - } else { - fromVal = fromObj.toString(); - } - LOG.debug("Setting property " + pfx + " to " + fromVal); - props.setProperty(pfx, fromVal); - } - - return (props); - } - - public static Object toBuilder(Properties props, Object toObj) { - - return (toBuilder(props, "", toObj)); - } - - public static List toList(Properties props, String pfx, List toObj, Class elemType) { - - int maxIdx = -1; - boolean foundValue = false; - - LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); - - if (props.contains(pfx + "_length")) { - try { - int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); - - if (listLength > 0) { - maxIdx = listLength - 1; - } - } catch (NumberFormatException e) { - LOG.info("Invalid input for length ", e); - } - } - - if (maxIdx == -1) { - // Figure out array size - for (Object pNameObj : props.keySet()) { - String key = (String) pNameObj; - - if (key.startsWith(pfx + "[")) { - String idxStr = key.substring(pfx.length() + 1); - int endloc = idxStr.indexOf("]"); - if (endloc != -1) { - idxStr = idxStr.substring(0, endloc); - } - - try { - int curIdx = Integer.parseInt(idxStr); - if (curIdx > maxIdx) { - maxIdx = curIdx; - } - } catch (Exception e) { - LOG.error("Illegal subscript in property {}", key, e); - } - - } - } - } - - LOG.trace(pfx + " has max index of " + maxIdx); - for (int i = 0; i <= maxIdx; i++) { - - String curBase = pfx + "[" + i + "]"; - - if (isYangGenerated(elemType)) { - - if (isIpAddress(elemType) || isIpv4Address(elemType) || isIpv6Address(elemType)) { - - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(IpAddressBuilder.getDefaultInstance(curValue)); - foundValue = true; - } - } else if (isIpPrefix(elemType)) { - - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(IpPrefixBuilder.getDefaultInstance(curValue)); - foundValue = true; - } - } else if (isPortNumber(elemType)) { - - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(PortNumber.getDefaultInstance(curValue)); - foundValue = true; - } - } else if (isDscp(elemType)) { - - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(Dscp.getDefaultInstance(curValue)); - foundValue = true; - } + } catch (Exception e) { + LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." + + m.getName() + "() to Properties entry", e); + } + + } else { + + // Method returns something that is not a List and not + // yang-generated. + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object propValObj = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (propValObj != null) { + if (propValObj instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + propVal = new String((byte[]) propValObj, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + + propVal); + + } else { + propVal = propValObj.toString(); + } + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } + } + } + + } + } + + // End of method loop. If there was only one getter, named + // "getValue", then + // set value identified by "prefix" to that one value. + if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { + LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + + " = " + propVal); + props.setProperty(propNamePfx, propVal); + } else { + LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " + + lastGetterName); + + } + + } else { + // Class is not yang generated and not a list + // It must be an element of a leaf list - set "prefix" to value + String fromVal = null; + if (fromObj instanceof byte[]) { + try { + fromVal = new String((byte[]) fromObj, "UTF-8"); + LOG.trace("Converted byte array " + pfx + "to string " + fromVal); + } catch (Exception e) { + LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); + fromVal = fromObj.toString(); + } + + } else { + fromVal = fromObj.toString(); + } + LOG.debug("Setting property " + pfx + " to " + fromVal); + props.setProperty(pfx, fromVal); + } + + return (props); + } + + public static Object toBuilder(Properties props, Object toObj) { + + return (toBuilder(props, "", toObj)); + } + + public static List toList(Properties props, String pfx, List toObj, Class elemType) { + + int maxIdx = -1; + boolean foundValue = false; + + LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); + + if (props.contains(pfx + "_length")) { + try { + int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); + + if (listLength > 0) { + maxIdx = listLength - 1; + } + } catch (NumberFormatException e) { + LOG.info("Invalid input for length ", e); + } + } + + if (maxIdx == -1) { + // Figure out array size + for (Object pNameObj : props.keySet()) { + String key = (String) pNameObj; + + if (key.startsWith(pfx + "[")) { + String idxStr = key.substring(pfx.length() + 1); + int endloc = idxStr.indexOf("]"); + if (endloc != -1) { + idxStr = idxStr.substring(0, endloc); + } + + try { + int curIdx = Integer.parseInt(idxStr); + if (curIdx > maxIdx) { + maxIdx = curIdx; + } + } catch (Exception e) { + LOG.error("Illegal subscript in property {}", key, e); + } + + } + } + } + + LOG.trace(pfx + " has max index of " + maxIdx); + for (int i = 0; i <= maxIdx; i++) { + + String curBase = pfx + "[" + i + "]"; + + if (isYangGenerated(elemType)) { + + if (isIpAddress(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(IpAddressBuilder.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isIpv4Address(elemType)) { + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(new Ipv4Address(curValue)); + foundValue = true; + } + + } else if (isIpv6Address(elemType)) { + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(new Ipv6Address(curValue)); + foundValue = true; + } + } else if (isIpPrefix(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(IpPrefixBuilder.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isPortNumber(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(PortNumber.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isDscp(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(Dscp.getDefaultInstance(curValue)); + foundValue = true; + } } else { String builderName = elemType.getName() + "Builder"; try { @@ -600,813 +504,823 @@ public class MdsalHelper { LOG.error("Caught exception trying to populate list from {}", pfx, e); } } - } else { - // Must be a leaf list - String curValue = props.getProperty(curBase, ""); + } else { + // Must be a leaf list + String curValue = props.getProperty(curBase, ""); - toObj.add(curValue); + toObj.add(curValue); + + if ((curValue != null) && (curValue.length() > 0)) { + foundValue = true; + } + } - if ((curValue != null) && (curValue.length() > 0)) { - foundValue = true; - } - } + } - } + if (foundValue) { + return (toObj); + } else { + return (null); + } - if (foundValue) { - return (toObj); - } else { - return (null); - } + } - } + public static Object toBuilder(Properties props, String pfx, Object toObj) { + return (toBuilder(props, pfx, toObj, false)); + } - public static Object toBuilder(Properties props, String pfx, Object toObj) { - return (toBuilder(props, pfx, toObj, false)); - } + public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { - public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { - Class toClass = toObj.getClass(); - boolean foundValue = false; + Class toClass = toObj.getClass(); + boolean foundValue = false; - LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); + LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); Ipv4Address addr; if (isYangGenerated(toClass)) { - // Class is yang generated. + // Class is yang generated. LOG.trace(toClass.getName() + " is a Yang-generated class"); - String propNamePfx = null; - if (preservePfx) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - if (toObj instanceof Identifier) { - LOG.trace(toClass.getName() + " is a Key - skipping"); - return (toObj); - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - if (isSetter(m)) { - Class paramTypes[] = m.getParameterTypes(); - Class paramClass = paramTypes[0]; - - String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - - String paramValue = props.getProperty(propName); - if (paramValue == null) { - LOG.trace(propName + " is unset"); - } else if ("".equals(paramValue)) { - LOG.trace(propName + " was set to the empty string, setting it to null"); - paramValue = null; - } else { - LOG.trace(propName + " = " + paramValue); - } - - // Is the return type a yang generated class? - if (isYangGenerated(paramClass)) { - // Is it an enum? - if (paramClass.isEnum()) { - - LOG.trace(m.getName() + " expects an Enum"); - // Param type is a typedef. - if ((paramValue != null) && (paramValue.length() > 0)) { - Object paramObj = null; - - try { - paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); - } catch (Exception e) { - LOG.error("Caught exception trying to convert field " + propName + " to enum " - + paramClass.getName(), e); - } - - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to create Yang-generated enum expected by" - + toClass.getName() + "." + m.getName() + "() from Properties entry", e); - } - } - } else { - - String simpleName = paramClass.getSimpleName(); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || "IpAddress".equals(simpleName)) { - - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); - - if ("Ipv4Address".equals(simpleName)) { - m.invoke(toObj, ipAddr.getIpv4Address()); - } else if ("Ipv6Address".equals(simpleName)) { - m.invoke(toObj, ipAddr.getIpv6Address()); - - } else { - m.invoke(toObj, ipAddr); - } - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to call " + toClass.getName() + "." - + m.getName() + "() with Properties entry", e); - } - } - } else if ("IpPrefix".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); - m.invoke(toObj, ipPrefix); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - } - } - } else if ("PortNumber".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - PortNumber portNumber = PortNumber.getDefaultInstance(paramValue); - m.invoke(toObj, portNumber); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - } - } - } else if ("Dscp".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - Dscp dscp = Dscp.getDefaultInstance(paramValue); - m.invoke(toObj, dscp); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - } - } - } else { - // setter expects a yang-generated class. Need - // to - // create a builder to set it. - - String builderName = paramClass.getName() + "Builder"; - Class builderClass = null; - Object builderObj = null; - Object paramObj = null; - - Object constObj = null; - - LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " - + builderName); - try { - builderClass = Class.forName(builderName); - builderObj = builderClass.newInstance(); - paramObj = toBuilder(props, propNamePfx, builderObj); - } catch (ClassNotFoundException e) { - LOG.info("Builder class {} not found ", builderName, e); - if (paramValue == null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() - + "(null)"); - m.invoke(toObj, new Object[] {null}); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e1) { - LOG.error("Caught exception trying to cally" + toClass.getName() + "." - + m.getName() + "() with Properties entry", e1); - } - } else { - try { - // See if I can find a constructor I - // can - // use - Constructor[] constructors = paramClass.getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (String.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (Long.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(Long.parseLong(paramValue)); - } - } - } - - } - - if (constObj == null) { - - // Last chance - see if - // parameter class has a static - // method - // getDefaultInstance(String) - try { + String propNamePfx = null; + if (preservePfx) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + if (toObj instanceof Identifier) { + LOG.trace(toClass.getName() + " is a Key - skipping"); + return (toObj); + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + if (isSetter(m)) { + Class paramTypes[] = m.getParameterTypes(); + Class paramClass = paramTypes[0]; + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + String paramValue = props.getProperty(propName); + if (paramValue == null) { + LOG.trace(propName + " is unset"); + } else if ("".equals(paramValue)) { + LOG.trace(propName + " was set to the empty string, setting it to null"); + paramValue = null; + } else { + LOG.trace(propName + " = " + paramValue); + } + + // Is the return type a yang generated class? + if (isYangGenerated(paramClass)) { + // Is it an enum? + if (paramClass.isEnum()) { + + LOG.trace(m.getName() + " expects an Enum"); + // Param type is a typedef. + if ((paramValue != null) && (paramValue.length() > 0)) { + Object paramObj = null; + + try { + paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); + } catch (Exception e) { + LOG.error("Caught exception trying to convert field " + propName + " to enum " + + paramClass.getName(), e); + } + + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to create Yang-generated enum expected by" + + toClass.getName() + "." + m.getName() + "() from Properties entry", e); + } + } + } else { + + String simpleName = paramClass.getSimpleName(); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) + || "IpAddress".equals(simpleName)) { + + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); + + if ("Ipv4Address".equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv4Address()); + } else if ("Ipv6Address".equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv6Address()); + + } else { + m.invoke(toObj, ipAddr); + } + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to call " + toClass.getName() + "." + + m.getName() + "() with Properties entry", e); + } + } + } else if ("IpPrefix".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); + m.invoke(toObj, ipPrefix); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } else if ("PortNumber".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + PortNumber portNumber = PortNumber.getDefaultInstance(paramValue); + m.invoke(toObj, portNumber); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } else if ("Dscp".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + Dscp dscp = Dscp.getDefaultInstance(paramValue); + m.invoke(toObj, dscp); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } else { + // setter expects a yang-generated class. Need + // to + // create a builder to set it. + + String builderName = paramClass.getName() + "Builder"; + Class builderClass = null; + Object builderObj = null; + Object paramObj = null; + + Object constObj = null; + + LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " + + builderName); + try { + builderClass = Class.forName(builderName); + builderObj = builderClass.newInstance(); + paramObj = toBuilder(props, propNamePfx, builderObj); + } catch (ClassNotFoundException e) { + LOG.info("Builder class {} not found ", builderName, e); + if (paramValue == null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + + "(null)"); + m.invoke(toObj, new Object[] { null }); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e1) { + LOG.error("Caught exception trying to cally" + toClass.getName() + "." + + m.getName() + "() with Properties entry", e1); + } + } else { + try { + // See if I can find a constructor I + // can + // use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj == null) { + + // Last chance - see if + // parameter class has a static + // method + // getDefaultInstance(String) + try { Method gm = paramClass.getMethod("getDefaultInstance", String.class); - int gmodifier = gm.getModifiers(); - if (Modifier.isStatic(gmodifier)) { - // Invoke static - // getDefaultInstance(String) - paramObj = gm.invoke(null, paramValue); - } - - } catch (Exception gme) { - LOG.info("Unable to find static method getDefaultInstance for " - + "class {}", paramClass.getSimpleName(), gme); - } - } - - } catch (Exception e1) { - LOG.warn( - "Could not find a suitable constructor for " + paramClass.getName(), - e1); - } - - if (constObj == null) { - LOG.warn("Could not find builder class " + builderName - + " and could not find a String or Long constructor or static " - + "getDefaultInstance(String) - trying just to set passing paramValue"); - - } - } - } catch (Exception e) { - LOG.error("Caught exception trying to create builder " + builderName, e); - } - - if (paramObj != null && builderClass != null) { - - try { - Method buildMethod = builderClass.getMethod("build"); - LOG.trace("Calling " + paramObj.getClass().getName() + "." - + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(paramObj); - - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); - m.invoke(toObj, builtObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to set Yang-generated class expected by" - + toClass.getName() + "." + m.getName() + "() from Properties entry", - e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - if (constObj != null) { - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + constObj.toString() + ")"); - m.invoke(toObj, constObj); - } else { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramValue); - - } - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" - + toClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(paramClass)) { + int gmodifier = gm.getModifiers(); + if (Modifier.isStatic(gmodifier)) { + // Invoke static + // getDefaultInstance(String) + paramObj = gm.invoke(null, paramValue); + } + + } catch (Exception gme) { + LOG.info("Unable to find static method getDefaultInstance for " + + "class {}", paramClass.getSimpleName(), gme); + } + } + + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + paramClass.getName(), + e1); + } + + if (constObj == null) { + LOG.warn("Could not find builder class " + builderName + + " and could not find a String or Long constructor or static " + + "getDefaultInstance(String) - trying just to set passing paramValue"); + + } + } + } catch (Exception e) { + LOG.error("Caught exception trying to create builder " + builderName, e); + } + + if (paramObj != null && builderClass != null) { + + try { + Method buildMethod = builderClass.getMethod("build"); + LOG.trace("Calling " + paramObj.getClass().getName() + "." + + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(paramObj); + + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); + m.invoke(toObj, builtObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to set Yang-generated class expected by" + + toClass.getName() + "." + m.getName() + "() from Properties entry", + e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + if (constObj != null) { + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + constObj.toString() + ")"); + m.invoke(toObj, constObj); + } else { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + + toClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(paramClass)) { LOG.trace("Parameter class " + paramClass.getName() + " is a List"); - // Figure out what type of args are in List and pass - // that to toList(). - - Type paramType = m.getGenericParameterTypes()[0]; - Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; - Object paramObj = new LinkedList(); - try { - paramObj = toList(props, propName, (List) paramObj, (Class) elementType); - } catch (Exception e) { - LOG.error("Caught exception trying to create list expected as argument to {}.{}", - toClass.getName(), m.getName(), e); - } - - if (paramObj != null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert List returned by" + toClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } - } else { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + paramClass.getName() - + " is not a yang-generated class or a List"); - - if ((paramValue != null) && (paramValue.length() > 0)) { - - Object constObj = null; - - try { - // See if I can find a constructor I can use - Constructor[] constructors = paramClass.getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (String.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (Long.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(Long.parseLong(paramValue)); - } - } - } - - } - - if (constObj != null) { - try { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + constObj + ")"); - m.invoke(toObj, constObj); - foundValue = true; - } catch (Exception e2) { - LOG.error("Caught exception trying to call " + m.getName(), e2); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" - + toClass.getName() + "." + m.getName() + "() to Properties entry", - e); - } - } - } catch (Exception e1) { - LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); - } - - } - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - if (foundValue) { - return (toObj); - } else { - return (null); - } - } - - public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { - boolean foundValue = false; - - LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); - - if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { - // Class is yang generated. - LOG.trace(toClass.getName() + " is a Yang-generated class"); + // Figure out what type of args are in List and pass + // that to toList(). + + Type paramType = m.getGenericParameterTypes()[0]; + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + Object paramObj = new LinkedList(); + try { + paramObj = toList(props, propName, (List) paramObj, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to create list expected as argument to {}.{}", + toClass.getName(), m.getName(), e); + } + + if (paramObj != null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert List returned by" + toClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } + } + } else { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace("Parameter class " + paramClass.getName() + + " is not a yang-generated class or a List"); + + if ((paramValue != null) && (paramValue.length() > 0)) { + + Object constObj = null; + + try { + // See if I can find a constructor I can use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + constObj + ")"); + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error("Caught exception trying to call " + m.getName(), e2); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + + toClass.getName() + "." + m.getName() + "() to Properties entry", + e); + } + } + } catch (Exception e1) { + LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); + } + + } + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + if (foundValue) { + return (toObj); + } else { + return (null); + } + } + + private static boolean classHasSpecialHandling(String simpleName) { + if ("IpAddress".equals(simpleName) || "Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) + || "IpPrefix".equals(simpleName) || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { + return true; + } + return false; + } + + public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { + boolean foundValue = false; + + LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); + + if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { + // Class is yang generated. + LOG.trace(toClass.getName() + " is a Yang-generated class"); + + if (toClass.getName().endsWith("Key")) { + if (Identifier.class.isAssignableFrom(toClass)) { + LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); + } else { + + LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); + } + } + + String propNamePfx = null; + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } - if (toClass.getName().endsWith("Key")) { - if (Identifier.class.isAssignableFrom(toClass)) { - LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); - } else { - - LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); - } - } - - String propNamePfx = null; - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - LOG.trace("Is " + m.getName() + " method a getter?"); - if (isGetter(m)) { - LOG.trace(m.getName() + " is a getter"); - Class returnClass = m.getReturnType(); - - String fieldName = toLowerHyphen(m.getName().substring(3)); - if(fieldName!=null) { - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - }else { - fieldName=""; - } - String propName = propNamePfx + "." + fieldName; - - // Is the return type a yang generated class? - if (isYangGenerated(returnClass)) { - // Is it an enum? - if (returnClass.isEnum()) { - - LOG.trace(m.getName() + " is an Enum"); - pstr.print("\n\n * " + propName); - - } else { - - String simpleName = returnClass.getSimpleName(); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName) - || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { - LOG.trace(m.getName() + " is an " + simpleName); - pstr.print("\n\n * " + propName); - } else { - printPropertyList(pstr, propNamePfx, returnClass); - } - - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(returnClass)) { - - LOG.trace("Parameter class " + returnClass.getName() + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type returnType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; - Class elementClass = (Class) elementType; - LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() - + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); - printPropertyList(pstr, - propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", - elementClass); - - } else if (!returnClass.equals(Class.class)) { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + returnClass.getName() - + " is not a yang-generated class or a List"); - - pstr.print("\n\n * " + propName); - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - } - - public static boolean isYangGenerated(Class c) { - if (c != null) { - return (c.getName().startsWith("org.opendaylight.yang.gen.")); - } - return false; - } - - public static boolean isIpPrefix(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("IpPrefix".equals(simpleName)); - } - - public static boolean isIpv4Address(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv4Address".equals(simpleName)); - } - - public static boolean isIpv6Address(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv6Address".equals(simpleName)); - } - - public static boolean isIpAddress(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("IpAddress".equals(simpleName)); - } - - public static boolean isPortNumber(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - - String simpleName = c.getSimpleName(); - return ("PortNumber".equals(simpleName)); - } - - public static boolean isDscp(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Dscp".equals(simpleName)); - } - - public static boolean isIetfInet(Class c) { - - Package p = c.getPackage(); - if (p != null) { - String pkgName = p.getName(); - - if ((pkgName != null) && (pkgName.indexOf("yang.ietf.inet.types") > -1)) { - return (true); - } - } - - return (false); - } - - public static String toLowerHyphen(String inStr) { - if (inStr == null) { - return (null); - } - - String str = inStr.substring(0, 1).toLowerCase(); - if (inStr.length() > 1) { - str = str + inStr.substring(1); - } - - String regex = "(([a-z0-9])([A-Z]))"; - String replacement = "$2-$3"; - - String retval = str.replaceAll(regex, replacement).toLowerCase(); - - LOG.trace("Converting " + inStr + " => " + str + " => " + retval); - return (retval); - } - - // This is called when mapping the yang value back to a valid java enumeration - public static String toJavaEnum(String inStr) { - if (inStr == null) { - return (null); - } else if (inStr.length() == 0) { - return (inStr); - } - - // This will strip out all periods, which cannot be in a java enum - inStr = inStr.replaceAll("\\.", ""); - - //This is needed for enums containing spaces - inStr = inStr.replaceAll(" ", ""); - - String[] terms = inStr.split("-"); - StringBuffer sbuff = new StringBuffer(); - - // appends an _ if the string starts with a digit to make it a valid java enum - if (Character.isDigit(inStr.charAt(0))) { - sbuff.append('_'); - } + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + LOG.trace("Is " + m.getName() + " method a getter?"); + if (isGetter(m)) { + LOG.trace(m.getName() + " is a getter"); + Class returnClass = m.getReturnType(); + + String fieldName = toLowerHyphen(m.getName().substring(3)); + if (fieldName != null) { + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + } else { + fieldName = ""; + } + String propName = propNamePfx + "." + fieldName; + + // Is the return type a yang generated class? + if (isYangGenerated(returnClass)) { + // Is it an enum? + if (returnClass.isEnum()) { + + LOG.trace(m.getName() + " is an Enum"); + pstr.print("\n\n * " + propName); + + } else { + + String simpleName = returnClass.getSimpleName(); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) + || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName) + || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { + LOG.trace(m.getName() + " is an " + simpleName); + pstr.print("\n\n * " + propName); + } else { + printPropertyList(pstr, propNamePfx, returnClass); + } + + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(returnClass)) { + + LOG.trace("Parameter class " + returnClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type returnType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + Class elementClass = (Class) elementType; + LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() + + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); + printPropertyList(pstr, + propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", + elementClass); + + } else if (!returnClass.equals(Class.class)) { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace("Parameter class " + returnClass.getName() + + " is not a yang-generated class or a List"); + + pstr.print("\n\n * " + propName); + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + } + + public static boolean isYangGenerated(Class c) { + if (c != null) { + return (c.getName().startsWith("org.opendaylight.yang.gen.")); + } + return false; + } + + public static boolean isIpPrefix(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("IpPrefix".equals(simpleName)); + } + + public static boolean isIpv4Address(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv4Address".equals(simpleName)); + } + + public static boolean isIpv6Address(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv6Address".equals(simpleName)); + } + + public static boolean isIpAddress(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("IpAddress".equals(simpleName)); + } + + public static boolean isPortNumber(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + + String simpleName = c.getSimpleName(); + return ("PortNumber".equals(simpleName)); + } + + public static boolean isDscp(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Dscp".equals(simpleName)); + } + + public static boolean isIetfInet(Class c) { + + Package p = c.getPackage(); + if (p != null) { + String pkgName = p.getName(); + + if ((pkgName != null) && (pkgName.indexOf("yang.ietf.inet.types") > -1)) { + return (true); + } + } + + return (false); + } + + public static String toLowerHyphen(String inStr) { + if (inStr == null) { + return (null); + } + + String str = inStr.substring(0, 1).toLowerCase(); + if (inStr.length() > 1) { + str = str + inStr.substring(1); + } + + String regex = "(([a-z0-9])([A-Z]))"; + String replacement = "$2-$3"; + + String retval = str.replaceAll(regex, replacement).toLowerCase(); + + LOG.trace("Converting " + inStr + " => " + str + " => " + retval); + return (retval); + } + + // This is called when mapping the yang value back to a valid java enumeration + public static String toJavaEnum(String inStr) { + if (inStr == null) { + return (null); + } else if (inStr.length() == 0) { + return (inStr); + } + + // This will strip out all periods, which cannot be in a java enum + inStr = inStr.replaceAll("\\.", ""); + + // This is needed for enums containing spaces + inStr = inStr.replaceAll(" ", ""); + + String[] terms = inStr.split("-"); + StringBuffer sbuff = new StringBuffer(); + + // appends an _ if the string starts with a digit to make it a valid java enum + if (Character.isDigit(inStr.charAt(0))) { + sbuff.append('_'); + } // If the string contains hyphens it will convert the string to upperCamelCase without hyphens - for (String term : terms) { - sbuff.append(term.substring(0, 1).toUpperCase()); - if (term.length() > 1) { - sbuff.append(term.substring(1)); - } - } - return (sbuff.toString()); - - } - - public static boolean isGetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { - if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { - if (!"getClass".equals(m.getName())) { - return (true); - } - } - - if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { - return (true); - } - - if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { - return (true); - } - } - - return (false); - } - - public static boolean isSetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { - if (m.getName().matches("^set[A-Z].*")) { - Class[] paramTypes = m.getParameterTypes(); - if (paramTypes[0].isAssignableFrom(Identifier.class) - || Identifier.class.isAssignableFrom(paramTypes[0])) { - return (false); - } else { - return (true); - } - } - - } - - return (false); - } - - @Deprecated - public static String getFullPropertiesPath(String propertiesFileName) { - return "/opt/bvc/controller/configuration/" + propertiesFileName; - } + for (String term : terms) { + sbuff.append(term.substring(0, 1).toUpperCase()); + if (term.length() > 1) { + sbuff.append(term.substring(1)); + } + } + return (sbuff.toString()); + + } + + public static boolean isGetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { + if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { + if (!"getClass".equals(m.getName())) { + return (true); + } + } + + if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { + return (true); + } + + if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { + return (true); + } + } + + return (false); + } + + public static boolean isSetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { + if (m.getName().matches("^set[A-Z].*")) { + Class[] paramTypes = m.getParameterTypes(); + if (paramTypes[0].isAssignableFrom(Identifier.class) + || Identifier.class.isAssignableFrom(paramTypes[0])) { + return (false); + } else { + return (true); + } + } + + } + + return (false); + } + + @Deprecated + public static String getFullPropertiesPath(String propertiesFileName) { + return "/opt/bvc/controller/configuration/" + propertiesFileName; + } // This is called when mapping a valid java enumeration back to the yang model value - @Deprecated - public static String mapEnumeratedValue(String propertyName, String propertyValue) { - LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); - String mappingKey = "yang." + propertyName + "." + propertyValue; - if (yangMappingProperties.containsKey(mappingKey)) { - return (yangMappingProperties.getProperty(mappingKey)); - } else { - LOG.info("yangMappingProperties did not contain the key " + mappingKey + " returning the original value."); - return propertyValue; - } - } + @Deprecated + public static String mapEnumeratedValue(String propertyName, String propertyValue) { + LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); + String mappingKey = "yang." + propertyName + "." + propertyValue; + if (yangMappingProperties.containsKey(mappingKey)) { + return (yangMappingProperties.getProperty(mappingKey)); + } else { + LOG.info("yangMappingProperties did not contain the key " + mappingKey + " returning the original value."); + return propertyValue; + } + } + } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java old mode 100644 new mode 100755 index d0ea4f551..cf27f9b93 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -3,9 +3,7 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. + * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,18 +21,27 @@ package org.onap.ccsdk.sli.core.sli.provider; +import java.net.Inet6Address; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Properties; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.opendaylight.yang.gen.v1.test.TestObjectBuilder; import org.opendaylight.yang.gen.v1.test.WrapperObj; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,142 +49,289 @@ import org.slf4j.LoggerFactory; import junit.framework.TestCase; public class MdsalHelperTest extends TestCase { - private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTest.class); - public static final String pathToSdnPropertiesFile = "src/test/resources/l3sdn.properties"; - - public void testSdnProperties() { - - MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile); - assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "synccomplete")); - assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); - assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete")); - assertEquals("service-configuration-operation", - MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", "service-configuration-operation")); - } - - public void testNegativeSdnProperties() { - assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); - } - - public void testToProperties() { - - ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); - SliParameterBuilder parmBuilder = new SliParameterBuilder(); - List params = new LinkedList(); - - parmBuilder.setParameterName("boolean-parm"); - parmBuilder.setBooleanValue(Boolean.TRUE); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("int-parm"); - parmBuilder.setBooleanValue(null); - parmBuilder.setIntValue(1); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("str-parm"); - parmBuilder.setIntValue(null); - parmBuilder.setStringValue("hello"); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("ipaddress4-parm"); - parmBuilder.setStringValue(null); - parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("ipaddress6-parm"); - parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1")); - params.add(parmBuilder.build()); - - execBuilder.setMode(Mode.Sync); - execBuilder.setModuleName("my-module"); - execBuilder.setRpcName("do-it-now"); - execBuilder.setSliParameter(params); - - Properties props = new Properties(); - - MdsalHelperTesterUtil.toProperties(props, execBuilder); - MdsalHelperTesterUtil.toProperties(props, "", execBuilder); - - LOG.info("Converted to properties"); - for (Map.Entry e : props.entrySet()) { - LOG.info(e.getKey().toString() + " = " + e.getValue().toString()); - - } - - } - - public void testToBuilder() { - - Properties props = new Properties(); - - props.setProperty("execute-graph-input.mode", "Sync"); - props.setProperty("execute-graph-input.module", "my-module"); - props.setProperty("execute-graph-input.rpc", "do-it-now"); - props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm"); - props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true"); - props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param"); - props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1"); - props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param"); - props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello"); - props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param"); - props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1"); - props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param"); - props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1"); - ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); - - MdsalHelperTesterUtil.toBuilder(props, execBuilder); - - } - - public void testToJavaEnum() throws Exception { - assertEquals("_2018HelloWorld", MdsalHelper.toJavaEnum("2018Hello World")); - assertEquals("SomethingElse", MdsalHelper.toJavaEnum("Something.Else")); - assertEquals("MyTestString", MdsalHelper.toJavaEnum("my-test-string")); - } - - // During the default enumeration mapping no properties file is needed, the - // yang value is returned - // by the java object - public void testDefaultEnumerationMapping() throws Exception { - Properties props = new Properties(); - MdsalHelper.toProperties(props, new WrapperObj()); - assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type")); - } - - // When no properties file exists the default java value will be returned if - // legacy enumeration - // mapping is enabled - public void testLegacyEnumerationMappingNoProperties() throws Exception { - Properties props = new Properties(); - MdsalHelper.toProperties(props, new WrapperObj(), true); - assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type")); - } - - // When a properties file exists & legacy enumeration mapping is enabled the - // value from the - // properties file should be returned - public void testLegacyEnumerationMappingWithProperties() throws Exception { - MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties"); - Properties props = new Properties(); - MdsalHelper.toProperties(props, new WrapperObj(), true); - assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type")); - } - - public void testGetFullPropertiesPath() { - String fullPath = MdsalHelper.getFullPropertiesPath("testFile"); - assertEquals("/opt/bvc/controller/configuration/testFile", fullPath); - - } - - public void testIsDscp() { - - assertTrue(MdsalHelper.isDscp(Dscp.class)); - - } - - public void testIsPortNumber() { - - assertTrue(MdsalHelper.isPortNumber(PortNumber.class)); - - } -} + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTest.class); + public static final String pathToSdnPropertiesFile = "src/test/resources/l3sdn.properties"; + + public void testSdnProperties() { + + MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile); + assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "synccomplete")); + assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); + assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete")); + assertEquals("service-configuration-operation", + MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", "service-configuration-operation")); + } + + public void testNegativeSdnProperties() { + assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); + } + + public void testToProperties() { + + ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); + SliParameterBuilder parmBuilder = new SliParameterBuilder(); + List params = new LinkedList(); + + parmBuilder.setParameterName("boolean-parm"); + parmBuilder.setBooleanValue(Boolean.TRUE); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("int-parm"); + parmBuilder.setBooleanValue(null); + parmBuilder.setIntValue(1); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("str-parm"); + parmBuilder.setIntValue(null); + parmBuilder.setStringValue("hello"); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("ipaddress4-parm"); + parmBuilder.setStringValue(null); + parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("ipaddress6-parm"); + parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1")); + params.add(parmBuilder.build()); + + execBuilder.setMode(Mode.Sync); + execBuilder.setModuleName("my-module"); + execBuilder.setRpcName("do-it-now"); + execBuilder.setSliParameter(params); + + Properties props = new Properties(); + + MdsalHelperTesterUtil.toProperties(props, execBuilder); + + LOG.info("Converted to properties"); + for (Map.Entry e : props.entrySet()) { + LOG.info(e.getKey().toString() + " = " + e.getValue().toString()); + + } + + } + + public void testToBuilder() { + + Properties props = new Properties(); + + props.setProperty("execute-graph-input.mode", "Sync"); + props.setProperty("execute-graph-input.module", "my-module"); + props.setProperty("execute-graph-input.rpc", "do-it-now"); + props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm"); + props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true"); + props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param"); + props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1"); + props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param"); + props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello"); + props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param"); + props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1"); + props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param"); + props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1"); + ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); + + MdsalHelperTesterUtil.toBuilder(props, execBuilder); + + } + + public void testToJavaEnum() throws Exception { + assertEquals("_2018HelloWorld", MdsalHelper.toJavaEnum("2018Hello World")); + assertEquals("SomethingElse", MdsalHelper.toJavaEnum("Something.Else")); + assertEquals("MyTestString", MdsalHelper.toJavaEnum("my-test-string")); + } + + // During the default enumeration mapping no properties file is needed, the yang + // value is returned + // by the java object + public void testDefaultEnumerationMapping() throws Exception { + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj()); + assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type")); + } + + // When no properties file exists the default java value will be returned if + // legacy enumeration + // mapping is enabled + public void testLegacyEnumerationMappingNoProperties() throws Exception { + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj(), true); + assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type")); + } + + // When a properties file exists & legacy enumeration mapping is enabled the + // value from the + // properties file should be returned + public void testLegacyEnumerationMappingWithProperties() throws Exception { + MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties"); + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj(), true); + assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type")); + } + + public void testSingleIpAddressToProperties() throws Exception { + Properties props = new Properties(); + String ipAddress = "11.11.11.11"; + MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(ipAddress)); + assertEquals(ipAddress, props.getProperty("")); + ipAddress = "cafe::8888"; + MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(ipAddress)); + assertEquals(ipAddress, props.getProperty("")); + } + + + public void testSingleIpAddressToBuilder() throws Exception { + Properties props = new Properties(); + String ipAddress = "11.11.11.11"; + props.setProperty("test-object.single-ip", ipAddress); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + + assertEquals(ipAddress,String.valueOf(b.getSingleIp().getValue())); + + ipAddress = "cafe::8888"; + props.setProperty("test-object.single-ip", ipAddress); + b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(ipAddress,String.valueOf(b.getSingleIp().getValue())); + } + + public void testIpAddressListToProperties() throws Exception { + Properties props = new Properties(); + String ipAddress = "11.11.11.11"; + TestObjectBuilder b = new TestObjectBuilder(); + List ipAddressList = new ArrayList(); + ipAddressList.add(IpAddressBuilder.getDefaultInstance(ipAddress)); + b.setFloatingIp(ipAddressList ); + MdsalHelper.toProperties(props, b.build()); + assertEquals(ipAddress, props.getProperty("test-object.floating-ip[0]")); + assertEquals("1", props.getProperty("test-object.floating-ip_length")); + } + + public void testIpAddressListToBuilder() throws Exception { + Properties props = new Properties(); + String ipaddress = "11.11.11.12"; + props.setProperty("test-object.floating-ip_length", "1"); + props.setProperty("test-object.floating-ip[0]", ipaddress); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(ipaddress,String.valueOf(b.getFloatingIp().get(0).getValue())); + + props = new Properties(); + ipaddress = "cafe::8888"; + props.setProperty("test-object.floating-ip_length", "1"); + props.setProperty("test-object.floating-ip[0]", ipaddress); + b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(ipaddress,String.valueOf(b.getFloatingIp().get(0).getValue())); + } + + + public void testSingleIpv4AddressToProperties() throws Exception { + Properties props = new Properties(); + String v4address = "11.11.11.11"; + MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(v4address).getIpv4Address()); + assertEquals(v4address, props.getProperty("")); + } + + public void testSingleIpv4AddressToBuilder() throws Exception { + Properties props = new Properties(); + String v4address = "11.11.11.11"; + props.setProperty("test-object.single-ip-v4", v4address); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(v4address,b.getSingleIpV4().getValue()); + } + + public void testIpv4AddressListToProperties() throws Exception { + Properties props = new Properties(); + String v4address = "11.11.11.11"; + + TestObjectBuilder b = new TestObjectBuilder(); + List v4list = new ArrayList(); + v4list.add(IpAddressBuilder.getDefaultInstance(v4address).getIpv4Address()); + b.setFloatingIpV4(v4list ); + MdsalHelper.toProperties(props, b.build()); + assertEquals(v4address, props.getProperty("test-object.floating-ip-v4[0]")); + assertEquals("1", props.getProperty("test-object.floating-ip-v4_length")); + } + + public void testIpv4AddressListToBuilder() throws Exception { + Properties props = new Properties(); + String v4address = "11.11.11.12"; + props.setProperty("test-object.floating-ip-v4_length", "1"); + props.setProperty("test-object.floating-ip-v4[0]", v4address); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(v4address,b.getFloatingIpV4().get(0).getValue()); + } + + public void testSingleIpv6AddressToProperties() throws Exception { + Properties props = new Properties(); + String v6address = "cafe::8888"; + MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(v6address).getIpv6Address()); + MdsalHelper.toBuilder(props, IpAddressBuilder.getDefaultInstance("cafe::8887")); + assertEquals(v6address, props.getProperty("")); + } + + public void testSingleIpv6AddressToBuilder() throws Exception { + Properties props = new Properties(); + String v6address = "cafe::8888"; + props.setProperty("test-object.single-ip-v6", v6address); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(v6address,b.getSingleIpV6().getValue()); + } + + public void testIpv6AddressListToProperties() throws Exception { + Properties props = new Properties(); + String v6address = "cafe::8888"; + + TestObjectBuilder b = new TestObjectBuilder(); + List v6list = new ArrayList(); + v6list.add(IpAddressBuilder.getDefaultInstance(v6address).getIpv6Address()); + b.setFloatingIpV6(v6list); + MdsalHelper.toProperties(props, b.build()); + assertEquals(v6address, props.getProperty("test-object.floating-ip-v6[0]")); + assertEquals("1", props.getProperty("test-object.floating-ip-v6_length")); + } + + public void testIpv6AddressListToBuilder() throws Exception { + Properties props = new Properties(); + String v6address = "cafe::8888"; + props.setProperty("test-object.floating-ip-v6_length", "1"); + props.setProperty("test-object.floating-ip-v6[0]", v6address); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(v6address,b.getFloatingIpV6().get(0).getValue()); + } + + public void testIpPrefix() throws Exception { + String ipPrefix = "10.0.0.0/24"; + Properties props = new Properties(); + MdsalHelper.toProperties(props, IpPrefixBuilder.getDefaultInstance(ipPrefix)); + assertEquals(ipPrefix, props.getProperty("")); + } + + public void testPortNumber() throws Exception { + Properties props = new Properties(); + String portNumber = "5"; + MdsalHelper.toProperties(props, PortNumber.getDefaultInstance(portNumber)); + assertEquals(portNumber, props.getProperty("")); + } + + public void testDscp() throws Exception { + Properties props = new Properties(); + String dscp = "1"; + MdsalHelper.toProperties(props, Dscp.getDefaultInstance(dscp)); + assertEquals(dscp, props.getProperty("")); + } + + public void testIetfInet() throws Exception { + Properties props = new Properties(); + Inet6Address address = IetfInetUtil.INSTANCE + .inet6AddressFor(IpAddressBuilder.getDefaultInstance("cafe::8888").getIpv6Address()); + MdsalHelper.toProperties(props, address); + assertEquals("/cafe:0:0:0:0:0:0:8888", props.getProperty("")); + } +} \ No newline at end of file diff --git a/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObject.java b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObject.java new file mode 100755 index 000000000..d9feaf634 --- /dev/null +++ b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObject.java @@ -0,0 +1,17 @@ +package org.opendaylight.yang.gen.v1.test; + +import java.util.List; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; + +public interface TestObject { + List getFloatingIp(); + List getFloatingIpV4(); + List getFloatingIpV6(); + Ipv4Address getSingleIpV4(); + Ipv6Address getSingleIpV6(); + IpAddress getSingleIp(); + +} diff --git a/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObjectBuilder.java b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObjectBuilder.java new file mode 100755 index 000000000..c15615519 --- /dev/null +++ b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObjectBuilder.java @@ -0,0 +1,134 @@ +package org.opendaylight.yang.gen.v1.test; + +import java.util.List; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yangtools.concepts.Builder; + +public class TestObjectBuilder implements Builder { + private List _floatingIp; + private List _floatingIpV4; + private List _floatingIpV6; + private IpAddress _singleIp; + private Ipv4Address _singleIpV4; + private Ipv6Address _singleIpV6; + + public List getFloatingIp() { + return _floatingIp; + } + + public List getFloatingIpV4() { + return _floatingIpV4; + } + + public List getFloatingIpV6() { + return _floatingIpV6; + } + + public Ipv4Address getSingleIpV4() { + return _singleIpV4; + } + + public Ipv6Address getSingleIpV6() { + return _singleIpV6; + } + + public IpAddress getSingleIp() { + return _singleIp; + } + + public TestObjectBuilder setFloatingIp(final List value) { + this._floatingIp = value; + return this; + } + + public TestObjectBuilder setFloatingIpV4(final List value) { + this._floatingIpV4 = value; + return this; + } + + public TestObjectBuilder setFloatingIpV6(final List value) { + this._floatingIpV6 = value; + return this; + } + + public TestObjectBuilder setSingleIp(final IpAddress value) { + this._singleIp = value; + return this; + } + + public TestObjectBuilder setSingleIpV4(final Ipv4Address value) { + this._singleIpV4 = value; + return this; + } + + public TestObjectBuilder setSingleIpV6(final Ipv6Address value) { + this._singleIpV6 = value; + return this; + } + + public TestObjectBuilder() { + + } + + public TestObject build() { + return new TestObjectImpl(this); + } + + @Override + public String toString() { + return "TestObjectBuilder [_floatingIp=" + _floatingIp + ", _floatingIpV4=" + _floatingIpV4 + ", _floatingIpV6=" + + _floatingIpV6 + ", _singleIp=" + _singleIp + ", _singleIpV4=" + _singleIpV4 + ", _singleIpV6=" + + _singleIpV6 + "]"; + } + + private static final class TestObjectImpl implements TestObject { + private List _floatingIp; + private List _floatingIpV4; + private List _floatingIpV6; + private IpAddress _singleIp; + private Ipv4Address _singleIpV4; + private Ipv6Address _singleIpV6; + + @Override + public List getFloatingIp() { + return _floatingIp; + } + + @Override + public List getFloatingIpV4() { + return _floatingIpV4; + } + + @Override + public List getFloatingIpV6() { + return _floatingIpV6; + } + + @Override + public Ipv4Address getSingleIpV4() { + return _singleIpV4; + } + + @Override + public Ipv6Address getSingleIpV6() { + return _singleIpV6; + } + + @Override + public IpAddress getSingleIp() { + return _singleIp; + } + + private TestObjectImpl(TestObjectBuilder base) { + this._floatingIp = base.getFloatingIp(); + this._floatingIpV4 = base.getFloatingIpV4(); + this._floatingIpV6 = base.getFloatingIpV6(); + this._singleIp = base.getSingleIp(); + this._singleIpV4 = base.getSingleIpV4(); + this._singleIpV6 = base.getSingleIpV6(); + } + } +} -- cgit 1.2.3-korg From 28e2e1ca2a9c9d1df3e2b3ab69c0aecbb62918bd Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 31 Oct 2018 15:57:51 +0000 Subject: SetNode patch Support nested array removal with setnode Change-Id: Ie70ef2ff7b84d35c9352c7597aef0f636128439b Issue-ID: CCSDK-643 Signed-off-by: Smokowski, Kevin (ks6305) --- .../sli/core/sli/provider/SetNodeExecutor.java | 29 +++--- .../sli/core/sli/provider/SetNodeExecutorTest.java | 113 ++++++++++++++++++++- .../src/test/resources/clearArrayValues.xml | 23 ----- .../test/resources/clearMultipleArrayValues.xml | 23 +++++ .../test/resources/clearNestedSubArrayValues.xml | 27 +++++ .../src/test/resources/clearSingleArrayValues.xml | 5 + .../test/resources/clearSingleSubArrayValues.xml | 27 +++++ .../src/test/resources/clearSubArrayValues.xml | 24 +++++ sli/provider/src/test/resources/clearValues.xml | 4 + 9 files changed, 236 insertions(+), 39 deletions(-) mode change 100644 => 100755 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java mode change 100644 => 100755 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java delete mode 100644 sli/provider/src/test/resources/clearArrayValues.xml create mode 100644 sli/provider/src/test/resources/clearMultipleArrayValues.xml create mode 100644 sli/provider/src/test/resources/clearNestedSubArrayValues.xml create mode 100644 sli/provider/src/test/resources/clearSingleSubArrayValues.xml create mode 100644 sli/provider/src/test/resources/clearSubArrayValues.xml diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java old mode 100644 new mode 100755 index 5019b5681..8275a8e40 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java @@ -110,17 +110,13 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { if (lhsPrefix.endsWith(".")) { lhsPrefix = lhsPrefix.substring(0, lhsPrefix.length() - 1); } - int lhsPfxLength = lhsPrefix.length(); + HashMap parmsToAdd = new HashMap(); for (String sourceVarName : ctx.getAttributeKeySet()) { - if (sourceVarName.startsWith(rhsRoot)) { - String targetVar = lhsPrefix + "." + sourceVarName.substring(rhsRoot.length()); - - LOG.debug("Copying " + sourceVarName + " value to " + targetVar); - + LOG.debug("Copying {} value to {}", sourceVarName, targetVar); parmsToAdd.put(targetVar, ctx.getAttribute(sourceVarName)); } } @@ -131,20 +127,26 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { // If RHS is empty, unset attributes in LHS LinkedList parmsToRemove = new LinkedList(); String prefix = lhsVarName + "."; + String arrayPrefix = lhsVarName + "["; //Clear length value in case an array exists with this prefix String lengthParamName = lhsVarName + "_length"; - parmsToRemove.add(lengthParamName); - LOG.debug("Unsetting " + lengthParamName + " because prefix " + prefix + " is being cleared."); + LOG.debug("Unsetting {} because prefix {} is being cleared.", lengthParamName, prefix); for (String curCtxVarname : ctx.getAttributeKeySet()) { String curCtxVarnameMatchingValue = curCtxVarname; //Special handling for reseting array values, strips out brackets and any numbers between the brackets //when testing if a context memory value starts with a prefix if(!prefix.contains("[") && curCtxVarnameMatchingValue.contains("[")) { - curCtxVarnameMatchingValue = curCtxVarname.replaceAll(arrayPattern, ""); + curCtxVarnameMatchingValue = curCtxVarname.replaceAll(arrayPattern, "") + "."; } if (curCtxVarnameMatchingValue.startsWith(prefix)) { - LOG.debug("Unsetting " + curCtxVarname + " because matching value " + curCtxVarnameMatchingValue + " starts with the prefix " + prefix); + LOG.debug("Unsetting {} because matching value {} starts with the prefix {}", curCtxVarname, curCtxVarnameMatchingValue, prefix); + parmsToRemove.add(curCtxVarname); + }else if (curCtxVarnameMatchingValue.startsWith(lengthParamName)) { + LOG.debug("Unsetting {} because matching value {} starts with the lengthParamName {}", curCtxVarname, curCtxVarnameMatchingValue, lengthParamName); + parmsToRemove.add(curCtxVarname); + }else if (curCtxVarnameMatchingValue.startsWith(arrayPrefix)) { + LOG.debug("Unsetting {} because matching value {} starts with the arrayPrefix {}", curCtxVarname, curCtxVarnameMatchingValue, arrayPrefix); parmsToRemove.add(curCtxVarname); } } @@ -158,16 +160,15 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor { String ctxValue = ctx.getAttribute(lhsVarName); if ((ctxValue != null) && (ctxValue.length() > 0)) { setValue = false; - LOG.debug("Attribute " + lhsVarName - + " already set and only-if-unset is true, so not overriding"); + LOG.debug("Attribute {} already set and only-if-unset is true, so not overriding", lhsVarName); } } if (setValue) { String curValue = SvcLogicExpressionResolver.evaluate(curEnt.getValue(), node, ctx); if (LOG.isDebugEnabled()) { - LOG.trace("Parameter value " + curEnt.getValue().asParsedExpr() + " resolves to " + curValue); - LOG.debug("Setting context attribute " + lhsVarName + " to " + curValue); + LOG.trace("Parameter value {} resolves to {}", curEnt.getValue().asParsedExpr(), curValue); + LOG.debug("Setting context attribute {} to {}", lhsVarName, curValue); } ctx.setAttribute(lhsVarName, curValue); } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java old mode 100644 new mode 100755 index 9ba2c05e6..7c6f4ce56 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java @@ -27,6 +27,10 @@ public class SetNodeExecutorTest { assertNull(ctx.getAttribute("si.field1")); assertNull(ctx.getAttribute("si.field2")); assertNull(ctx.getAttribute("si.field3")); + assertNull(ctx.getAttribute("si.subarray[0]")); + assertNull(ctx.getAttribute("si.subarray[1]")); + assertNull(ctx.getAttribute("si.subarray[2]")); + assertNull(ctx.getAttribute("si.subarray_length")); assertEquals("6", ctx.getAttribute("search1")); assertEquals("KeepMe!", ctx.getAttribute("simonSays")); } @@ -37,7 +41,7 @@ public class SetNodeExecutorTest { SvcLogicContext ctx = new SvcLogicContext(); SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/clearArrayValues.xml"); + LinkedList graph = slp.parse("src/test/resources/clearMultipleArrayValues.xml"); SvcLogicNode root = graph.getFirst().getRootNode(); SvcLogicNode nodeOne = root.getOutcomeValue("1"); SvcLogicNode nodeTwo = root.getOutcomeValue("2"); @@ -56,7 +60,7 @@ public class SetNodeExecutorTest { assertEquals("6", ctx.getAttribute("search1")); assertEquals("KeepMe!", ctx.getAttribute("simonSays")); } - + @Test public void clearSingleArrayProperties() throws Exception { SetNodeExecutor sne = new SetNodeExecutor(); @@ -72,8 +76,80 @@ public class SetNodeExecutorTest { sne.execute(nodeTwo, ctx); assertNull(ctx.getAttribute("si[0].field1")); + assertNull(ctx.getAttribute("si[0].subarray[0]")); + assertNull(ctx.getAttribute("si[0].subarray[1]")); + assertNull(ctx.getAttribute("si[0].subarray[2]")); + assertNull(ctx.getAttribute("si[0].subarray_length")); + + // TODO: This is just setting up elements as null but note reducing the size of Array. + assertEquals("3",ctx.getAttribute("si_length")); + + assertEquals("2",ctx.getAttribute("si[1].field2")); + assertEquals("3", ctx.getAttribute("si[2].field3")); + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void clearSingleSubArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearSingleSubArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1",ctx.getAttribute("tmp.si[0].field1")); + assertEquals("2",ctx.getAttribute("tmp.si[1].field2")); + assertEquals("3", ctx.getAttribute("tmp.si[2].field3")); + assertEquals("3", ctx.getAttribute("tmp.si_length")); + + assertEquals("a",ctx.getAttribute("tmp.si[0].subarray[0]")); + + // TODO: This is setting up element as Empty instead null + //assertNull(ctx.getAttribute("tmp.si[0].subarray[1]")); + assertEquals("", ctx.getAttribute("tmp.si[0].subarray[1]")); + + assertEquals("c", ctx.getAttribute("tmp.si[0].subarray[2]")); + assertEquals("3", ctx.getAttribute("tmp.si[0].subarray_length")); + + assertEquals("x",ctx.getAttribute("tmp.si[1].subarray[0]")); + assertEquals("y",ctx.getAttribute("tmp.si[1].subarray[1]")); + assertEquals("z", ctx.getAttribute("tmp.si[1].subarray[2]")); + assertEquals("3", ctx.getAttribute("tmp.si[1].subarray_length")); + + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void clearSubArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearSubArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1", ctx.getAttribute("si[0].field1")); assertEquals("2",ctx.getAttribute("si[1].field2")); assertEquals("3", ctx.getAttribute("si[2].field3")); + assertEquals("3", ctx.getAttribute("si_length")); + assertNull(ctx.getAttribute("si[0].subarray[0]")); + assertNull(ctx.getAttribute("si[0].subarray[1]")); + assertNull(ctx.getAttribute("si[0].subarray[2]")); + assertNull(ctx.getAttribute("si[0].subarray_length")); + assertEquals("6", ctx.getAttribute("search1")); assertEquals("KeepMe!", ctx.getAttribute("simonSays")); } @@ -107,4 +183,37 @@ public class SetNodeExecutorTest { assertEquals("3", ctx.getAttribute("rootTwo.field3")); } + @Test + public void clearNestedSubArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearNestedSubArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1", ctx.getAttribute("tmp.si[0].field1")); + assertEquals("2",ctx.getAttribute("tmp.si[1].field2")); + assertEquals("3", ctx.getAttribute("tmp.si[2].field3")); + assertEquals("3", ctx.getAttribute("tmp.si_length")); + + assertNull(ctx.getAttribute("tmp.si[0].subarray[0]")); + assertNull(ctx.getAttribute("tmp.si[0].subarray[1]")); + assertNull(ctx.getAttribute("tmp.si[0].subarray[2]")); + assertNull(ctx.getAttribute("tmp.si[0].subarray_length")); + + assertEquals("x", ctx.getAttribute("tmp.si[1].subarray[0]")); + assertEquals("y",ctx.getAttribute("tmp.si[1].subarray[1]")); + assertEquals("z", ctx.getAttribute("tmp.si[1].subarray[2]")); + assertEquals("3", ctx.getAttribute("tmp.si[1].subarray_length")); + + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + } diff --git a/sli/provider/src/test/resources/clearArrayValues.xml b/sli/provider/src/test/resources/clearArrayValues.xml deleted file mode 100644 index 8f40058f1..000000000 --- a/sli/provider/src/test/resources/clearArrayValues.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearMultipleArrayValues.xml b/sli/provider/src/test/resources/clearMultipleArrayValues.xml new file mode 100644 index 000000000..8f40058f1 --- /dev/null +++ b/sli/provider/src/test/resources/clearMultipleArrayValues.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearNestedSubArrayValues.xml b/sli/provider/src/test/resources/clearNestedSubArrayValues.xml new file mode 100644 index 000000000..a80b3e56c --- /dev/null +++ b/sli/provider/src/test/resources/clearNestedSubArrayValues.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearSingleArrayValues.xml b/sli/provider/src/test/resources/clearSingleArrayValues.xml index 3e4e5d98d..56781a066 100644 --- a/sli/provider/src/test/resources/clearSingleArrayValues.xml +++ b/sli/provider/src/test/resources/clearSingleArrayValues.xml @@ -7,6 +7,11 @@ + + + + + diff --git a/sli/provider/src/test/resources/clearSingleSubArrayValues.xml b/sli/provider/src/test/resources/clearSingleSubArrayValues.xml new file mode 100644 index 000000000..22f14f37b --- /dev/null +++ b/sli/provider/src/test/resources/clearSingleSubArrayValues.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearSubArrayValues.xml b/sli/provider/src/test/resources/clearSubArrayValues.xml new file mode 100644 index 000000000..cb25f38af --- /dev/null +++ b/sli/provider/src/test/resources/clearSubArrayValues.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearValues.xml b/sli/provider/src/test/resources/clearValues.xml index 615c8566a..dc7f5c8a2 100644 --- a/sli/provider/src/test/resources/clearValues.xml +++ b/sli/provider/src/test/resources/clearValues.xml @@ -7,6 +7,10 @@ + + + + -- cgit 1.2.3-korg From 00248de1226185c9c4d0f43983fafc2eb4087d95 Mon Sep 17 00:00:00 2001 From: Stanislav Chlebec Date: Thu, 8 Nov 2018 14:04:43 +0100 Subject: fix typos Change-Id: I3a7a4e5b19ac6a54f637fc459d34f3abe7cf4a69 Signed-off-by: Stanislav Chlebec Issue-ID: AAF-582 --- dblib/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dblib/README.md b/dblib/README.md index 98e8f0c6f..ab2c5130e 100755 --- a/dblib/README.md +++ b/dblib/README.md @@ -3,4 +3,4 @@ DBLIB Utility DBLIB utility is designed as a high availability connection manager. It is configured to use multiple databases, and based on the configured rules -always provide the connection to te active database. +always provide the connection to the active database. -- cgit 1.2.3-korg From 5f3cb802bec2fdbfa6e78518605257bff72615cb Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 9 Nov 2018 15:48:47 -0500 Subject: Fix node id / type in log entry Node id and type in log entries are not correct for nodes within a block, for example. Change-Id: I4023de08215ba6de5bfdd2a561048d9fe84201e5 Issue-ID: CCSDK-657 Signed-off-by: Timoney, Dan (dt5972) --- .../org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index dd7139a7b..c5a848a17 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -154,8 +154,6 @@ public class SvcLogicServiceImpl implements SvcLogicService { LOG.info("About to execute graph {}", graph.toString()); try { while (curNode != null) { - MDC.put("nodeId", curNode.getNodeId() + " (" + curNode.getNodeType() + ")"); - LOG.info("About to execute node # {} ({})", curNode.getNodeId(), curNode.getNodeType()); SvcLogicNode nextNode = executeNode(curNode, ctx); curNode = nextNode; @@ -174,6 +172,8 @@ public class SvcLogicServiceImpl implements SvcLogicService { return (null); } + LOG.info("About to execute node # {} ({})", node.getNodeId(), node.getNodeType()); + if (LOG.isDebugEnabled()) { LOG.debug("Executing node {}", node.getNodeId()); } @@ -183,6 +183,8 @@ public class SvcLogicServiceImpl implements SvcLogicService { if (executor != null) { LOG.debug("Executing node executor for node type {} - {}", node.getNodeType(), executor.getClass().getName()); + + MDC.put("nodeId", node.getNodeId() + " (" + node.getNodeType() + ")"); return (executor.execute(this, node, ctx)); } else { throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type"); -- cgit 1.2.3-korg From 3e64dafb04f0f7d40613bcc67efbe999ed132b47 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Wed, 7 Nov 2018 15:58:19 +0900 Subject: Fix blocker sonar issue in sli/core Fix use try with resources issue in FileRecorder.java Issue-ID: CCSDK-647 Change-Id: Ibe8afb5873b3af681def5310cc53ea0172608f1a Signed-off-by: Parshad Patel --- .../ccsdk/sli/core/sli/recording/FileRecorder.java | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) 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 index 772906e59..ac3dbd2a9 100644 --- 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 @@ -82,7 +82,6 @@ public class FileRecorder implements SvcLogicRecorder { } File recordFile = new File(fileName); - FileWriter fileWriter = null; Date now = new Date(); TimeZone tz = TimeZone.getTimeZone("UTC"); @@ -93,8 +92,8 @@ public class FileRecorder implements SvcLogicRecorder { record = record.replaceFirst("__TIMESTAMP__", dateFmt.format(now)); } - try ( PrintWriter recPrinter = new PrintWriter(fileWriter = new - FileWriter(recordFile, true))) + try ( FileWriter fileWriter = new FileWriter(recordFile, true); + PrintWriter recPrinter = new PrintWriter(fileWriter)) { recPrinter.println(record); } @@ -102,19 +101,6 @@ public class FileRecorder implements SvcLogicRecorder { { throw new SvcLogicException("Cannot write record to file", e); } - finally - { - if (fileWriter != null) - { - try { - fileWriter.close(); - } catch (IOException e) { - - } - } - } - - } } -- cgit 1.2.3-korg From 0f74e8a3a48c421ed4074c762701b16427ee8e57 Mon Sep 17 00:00:00 2001 From: ezhil Date: Mon, 19 Nov 2018 17:58:22 +0530 Subject: Sonar fixes for PrintYangToProp.java Fixed sonar issues in PrintYangToProp class Issue-ID: CCSDK-730 Change-Id: If344af657356ee0d2499fbd061e23fbd06617d2b Signed-off-by: ezhil --- .../onap/ccsdk/sli/core/sli/PrintYangToProp.java | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java index 554927768..2e2910235 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java @@ -21,14 +21,9 @@ package org.onap.ccsdk.sli.core.sli; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; import java.io.PrintStream; import java.io.FileDescriptor; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; @@ -52,7 +47,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.CaseFormat; public class PrintYangToProp { @@ -96,12 +90,8 @@ public class PrintYangToProp { String simpleName = fromClass.getSimpleName(); - //LOG.debug("Extracting properties from " + fromClass.getName() - // + " class"); if (fromObj instanceof List) { - // Class is a List. List should contain yang-generated classes. - //LOG.debug(fromClass.getName() + " is a List"); List fromList = (List) fromObj; @@ -111,8 +101,6 @@ public class PrintYangToProp { props.setProperty(pfx + "_length", "" + fromList.size()); } else if (isYangGenerated(fromClass)) { - // Class is yang generated. - //LOG.debug(fromClass.getName() + " is a Yang-generated class"); String propNamePfx = null; @@ -142,9 +130,9 @@ public class PrintYangToProp { // save from for (Method m : fromClass.getMethods()) { - // LOG.debug("Checking " + m.getName() + " method"); + if (isGetter(m)) { - // LOG.debug(m.getName() + " is a getter"); + Class returnType = m.getReturnType(); String fieldName = toLowerHyphen(m.getName().substring(3)); if(m != null && m.getName().matches("^is[A-Z].*")){ @@ -156,7 +144,7 @@ public class PrintYangToProp { // Is the return type a yang generated class? if (isYangGenerated(returnType)) { - //System.out.println("returnType:" +returnType); + // Is it an enum? if (returnType.isEnum()) { // Return type is a typedef. Save its value. @@ -178,10 +166,7 @@ public class PrintYangToProp { String yangProp = "yang." + fieldName + "." + propVal; if ( properties.containsKey(yangProp)) { propVal = properties.getProperty(yangProp); - //LOG.debug("Adjusting property " + yangProp + " " + propVal); } - //LOG.debug("Setting property " + propName - // + " to " + propVal); props.setProperty(propName, propVal); } } catch (Exception e) { -- cgit 1.2.3-korg From bcd44237af5b45f1c37a91c85e8f27ea56446d42 Mon Sep 17 00:00:00 2001 From: ezhil Date: Tue, 27 Nov 2018 16:44:40 +0530 Subject: Sonar fix in SvcLogicNodeExecutor Remove unused imports Issue-ID: CCSDK-753 Change-Id: I790c095924d35f2be6fcb92c8fcfbbb43464b9c5 Signed-off-by: ezhil --- .../org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java index f34c261d6..34fdb5373 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java @@ -29,10 +29,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -- cgit 1.2.3-korg From eae054f3173db091814435e47032c9a9aeacc631 Mon Sep 17 00:00:00 2001 From: ezhil Date: Tue, 27 Nov 2018 16:56:28 +0530 Subject: Fixed Sonar issue in SvcLogicServiceImpl Removed unused imports and duplicate literals Issue-ID: CCSDK-754 Change-Id: I797475aec7519928f3676af189a45790a9b84a29 Signed-off-by: ezhil --- .../ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index c5a848a17..fe1d484ec 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -5,6 +5,8 @@ * 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 @@ -37,12 +39,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceEvent; -import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -80,6 +77,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { protected BundleContext bctx = null; protected Properties properties; protected SvcLogicStore store; + private static final String CURRENT_GRAPH="currentGraph"; public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider) throws SvcLogicException { properties = resourceProvider.getProperties(); @@ -148,7 +146,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { // Set service name in MDC to reference current working directed graph MDC.put(MetricLogger.SERVICE_NAME, graph.getModule() + ":" + graph.getRpc() + "/v" + graph.getVersion()); - MDC.put("currentGraph", graph.toString()); + MDC.put(CURRENT_GRAPH, graph.toString()); SvcLogicNode curNode = graph.getRootNode(); LOG.info("About to execute graph {}", graph.toString()); @@ -162,7 +160,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { LOG.debug("SvcLogicServiceImpl caught ExitNodeException"); } MDC.remove("nodeId"); - MDC.remove("currentGraph"); + MDC.remove(CURRENT_GRAPH); return (ctx); } @@ -217,7 +215,7 @@ public class SvcLogicServiceImpl implements SvcLogicService { } SvcLogicContext ctx = new SvcLogicContext(props); - ctx.setAttribute("currentGraph", graph.toString()); + ctx.setAttribute(CURRENT_GRAPH, graph.toString()); ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); ctx.setDomDataBroker(domDataBroker); -- cgit 1.2.3-korg From f2a8be2ff5e94c1d0f008cc61be38d14597d3538 Mon Sep 17 00:00:00 2001 From: ezhil Date: Tue, 27 Nov 2018 17:05:37 +0530 Subject: Fixed Sonar issue in FileRecorder Removed unused imports Issue-ID: CCSDK-755 Change-Id: I1e303a0490e0da0f1ca998197524d4400ad80eb5 Signed-off-by: ezhil --- .../main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index ac3dbd2a9..37e4fe877 100644 --- 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 @@ -5,6 +5,8 @@ * 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 @@ -24,7 +26,6 @@ package org.onap.ccsdk.sli.core.sli.recording; import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; -import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; -- cgit 1.2.3-korg From f182003d772efe8f9d22876b1a5b7991f4e14afc Mon Sep 17 00:00:00 2001 From: "Brandon, Bruce (bb2697)" Date: Wed, 28 Nov 2018 22:10:56 +0000 Subject: Add DG name to debug Add DG name to debug line giving node ID execution Change-Id: I95ef74982694ab53068339cce88ec3ea8ccf2258 Issue-ID: SDNC-538 Signed-off-by: Brandon, Bruce (bb2697) --- .../org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index c5a848a17..8755ea1db 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -173,9 +173,9 @@ public class SvcLogicServiceImpl implements SvcLogicService { } LOG.info("About to execute node # {} ({})", node.getNodeId(), node.getNodeType()); - + if (LOG.isDebugEnabled()) { - LOG.debug("Executing node {}", node.getNodeId()); + LOG.debug("Executing node " + node.getNodeId() + " of " + node.getGraph().getRpc()); } SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); -- cgit 1.2.3-korg From 959f2e22cf3f794e040dde4d687712cfefd3b00a Mon Sep 17 00:00:00 2001 From: ezhil Date: Fri, 30 Nov 2018 17:02:27 +0530 Subject: Fixed Sonar issue in BaseDBConfiguration.java Logged exception in Logger Issue-ID: CCSDK-774 Change-Id: I28d10215daafd9f0dcaf7e0d765afbe72c184053 Signed-off-by: ezhil --- .../onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java index a8bc58b8b..5f0209b67 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java @@ -3,6 +3,7 @@ * onap * ================================================================================ * Copyright (C) 2016 - 2017 ONAP + * 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. @@ -21,12 +22,14 @@ package org.onap.ccsdk.sli.core.dblib.config; import java.util.Properties; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Base class responsible for parsing business logic for database configuration from given Properties. */ public abstract class BaseDBConfiguration { + private Logger logger = LoggerFactory.getLogger(BaseDBConfiguration.class); /** * Property key within a properties configuration File for db type */ @@ -45,7 +48,7 @@ public abstract class BaseDBConfiguration { /** * Property key with a properties configuration File for jdbc driver */ - public static final String DRIVER_NAME = "org.onap.ccsdk.sli.jdbc.driver"; + public static final String DRIVER_NAME = "org.onap.ccsdk.sli.jdbc.driver"; /** * Property key with a properties configuration File for db database connection name @@ -131,6 +134,7 @@ public abstract class BaseDBConfiguration { String value = properties.getProperty(CONNECTION_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE); return Integer.parseInt(value); } catch (Exception exc) { + logger.error("Exception",exc); return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE); } } @@ -146,6 +150,7 @@ public abstract class BaseDBConfiguration { String value = properties.getProperty(REQUEST_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE); return Integer.parseInt(value); } catch (Exception exc) { + logger.error("Exception",exc); return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE); } } -- cgit 1.2.3-korg From 31252640fff84fb2351696105751eae4f3240ed2 Mon Sep 17 00:00:00 2001 From: ezhil Date: Fri, 30 Nov 2018 18:28:29 +0530 Subject: Fixed Sonar issue in DeleteNodeExecutor.java Replaced litrals with constant Issue-ID: CCSDK-776 Change-Id: I58c02ec0ee78e9e4b852aa11266dc720fffbd172 Signed-off-by: ezhil --- .../org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java index 571dd37cd..18f1ce9a7 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java @@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory; public class DeleteNodeExecutor extends SvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class); + private static final String FAILURE="failure"; @Override public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) @@ -40,7 +41,7 @@ public class DeleteNodeExecutor extends SvcLogicNodeExecutor { String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String outValue = "failure"; + String outValue = FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("delete node encountered - looking for resource class " + plugin); @@ -58,11 +59,11 @@ public class DeleteNodeExecutor extends SvcLogicNodeExecutor { break; case FAILURE: default: - outValue = "failure"; + outValue = FAILURE; } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); -- cgit 1.2.3-korg From 7f8fd751c9272c33be0b74f02cd962dd615b63d3 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 30 Nov 2018 18:00:42 +0000 Subject: refactor sli-provider split sli-provider into sli-provider and sli-provider-base Change-Id: I7b7edb767c04c9a6caf72a9172f49518655e33b7 Issue-ID: CCSDK-778 Signed-off-by: Smokowski, Kevin (ks6305) --- sli/pom.xml | 1 + sli/provider-base/pom.xml | 61 +++ .../base/AbstractSvcLogicNodeExecutor.java | 93 ++++ .../core/sli/provider/base/BlockNodeExecutor.java | 76 +++ .../core/sli/provider/base/BreakNodeExecutor.java | 42 ++ .../core/sli/provider/base/CallNodeExecutor.java | 175 ++++++ .../sli/provider/base/ConfigureNodeExecutor.java | 248 +++++++++ .../core/sli/provider/base/DeleteNodeExecutor.java | 74 +++ .../sli/provider/base/ExecuteNodeExecutor.java | 141 +++++ .../core/sli/provider/base/ExistsNodeExecutor.java | 75 +++ .../core/sli/provider/base/ExitNodeExecutor.java | 42 ++ .../core/sli/provider/base/ForNodeExecutor.java | 109 ++++ .../sli/provider/base/GetResourceNodeExecutor.java | 99 ++++ .../sli/provider/base/IsAvailableNodeExecutor.java | 71 +++ .../core/sli/provider/base/NotifyNodeExecutor.java | 74 +++ .../core/sli/provider/base/RecordNodeExecutor.java | 82 +++ .../sli/provider/base/ReleaseNodeExecutor.java | 73 +++ .../sli/provider/base/ReserveNodeExecutor.java | 87 +++ .../core/sli/provider/base/ReturnNodeExecutor.java | 78 +++ .../core/sli/provider/base/SaveNodeExecutor.java | 107 ++++ .../core/sli/provider/base/SetNodeExecutor.java | 179 ++++++ .../provider/base/SvcLogicExpressionResolver.java | 605 +++++++++++++++++++++ .../provider/base/SvcLogicPropertiesProvider.java | 28 + .../core/sli/provider/base/SvcLogicResolver.java | 17 + .../sli/provider/base/SvcLogicServiceBase.java | 66 +++ .../sli/provider/base/SvcLogicServiceImplBase.java | 189 +++++++ .../core/sli/provider/base/SwitchNodeExecutor.java | 63 +++ .../core/sli/provider/base/UpdateNodeExecutor.java | 103 ++++ .../core/sli/provider/base/WhileNodeExecutor.java | 75 +++ .../sli/core/sli/provider/base/BadPlugin.java | 56 ++ .../sli/core/sli/provider/base/DummyAdaptor.java | 54 ++ .../sli/core/sli/provider/base/DummyRecorder.java | 14 + .../sli/core/sli/provider/base/DummyResource.java | 97 ++++ .../sli/provider/base/ExecuteNodeExecutorTest.java | 69 +++ .../sli/provider/base/LunchSelectorPlugin.java | 78 +++ .../sli/core/sli/provider/base/PluginTest.java | 108 ++++ .../sli/provider/base/SetNodeExecutorTest.java | 220 ++++++++ .../base/SvcLogicExpressionResolverTest.java | 123 +++++ .../core/sli/provider/base/VoidDummyPlugin.java | 38 ++ .../test/resources/clearMultipleArrayValues.xml | 23 + .../test/resources/clearNestedSubArrayValues.xml | 27 + .../src/test/resources/clearSingleArrayValues.xml | 23 + .../test/resources/clearSingleSubArrayValues.xml | 27 + .../src/test/resources/clearSubArrayValues.xml | 24 + .../src/test/resources/clearValues.xml | 22 + .../src/test/resources/copyValues.xml | 16 + .../src/test/resources/expression.tests | 24 + .../src/test/resources/simplelogger.properties | 22 + sli/provider/pom.xml | 7 +- .../sli/core/sli/provider/BlockNodeExecutor.java | 75 --- .../sli/core/sli/provider/BreakNodeExecutor.java | 42 -- .../sli/core/sli/provider/CallNodeExecutor.java | 175 ------ .../core/sli/provider/ConfigureNodeExecutor.java | 248 --------- .../sli/core/sli/provider/DeleteNodeExecutor.java | 74 --- .../sli/core/sli/provider/ExecuteNodeExecutor.java | 141 ----- .../sli/core/sli/provider/ExistsNodeExecutor.java | 75 --- .../sli/core/sli/provider/ExitNodeExecutor.java | 42 -- .../sli/core/sli/provider/ForNodeExecutor.java | 109 ---- .../core/sli/provider/GetResourceNodeExecutor.java | 99 ---- .../core/sli/provider/IsAvailableNodeExecutor.java | 71 --- .../sli/core/sli/provider/NotifyNodeExecutor.java | 74 --- .../sli/core/sli/provider/RecordNodeExecutor.java | 82 --- .../sli/core/sli/provider/ReleaseNodeExecutor.java | 73 --- .../sli/core/sli/provider/ReserveNodeExecutor.java | 87 --- .../sli/core/sli/provider/ReturnNodeExecutor.java | 78 --- .../sli/core/sli/provider/SaveNodeExecutor.java | 107 ---- .../sli/core/sli/provider/SetNodeExecutor.java | 179 ------ .../core/sli/provider/SvcLogicAdaptorFactory.java | 5 +- .../core/sli/provider/SvcLogicClassResolver.java | 81 ++- .../sli/provider/SvcLogicExpressionResolver.java | 605 --------------------- .../core/sli/provider/SvcLogicNodeExecutor.java | 94 ---- .../sli/provider/SvcLogicPropertiesProvider.java | 28 - .../provider/SvcLogicPropertiesProviderImpl.java | 1 + .../sli/core/sli/provider/SvcLogicService.java | 39 +- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 143 +---- .../sli/core/sli/provider/SwitchNodeExecutor.java | 63 --- .../sli/core/sli/provider/UpdateNodeExecutor.java | 103 ---- .../sli/core/sli/provider/WhileNodeExecutor.java | 75 --- .../ccsdk/sli/core/sli/provider/BadPlugin.java | 56 -- .../ccsdk/sli/core/sli/provider/DummyAdaptor.java | 54 -- .../ccsdk/sli/core/sli/provider/DummyRecorder.java | 14 - .../ccsdk/sli/core/sli/provider/DummyResource.java | 97 ---- .../core/sli/provider/ExecuteNodeExecutorTest.java | 60 -- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 30 +- .../sli/core/sli/provider/LunchSelectorPlugin.java | 78 --- .../ccsdk/sli/core/sli/provider/PluginTest.java | 108 ---- .../sli/core/sli/provider/SetNodeExecutorTest.java | 219 -------- .../provider/SvcLogicExpressionResolverTest.java | 123 ----- .../sli/core/sli/provider/VoidDummyPlugin.java | 38 -- .../test/resources/clearMultipleArrayValues.xml | 23 - .../test/resources/clearNestedSubArrayValues.xml | 27 - .../src/test/resources/clearSingleArrayValues.xml | 23 - .../test/resources/clearSingleSubArrayValues.xml | 27 - .../src/test/resources/clearSubArrayValues.xml | 24 - sli/provider/src/test/resources/clearValues.xml | 22 - sli/provider/src/test/resources/copyValues.xml | 16 - sli/provider/src/test/resources/expression.tests | 24 - sliPluginUtils/provider/testFileName | 1 - sliapi/provider/pom.xml | 5 + .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 42 +- 100 files changed, 4336 insertions(+), 4048 deletions(-) create mode 100644 sli/provider-base/pom.xml create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BreakNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/DeleteNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExistsNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExitNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ForNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/GetResourceNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/IsAvailableNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/NotifyNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReleaseNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReserveNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicPropertiesProvider.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicResolver.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceBase.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SwitchNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/WhileNodeExecutor.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/BadPlugin.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyAdaptor.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyRecorder.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyResource.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/LunchSelectorPlugin.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutorTest.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/VoidDummyPlugin.java create mode 100644 sli/provider-base/src/test/resources/clearMultipleArrayValues.xml create mode 100644 sli/provider-base/src/test/resources/clearNestedSubArrayValues.xml create mode 100644 sli/provider-base/src/test/resources/clearSingleArrayValues.xml create mode 100644 sli/provider-base/src/test/resources/clearSingleSubArrayValues.xml create mode 100644 sli/provider-base/src/test/resources/clearSubArrayValues.xml create mode 100644 sli/provider-base/src/test/resources/clearValues.xml create mode 100644 sli/provider-base/src/test/resources/copyValues.xml create mode 100644 sli/provider-base/src/test/resources/expression.tests create mode 100644 sli/provider-base/src/test/resources/simplelogger.properties delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java delete mode 100755 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java delete mode 100755 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java delete mode 100755 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java delete mode 100755 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java delete mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java delete mode 100644 sli/provider/src/test/resources/clearMultipleArrayValues.xml delete mode 100644 sli/provider/src/test/resources/clearNestedSubArrayValues.xml delete mode 100644 sli/provider/src/test/resources/clearSingleArrayValues.xml delete mode 100644 sli/provider/src/test/resources/clearSingleSubArrayValues.xml delete mode 100644 sli/provider/src/test/resources/clearSubArrayValues.xml delete mode 100644 sli/provider/src/test/resources/clearValues.xml delete mode 100644 sli/provider/src/test/resources/copyValues.xml delete mode 100755 sli/provider/src/test/resources/expression.tests delete mode 100644 sliPluginUtils/provider/testFileName diff --git a/sli/pom.xml b/sli/pom.xml index 7b1fd9d2b..7060541aa 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -21,6 +21,7 @@ + provider-base model common provider diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml new file mode 100644 index 000000000..63cba8307 --- /dev/null +++ b/sli/provider-base/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.2.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + sli-provider-base + 0.4.0-SNAPSHOT + + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + 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/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java new file mode 100644 index 000000000..a51accbb9 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java @@ -0,0 +1,93 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class AbstractSvcLogicNodeExecutor { + protected SvcLogicResolver resolver; + public abstract SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; + + private static final Logger LOG = LoggerFactory.getLogger(AbstractSvcLogicNodeExecutor.class); + + protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + if (node == null) { + return null; + } + + return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"), + node, ctx)); + + } + + public void setResolver(SvcLogicResolver resolver) { + this.resolver = resolver; + } + + protected SvcLogicAdaptor getAdaptor(String adaptorName) { + return resolver.getSvcLogicAdaptor(adaptorName); + } + + protected SvcLogicResource getSvcLogicResource(String resourceName) { + return resolver.getSvcLogicResource(resourceName); + } + + protected SvcLogicRecorder getSvcLogicRecorder(String recorderName) { + return resolver.getSvcLogicRecorder(recorderName); + } + + protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){ + return resolver.getSvcLogicJavaPlugin(pluginName); + } + + protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) { + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java new file mode 100644 index 000000000..7aaf795b3 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java @@ -0,0 +1,76 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BlockNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(BlockNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + SvcLogicExpression atomicExpr = node.getAttribute("atomic"); + String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); + boolean isAtomic = "true".equalsIgnoreCase(atomicStr); + + // Initialize status to success so that at least one outcome will execute + ctx.setStatus("success"); + + int numOutcomes = node.getNumOutcomes(); + + for (int i = 0; i < numOutcomes; i++) { + if ("failure".equals(ctx.getStatus()) && isAtomic) { + LOG.info("Block - stopped executing nodes due to failure status"); + return(null); + } + + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Block - executing outcome " + (i + 1)); + } + while (nextNode != null) + { + nextNode = svc.executeNode(nextNode, ctx); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("Block - done: no outcome " + (i + 1)); + } + } + } + + return (null); + } + + + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BreakNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BreakNodeExecutor.java new file mode 100644 index 000000000..603d7abc5 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BreakNodeExecutor.java @@ -0,0 +1,42 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.BreakNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BreakNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(BreakNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + String message = "BreakNodeExecutor encountered break with nodeId " + node.getNodeId(); + LOG.debug(message); + throw new BreakNodeException(message); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java new file mode 100644 index 000000000..284795bd0 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java @@ -0,0 +1,175 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(CallNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String outValue = "not-found"; + + SvcLogicGraph myGraph = node.getGraph(); + + if (myGraph == null) + { + LOG.debug("execute: getGraph returned null"); + } + else + { + LOG.debug("execute: got SvcLogicGraph"); + } + + SvcLogicExpression moduleExpr = null; + + String module = null; + + moduleExpr = node.getAttribute("module"); + if (moduleExpr != null) + { + module = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + if ((module == null) || (module.length() == 0)) + { + if (myGraph != null) + { + module = myGraph.getModule(); + LOG.debug("myGraph.getModule() returned "+module); + } + } + + SvcLogicExpression rpcExpr = null; + String rpc = null; + rpcExpr = node.getAttribute("rpc"); + if (rpcExpr != null) + { + rpc = SvcLogicExpressionResolver.evaluate(rpcExpr, node, ctx); + } + + if ((rpc == null) || (rpc.length() == 0)) + { + if (myGraph != null) + { + rpc = myGraph.getRpc(); + LOG.debug("myGraph.getRpc() returned "+rpc); + } + } + + String mode = null; + + moduleExpr = node.getAttribute("mode"); + if (moduleExpr != null) + { + mode = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + if ((mode == null) || (mode.length() == 0)) + { + if (myGraph != null) + { + mode = myGraph.getMode(); + + LOG.debug("myGraph.getMode() returned "+mode); + } + } + + String version = null; + + moduleExpr = node.getAttribute("version"); + if (moduleExpr != null) + { + version = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); + } + + String parentGraph = ctx.getAttribute("currentGraph"); + ctx.setAttribute("parentGraph", parentGraph); + + SvcLogicStore store = svc.getStore(); + String errorMessage = "Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found"; + boolean graphWasCalled = false; + if (store != null) { + SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); + if (calledGraph != null) { + LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); + ctx.setAttribute("currentGraph", calledGraph.toString()); + svc.execute(calledGraph, ctx); + outValue = ctx.getStatus(); + graphWasCalled = true; + } else { + LOG.debug(errorMessage); + } + } else { + LOG.debug("Could not get SvcLogicStore reference"); + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + ctx.setAttribute("currentGraph", parentGraph); + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + + if (graphWasCalled == false) { + if (node.getOutcomeValue("catch") != null) { + nextNode = node.getOutcomeValue("catch"); + LOG.debug("graph could not be called, but catch node was found and will be executed"); + } else { + LOG.debug("graph could not be called and no catch node was found, throwing exception"); + throw new SvcLogicException(errorMessage); + } + } + + ctx.setAttribute("currentGraph", parentGraph); + ctx.setAttribute("parentGraph", null); + + return (nextNode); + + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java new file mode 100644 index 000000000..5b1d9efe9 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java @@ -0,0 +1,248 @@ +/*- + * ============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.provider.base; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { + private static final Logger LOG = LoggerFactory + .getLogger(ConfigureNodeExecutor.class); + + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String adaptorName = SvcLogicExpressionResolver.evaluate( + node.getAttribute("adaptor"), node, ctx); + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("configure node encountered - looking for adaptor " + + adaptorName); + } + + SvcLogicAdaptor adaptor = getAdaptor(adaptorName); + + if (adaptor != null) { + String activate = SvcLogicExpressionResolver.evaluate( + node.getAttribute("activate"), node, ctx); + String key = SvcLogicExpressionResolver.evaluate( + node.getAttribute("key"), node, ctx); + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); + + parmMap.put(curName,curExprValue); + } + + if (hasParms) { + SvcLogicAdaptor.ConfigStatus confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + confStatus = adaptor.configure(key, parmMap, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".configure", e); + confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + + switch (confStatus) { + case SUCCESS: + outValue = "success"; + if ((activate != null) && (activate.length() > 0)) { + if ("true".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + activateStatus = adaptor.activate(key, ctx); + } catch (Exception e) { + + LOG.warn("Caught exception from "+adaptorName+".activate", e); + activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (activateStatus) { + case SUCCESS: + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else if ("false".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + deactivateStatus = adaptor.deactivate(key, ctx); + } catch (Exception e) { + + LOG.warn("Caught exception from "+adaptorName+".deactivate", e); + deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (deactivateStatus) { + case SUCCESS: + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } + } + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else { + if ((activate != null) && (activate.length() > 0)) { + if ("true".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + try { + activateStatus = adaptor.activate(key, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".activate", e); + activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (activateStatus) { + case SUCCESS: + outValue = "success"; + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } else if ("false".equalsIgnoreCase(activate)) { + SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + + try { + deactivateStatus = adaptor.deactivate(key, ctx); + } catch (Exception e) { + LOG.warn("Caught exception from "+adaptorName+".deactivate", e); + deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; + } + switch (deactivateStatus) { + case SUCCESS: + outValue = "success"; + break; + case ALREADY_ACTIVE: + outValue = "already-active"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case NOT_READY: + outValue = "not-ready"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } + } else { + LOG.warn("Nothing to configure - no parameters passed, and activate attribute is not set"); + outValue = "success"; + } + } + } else { + if (LOG.isWarnEnabled()) { + LOG.warn("Adaptor for " + adaptorName + " not found"); + } + } + + SvcLogicNode nextNode = node.getOutcomeValue(outValue); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute " + outValue + " branch"); + } + return (nextNode); + } + + nextNode = node.getOutcomeValue("Other"); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("about to execute Other branch"); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("no " + outValue + " or Other branch found"); + } + } + return (nextNode); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/DeleteNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/DeleteNodeExecutor.java new file mode 100644 index 000000000..2393a159d --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/DeleteNodeExecutor.java @@ -0,0 +1,74 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DeleteNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class); + private static final String FAILURE="failure"; + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + + String outValue = FAILURE; + + if (LOG.isDebugEnabled()) { + LOG.debug("delete node encountered - looking for resource class " + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + try { + switch (resourcePlugin.delete(resourceType, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = FAILURE; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = FAILURE; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java new file mode 100644 index 000000000..357f11d02 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java @@ -0,0 +1,141 @@ +/*- + * ============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.provider.base; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { + private static final Logger LOG = LoggerFactory + .getLogger(ExecuteNodeExecutor.class); + + private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure."; + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String pluginName = SvcLogicExpressionResolver.evaluate( + node.getAttribute("plugin"), node, ctx); + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("execute node encountered - looking for plugin " + + pluginName); + } + + SvcLogicJavaPlugin plugin = getSvcLogicJavaPlugin(pluginName); + + if (plugin == null) { + outValue = "not-found"; + } else { + + String methodName = evaluate(node.getAttribute("method"), node, ctx); + + Class pluginClass = plugin.getClass(); + + Method pluginMethod = null; + + try { + pluginMethod = pluginClass.getMethod(methodName, Map.class, SvcLogicContext.class); + } catch (NoSuchMethodException e) { + LOG.error(pluginErrorMessage, e); + } + + if (pluginMethod == null) { + outValue = "unsupported-method"; + } else { + try { + + Map parmMap = new HashMap(); + + Set> parmSet = node + .getParameterSet(); + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); + + parmMap.put(curName,curExprValue); + } + + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + + outValue = mapOutcome(o, emitsOutcome); + + } catch (InvocationTargetException e) { + if(e.getCause() != null){ + LOG.error(pluginErrorMessage, e.getCause()); + }else{ + LOG.error(pluginErrorMessage, e); + } + outValue = "failure"; + ctx.setStatus("failure"); + } catch (IllegalAccessException e) { + LOG.error(pluginErrorMessage, e); + outValue = "failure"; + ctx.setStatus("failure"); + } catch (IllegalArgumentException e) { + LOG.error(pluginErrorMessage, e); + outValue = "failure"; + ctx.setStatus("failure"); + } + } + + } + return (getNextNode(node, outValue)); + } + + protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + return SvcLogicExpressionResolver.evaluate(node.getAttribute("method"), node, ctx); + } + + public String mapOutcome(Object o, String emitsOutcome) { + if (emitsOutcome != null) { + Boolean nodeEmitsOutcome = Boolean.valueOf(emitsOutcome); + if (nodeEmitsOutcome) { + return (String) o; + } else { + return "success"; + } + } else { + return "success"; + } + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExistsNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExistsNodeExecutor.java new file mode 100644 index 000000000..397c5f326 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExistsNodeExecutor.java @@ -0,0 +1,75 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExistsNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(ExistsNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("exists node encountered - looking for resource class " + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + try { + switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) { + case SUCCESS: + outValue = "true"; + break; + case NOT_FOUND: + outValue = "false"; + break; + case FAILURE: + default: + outValue = "false"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExitNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExitNodeExecutor.java new file mode 100644 index 000000000..828e10152 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExitNodeExecutor.java @@ -0,0 +1,42 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.ExitNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExitNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(ExitNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + String message = "ExitNodeExecutor encountered exit with nodeId " + node.getNodeId(); + LOG.debug(message); + throw new ExitNodeException(message); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ForNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ForNodeExecutor.java new file mode 100644 index 000000000..8ca1f32d5 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ForNodeExecutor.java @@ -0,0 +1,109 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.BreakNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ForNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ForNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + SvcLogicExpression atomicExpr = node.getAttribute("atomic"); + String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); + boolean isAtomic = !("false".equalsIgnoreCase(atomicStr)); + + int numOutcomes = node.getNumOutcomes(); + String idxVar = SvcLogicExpressionResolver.evaluate( + node.getAttribute("index"), node, ctx); + String startVal = SvcLogicExpressionResolver.evaluate( + node.getAttribute("start"), node, ctx); + String endVal = SvcLogicExpressionResolver.evaluate( + node.getAttribute("end"), node, ctx); + + LOG.debug("Executing "+ (isAtomic ? "atomic" : "non-atomic") + " for loop - for (int " + idxVar + " = " + startVal + + "; " + idxVar + " < " + endVal + "; " + idxVar + "++)"); + + int startIdx = 0; + int endIdx = 0; + + try { + startIdx = Integer.parseInt(startVal); + endIdx = Integer.parseInt(endVal); + } catch (NumberFormatException e) { + SvcLogicExpression silentFailureExpr = node.getAttribute("silentFailure"); + String silentFailure = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); + boolean isSilentFailure = Boolean.parseBoolean(silentFailure); + String message = "Invalid index values [" + startVal + "," + endVal + "]"; + if(!isSilentFailure){ + throw new SvcLogicException(message); + }else{ + LOG.debug(message + ". Not exiting because silentFailure was set to true."); + return(null); + } + } + + try { + for (int ctr = startIdx; ctr < endIdx; ctr++) { + + ctx.setAttribute(idxVar, "" + ctr); + + for (int i = 0; i < numOutcomes; i++) { + + if ("failure".equals(ctx.getStatus()) && isAtomic) { + LOG.info("For - stopped executing nodes due to failure status"); + return(null); + } + + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("For - executing outcome " + (i + 1)); + } + SvcLogicNode innerNextNode = nextNode; + while (innerNextNode != null) { + innerNextNode = svc.executeNode(innerNextNode, ctx); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("For - done: no outcome " + (i + 1)); + } + } + } + } + } catch (BreakNodeException br) { + LOG.error("ForNodeExecutor caught break",br); + } + return (null); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/GetResourceNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/GetResourceNodeExecutor.java new file mode 100644 index 000000000..a2f1c63d8 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/GetResourceNodeExecutor.java @@ -0,0 +1,99 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GetResourceNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(GetResourceNodeExecutor.class); + + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx); + + // Note: for get-resource, only refresh from A&AI if the DG explicitly set + // local-only to false. Otherwise, just read from local database. + boolean localOnly = true; + + if ("false".equalsIgnoreCase(localOnlyStr)) { + localOnly = false; + } + + SvcLogicExpression selectExpr = node.getAttribute("select"); + String select = null; + + if (selectExpr != null) { + select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); + } + + SvcLogicExpression orderByExpr = node.getAttribute("order-by"); + String orderBy = null; + + if (orderByExpr != null) { + orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, ctx); + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug(node.getNodeType() + " node encountered - looking for resource class " + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + try { + switch (resourcePlugin.query(resourceType, localOnly, select, key, pfx, orderBy, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/IsAvailableNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/IsAvailableNodeExecutor.java new file mode 100644 index 000000000..a93c0d6f2 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/IsAvailableNodeExecutor.java @@ -0,0 +1,71 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IsAvailableNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(IsAvailableNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + String outValue = "failure"; + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + try { + switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) { + case SUCCESS: + outValue = "true"; + break; + case NOT_FOUND: + outValue = "false"; + break; + case FAILURE: + default: + outValue = "false"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/NotifyNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/NotifyNodeExecutor.java new file mode 100644 index 000000000..de59a4b73 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/NotifyNodeExecutor.java @@ -0,0 +1,74 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NotifyNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(NotifyNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String action = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("action"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("release node encountered - looking for resource class " + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + try { + switch (resourcePlugin.notify(resourceType, action, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java new file mode 100644 index 000000000..3522c0a79 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java @@ -0,0 +1,82 @@ +/*- + * ============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.provider.base; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RecordNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(RecordNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String outValue = "failure"; + + if (LOG.isTraceEnabled()) { + LOG.trace(node.getNodeType() + " node encountered - looking for recorder class " + plugin); + } + + Map parmMap = new HashMap(); + + Set> parmSet = node.getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + if (LOG.isTraceEnabled()) { + LOG.trace("executeRecordNode : parameter " + curName + " = " + curExpr + " => " + curExprValue); + } + parmMap.put(curName, curExprValue); + } + + SvcLogicRecorder recorder = getSvcLogicRecorder(plugin); + if (recorder != null) { + try { + recorder.record(parmMap); + } catch (SvcLogicException e) { + LOG.error("Caught exception from recorder plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicRecorder object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReleaseNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReleaseNodeExecutor.java new file mode 100644 index 000000000..ed9d7d7d0 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReleaseNodeExecutor.java @@ -0,0 +1,73 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReleaseNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(ReleaseNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("release node encountered - looking for resource class " + plugin); + } + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + if (resourcePlugin != null) { + try { + switch (resourcePlugin.release(resourceType, key, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReserveNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReserveNodeExecutor.java new file mode 100644 index 000000000..8e21a4594 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReserveNodeExecutor.java @@ -0,0 +1,87 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReserveNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(ReserveNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + + SvcLogicExpression selectExpr = node.getAttribute("select"); + String select = null; + + if (selectExpr != null) { + select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("reserve node encountered - looking for resource class " + plugin); + } + + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java new file mode 100644 index 000000000..d2fe35d75 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java @@ -0,0 +1,78 @@ +/*- + * ============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.provider.base; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ReturnNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(ReturnNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + String status = SvcLogicExpressionResolver.evaluate( + node.getAttribute("status"), node, ctx); + + if (status != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Returning status " + status); + } + ctx.setStatus(status); + } else { + if (LOG.isWarnEnabled()) { + LOG.warn("Return node has no status attribute set"); + } + } + + Set> parameterSet = node + .getParameterSet(); + + for (Iterator> iter = parameterSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + String curValue = SvcLogicExpressionResolver.evaluate( + curEnt.getValue(), node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.debug("Setting context attribute " + curName + " to " + + curValue); + } + ctx.setAttribute(curName, curValue); + } + return null; + } + + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java new file mode 100644 index 000000000..2dfc4074b --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java @@ -0,0 +1,107 @@ +/*- + * ============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.provider.base; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String forceStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("force"), node, ctx); + String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + boolean force = "true".equalsIgnoreCase(forceStr); + boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); + + Map parmMap = new HashMap(); + + Set> parmSet = node.getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); + + parmMap.put(curName, curExprValue); + } + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + plugin); + } + + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.save(resourceType, force, localOnly, key, parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java new file mode 100644 index 000000000..8bebb336e --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java @@ -0,0 +1,179 @@ +/*- + * ============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.provider.base; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.Set; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SetNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(SetNodeExecutor.class); + protected final String arrayPattern = "\\[\\d*\\]"; + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + execute(node,ctx); + return null; + } + + public void execute(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + String ifunsetStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("only-if-unset"), node, ctx); + + boolean ifunset = "true".equalsIgnoreCase(ifunsetStr); + + Set> parameterSet = node.getParameterSet(); + + for (Iterator> iter = parameterSet.iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + String lhsVarName = curName; + + // Resolve LHS of assignment (could contain index variables) + try { + // Backticks symbolize the variable should be handled as an expression instead of as a variable + if (curName.trim().startsWith("`")) { + int lastParen = curName.lastIndexOf("`"); + String evalExpr = curName.trim().substring(1, lastParen); + SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(evalExpr); + lhsVarName = SvcLogicExpressionResolver.evaluate(lhsExpr, node, ctx); + } else { + SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); + lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); + } + } catch (Exception e) { + LOG.warn("Caught exception trying to resolve variable name (" + curName + ")", e); + } + + boolean setValue = true; + + if (curName.endsWith(".")) { + // Copy subtree - value should be a variable name + SvcLogicExpression curValue = curEnt.getValue(); + + if (curValue != null) { + String rhsRoot = curValue.toString(); + + if ((rhsRoot != null) && (rhsRoot.length() > 0)) { + if (rhsRoot.endsWith(".")) { + rhsRoot = rhsRoot.substring(0, rhsRoot.length() - 1); + } + + // SDNGC-2321 : rhsRoot is variable name, possibly with subscript(s) to be resolved + try { + SvcLogicExpression rhsExpr = SvcLogicExpressionFactory.parse(rhsRoot); + rhsRoot = SvcLogicExpressionResolver.resolveVariableName(rhsExpr, node, ctx); + } catch (Exception e) { + LOG.warn("Caught exception trying to resolve variable name (" + rhsRoot + ")", e); + } + + // See if the parameters are reversed (copying service-data to input) .. this + // was done as a workaround to earlier issue + if (curName.endsWith("-input.") && rhsRoot.startsWith("service-data")) { + LOG.warn("Arguments appear to be reversed .. will copy input to service-data instead"); + lhsVarName = rhsRoot + "."; + rhsRoot = curName.substring(0, curName.length() - 1); + } + + rhsRoot = rhsRoot + "."; + String lhsPrefix = lhsVarName; + + if (lhsPrefix.endsWith(".")) { + lhsPrefix = lhsPrefix.substring(0, lhsPrefix.length() - 1); + } + + HashMap parmsToAdd = new HashMap(); + + for (String sourceVarName : ctx.getAttributeKeySet()) { + if (sourceVarName.startsWith(rhsRoot)) { + String targetVar = lhsPrefix + "." + sourceVarName.substring(rhsRoot.length()); + LOG.debug("Copying {} value to {}", sourceVarName, targetVar); + parmsToAdd.put(targetVar, ctx.getAttribute(sourceVarName)); + } + } + for (String newParmName : parmsToAdd.keySet()) { + ctx.setAttribute(newParmName, parmsToAdd.get(newParmName)); + } + } else { + // If RHS is empty, unset attributes in LHS + LinkedList parmsToRemove = new LinkedList(); + String prefix = lhsVarName + "."; + String arrayPrefix = lhsVarName + "["; + //Clear length value in case an array exists with this prefix + String lengthParamName = lhsVarName + "_length"; + LOG.debug("Unsetting {} because prefix {} is being cleared.", lengthParamName, prefix); + + for (String curCtxVarname : ctx.getAttributeKeySet()) { + String curCtxVarnameMatchingValue = curCtxVarname; + //Special handling for reseting array values, strips out brackets and any numbers between the brackets + //when testing if a context memory value starts with a prefix + if(!prefix.contains("[") && curCtxVarnameMatchingValue.contains("[")) { + curCtxVarnameMatchingValue = curCtxVarname.replaceAll(arrayPattern, "") + "."; + } + if (curCtxVarnameMatchingValue.startsWith(prefix)) { + LOG.debug("Unsetting {} because matching value {} starts with the prefix {}", curCtxVarname, curCtxVarnameMatchingValue, prefix); + parmsToRemove.add(curCtxVarname); + }else if (curCtxVarnameMatchingValue.startsWith(lengthParamName)) { + LOG.debug("Unsetting {} because matching value {} starts with the lengthParamName {}", curCtxVarname, curCtxVarnameMatchingValue, lengthParamName); + parmsToRemove.add(curCtxVarname); + }else if (curCtxVarnameMatchingValue.startsWith(arrayPrefix)) { + LOG.debug("Unsetting {} because matching value {} starts with the arrayPrefix {}", curCtxVarname, curCtxVarnameMatchingValue, arrayPrefix); + parmsToRemove.add(curCtxVarname); + } + } + for (String parmName : parmsToRemove) { + ctx.setAttribute(parmName, null); + } + } + } + } else { + if (ifunset) { + String ctxValue = ctx.getAttribute(lhsVarName); + if ((ctxValue != null) && (ctxValue.length() > 0)) { + setValue = false; + LOG.debug("Attribute {} already set and only-if-unset is true, so not overriding", lhsVarName); + } + } + if (setValue) { + String curValue = SvcLogicExpressionResolver.evaluate(curEnt.getValue(), node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.trace("Parameter value {} resolves to {}", curEnt.getValue().asParsedExpr(), curValue); + LOG.debug("Setting context attribute {} to {}", lhsVarName, curValue); + } + ctx.setAttribute(lhsVarName, curValue); + } + } + } + } +} + diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java new file mode 100644 index 000000000..779be9e9e --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java @@ -0,0 +1,605 @@ +/*- + * ============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.provider.base; + +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicAtom; +import org.onap.ccsdk.sli.core.sli.SvcLogicBinaryExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicFunctionCall; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicVariableTerm; +import org.onap.ccsdk.sli.core.sli.SvcLogicAtom.AtomType; +import org.onap.ccsdk.sli.core.sli.SvcLogicBinaryExpression.OperatorType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicExpressionResolver { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExpressionResolver.class); + + public static String evaluate(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + if (expr == null) { + return (null); + } + + + + if (expr instanceof SvcLogicAtom) { + SvcLogicAtom atom = (SvcLogicAtom) expr; + + AtomType atomType = atom.getAtomType(); + switch (atomType) { + case NUMBER: + case STRING: + return (atom.toString()); + case CONTEXT_VAR: + case IDENTIFIER: + + String varName = resolveVariableName(atom, node, ctx); + + if (atomType == AtomType.CONTEXT_VAR) + { + LOG.trace("Evaluating context variable $"+varName); + + String varValue = ctx.getAttribute(varName); + + if (varValue == null) { + LOG.trace("Context variable $"+varName+" unset - treating as empty string"); + varValue = ""; + } + + return (varValue); + } + SvcLogicExpression parm = node.getParameter(varName); + if (parm != null) { + LOG.trace("Evaluating value of parameter "+varName+": "+parm.asParsedExpr()); + + return (evaluate(parm, node, ctx)); + } + else + { + return(varName); + } + default: + return(null); + } + + } else if (expr instanceof SvcLogicBinaryExpression) { + SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; + List operators = binExpr.getOperators(); + if (operators.isEmpty()) + { + List operands = binExpr.getOperands(); + if (operands.size() == 1) + { + LOG.trace("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); + return(evaluate(operands.get(0), node, ctx)); + } + else + { + if (operands.isEmpty()) + { + LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); + } + else + { + LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); + } + return(null); + } + } + switch (operators.get(0)) { + case addOp: + case subOp: + case multOp: + case divOp: + return(evalArithExpression(binExpr, node, ctx)); + case equalOp: + case neOp: + case ltOp: + case leOp: + case gtOp: + case geOp: + return (evalCompareExpression(binExpr, node, ctx)); + case andOp: + case orOp: + return(evalLogicExpression(binExpr, node, ctx)); + + default: + return(null); + } + } + else if (expr instanceof SvcLogicFunctionCall) + { + return(evalFunctionCall((SvcLogicFunctionCall)expr, node, ctx)); + } + else + { + throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); + } + } + + private static String evalArithExpression(SvcLogicBinaryExpression binExpr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + List operands = binExpr.getOperands(); + List operators = binExpr.getOperators(); + if (operands.size() != (operators.size()+1)) + { + throw new SvcLogicException("Invalid expression ("+binExpr+")"); + } + String retval = evaluate(operands.get(0), node, ctx); + String retsval = retval; + long retlval = 0; + boolean valueIsLong = false; + + int i = 1; + try + { + + if ((retval.length() > 0) && StringUtils.isNumeric(retval)) + { + retlval = Long.parseLong(retval); + valueIsLong = true; + } + for (OperatorType operator: operators) + { + String curOperandValue = evaluate(operands.get(i++), node, ctx); + switch(operator) { + case addOp: + retsval = retsval + curOperandValue; + if (valueIsLong) + { + if ((curOperandValue.length() > 0) && StringUtils.isNumeric(curOperandValue) ) + { + retlval = retlval + Long.parseLong(curOperandValue); + } + else + { + valueIsLong = false; + } + } + break; + case subOp: + retlval = retlval - Long.parseLong(curOperandValue); + break; + case multOp: + retlval = retlval * Long.parseLong(curOperandValue); + break; + case divOp: + retlval = retlval / Long.parseLong(curOperandValue); + break; + } + + } + } + catch (NumberFormatException e1) + { + throw new SvcLogicException("Illegal value in arithmetic expression", e1); + } + + if (valueIsLong) + { + return("" + retlval); + } + else + { + return(retsval); + } + + } + + + + private static String evalCompareExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + + List operators = expr.getOperators(); + List operands = expr.getOperands(); + + if ((operators.size() != 1) || (operands.size() != 2)) + { + throw new SvcLogicException ("Invalid comparison expression : "+expr); + } + + OperatorType operator = operators.get(0); + String op1Value = evaluate(operands.get(0), node, ctx); + String op2Value = evaluate(operands.get(1), node, ctx); + + if ((StringUtils.isNotEmpty(op1Value) && StringUtils.isNumeric(op1Value) && StringUtils.isNotEmpty(op2Value) && StringUtils.isNumeric(op2Value))) + { + try + { + double op1dbl = Double.parseDouble(op1Value); + double op2dbl = Double.parseDouble(op2Value); + + switch(operator) + { + case equalOp: + return(Boolean.toString(op1dbl == op2dbl)); + case neOp: + return(Boolean.toString(op1dbl != op2dbl)); + case ltOp: + return(Boolean.toString(op1dbl < op2dbl)); + case leOp: + return(Boolean.toString(op1dbl <= op2dbl)); + case gtOp: + return(Boolean.toString(op1dbl > op2dbl)); + case geOp: + return(Boolean.toString(op1dbl >= op2dbl)); + default: + return(null); + } + } + catch (NumberFormatException e) + { + throw new SvcLogicException("Caught exception trying to compare numeric values", e); + } + } + else + { + + int compResult = 0; + + if (op1Value == null) { + compResult = -1; + } else if (op2Value == null ) { + compResult = 1; + } else { + compResult = op1Value.compareToIgnoreCase(op2Value); + } + + switch(operator) + { + case equalOp: + return(Boolean.toString(compResult == 0)); + case neOp: + return(Boolean.toString(compResult != 0)); + case ltOp: + return(Boolean.toString(compResult < 0)); + case leOp: + return(Boolean.toString(compResult <= 0)); + case gtOp: + return(Boolean.toString(compResult > 0)); + case geOp: + return(Boolean.toString(compResult >= 0)); + default: + return(null); + } + } + + } + + private static String evalLogicExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + boolean retval; + + List operands = expr.getOperands(); + List operators = expr.getOperators(); + + if (operands.size() != (operators.size()+1)) + { + throw new SvcLogicException("Invalid expression ("+expr+")"); + } + + try + { + retval = Boolean.parseBoolean(evaluate(operands.get(0), node, ctx)); + int i = 1; + for (OperatorType operator : operators) + { + if (operator == OperatorType.andOp) + { + retval = retval && Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); + } + else + { + + retval = retval || Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); + } + + } + } + catch (Exception e) + { + throw new SvcLogicException("Invalid expression ("+expr+")"); + } + + + return(Boolean.toString(retval)); + } + + private static String evalFunctionCall(SvcLogicFunctionCall func, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + String funcName = func.getFunctionName(); + List operands = func.getOperands(); + + if ("length".equalsIgnoreCase(funcName)) + { + + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + return(""+opValue.length()); + } + else + { + throw new SvcLogicException("Invalid call to length() function"); + } + } + else if ("substr".equalsIgnoreCase(funcName)) + { + if (operands.size() == 3) + { + String op1Value = evaluate(operands.get(0), node, ctx); + String op2Value = evaluate(operands.get(1), node, ctx); + String op3Value = evaluate(operands.get(2), node, ctx); + + if (!StringUtils.isNumeric(op2Value) || !StringUtils.isNumeric(op3Value)) + { + throw new SvcLogicException("Invalid arguments to substr() function"); + } + + try + { + return(op1Value.substring(Integer.parseInt(op2Value), Integer.parseInt(op3Value))); + } + catch (Exception e) + { + throw new SvcLogicException("Caught exception trying to take substring", e); + } + } + else + { + + throw new SvcLogicException("Invalid call to substr() function"); + } + + } + else if ("toUpperCase".equalsIgnoreCase(funcName)) + { + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + if (opValue != null) { + return(opValue.toUpperCase()); + } else { + return(""); + } + } + else + { + throw new SvcLogicException("Invalid call to toUpperCase() function"); + } + } + else if ("toLowerCase".equalsIgnoreCase(funcName)) + { + if (operands.size() == 1) + { + String opValue = evaluate(operands.get(0), node, ctx); + if (opValue != null) { + return(opValue.toLowerCase()); + } else { + return(""); + } + } + else + { + throw new SvcLogicException("Invalid call to toLowerCase() function"); + } + } + else if ("convertBase".equalsIgnoreCase(funcName)) { + int fromBase = 10; + int toBase = 10; + String srcString = ""; + + if (operands.size() == 2) + { + fromBase = 10; + srcString = evaluate(operands.get(0), node, ctx); + toBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); + } else if (operands.size() == 3) { + + srcString = evaluate(operands.get(0), node, ctx); + fromBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); + toBase = Integer.parseInt(evaluate(operands.get(2), node, ctx)); + } else { + throw new SvcLogicException("Invalid call to convertBase() function"); + } + + long srcValue = Long.parseLong(srcString, fromBase); + return(Long.toString(srcValue, toBase)); + } + else + { + throw new SvcLogicException("Unrecognized function ("+funcName+")"); + } + + } + + public static String evaluateAsKey(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + if (expr == null) { + return (null); + } + + + + if (expr instanceof SvcLogicAtom) { + SvcLogicAtom atom = (SvcLogicAtom) expr; + + AtomType atomType = atom.getAtomType(); + StringBuffer varNameBuff = new StringBuffer(); + switch (atomType) { + case NUMBER: + return (atom.toString()); + case STRING: + return("'"+atom.toString()+"'"); + case CONTEXT_VAR: + case IDENTIFIER: + boolean needDot = false; + for (SvcLogicExpression term : atom.getOperands()) + { + if (needDot) + { + varNameBuff.append("."); + } + if (term instanceof SvcLogicVariableTerm) + { + SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; + varNameBuff.append(vterm.getName()); + if (vterm.numOperands() > 0) + { + varNameBuff.append("["); + varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); + varNameBuff.append("]"); + + } + } + else + { + varNameBuff.append(term.toString()); + } + needDot = true; + } + + String varName = varNameBuff.toString(); + LOG.debug("Evaluating context variable $"+varName); + String ctxValue = ctx.getAttribute(varName); + if (ctxValue == null) + { + return(null); + } + if (StringUtils.isNumeric(ctxValue)) + { + return(ctxValue); + } + else + { + return("'"+ctxValue+"'"); + } + + default: + return(null); + } + + } else if (expr instanceof SvcLogicBinaryExpression) { + SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; + List operators = binExpr.getOperators(); + List operands = binExpr.getOperands(); + if (operators.isEmpty()) + { + if (operands.size() == 1) + { + LOG.debug("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); + return(evaluateAsKey(operands.get(0), node, ctx)); + } + else + { + if (operands.isEmpty()) + { + LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); + } + else + { + LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); + } + return(null); + } + } + StringBuffer sbuff = new StringBuffer(); + sbuff.append(evaluateAsKey(operands.get(0), node, ctx)); + int i = 1; + for (OperatorType operator : operators) + { + sbuff.append(" "); + sbuff.append(operator.toString()); + sbuff.append(" "); + sbuff.append(evaluateAsKey(operands.get(i++), node,ctx)); + } + return(sbuff.toString()); + } + else if (expr instanceof SvcLogicFunctionCall) + { + StringBuffer sbuff = new StringBuffer(); + SvcLogicFunctionCall funcCall = (SvcLogicFunctionCall) expr; + sbuff.append(funcCall.getFunctionName()); + sbuff.append("("); + boolean needComma = false; + for (SvcLogicExpression operand : funcCall.getOperands()) + { + if (needComma) + { + sbuff.append(","); + } + else + { + needComma = true; + } + sbuff.append(evaluateAsKey(operand, node, ctx)); + } + sbuff.append(")"); + return(sbuff.toString()); + } + else + { + throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); + } + } + + public static String resolveVariableName(SvcLogicExpression atom, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException + { + StringBuffer varNameBuff = new StringBuffer(); + + boolean needDot = false; + for (SvcLogicExpression term : atom.getOperands()) + { + if (needDot) + { + varNameBuff.append("."); + } + if (term instanceof SvcLogicVariableTerm) + { + SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; + varNameBuff.append(vterm.getName()); + if (vterm.numOperands() > 0) + { + varNameBuff.append("["); + varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); + varNameBuff.append("]"); + } + } + else + { + varNameBuff.append(term.toString()); + } + needDot = true; + } + return(varNameBuff.toString()); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicPropertiesProvider.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicPropertiesProvider.java new file mode 100644 index 000000000..fc108f951 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicPropertiesProvider.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.provider.base; + +import java.util.Properties; + +public interface SvcLogicPropertiesProvider { + + public Properties getProperties();; +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicResolver.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicResolver.java new file mode 100644 index 000000000..08b675958 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicResolver.java @@ -0,0 +1,17 @@ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; + +public interface SvcLogicResolver { + + abstract SvcLogicResource getSvcLogicResource(String resourceName); + + abstract SvcLogicRecorder getSvcLogicRecorder(String recorderName); + + abstract SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName); + + abstract SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName); +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceBase.java new file mode 100644 index 000000000..8c436fef7 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceBase.java @@ -0,0 +1,66 @@ +/*- + * ============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.provider.base; + +import java.util.Properties; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; + +public interface SvcLogicServiceBase { + + + /** + * Check for existence of a directed graph + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, looks for active version + * @param mode - mode (sync/async) + * @return true if directed graph found, false otherwise + * @throws SvcLogicException + */ + boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; + + /** + * Execute a directed graph + * + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, use active version + * @param mode - mode (sync/async) + * @param parms - parameters, used to set SvcLogicContext attributes + * @return final values of attributes from SvcLogicContext, as Properties + * @throws SvcLogicException + * + * + */ + Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; + + SvcLogicStore getStore() throws SvcLogicException; + + SvcLogicContext execute(SvcLogicGraph calledGraph, SvcLogicContext ctx) throws SvcLogicException; + + SvcLogicNode executeNode(SvcLogicNode nextNode, SvcLogicContext ctx) throws SvcLogicException; + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java new file mode 100644 index 000000000..92fdb9a30 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java @@ -0,0 +1,189 @@ +/*- + * ============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.provider.base; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.ExitNodeException; +import org.onap.ccsdk.sli.core.sli.MetricLogger; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +public class SvcLogicServiceImplBase implements SvcLogicServiceBase { + protected SvcLogicResolver resolver; + protected static final Map BUILTIN_NODES = new HashMap() { + { + put("block", new BlockNodeExecutor()); + put("call", new CallNodeExecutor()); + put("configure", new ConfigureNodeExecutor()); + put("delete", new DeleteNodeExecutor()); + put("execute", new ExecuteNodeExecutor()); + put("exists", new ExistsNodeExecutor()); + put("for", new ForNodeExecutor()); + put("get-resource", new GetResourceNodeExecutor()); + put("is-available", new IsAvailableNodeExecutor()); + put("notify", new NotifyNodeExecutor()); + put("record", new RecordNodeExecutor()); + put("release", new ReleaseNodeExecutor()); + put("reserve", new ReserveNodeExecutor()); + put("return", new ReturnNodeExecutor()); + put("save", new SaveNodeExecutor()); + put("set", new SetNodeExecutor()); + put("switch", new SwitchNodeExecutor()); + put("update", new UpdateNodeExecutor()); + put("break", new BreakNodeExecutor()); + put("while", new WhileNodeExecutor()); + put("exit", new ExitNodeExecutor()); + } + }; + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImplBase.class); + protected HashMap nodeExecutors = null; + protected Properties properties; + protected SvcLogicStore store; + protected static final String CURRENT_GRAPH="currentGraph"; + + public SvcLogicServiceImplBase(SvcLogicStore store) { + this.store = store; + } + + protected void registerExecutors() { + + LOG.info("Entered register executors"); + for (String nodeType : BUILTIN_NODES.keySet()) { + LOG.info("SLI - registering node executor for node type " + nodeType); + registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); + } + LOG.info("Done registerExecutors"); + } + + public void registerExecutor(String nodeName, AbstractSvcLogicNodeExecutor executor) { + if (nodeExecutors == null) { + nodeExecutors = new HashMap<>(); + } + LOG.info("SLI - registering executor for node type {}", nodeName); + executor.setResolver(resolver); + nodeExecutors.put(nodeName, executor); + } + + public void unregisterExecutor(String nodeName) { + LOG.info("SLI - unregistering executor for node type {}", nodeName); + nodeExecutors.remove(nodeName); + } + + public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException { + if (nodeExecutors == null) { + registerExecutors(); + } + + // Set service name in MDC to reference current working directed graph + MDC.put(MetricLogger.SERVICE_NAME, graph.getModule() + ":" + graph.getRpc() + "/v" + graph.getVersion()); + + MDC.put(CURRENT_GRAPH, graph.toString()); + + SvcLogicNode curNode = graph.getRootNode(); + LOG.info("About to execute graph {}", graph.toString()); + try { + while (curNode != null) { + resetContext(); + SvcLogicNode nextNode = executeNode(curNode, ctx); + curNode = nextNode; + } + } catch (ExitNodeException e) { + LOG.debug("SvcLogicServiceImpl caught ExitNodeException"); + } + MDC.remove("nodeId"); + MDC.remove(CURRENT_GRAPH); + + return (ctx); + } + + protected void resetContext() { + + } + + public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + if (node == null) { + return (null); + } + + LOG.info("About to execute node # {} ({})", node.getNodeId(), node.getNodeType()); + + if (LOG.isDebugEnabled()) { + LOG.debug("Executing node " + node.getNodeId() + " of " + node.getGraph().getRpc()); + } + + AbstractSvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); + + if (executor != null) { + LOG.debug("Executing node executor for node type {} - {}", node.getNodeType(), + executor.getClass().getName()); + + MDC.put("nodeId", node.getNodeId() + " (" + node.getNodeType() + ")"); + return (executor.execute(this, node, ctx)); + } else { + throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type"); + } + } + + @Override + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { + return (store.hasGraph(module, rpc, version, mode)); + } + + @Override + public Properties execute(String module, String rpc, String version, String mode, Properties props) + throws SvcLogicException { + LOG.info("Fetching service logic from data store"); + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + + if (graph == null) { + Properties retProps = new Properties(); + retProps.setProperty("error-code", "401"); + retProps.setProperty("error-message", + "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]"); + return (retProps); + } + + SvcLogicContext ctx = new SvcLogicContext(props); + ctx.setAttribute(CURRENT_GRAPH, graph.toString()); + ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); + execute(graph, ctx); + return (ctx.toProperties()); + } + + @Override + public SvcLogicStore getStore() throws SvcLogicException { + return this.store; + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SwitchNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SwitchNodeExecutor.java new file mode 100644 index 000000000..2186a38e0 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SwitchNodeExecutor.java @@ -0,0 +1,63 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SwitchNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory + .getLogger(SwitchNodeExecutor.class); + + @Override + + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + + + String testResult = evaluateNodeTest(node, ctx); + + if (LOG.isDebugEnabled()) { + LOG.debug("Executing switch node"); + + + LOG.debug("test expression (" + node.getAttribute("test") + + ") evaluates to " + testResult); + } + + SvcLogicNode nextNode = node.getOutcomeValue(testResult); + + if (LOG.isDebugEnabled()) { + if (nextNode != null) { + LOG.debug("Next node to execute is node " + nextNode.getNodeId()); + } else { + LOG.debug("No next node found"); + } + } + return (nextNode); + + } +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java new file mode 100644 index 000000000..c4c8faa83 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java @@ -0,0 +1,103 @@ +/*- + * ============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.provider.base; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UpdateNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(UpdateNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) + throws SvcLogicException { + + String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); + String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); + String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); + String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); + + + Map parmMap = new HashMap(); + + Set> parmSet = node.getParameterSet(); + boolean hasParms = false; + + for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { + hasParms = true; + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + if (curExpr != null) { + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + + LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); + + parmMap.put(curName, curExprValue); + } + } + + String outValue = "failure"; + + if (LOG.isDebugEnabled()) { + LOG.debug("save node encountered - looking for resource class " + plugin); + } + + + SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); + + + if (resourcePlugin != null) { + + try { + switch (resourcePlugin.update(resourceType, key, parmMap, pfx, ctx)) { + case SUCCESS: + outValue = "success"; + break; + case NOT_FOUND: + outValue = "not-found"; + break; + case FAILURE: + default: + outValue = "failure"; + } + } catch (SvcLogicException e) { + LOG.error("Caught exception from resource plugin", e); + outValue = "failure"; + } + } else { + LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); + } + return (getNextNode(node, outValue)); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/WhileNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/WhileNodeExecutor.java new file mode 100644 index 000000000..c01e2f51f --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/WhileNodeExecutor.java @@ -0,0 +1,75 @@ +/*- + * ============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.provider.base; + +import org.onap.ccsdk.sli.core.sli.BreakNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WhileNodeExecutor extends AbstractSvcLogicNodeExecutor { + + private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class); + + @Override + public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { + + String testResult = evaluateNodeTest(node, ctx); + SvcLogicExpression silentFailureExpr = node.getAttribute("do"); + String doWhile = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); + if ("true".equals(doWhile)) { + LOG.debug("While loop will execute once regardless of expression because do is set to true"); + } + + try { + while ("true".equals(testResult) || "true".equals(doWhile)) { + if (!"true".equals(doWhile)) { + LOG.debug("Test expression (" + node.getAttribute("test") + ") evaluates to true, executing loop."); + } + int numOutcomes = node.getNumOutcomes() + 1; + for (int i = 0; i < numOutcomes; i++) { + SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); + if (nextNode != null) { + while (nextNode != null) { + nextNode = svc.executeNode(nextNode, ctx); + } + } else { + if ("true".equals(doWhile)) { + LOG.debug("Do executed, will only execute again if test expression is true."); + doWhile = "false"; + } + testResult = evaluateNodeTest(node, ctx); + LOG.debug("test expression (" + node.getAttribute("test") + ") evaluates to " + testResult); + } + } + } + LOG.debug("testResult was " + testResult + " which is not equal to true, exiting while loop."); + } catch (BreakNodeException e) { + LOG.debug("WhileNodeExecutor caught break"); + } + return (null); + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/BadPlugin.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/BadPlugin.java new file mode 100644 index 000000000..6c5877ebc --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/BadPlugin.java @@ -0,0 +1,56 @@ +/*- + * ============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.provider.base; + +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + + +public class BadPlugin implements SvcLogicJavaPlugin { + public String selectLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + String day = parameters.get("day"); + if (day == null || day.length() < 1) { + throw new SvcLogicException("What day is it?"); + } + switch (day) { + case ("monday"): { + return "pizza"; + } + case ("tuesday"): { + return "soup"; + } + case ("wednesday"): { + return "salad"; + } + case ("thursday"): { + return "sushi"; + } + case ("friday"): { + return "bbq"; + } + } + throw new SvcLogicException("Lunch cannot be served"); + } +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyAdaptor.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyAdaptor.java new file mode 100644 index 000000000..58582e0e6 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyAdaptor.java @@ -0,0 +1,54 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +/** + * @author dt5972 + * + */ + +public class DummyAdaptor implements SvcLogicAdaptor { + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#configure(java.lang.String, java.util.Map, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus configure(String key, Map parameters, SvcLogicContext ctx) { + + if ("ALREADY_ACTIVE".equalsIgnoreCase(key)) { + return ConfigStatus.ALREADY_ACTIVE; + } else if ("NOT_FOUND".equalsIgnoreCase(key)) { + return ConfigStatus.NOT_FOUND; + }else if ("NOT_READY".equalsIgnoreCase(key)) { + return ConfigStatus.NOT_READY; + } else if ("FAILURE".equalsIgnoreCase(key)) { + return ConfigStatus.FAILURE; + } else if ("SUCCESS".equalsIgnoreCase(key)) { + return ConfigStatus.SUCCESS; + } + + return ConfigStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#activate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus activate(String key, SvcLogicContext ctx) { + return ConfigStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#deactivate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus deactivate(String key, SvcLogicContext ctx) { + return ConfigStatus.SUCCESS; + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyRecorder.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyRecorder.java new file mode 100644 index 000000000..52bc123a4 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyRecorder.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; + +public class DummyRecorder implements SvcLogicRecorder { + + @Override + public void record(Map parmMap) throws SvcLogicException { + return; + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyResource.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyResource.java new file mode 100644 index 000000000..2e15f3fb7 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyResource.java @@ -0,0 +1,97 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; + +/** + * @author dt5972 + * + */ +public class DummyResource implements SvcLogicResource { + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#isAvailable(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#exists(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#query(java.lang.String, boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, + String orderBy, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#reserve(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#save(java.lang.String, boolean, boolean, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map parms, + String prefix, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#release(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { + + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#delete(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#notify(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#update(java.lang.String, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus update(String resource, String key, Map parms, String prefix, + SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java new file mode 100644 index 000000000..474136d5b --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java @@ -0,0 +1,69 @@ +/*- + * ============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.provider.base; + +import java.util.Map.Entry; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.DuplicateValueException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; + +import junit.framework.TestCase; + +public class ExecuteNodeExecutorTest extends TestCase { + public class MockExecuteNodeExecutor extends ExecuteNodeExecutor { + + protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { + return (SvcLogicJavaPlugin) new LunchSelectorPlugin(); + } + + protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, + SvcLogicContext ctx) throws SvcLogicException { + return "selectLunch"; + } + } + + public void testBadPlugin() throws DuplicateValueException, SvcLogicException { + LunchSelectorPlugin p = new LunchSelectorPlugin(); + MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor(); + SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph()); + node.setAttribute("method", "selectLunch"); + SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider() { + + public Properties getProperties() { + return new Properties(); + }; + }; + + + execute.execute(new SvcLogicServiceImplBase(null), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/LunchSelectorPlugin.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/LunchSelectorPlugin.java new file mode 100644 index 000000000..0f4cab748 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/LunchSelectorPlugin.java @@ -0,0 +1,78 @@ +/*- + * ============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.provider.base; + +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + + + +public class LunchSelectorPlugin implements SvcLogicJavaPlugin { + public class UnknownLunchDayException extends Exception{ + + public UnknownLunchDayException(String string) { + super(string); + } + + } + class Sandwhich { + String meat; + String cheese; + + public Sandwhich(String meat, String cheese) { + this.meat = meat; + this.cheese = cheese; + } + } + + public String selectLunch(Map parameters, SvcLogicContext ctx) throws Exception { + String day = parameters.get("day"); + if (day == null || day.length() < 1) { + throw new UnknownLunchDayException("What day is it?"); + } + switch (day) { + case ("monday"): { + return "pizza"; + } + case ("tuesday"): { + return "soup"; + } + case ("wednesday"): { + return "salad"; + } + case ("thursday"): { + return "sushi"; + } + case ("friday"): { + return "bbq"; + } + } + throw new SvcLogicException("Lunch cannot be served"); + } + + public Sandwhich makeLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + return new Sandwhich("ham", "american"); + } +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java new file mode 100644 index 000000000..cbeb59715 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java @@ -0,0 +1,108 @@ +/*- + * ============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.provider.base; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver; + +import junit.framework.TestCase; + +public class PluginTest extends TestCase { + + // The existing plugins work just like a VoidDummyPlugin + // They will return null simply because they are all void + // The attribute emitsOutcome will not be present, the expected outcome is success when no exception is thrown by the plugin + public void testOldPlugin() throws Exception { + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new VoidDummyPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("dummy", Map.class, SvcLogicContext.class); + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("success",outValue); + } + + //Newer plugins can set the attribute emitsOutcome to true, if so they should return a string + //The string represents the outcome value + public void testNewPlugin() throws Exception { + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("selectLunch", Map.class, SvcLogicContext.class); + + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + + parmMap.put("day", "monday"); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + node.setAttribute("emitsOutcome", "true"); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("pizza", outValue); + + parmMap.put("day", "tuesday"); + outValue = (String) pluginMethod.invoke(plugin, parmMap, ctx); + o = pluginMethod.invoke(plugin, parmMap, ctx); + outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("soup",outValue); + + } + + //APPC had some legacy plugins returning objects which should not be treated as outcomes + //The attribute emitsOutcome will not be set + //The outcome should be success as it has always been + public void testObjPlugin() throws Exception{ + ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); + SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); + + Class pluginClass = plugin.getClass(); + Method pluginMethod = pluginClass.getMethod("makeLunch", Map.class, SvcLogicContext.class); + + Map parmMap = new HashMap(); + SvcLogicContext ctx = new SvcLogicContext(); + Object o = pluginMethod.invoke(plugin, parmMap, ctx); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); + String outValue = executor.mapOutcome(o, emitsOutcome); + assertEquals("success",outValue); + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutorTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutorTest.java new file mode 100644 index 000000000..115989a80 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutorTest.java @@ -0,0 +1,220 @@ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import java.util.LinkedList; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor; + +public class SetNodeExecutorTest { + @Test + public void clearProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertNull(ctx.getAttribute("si.field1")); + assertNull(ctx.getAttribute("si.field2")); + assertNull(ctx.getAttribute("si.field3")); + assertNull(ctx.getAttribute("si.subarray[0]")); + assertNull(ctx.getAttribute("si.subarray[1]")); + assertNull(ctx.getAttribute("si.subarray[2]")); + assertNull(ctx.getAttribute("si.subarray_length")); + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void clearMultipleArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearMultipleArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertNull(ctx.getAttribute("si[0].field1")); + assertNull(ctx.getAttribute("si[1].field2")); + assertNull(ctx.getAttribute("si[2].field3")); + assertNull(ctx.getAttribute("si_length")); + assertNull(ctx.getAttribute("si[0].subarray[0]")); + assertNull(ctx.getAttribute("si[0].subarray[1]")); + assertNull(ctx.getAttribute("si[0].subarray[2]")); + assertNull(ctx.getAttribute("si[0].subarray_length")); + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void clearSingleArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearSingleArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertNull(ctx.getAttribute("si[0].field1")); + assertNull(ctx.getAttribute("si[0].subarray[0]")); + assertNull(ctx.getAttribute("si[0].subarray[1]")); + assertNull(ctx.getAttribute("si[0].subarray[2]")); + assertNull(ctx.getAttribute("si[0].subarray_length")); + + // TODO: This is just setting up elements as null but note reducing the size of Array. + assertEquals("3",ctx.getAttribute("si_length")); + + assertEquals("2",ctx.getAttribute("si[1].field2")); + assertEquals("3", ctx.getAttribute("si[2].field3")); + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void clearSingleSubArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearSingleSubArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1",ctx.getAttribute("tmp.si[0].field1")); + assertEquals("2",ctx.getAttribute("tmp.si[1].field2")); + assertEquals("3", ctx.getAttribute("tmp.si[2].field3")); + assertEquals("3", ctx.getAttribute("tmp.si_length")); + + assertEquals("a",ctx.getAttribute("tmp.si[0].subarray[0]")); + + // TODO: This is setting up element as Empty instead null + //assertNull(ctx.getAttribute("tmp.si[0].subarray[1]")); + assertEquals("", ctx.getAttribute("tmp.si[0].subarray[1]")); + + assertEquals("c", ctx.getAttribute("tmp.si[0].subarray[2]")); + assertEquals("3", ctx.getAttribute("tmp.si[0].subarray_length")); + + assertEquals("x",ctx.getAttribute("tmp.si[1].subarray[0]")); + assertEquals("y",ctx.getAttribute("tmp.si[1].subarray[1]")); + assertEquals("z", ctx.getAttribute("tmp.si[1].subarray[2]")); + assertEquals("3", ctx.getAttribute("tmp.si[1].subarray_length")); + + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void clearSubArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearSubArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1", ctx.getAttribute("si[0].field1")); + assertEquals("2",ctx.getAttribute("si[1].field2")); + assertEquals("3", ctx.getAttribute("si[2].field3")); + assertEquals("3", ctx.getAttribute("si_length")); + assertNull(ctx.getAttribute("si[0].subarray[0]")); + assertNull(ctx.getAttribute("si[0].subarray[1]")); + assertNull(ctx.getAttribute("si[0].subarray[2]")); + assertNull(ctx.getAttribute("si[0].subarray_length")); + + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + + @Test + public void arrayPattern() { + SetNodeExecutor sne = new SetNodeExecutor(); + String source = "one.two[0].three[0].four"; + assertEquals("one.two.three.four", source.replaceAll(sne.arrayPattern, "")); + } + + @Test + public void subtreeCopy() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/copyValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1", ctx.getAttribute("si.field1")); + assertEquals("2", ctx.getAttribute("si.field2")); + assertEquals("3", ctx.getAttribute("si.field3")); + assertEquals("1", ctx.getAttribute("rootTwo.field1")); + assertEquals("2", ctx.getAttribute("rootTwo.field2")); + assertEquals("3", ctx.getAttribute("rootTwo.field3")); + } + + @Test + public void clearNestedSubArrayProperties() throws Exception { + SetNodeExecutor sne = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/clearNestedSubArrayValues.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); + SvcLogicNode nodeOne = root.getOutcomeValue("1"); + SvcLogicNode nodeTwo = root.getOutcomeValue("2"); + + sne.execute(nodeOne, ctx); + sne.execute(nodeTwo, ctx); + + assertEquals("1", ctx.getAttribute("tmp.si[0].field1")); + assertEquals("2",ctx.getAttribute("tmp.si[1].field2")); + assertEquals("3", ctx.getAttribute("tmp.si[2].field3")); + assertEquals("3", ctx.getAttribute("tmp.si_length")); + + assertNull(ctx.getAttribute("tmp.si[0].subarray[0]")); + assertNull(ctx.getAttribute("tmp.si[0].subarray[1]")); + assertNull(ctx.getAttribute("tmp.si[0].subarray[2]")); + assertNull(ctx.getAttribute("tmp.si[0].subarray_length")); + + assertEquals("x", ctx.getAttribute("tmp.si[1].subarray[0]")); + assertEquals("y",ctx.getAttribute("tmp.si[1].subarray[1]")); + assertEquals("z", ctx.getAttribute("tmp.si[1].subarray[2]")); + assertEquals("3", ctx.getAttribute("tmp.si[1].subarray_length")); + + assertEquals("6", ctx.getAttribute("search1")); + assertEquals("KeepMe!", ctx.getAttribute("simonSays")); + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java new file mode 100644 index 000000000..bf4a2622e --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java @@ -0,0 +1,123 @@ +/*- + * ============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.provider.base; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicExprListener; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicNode; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.Assert; +import junit.framework.TestCase; + +public class SvcLogicExpressionResolverTest extends TestCase { + + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicExpressionResolver.class); + + public void testEvaluate() + { + InputStream testStr = getClass().getResourceAsStream("/expression.tests"); + BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); + + try + { + SvcLogicContext ctx = new SvcLogicContext(); + SvcLogicGraph graph = new SvcLogicGraph(); + SvcLogicNode node = new SvcLogicNode(1, "return", graph); + graph.setRootNode(node); + + String line = null; + int lineNo = 0; + while ((line = testsReader.readLine()) != null) { + ++lineNo; + if (line.startsWith("#")) + { + String testExpr = line.trim().substring(1).trim(); + String[] nameValue = testExpr.split("="); + String name = nameValue[0].trim(); + String value = nameValue[1].trim(); + + if (name.startsWith("$")) + { + LOG.info("Setting context attribute "+name+" = "+value); + ctx.setAttribute(name.substring(1), value); + } + else + { + + LOG.info("Setting node attribute "+name+" = "+value); + node.setAttribute(name, value); + + } + } + else + { + // if the line contains #, what comes before is the expression to evaluate, and what comes after + // is the expected value + String[] substrings = line.split("#"); + String expectedValue = substrings.length > 1 ? substrings[1].trim() : null; + String testExpr = substrings[0].trim(); + + LOG.info("Parsing expression "+testExpr); + SvcLogicExpression expr = SvcLogicExpressionFactory.parse(testExpr); + if (expr == null) + { + fail("Unable to parse expression "+testExpr); + } + else + { + LOG.info("Evaluating parsed expression "+expr.asParsedExpr()); + String exprValue = SvcLogicExpressionResolver.evaluate(expr, node, ctx); + if (exprValue == null) + { + fail("Unable to evaluate expression "+testExpr); + } + else + { + LOG.info("Expression " + testExpr + " evaluates to " + exprValue); + if (expectedValue != null) { + Assert.assertEquals("Line " + lineNo + ": " + testExpr, expectedValue, exprValue); + } + } + } + } + } + } + catch (Exception e) + { + LOG.error("Caught exception", e); + fail("Caught exception"); + } + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/VoidDummyPlugin.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/VoidDummyPlugin.java new file mode 100644 index 000000000..b2332e056 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/VoidDummyPlugin.java @@ -0,0 +1,38 @@ +/*- + * ============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.provider.base; + +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + + + +public class VoidDummyPlugin implements SvcLogicJavaPlugin { + + public void dummy(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + return; + } + +} diff --git a/sli/provider-base/src/test/resources/clearMultipleArrayValues.xml b/sli/provider-base/src/test/resources/clearMultipleArrayValues.xml new file mode 100644 index 000000000..8f40058f1 --- /dev/null +++ b/sli/provider-base/src/test/resources/clearMultipleArrayValues.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider-base/src/test/resources/clearNestedSubArrayValues.xml b/sli/provider-base/src/test/resources/clearNestedSubArrayValues.xml new file mode 100644 index 000000000..a80b3e56c --- /dev/null +++ b/sli/provider-base/src/test/resources/clearNestedSubArrayValues.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider-base/src/test/resources/clearSingleArrayValues.xml b/sli/provider-base/src/test/resources/clearSingleArrayValues.xml new file mode 100644 index 000000000..56781a066 --- /dev/null +++ b/sli/provider-base/src/test/resources/clearSingleArrayValues.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider-base/src/test/resources/clearSingleSubArrayValues.xml b/sli/provider-base/src/test/resources/clearSingleSubArrayValues.xml new file mode 100644 index 000000000..22f14f37b --- /dev/null +++ b/sli/provider-base/src/test/resources/clearSingleSubArrayValues.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider-base/src/test/resources/clearSubArrayValues.xml b/sli/provider-base/src/test/resources/clearSubArrayValues.xml new file mode 100644 index 000000000..cb25f38af --- /dev/null +++ b/sli/provider-base/src/test/resources/clearSubArrayValues.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider-base/src/test/resources/clearValues.xml b/sli/provider-base/src/test/resources/clearValues.xml new file mode 100644 index 000000000..dc7f5c8a2 --- /dev/null +++ b/sli/provider-base/src/test/resources/clearValues.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider-base/src/test/resources/copyValues.xml b/sli/provider-base/src/test/resources/copyValues.xml new file mode 100644 index 000000000..f56f7140a --- /dev/null +++ b/sli/provider-base/src/test/resources/copyValues.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sli/provider-base/src/test/resources/expression.tests b/sli/provider-base/src/test/resources/expression.tests new file mode 100644 index 000000000..848a0e7a4 --- /dev/null +++ b/sli/provider-base/src/test/resources/expression.tests @@ -0,0 +1,24 @@ +# $uni-circuit-id = abc123 +# $uni-cir-units = 10 +# value = 1 +# $arg1 = 2 +# $network.name = vCE0001.in +# $network.segment[0].provider-segmentation-id = 1212 +# $network.segment[1].provider-segmentation-id = 1213 +# $availability-zone = mtsnj-esx-az01 +length($uni-circuit-id) > 0 # true +$uni-cir-units * 1000 * 100 / 100 # 10000 +$uni-cir-units / 1000 # 0 +$uni-cir-units - 100 # -90 +$uni-cir-units + 100 # 110 +(value * 3 - $arg1 > 0) and (length($uni-circuit-id) == 0) # true +'pg-'+$network.name # pg-vCE0001.in +$network.segment[0].provider-segmentation-id # 1212 +toUpperCase($network.name) # VCE0001.IN +toLowerCase($network.name) # vce0001.in +toUpperCase(substr($availability-zone, 0, 5)) # MTSNJ +convertBase(1234, 10) # 1234 +convertBase(10, 16, 10) # 16 +convertBase(ZZ, 36, 10) # 1295 +convertBase(10, 10, 36) # a +(0 - 1) * $arg1 # -1 diff --git a/sli/provider-base/src/test/resources/simplelogger.properties b/sli/provider-base/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..07ab67f70 --- /dev/null +++ b/sli/provider-base/src/test/resources/simplelogger.properties @@ -0,0 +1,22 @@ +### +# ============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.slf4j.simpleLogger.defaultLogLevel=info diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 3bf931a7e..0a090282a 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -47,7 +47,12 @@ ${project.version} compile - + + org.onap.ccsdk.sli.core + sli-provider-base + ${project.version} + compile + org.slf4j slf4j-api diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java deleted file mode 100644 index e5ae021fa..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BlockNodeExecutor.java +++ /dev/null @@ -1,75 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BlockNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(BlockNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - SvcLogicExpression atomicExpr = node.getAttribute("atomic"); - String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); - boolean isAtomic = "true".equalsIgnoreCase(atomicStr); - - // Initialize status to success so that at least one outcome will execute - ctx.setStatus("success"); - - int numOutcomes = node.getNumOutcomes(); - - for (int i = 0; i < numOutcomes; i++) { - if ("failure".equals(ctx.getStatus()) && isAtomic) { - LOG.info("Block - stopped executing nodes due to failure status"); - return(null); - } - - SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("Block - executing outcome " + (i + 1)); - } - while (nextNode != null) - { - nextNode = svc.executeNode(nextNode, ctx); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("Block - done: no outcome " + (i + 1)); - } - } - } - - return (null); - } - - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java deleted file mode 100644 index fc6f0a505..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/BreakNodeExecutor.java +++ /dev/null @@ -1,42 +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.provider; - -import org.onap.ccsdk.sli.core.sli.BreakNodeException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BreakNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(BreakNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - String message = "BreakNodeExecutor encountered break with nodeId " + node.getNodeId(); - LOG.debug(message); - throw new BreakNodeException(message); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java deleted file mode 100755 index c8e6548fd..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java +++ /dev/null @@ -1,175 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CallNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(CallNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String outValue = "not-found"; - - SvcLogicGraph myGraph = node.getGraph(); - - if (myGraph == null) - { - LOG.debug("execute: getGraph returned null"); - } - else - { - LOG.debug("execute: got SvcLogicGraph"); - } - - SvcLogicExpression moduleExpr = null; - - String module = null; - - moduleExpr = node.getAttribute("module"); - if (moduleExpr != null) - { - module = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); - } - - if ((module == null) || (module.length() == 0)) - { - if (myGraph != null) - { - module = myGraph.getModule(); - LOG.debug("myGraph.getModule() returned "+module); - } - } - - SvcLogicExpression rpcExpr = null; - String rpc = null; - rpcExpr = node.getAttribute("rpc"); - if (rpcExpr != null) - { - rpc = SvcLogicExpressionResolver.evaluate(rpcExpr, node, ctx); - } - - if ((rpc == null) || (rpc.length() == 0)) - { - if (myGraph != null) - { - rpc = myGraph.getRpc(); - LOG.debug("myGraph.getRpc() returned "+rpc); - } - } - - String mode = null; - - moduleExpr = node.getAttribute("mode"); - if (moduleExpr != null) - { - mode = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); - } - - if ((mode == null) || (mode.length() == 0)) - { - if (myGraph != null) - { - mode = myGraph.getMode(); - - LOG.debug("myGraph.getMode() returned "+mode); - } - } - - String version = null; - - moduleExpr = node.getAttribute("version"); - if (moduleExpr != null) - { - version = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); - } - - String parentGraph = ctx.getAttribute("currentGraph"); - ctx.setAttribute("parentGraph", parentGraph); - - SvcLogicStore store = svc.getStore(); - String errorMessage = "Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found"; - boolean graphWasCalled = false; - if (store != null) { - SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); - if (calledGraph != null) { - LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); - ctx.setAttribute("currentGraph", calledGraph.toString()); - svc.execute(calledGraph, ctx); - outValue = ctx.getStatus(); - graphWasCalled = true; - } else { - LOG.debug(errorMessage); - } - } else { - LOG.debug("Could not get SvcLogicStore reference"); - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - ctx.setAttribute("currentGraph", parentGraph); - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no " + outValue + " or Other branch found"); - } - } - - if (graphWasCalled == false) { - if (node.getOutcomeValue("catch") != null) { - nextNode = node.getOutcomeValue("catch"); - LOG.debug("graph could not be called, but catch node was found and will be executed"); - } else { - LOG.debug("graph could not be called and no catch node was found, throwing exception"); - throw new SvcLogicException(errorMessage); - } - } - - ctx.setAttribute("currentGraph", parentGraph); - ctx.setAttribute("parentGraph", null); - - return (nextNode); - - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java deleted file mode 100644 index 337b7064b..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ConfigureNodeExecutor.java +++ /dev/null @@ -1,248 +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.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ConfigureNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(ConfigureNodeExecutor.class); - - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String adaptorName = SvcLogicExpressionResolver.evaluate( - node.getAttribute("adaptor"), node, ctx); - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("configure node encountered - looking for adaptor " - + adaptorName); - } - - SvcLogicAdaptor adaptor = getAdaptor(adaptorName); - - if (adaptor != null) { - String activate = SvcLogicExpressionResolver.evaluate( - node.getAttribute("activate"), node, ctx); - String key = SvcLogicExpressionResolver.evaluate( - node.getAttribute("key"), node, ctx); - - Map parmMap = new HashMap(); - - Set> parmSet = node - .getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); - - parmMap.put(curName,curExprValue); - } - - if (hasParms) { - SvcLogicAdaptor.ConfigStatus confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - - try { - confStatus = adaptor.configure(key, parmMap, ctx); - } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".configure", e); - confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - - switch (confStatus) { - case SUCCESS: - outValue = "success"; - if ((activate != null) && (activate.length() > 0)) { - if ("true".equalsIgnoreCase(activate)) { - SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - - try { - activateStatus = adaptor.activate(key, ctx); - } catch (Exception e) { - - LOG.warn("Caught exception from "+adaptorName+".activate", e); - activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - switch (activateStatus) { - case SUCCESS: - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } else if ("false".equalsIgnoreCase(activate)) { - SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - - try { - deactivateStatus = adaptor.deactivate(key, ctx); - } catch (Exception e) { - - LOG.warn("Caught exception from "+adaptorName+".deactivate", e); - deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - switch (deactivateStatus) { - case SUCCESS: - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } - } - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } else { - if ((activate != null) && (activate.length() > 0)) { - if ("true".equalsIgnoreCase(activate)) { - SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - try { - activateStatus = adaptor.activate(key, ctx); - } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".activate", e); - activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - switch (activateStatus) { - case SUCCESS: - outValue = "success"; - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } else if ("false".equalsIgnoreCase(activate)) { - SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - - try { - deactivateStatus = adaptor.deactivate(key, ctx); - } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".deactivate", e); - deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; - } - switch (deactivateStatus) { - case SUCCESS: - outValue = "success"; - break; - case ALREADY_ACTIVE: - outValue = "already-active"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case NOT_READY: - outValue = "not-ready"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } - } else { - LOG.warn("Nothing to configure - no parameters passed, and activate attribute is not set"); - outValue = "success"; - } - } - } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Adaptor for " + adaptorName + " not found"); - } - } - - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no " + outValue + " or Other branch found"); - } - } - return (nextNode); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java deleted file mode 100644 index 18f1ce9a7..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/DeleteNodeExecutor.java +++ /dev/null @@ -1,74 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DeleteNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class); - private static final String FAILURE="failure"; - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - - String outValue = FAILURE; - - if (LOG.isDebugEnabled()) { - LOG.debug("delete node encountered - looking for resource class " + plugin); - } - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - try { - switch (resourcePlugin.delete(resourceType, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = FAILURE; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = FAILURE; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java deleted file mode 100644 index ed75c335a..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutor.java +++ /dev/null @@ -1,141 +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.provider; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ExecuteNodeExecutor extends SvcLogicNodeExecutor { - private static final Logger LOG = LoggerFactory - .getLogger(ExecuteNodeExecutor.class); - - private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure."; - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String pluginName = SvcLogicExpressionResolver.evaluate( - node.getAttribute("plugin"), node, ctx); - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("execute node encountered - looking for plugin " - + pluginName); - } - - SvcLogicJavaPlugin plugin = getSvcLogicJavaPlugin(pluginName); - - if (plugin == null) { - outValue = "not-found"; - } else { - - String methodName = evaluate(node.getAttribute("method"), node, ctx); - - Class pluginClass = plugin.getClass(); - - Method pluginMethod = null; - - try { - pluginMethod = pluginClass.getMethod(methodName, Map.class, SvcLogicContext.class); - } catch (NoSuchMethodException e) { - LOG.error(pluginErrorMessage, e); - } - - if (pluginMethod == null) { - outValue = "unsupported-method"; - } else { - try { - - Map parmMap = new HashMap(); - - Set> parmSet = node - .getParameterSet(); - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); - - parmMap.put(curName,curExprValue); - } - - Object o = pluginMethod.invoke(plugin, parmMap, ctx); - String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); - - outValue = mapOutcome(o, emitsOutcome); - - } catch (InvocationTargetException e) { - if(e.getCause() != null){ - LOG.error(pluginErrorMessage, e.getCause()); - }else{ - LOG.error(pluginErrorMessage, e); - } - outValue = "failure"; - ctx.setStatus("failure"); - } catch (IllegalAccessException e) { - LOG.error(pluginErrorMessage, e); - outValue = "failure"; - ctx.setStatus("failure"); - } catch (IllegalArgumentException e) { - LOG.error(pluginErrorMessage, e); - outValue = "failure"; - ctx.setStatus("failure"); - } - } - - } - return (getNextNode(node, outValue)); - } - - protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - return SvcLogicExpressionResolver.evaluate(node.getAttribute("method"), node, ctx); - } - - public String mapOutcome(Object o, String emitsOutcome) { - if (emitsOutcome != null) { - Boolean nodeEmitsOutcome = Boolean.valueOf(emitsOutcome); - if (nodeEmitsOutcome) { - return (String) o; - } else { - return "success"; - } - } else { - return "success"; - } - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java deleted file mode 100644 index 80aec0756..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExistsNodeExecutor.java +++ /dev/null @@ -1,75 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ExistsNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(ExistsNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("exists node encountered - looking for resource class " + plugin); - } - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - try { - switch (resourcePlugin.exists(resourceType, key, pfx, ctx)) { - case SUCCESS: - outValue = "true"; - break; - case NOT_FOUND: - outValue = "false"; - break; - case FAILURE: - default: - outValue = "false"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java deleted file mode 100755 index fc667f40b..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ExitNodeExecutor.java +++ /dev/null @@ -1,42 +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.provider; - -import org.onap.ccsdk.sli.core.sli.ExitNodeException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ExitNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(ExitNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - String message = "ExitNodeExecutor encountered exit with nodeId " + node.getNodeId(); - LOG.debug(message); - throw new ExitNodeException(message); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java deleted file mode 100644 index a73fadcfc..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ForNodeExecutor.java +++ /dev/null @@ -1,109 +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.provider; - -import org.onap.ccsdk.sli.core.sli.BreakNodeException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ForNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(ForNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - SvcLogicExpression atomicExpr = node.getAttribute("atomic"); - String atomicStr = SvcLogicExpressionResolver.evaluate(atomicExpr, node, ctx); - boolean isAtomic = !("false".equalsIgnoreCase(atomicStr)); - - int numOutcomes = node.getNumOutcomes(); - String idxVar = SvcLogicExpressionResolver.evaluate( - node.getAttribute("index"), node, ctx); - String startVal = SvcLogicExpressionResolver.evaluate( - node.getAttribute("start"), node, ctx); - String endVal = SvcLogicExpressionResolver.evaluate( - node.getAttribute("end"), node, ctx); - - LOG.debug("Executing "+ (isAtomic ? "atomic" : "non-atomic") + " for loop - for (int " + idxVar + " = " + startVal - + "; " + idxVar + " < " + endVal + "; " + idxVar + "++)"); - - int startIdx = 0; - int endIdx = 0; - - try { - startIdx = Integer.parseInt(startVal); - endIdx = Integer.parseInt(endVal); - } catch (NumberFormatException e) { - SvcLogicExpression silentFailureExpr = node.getAttribute("silentFailure"); - String silentFailure = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); - boolean isSilentFailure = Boolean.parseBoolean(silentFailure); - String message = "Invalid index values [" + startVal + "," + endVal + "]"; - if(!isSilentFailure){ - throw new SvcLogicException(message); - }else{ - LOG.debug(message + ". Not exiting because silentFailure was set to true."); - return(null); - } - } - - try { - for (int ctr = startIdx; ctr < endIdx; ctr++) { - - ctx.setAttribute(idxVar, "" + ctr); - - for (int i = 0; i < numOutcomes; i++) { - - if ("failure".equals(ctx.getStatus()) && isAtomic) { - LOG.info("For - stopped executing nodes due to failure status"); - return(null); - } - - SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("For - executing outcome " + (i + 1)); - } - SvcLogicNode innerNextNode = nextNode; - while (innerNextNode != null) { - innerNextNode = svc.executeNode(innerNextNode, ctx); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("For - done: no outcome " + (i + 1)); - } - } - } - } - } catch (BreakNodeException br) { - LOG.error("ForNodeExecutor caught break",br); - } - return (null); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java deleted file mode 100644 index 468a6fffc..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/GetResourceNodeExecutor.java +++ /dev/null @@ -1,99 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GetResourceNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(GetResourceNodeExecutor.class); - - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - - String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx); - - // Note: for get-resource, only refresh from A&AI if the DG explicitly set - // local-only to false. Otherwise, just read from local database. - boolean localOnly = true; - - if ("false".equalsIgnoreCase(localOnlyStr)) { - localOnly = false; - } - - SvcLogicExpression selectExpr = node.getAttribute("select"); - String select = null; - - if (selectExpr != null) { - select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); - } - - SvcLogicExpression orderByExpr = node.getAttribute("order-by"); - String orderBy = null; - - if (orderByExpr != null) { - orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, ctx); - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug(node.getNodeType() + " node encountered - looking for resource class " + plugin); - } - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - try { - switch (resourcePlugin.query(resourceType, localOnly, select, key, pfx, orderBy, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java deleted file mode 100644 index 72d99e4f2..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/IsAvailableNodeExecutor.java +++ /dev/null @@ -1,71 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IsAvailableNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(IsAvailableNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - - String outValue = "failure"; - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - try { - switch (resourcePlugin.isAvailable(resourceType, key, pfx, ctx)) { - case SUCCESS: - outValue = "true"; - break; - case NOT_FOUND: - outValue = "false"; - break; - case FAILURE: - default: - outValue = "false"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java deleted file mode 100644 index 44d1ec8fd..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/NotifyNodeExecutor.java +++ /dev/null @@ -1,74 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NotifyNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(NotifyNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String action = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("action"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("release node encountered - looking for resource class " + plugin); - } - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - try { - switch (resourcePlugin.notify(resourceType, action, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java deleted file mode 100644 index e39414461..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/RecordNodeExecutor.java +++ /dev/null @@ -1,82 +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.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RecordNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(RecordNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String outValue = "failure"; - - if (LOG.isTraceEnabled()) { - LOG.trace(node.getNodeType() + " node encountered - looking for recorder class " + plugin); - } - - Map parmMap = new HashMap(); - - Set> parmSet = node.getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - if (LOG.isTraceEnabled()) { - LOG.trace("executeRecordNode : parameter " + curName + " = " + curExpr + " => " + curExprValue); - } - parmMap.put(curName, curExprValue); - } - - SvcLogicRecorder recorder = getSvcLogicRecorder(plugin); - if (recorder != null) { - try { - recorder.record(parmMap); - } catch (SvcLogicException e) { - LOG.error("Caught exception from recorder plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicRecorder object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java deleted file mode 100644 index b0453fadc..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReleaseNodeExecutor.java +++ /dev/null @@ -1,73 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReleaseNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(ReleaseNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("release node encountered - looking for resource class " + plugin); - } - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - if (resourcePlugin != null) { - try { - switch (resourcePlugin.release(resourceType, key, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java deleted file mode 100644 index 00355cd0e..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReserveNodeExecutor.java +++ /dev/null @@ -1,87 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReserveNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(ReserveNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - - - SvcLogicExpression selectExpr = node.getAttribute("select"); - String select = null; - - if (selectExpr != null) { - select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("reserve node encountered - looking for resource class " + plugin); - } - - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java deleted file mode 100644 index e05692d5d..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/ReturnNodeExecutor.java +++ /dev/null @@ -1,78 +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.provider; - -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ReturnNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(ReturnNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - String status = SvcLogicExpressionResolver.evaluate( - node.getAttribute("status"), node, ctx); - - if (status != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("Returning status " + status); - } - ctx.setStatus(status); - } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Return node has no status attribute set"); - } - } - - Set> parameterSet = node - .getParameterSet(); - - for (Iterator> iter = parameterSet - .iterator(); iter.hasNext();) { - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - String curValue = SvcLogicExpressionResolver.evaluate( - curEnt.getValue(), node, ctx); - - if (LOG.isDebugEnabled()) { - LOG.debug("Setting context attribute " + curName + " to " - + curValue); - } - ctx.setAttribute(curName, curValue); - } - return null; - } - - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java deleted file mode 100644 index 1b5219bea..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SaveNodeExecutor.java +++ /dev/null @@ -1,107 +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.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SaveNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String forceStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("force"), node, ctx); - String localOnlyStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("local-only"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - - boolean force = "true".equalsIgnoreCase(forceStr); - boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); - - Map parmMap = new HashMap(); - - Set> parmSet = node.getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); - - parmMap.put(curName, curExprValue); - } - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("save node encountered - looking for resource class " + plugin); - } - - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.save(resourceType, force, localOnly, key, parmMap, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java deleted file mode 100755 index 8275a8e40..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java +++ /dev/null @@ -1,179 +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.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.Set; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SetNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(SetNodeExecutor.class); - protected final String arrayPattern = "\\[\\d*\\]"; - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - execute(node,ctx); - return null; - } - - public void execute(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - String ifunsetStr = SvcLogicExpressionResolver.evaluate(node.getAttribute("only-if-unset"), node, ctx); - - boolean ifunset = "true".equalsIgnoreCase(ifunsetStr); - - Set> parameterSet = node.getParameterSet(); - - for (Iterator> iter = parameterSet.iterator(); iter.hasNext();) { - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - String lhsVarName = curName; - - // Resolve LHS of assignment (could contain index variables) - try { - // Backticks symbolize the variable should be handled as an expression instead of as a variable - if (curName.trim().startsWith("`")) { - int lastParen = curName.lastIndexOf("`"); - String evalExpr = curName.trim().substring(1, lastParen); - SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(evalExpr); - lhsVarName = SvcLogicExpressionResolver.evaluate(lhsExpr, node, ctx); - } else { - SvcLogicExpression lhsExpr = SvcLogicExpressionFactory.parse(curName); - lhsVarName = SvcLogicExpressionResolver.resolveVariableName(lhsExpr, node, ctx); - } - } catch (Exception e) { - LOG.warn("Caught exception trying to resolve variable name (" + curName + ")", e); - } - - boolean setValue = true; - - if (curName.endsWith(".")) { - // Copy subtree - value should be a variable name - SvcLogicExpression curValue = curEnt.getValue(); - - if (curValue != null) { - String rhsRoot = curValue.toString(); - - if ((rhsRoot != null) && (rhsRoot.length() > 0)) { - if (rhsRoot.endsWith(".")) { - rhsRoot = rhsRoot.substring(0, rhsRoot.length() - 1); - } - - // SDNGC-2321 : rhsRoot is variable name, possibly with subscript(s) to be resolved - try { - SvcLogicExpression rhsExpr = SvcLogicExpressionFactory.parse(rhsRoot); - rhsRoot = SvcLogicExpressionResolver.resolveVariableName(rhsExpr, node, ctx); - } catch (Exception e) { - LOG.warn("Caught exception trying to resolve variable name (" + rhsRoot + ")", e); - } - - // See if the parameters are reversed (copying service-data to input) .. this - // was done as a workaround to earlier issue - if (curName.endsWith("-input.") && rhsRoot.startsWith("service-data")) { - LOG.warn("Arguments appear to be reversed .. will copy input to service-data instead"); - lhsVarName = rhsRoot + "."; - rhsRoot = curName.substring(0, curName.length() - 1); - } - - rhsRoot = rhsRoot + "."; - String lhsPrefix = lhsVarName; - - if (lhsPrefix.endsWith(".")) { - lhsPrefix = lhsPrefix.substring(0, lhsPrefix.length() - 1); - } - - HashMap parmsToAdd = new HashMap(); - - for (String sourceVarName : ctx.getAttributeKeySet()) { - if (sourceVarName.startsWith(rhsRoot)) { - String targetVar = lhsPrefix + "." + sourceVarName.substring(rhsRoot.length()); - LOG.debug("Copying {} value to {}", sourceVarName, targetVar); - parmsToAdd.put(targetVar, ctx.getAttribute(sourceVarName)); - } - } - for (String newParmName : parmsToAdd.keySet()) { - ctx.setAttribute(newParmName, parmsToAdd.get(newParmName)); - } - } else { - // If RHS is empty, unset attributes in LHS - LinkedList parmsToRemove = new LinkedList(); - String prefix = lhsVarName + "."; - String arrayPrefix = lhsVarName + "["; - //Clear length value in case an array exists with this prefix - String lengthParamName = lhsVarName + "_length"; - LOG.debug("Unsetting {} because prefix {} is being cleared.", lengthParamName, prefix); - - for (String curCtxVarname : ctx.getAttributeKeySet()) { - String curCtxVarnameMatchingValue = curCtxVarname; - //Special handling for reseting array values, strips out brackets and any numbers between the brackets - //when testing if a context memory value starts with a prefix - if(!prefix.contains("[") && curCtxVarnameMatchingValue.contains("[")) { - curCtxVarnameMatchingValue = curCtxVarname.replaceAll(arrayPattern, "") + "."; - } - if (curCtxVarnameMatchingValue.startsWith(prefix)) { - LOG.debug("Unsetting {} because matching value {} starts with the prefix {}", curCtxVarname, curCtxVarnameMatchingValue, prefix); - parmsToRemove.add(curCtxVarname); - }else if (curCtxVarnameMatchingValue.startsWith(lengthParamName)) { - LOG.debug("Unsetting {} because matching value {} starts with the lengthParamName {}", curCtxVarname, curCtxVarnameMatchingValue, lengthParamName); - parmsToRemove.add(curCtxVarname); - }else if (curCtxVarnameMatchingValue.startsWith(arrayPrefix)) { - LOG.debug("Unsetting {} because matching value {} starts with the arrayPrefix {}", curCtxVarname, curCtxVarnameMatchingValue, arrayPrefix); - parmsToRemove.add(curCtxVarname); - } - } - for (String parmName : parmsToRemove) { - ctx.setAttribute(parmName, null); - } - } - } - } else { - if (ifunset) { - String ctxValue = ctx.getAttribute(lhsVarName); - if ((ctxValue != null) && (ctxValue.length() > 0)) { - setValue = false; - LOG.debug("Attribute {} already set and only-if-unset is true, so not overriding", lhsVarName); - } - } - if (setValue) { - String curValue = SvcLogicExpressionResolver.evaluate(curEnt.getValue(), node, ctx); - - if (LOG.isDebugEnabled()) { - LOG.trace("Parameter value {} resolves to {}", curEnt.getValue().asParsedExpr(), curValue); - LOG.debug("Setting context attribute {} to {}", lhsVarName, curValue); - } - ctx.setAttribute(lhsVarName, curValue); - } - } - } - } -} - diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java index ecfe6b69a..540c04ef0 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java @@ -24,9 +24,6 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.util.HashMap; import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +53,7 @@ public class SvcLogicAdaptorFactory { return adaptorMap.get(name); } else { - SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.resolve(name); + SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.getInstance().resolve(name); if (adaptor != null) { registerAdaptor(adaptor); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java index d2b733fc3..f10976a5d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java @@ -1,5 +1,10 @@ package org.onap.ccsdk.sli.core.sli.provider; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -7,35 +12,63 @@ import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SvcLogicClassResolver { - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class); +public class SvcLogicClassResolver implements SvcLogicResolver { + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class); + private static SvcLogicClassResolver instance = new SvcLogicClassResolver(); - public static Object resolve(String className) { + private SvcLogicClassResolver() { + } - Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class); + public static SvcLogicClassResolver getInstance() { + return instance; + } - if (bundle == null) { - // Running outside OSGi container (e.g. jUnit). Use Reflection - // to resolve class - try { - return(Class.forName(className).newInstance()); - } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + public Object resolve(String className) { - LOG.error("Could not resolve class "+className, e); - return null; - } + Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class); - } else { - BundleContext bctx = bundle.getBundleContext(); - ServiceReference sref = bctx.getServiceReference(className); - if (sref != null) { - return bctx.getService(sref); - } else { + if (bundle == null) { + // Running outside OSGi container (e.g. jUnit). Use Reflection + // to resolve class + try { + return (Class.forName(className).newInstance()); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { - LOG.warn("Could not find service reference object for class " + className); - return null; - } - } - } + LOG.error("Could not resolve class " + className, e); + return null; + } + + } else { + BundleContext bctx = bundle.getBundleContext(); + ServiceReference sref = bctx.getServiceReference(className); + if (sref != null) { + return bctx.getService(sref); + } else { + + LOG.warn("Could not find service reference object for class " + className); + return null; + } + } + } + + @Override + public SvcLogicResource getSvcLogicResource(String resourceName) { + return (SvcLogicResource) resolve(resourceName); + } + + @Override + public SvcLogicRecorder getSvcLogicRecorder(String recorderName) { + return (SvcLogicRecorder) resolve(recorderName); + } + + @Override + public SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { + return (SvcLogicJavaPlugin) resolve(pluginName); + } + + @Override + public SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName) { + return SvcLogicAdaptorFactory.getInstance(adaptorName); + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java deleted file mode 100644 index c9446bdaa..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolver.java +++ /dev/null @@ -1,605 +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.provider; - -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicAtom; -import org.onap.ccsdk.sli.core.sli.SvcLogicBinaryExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicFunctionCall; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicVariableTerm; -import org.onap.ccsdk.sli.core.sli.SvcLogicAtom.AtomType; -import org.onap.ccsdk.sli.core.sli.SvcLogicBinaryExpression.OperatorType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SvcLogicExpressionResolver { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicExpressionResolver.class); - - public static String evaluate(SvcLogicExpression expr, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - if (expr == null) { - return (null); - } - - - - if (expr instanceof SvcLogicAtom) { - SvcLogicAtom atom = (SvcLogicAtom) expr; - - AtomType atomType = atom.getAtomType(); - switch (atomType) { - case NUMBER: - case STRING: - return (atom.toString()); - case CONTEXT_VAR: - case IDENTIFIER: - - String varName = resolveVariableName(atom, node, ctx); - - if (atomType == AtomType.CONTEXT_VAR) - { - LOG.trace("Evaluating context variable $"+varName); - - String varValue = ctx.getAttribute(varName); - - if (varValue == null) { - LOG.trace("Context variable $"+varName+" unset - treating as empty string"); - varValue = ""; - } - - return (varValue); - } - SvcLogicExpression parm = node.getParameter(varName); - if (parm != null) { - LOG.trace("Evaluating value of parameter "+varName+": "+parm.asParsedExpr()); - - return (evaluate(parm, node, ctx)); - } - else - { - return(varName); - } - default: - return(null); - } - - } else if (expr instanceof SvcLogicBinaryExpression) { - SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; - List operators = binExpr.getOperators(); - if (operators.isEmpty()) - { - List operands = binExpr.getOperands(); - if (operands.size() == 1) - { - LOG.trace("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); - return(evaluate(operands.get(0), node, ctx)); - } - else - { - if (operands.isEmpty()) - { - LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); - } - else - { - LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); - } - return(null); - } - } - switch (operators.get(0)) { - case addOp: - case subOp: - case multOp: - case divOp: - return(evalArithExpression(binExpr, node, ctx)); - case equalOp: - case neOp: - case ltOp: - case leOp: - case gtOp: - case geOp: - return (evalCompareExpression(binExpr, node, ctx)); - case andOp: - case orOp: - return(evalLogicExpression(binExpr, node, ctx)); - - default: - return(null); - } - } - else if (expr instanceof SvcLogicFunctionCall) - { - return(evalFunctionCall((SvcLogicFunctionCall)expr, node, ctx)); - } - else - { - throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); - } - } - - private static String evalArithExpression(SvcLogicBinaryExpression binExpr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - List operands = binExpr.getOperands(); - List operators = binExpr.getOperators(); - if (operands.size() != (operators.size()+1)) - { - throw new SvcLogicException("Invalid expression ("+binExpr+")"); - } - String retval = evaluate(operands.get(0), node, ctx); - String retsval = retval; - long retlval = 0; - boolean valueIsLong = false; - - int i = 1; - try - { - - if ((retval.length() > 0) && StringUtils.isNumeric(retval)) - { - retlval = Long.parseLong(retval); - valueIsLong = true; - } - for (OperatorType operator: operators) - { - String curOperandValue = evaluate(operands.get(i++), node, ctx); - switch(operator) { - case addOp: - retsval = retsval + curOperandValue; - if (valueIsLong) - { - if ((curOperandValue.length() > 0) && StringUtils.isNumeric(curOperandValue) ) - { - retlval = retlval + Long.parseLong(curOperandValue); - } - else - { - valueIsLong = false; - } - } - break; - case subOp: - retlval = retlval - Long.parseLong(curOperandValue); - break; - case multOp: - retlval = retlval * Long.parseLong(curOperandValue); - break; - case divOp: - retlval = retlval / Long.parseLong(curOperandValue); - break; - } - - } - } - catch (NumberFormatException e1) - { - throw new SvcLogicException("Illegal value in arithmetic expression", e1); - } - - if (valueIsLong) - { - return("" + retlval); - } - else - { - return(retsval); - } - - } - - - - private static String evalCompareExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException - { - - List operators = expr.getOperators(); - List operands = expr.getOperands(); - - if ((operators.size() != 1) || (operands.size() != 2)) - { - throw new SvcLogicException ("Invalid comparison expression : "+expr); - } - - OperatorType operator = operators.get(0); - String op1Value = evaluate(operands.get(0), node, ctx); - String op2Value = evaluate(operands.get(1), node, ctx); - - if ((StringUtils.isNotEmpty(op1Value) && StringUtils.isNumeric(op1Value) && StringUtils.isNotEmpty(op2Value) && StringUtils.isNumeric(op2Value))) - { - try - { - double op1dbl = Double.parseDouble(op1Value); - double op2dbl = Double.parseDouble(op2Value); - - switch(operator) - { - case equalOp: - return(Boolean.toString(op1dbl == op2dbl)); - case neOp: - return(Boolean.toString(op1dbl != op2dbl)); - case ltOp: - return(Boolean.toString(op1dbl < op2dbl)); - case leOp: - return(Boolean.toString(op1dbl <= op2dbl)); - case gtOp: - return(Boolean.toString(op1dbl > op2dbl)); - case geOp: - return(Boolean.toString(op1dbl >= op2dbl)); - default: - return(null); - } - } - catch (NumberFormatException e) - { - throw new SvcLogicException("Caught exception trying to compare numeric values", e); - } - } - else - { - - int compResult = 0; - - if (op1Value == null) { - compResult = -1; - } else if (op2Value == null ) { - compResult = 1; - } else { - compResult = op1Value.compareToIgnoreCase(op2Value); - } - - switch(operator) - { - case equalOp: - return(Boolean.toString(compResult == 0)); - case neOp: - return(Boolean.toString(compResult != 0)); - case ltOp: - return(Boolean.toString(compResult < 0)); - case leOp: - return(Boolean.toString(compResult <= 0)); - case gtOp: - return(Boolean.toString(compResult > 0)); - case geOp: - return(Boolean.toString(compResult >= 0)); - default: - return(null); - } - } - - } - - private static String evalLogicExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException - { - boolean retval; - - List operands = expr.getOperands(); - List operators = expr.getOperators(); - - if (operands.size() != (operators.size()+1)) - { - throw new SvcLogicException("Invalid expression ("+expr+")"); - } - - try - { - retval = Boolean.parseBoolean(evaluate(operands.get(0), node, ctx)); - int i = 1; - for (OperatorType operator : operators) - { - if (operator == OperatorType.andOp) - { - retval = retval && Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); - } - else - { - - retval = retval || Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); - } - - } - } - catch (Exception e) - { - throw new SvcLogicException("Invalid expression ("+expr+")"); - } - - - return(Boolean.toString(retval)); - } - - private static String evalFunctionCall(SvcLogicFunctionCall func, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException - { - String funcName = func.getFunctionName(); - List operands = func.getOperands(); - - if ("length".equalsIgnoreCase(funcName)) - { - - if (operands.size() == 1) - { - String opValue = evaluate(operands.get(0), node, ctx); - return(""+opValue.length()); - } - else - { - throw new SvcLogicException("Invalid call to length() function"); - } - } - else if ("substr".equalsIgnoreCase(funcName)) - { - if (operands.size() == 3) - { - String op1Value = evaluate(operands.get(0), node, ctx); - String op2Value = evaluate(operands.get(1), node, ctx); - String op3Value = evaluate(operands.get(2), node, ctx); - - if (!StringUtils.isNumeric(op2Value) || !StringUtils.isNumeric(op3Value)) - { - throw new SvcLogicException("Invalid arguments to substr() function"); - } - - try - { - return(op1Value.substring(Integer.parseInt(op2Value), Integer.parseInt(op3Value))); - } - catch (Exception e) - { - throw new SvcLogicException("Caught exception trying to take substring", e); - } - } - else - { - - throw new SvcLogicException("Invalid call to substr() function"); - } - - } - else if ("toUpperCase".equalsIgnoreCase(funcName)) - { - if (operands.size() == 1) - { - String opValue = evaluate(operands.get(0), node, ctx); - if (opValue != null) { - return(opValue.toUpperCase()); - } else { - return(""); - } - } - else - { - throw new SvcLogicException("Invalid call to toUpperCase() function"); - } - } - else if ("toLowerCase".equalsIgnoreCase(funcName)) - { - if (operands.size() == 1) - { - String opValue = evaluate(operands.get(0), node, ctx); - if (opValue != null) { - return(opValue.toLowerCase()); - } else { - return(""); - } - } - else - { - throw new SvcLogicException("Invalid call to toLowerCase() function"); - } - } - else if ("convertBase".equalsIgnoreCase(funcName)) { - int fromBase = 10; - int toBase = 10; - String srcString = ""; - - if (operands.size() == 2) - { - fromBase = 10; - srcString = evaluate(operands.get(0), node, ctx); - toBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); - } else if (operands.size() == 3) { - - srcString = evaluate(operands.get(0), node, ctx); - fromBase = Integer.parseInt(evaluate(operands.get(1), node, ctx)); - toBase = Integer.parseInt(evaluate(operands.get(2), node, ctx)); - } else { - throw new SvcLogicException("Invalid call to convertBase() function"); - } - - long srcValue = Long.parseLong(srcString, fromBase); - return(Long.toString(srcValue, toBase)); - } - else - { - throw new SvcLogicException("Unrecognized function ("+funcName+")"); - } - - } - - public static String evaluateAsKey(SvcLogicExpression expr, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - if (expr == null) { - return (null); - } - - - - if (expr instanceof SvcLogicAtom) { - SvcLogicAtom atom = (SvcLogicAtom) expr; - - AtomType atomType = atom.getAtomType(); - StringBuffer varNameBuff = new StringBuffer(); - switch (atomType) { - case NUMBER: - return (atom.toString()); - case STRING: - return("'"+atom.toString()+"'"); - case CONTEXT_VAR: - case IDENTIFIER: - boolean needDot = false; - for (SvcLogicExpression term : atom.getOperands()) - { - if (needDot) - { - varNameBuff.append("."); - } - if (term instanceof SvcLogicVariableTerm) - { - SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; - varNameBuff.append(vterm.getName()); - if (vterm.numOperands() > 0) - { - varNameBuff.append("["); - varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); - varNameBuff.append("]"); - - } - } - else - { - varNameBuff.append(term.toString()); - } - needDot = true; - } - - String varName = varNameBuff.toString(); - LOG.debug("Evaluating context variable $"+varName); - String ctxValue = ctx.getAttribute(varName); - if (ctxValue == null) - { - return(null); - } - if (StringUtils.isNumeric(ctxValue)) - { - return(ctxValue); - } - else - { - return("'"+ctxValue+"'"); - } - - default: - return(null); - } - - } else if (expr instanceof SvcLogicBinaryExpression) { - SvcLogicBinaryExpression binExpr = (SvcLogicBinaryExpression) expr; - List operators = binExpr.getOperators(); - List operands = binExpr.getOperands(); - if (operators.isEmpty()) - { - if (operands.size() == 1) - { - LOG.debug("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); - return(evaluateAsKey(operands.get(0), node, ctx)); - } - else - { - if (operands.isEmpty()) - { - LOG.error("SvcLogicBinaryExpression has no operators and no operands - evaluating value as null"); - } - else - { - LOG.error("SvcLogicBinaryExpression has no operators and "+operands.size()+" operands - evaluating value as null"); - } - return(null); - } - } - StringBuffer sbuff = new StringBuffer(); - sbuff.append(evaluateAsKey(operands.get(0), node, ctx)); - int i = 1; - for (OperatorType operator : operators) - { - sbuff.append(" "); - sbuff.append(operator.toString()); - sbuff.append(" "); - sbuff.append(evaluateAsKey(operands.get(i++), node,ctx)); - } - return(sbuff.toString()); - } - else if (expr instanceof SvcLogicFunctionCall) - { - StringBuffer sbuff = new StringBuffer(); - SvcLogicFunctionCall funcCall = (SvcLogicFunctionCall) expr; - sbuff.append(funcCall.getFunctionName()); - sbuff.append("("); - boolean needComma = false; - for (SvcLogicExpression operand : funcCall.getOperands()) - { - if (needComma) - { - sbuff.append(","); - } - else - { - needComma = true; - } - sbuff.append(evaluateAsKey(operand, node, ctx)); - } - sbuff.append(")"); - return(sbuff.toString()); - } - else - { - throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); - } - } - - public static String resolveVariableName(SvcLogicExpression atom, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException - { - StringBuffer varNameBuff = new StringBuffer(); - - boolean needDot = false; - for (SvcLogicExpression term : atom.getOperands()) - { - if (needDot) - { - varNameBuff.append("."); - } - if (term instanceof SvcLogicVariableTerm) - { - SvcLogicVariableTerm vterm = (SvcLogicVariableTerm) term; - varNameBuff.append(vterm.getName()); - if (vterm.numOperands() > 0) - { - varNameBuff.append("["); - varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); - varNameBuff.append("]"); - } - } - else - { - varNameBuff.append(term.toString()); - } - needDot = true; - } - return(varNameBuff.toString()); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java deleted file mode 100644 index 34fdb5373..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java +++ /dev/null @@ -1,94 +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.provider; - -import org.onap.ccsdk.sli.core.sli.MetricLogger; -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public abstract class SvcLogicNodeExecutor { - - public abstract SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; - - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicNodeExecutor.class); - - protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - if (node == null) { - return null; - } - - return (SvcLogicExpressionResolver.evaluate(node.getAttribute("test"), - node, ctx)); - - } - - - - protected SvcLogicAdaptor getAdaptor(String adaptorName) { - return SvcLogicAdaptorFactory.getInstance(adaptorName); - } - - protected SvcLogicResource getSvcLogicResource(String plugin) { - - return((SvcLogicResource) SvcLogicClassResolver.resolve(plugin)); - } - - protected SvcLogicRecorder getSvcLogicRecorder(String plugin) { - return((SvcLogicRecorder) SvcLogicClassResolver.resolve(plugin)); - } - - protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){ - return((SvcLogicJavaPlugin) SvcLogicClassResolver.resolve(pluginName)); - - } - - protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) { - MetricLogger.resetContext(); - SvcLogicNode nextNode = node.getOutcomeValue(outValue); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute " + outValue + " branch"); - } - return (nextNode); - } - - nextNode = node.getOutcomeValue("Other"); - if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("about to execute Other branch"); - } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("no " + outValue + " or Other branch found"); - } - } - return (nextNode); - } -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java deleted file mode 100644 index 9debd6bc5..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.provider; - -import java.util.Properties; - -public interface SvcLogicPropertiesProvider { - - public Properties getProperties();; -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java index a9992a094..c4680cce5 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java @@ -31,6 +31,7 @@ import java.util.Vector; import org.onap.ccsdk.sli.core.dblib.DblibConfigurationException; import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; import org.onap.ccsdk.sli.core.utils.JREFileResolver; import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java index 3f24adff7..a23594ee3 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicService.java @@ -22,43 +22,15 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -public interface SvcLogicService { +public interface SvcLogicService extends SvcLogicServiceBase { String NAME = "org.onap.ccsdk.sli.core.sli.provider.SvcLogicService"; - // public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException; - /** - * Check for existence of a directed graph - * @param module - module name - * @param rpc - rpc name - * @param version - version. If null, looks for active version - * @param mode - mode (sync/async) - * @return true if directed graph found, false otherwise - * @throws SvcLogicException - */ - boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException; - - /** - * Execute a directed graph - * - * @param module - module name - * @param rpc - rpc name - * @param version - version. If null, use active version - * @param mode - mode (sync/async) - * @param parms - parameters, used to set SvcLogicContext attributes - * @return final values of attributes from SvcLogicContext, as Properties - * @throws SvcLogicException - * - * - * @deprecated use execute(String module, String rpc, String version, String mode, DOMDataBroker dataBroker) instead - */ @Deprecated Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; @@ -76,10 +48,5 @@ public interface SvcLogicService { */ Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker domDataBroker) throws SvcLogicException; - SvcLogicStore getStore() throws SvcLogicException; - - SvcLogicContext execute(SvcLogicGraph calledGraph, SvcLogicContext ctx) throws SvcLogicException; - - SvcLogicNode executeNode(SvcLogicNode nextNode, SvcLogicContext ctx) throws SvcLogicException; } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index c79425638..23d703c2f 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -23,20 +23,20 @@ package org.onap.ccsdk.sli.core.sli.provider; -import java.util.HashMap; -import java.util.Map; import java.util.Properties; + import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.ExitNodeException; import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -44,71 +44,32 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; -public class SvcLogicServiceImpl implements SvcLogicService { - - private static final Map BUILTIN_NODES = new HashMap() { - { - put("block", new BlockNodeExecutor()); - put("call", new CallNodeExecutor()); - put("configure", new ConfigureNodeExecutor()); - put("delete", new DeleteNodeExecutor()); - put("execute", new ExecuteNodeExecutor()); - put("exists", new ExistsNodeExecutor()); - put("for", new ForNodeExecutor()); - put("get-resource", new GetResourceNodeExecutor()); - put("is-available", new IsAvailableNodeExecutor()); - put("notify", new NotifyNodeExecutor()); - put("record", new RecordNodeExecutor()); - put("release", new ReleaseNodeExecutor()); - put("reserve", new ReserveNodeExecutor()); - put("return", new ReturnNodeExecutor()); - put("save", new SaveNodeExecutor()); - put("set", new SetNodeExecutor()); - put("switch", new SwitchNodeExecutor()); - put("update", new UpdateNodeExecutor()); - put("break", new BreakNodeExecutor()); - put("while", new WhileNodeExecutor()); - put("exit", new ExitNodeExecutor()); - } - }; +public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService { private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImpl.class); - protected HashMap nodeExecutors = null; protected BundleContext bctx = null; - protected Properties properties; - protected SvcLogicStore store; - private static final String CURRENT_GRAPH="currentGraph"; public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider) throws SvcLogicException { + super(null); + this.resolver = SvcLogicClassResolver.getInstance(); properties = resourceProvider.getProperties(); - getStore(); + this.store = getStore(); } public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc) throws SvcLogicException { + super(null); + this.resolver = SvcLogicClassResolver.getInstance(); properties = resourceProvider.getProperties(); - store = new SvcLogicDblibStore(dbSvc); - } - - - protected void registerExecutors() { - - LOG.info("Entered register executors"); - for (String nodeType : BUILTIN_NODES.keySet()) { - LOG.info("SLI - registering node executor for node type " + nodeType); - registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); - } - LOG.info("Done registerExecutors"); + this.store = new SvcLogicDblibStore(dbSvc); } public void registerExecutor(ServiceReference sr) { String nodeName = (String) sr.getProperty("nodeType"); if (nodeName != null) { - - SvcLogicNodeExecutor executor; - + AbstractSvcLogicNodeExecutor executor; try { - executor = (SvcLogicNodeExecutor) bctx.getService(sr); + executor = (AbstractSvcLogicNodeExecutor) bctx.getService(sr); } catch (Exception e) { LOG.error("Cannot get service executor for {}", nodeName, e); return; @@ -117,14 +78,6 @@ public class SvcLogicServiceImpl implements SvcLogicService { } } - public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor) { - if (nodeExecutors == null) { - nodeExecutors = new HashMap<>(); - } - LOG.info("SLI - registering executor for node type {}", nodeName); - nodeExecutors.put(nodeName, executor); - } - public void unregisterExecutor(ServiceReference sr) { String nodeName = (String) sr.getProperty("nodeType"); @@ -133,67 +86,6 @@ public class SvcLogicServiceImpl implements SvcLogicService { } } - public void unregisterExecutor(String nodeName) { - LOG.info("SLI - unregistering executor for node type {}", nodeName); - nodeExecutors.remove(nodeName); - } - - public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException { - if (nodeExecutors == null) { - registerExecutors(); - } - - // Set service name in MDC to reference current working directed graph - MDC.put(MetricLogger.SERVICE_NAME, graph.getModule() + ":" + graph.getRpc() + "/v" + graph.getVersion()); - - MDC.put(CURRENT_GRAPH, graph.toString()); - - SvcLogicNode curNode = graph.getRootNode(); - LOG.info("About to execute graph {}", graph.toString()); - try { - while (curNode != null) { - - SvcLogicNode nextNode = executeNode(curNode, ctx); - curNode = nextNode; - } - } catch (ExitNodeException e) { - LOG.debug("SvcLogicServiceImpl caught ExitNodeException"); - } - MDC.remove("nodeId"); - MDC.remove(CURRENT_GRAPH); - - return (ctx); - } - - public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - if (node == null) { - return (null); - } - - LOG.info("About to execute node # {} ({})", node.getNodeId(), node.getNodeType()); - - if (LOG.isDebugEnabled()) { - LOG.debug("Executing node " + node.getNodeId() + " of " + node.getGraph().getRpc()); - } - - SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); - - if (executor != null) { - LOG.debug("Executing node executor for node type {} - {}", node.getNodeType(), - executor.getClass().getName()); - - MDC.put("nodeId", node.getNodeId() + " (" + node.getNodeType() + ")"); - return (executor.execute(this, node, ctx)); - } else { - throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type"); - } - } - - @Override - public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { - return (store.hasGraph(module, rpc, version, mode)); - } - @Override public Properties execute(String module, String rpc, String version, String mode, Properties props) throws SvcLogicException { @@ -218,12 +110,16 @@ public class SvcLogicServiceImpl implements SvcLogicService { ctx.setAttribute(CURRENT_GRAPH, graph.toString()); ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); ctx.setDomDataBroker(domDataBroker); - execute(graph, ctx); - return (ctx.toProperties()); } + + @Override + protected void resetContext() { + MetricLogger.resetContext(); + } + @Override public SvcLogicStore getStore() throws SvcLogicException { // Create and initialize SvcLogicStore object - used to access // saved service logic. @@ -246,4 +142,5 @@ public class SvcLogicServiceImpl implements SvcLogicService { return store; } + } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java deleted file mode 100644 index 592fb2885..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SwitchNodeExecutor.java +++ /dev/null @@ -1,63 +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.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SwitchNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory - .getLogger(SwitchNodeExecutor.class); - - @Override - - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - - - String testResult = evaluateNodeTest(node, ctx); - - if (LOG.isDebugEnabled()) { - LOG.debug("Executing switch node"); - - - LOG.debug("test expression (" + node.getAttribute("test") - + ") evaluates to " + testResult); - } - - SvcLogicNode nextNode = node.getOutcomeValue(testResult); - - if (LOG.isDebugEnabled()) { - if (nextNode != null) { - LOG.debug("Next node to execute is node " + nextNode.getNodeId()); - } else { - LOG.debug("No next node found"); - } - } - return (nextNode); - - } -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java deleted file mode 100644 index a783df41f..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/UpdateNodeExecutor.java +++ /dev/null @@ -1,103 +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.provider; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class UpdateNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(UpdateNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) - throws SvcLogicException { - - String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); - String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - - - Map parmMap = new HashMap(); - - Set> parmSet = node.getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); - - parmMap.put(curName, curExprValue); - } - } - - String outValue = "failure"; - - if (LOG.isDebugEnabled()) { - LOG.debug("save node encountered - looking for resource class " + plugin); - } - - - SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); - - - if (resourcePlugin != null) { - - try { - switch (resourcePlugin.update(resourceType, key, parmMap, pfx, ctx)) { - case SUCCESS: - outValue = "success"; - break; - case NOT_FOUND: - outValue = "not-found"; - break; - case FAILURE: - default: - outValue = "failure"; - } - } catch (SvcLogicException e) { - LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; - } - } else { - LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); - } - return (getNextNode(node, outValue)); - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java deleted file mode 100644 index b717aa986..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/WhileNodeExecutor.java +++ /dev/null @@ -1,75 +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.provider; - -import org.onap.ccsdk.sli.core.sli.BreakNodeException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WhileNodeExecutor extends SvcLogicNodeExecutor { - - private static final Logger LOG = LoggerFactory.getLogger(WhileNodeExecutor.class); - - @Override - public SvcLogicNode execute(SvcLogicService svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { - - String testResult = evaluateNodeTest(node, ctx); - SvcLogicExpression silentFailureExpr = node.getAttribute("do"); - String doWhile = SvcLogicExpressionResolver.evaluate(silentFailureExpr, node, ctx); - if ("true".equals(doWhile)) { - LOG.debug("While loop will execute once regardless of expression because do is set to true"); - } - - try { - while ("true".equals(testResult) || "true".equals(doWhile)) { - if (!"true".equals(doWhile)) { - LOG.debug("Test expression (" + node.getAttribute("test") + ") evaluates to true, executing loop."); - } - int numOutcomes = node.getNumOutcomes() + 1; - for (int i = 0; i < numOutcomes; i++) { - SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); - if (nextNode != null) { - while (nextNode != null) { - nextNode = svc.executeNode(nextNode, ctx); - } - } else { - if ("true".equals(doWhile)) { - LOG.debug("Do executed, will only execute again if test expression is true."); - doWhile = "false"; - } - testResult = evaluateNodeTest(node, ctx); - LOG.debug("test expression (" + node.getAttribute("test") + ") evaluates to " + testResult); - } - } - } - LOG.debug("testResult was " + testResult + " which is not equal to true, exiting while loop."); - } catch (BreakNodeException e) { - LOG.debug("WhileNodeExecutor caught break"); - } - return (null); - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java deleted file mode 100644 index f5a39f50f..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/BadPlugin.java +++ /dev/null @@ -1,56 +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.provider; - -import java.util.Map; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - - -public class BadPlugin implements SvcLogicJavaPlugin { - public String selectLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - String day = parameters.get("day"); - if (day == null || day.length() < 1) { - throw new SvcLogicException("What day is it?"); - } - switch (day) { - case ("monday"): { - return "pizza"; - } - case ("tuesday"): { - return "soup"; - } - case ("wednesday"): { - return "salad"; - } - case ("thursday"): { - return "sushi"; - } - case ("friday"): { - return "bbq"; - } - } - throw new SvcLogicException("Lunch cannot be served"); - } -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java deleted file mode 100644 index 0f3893efb..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - */ -package org.onap.ccsdk.sli.core.sli.provider; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -/** - * @author dt5972 - * - */ - -public class DummyAdaptor implements SvcLogicAdaptor { - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#configure(java.lang.String, java.util.Map, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public ConfigStatus configure(String key, Map parameters, SvcLogicContext ctx) { - - if ("ALREADY_ACTIVE".equalsIgnoreCase(key)) { - return ConfigStatus.ALREADY_ACTIVE; - } else if ("NOT_FOUND".equalsIgnoreCase(key)) { - return ConfigStatus.NOT_FOUND; - }else if ("NOT_READY".equalsIgnoreCase(key)) { - return ConfigStatus.NOT_READY; - } else if ("FAILURE".equalsIgnoreCase(key)) { - return ConfigStatus.FAILURE; - } else if ("SUCCESS".equalsIgnoreCase(key)) { - return ConfigStatus.SUCCESS; - } - - return ConfigStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#activate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public ConfigStatus activate(String key, SvcLogicContext ctx) { - return ConfigStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#deactivate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public ConfigStatus deactivate(String key, SvcLogicContext ctx) { - return ConfigStatus.SUCCESS; - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java deleted file mode 100644 index e87f9628d..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.onap.ccsdk.sli.core.sli.provider; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; - -public class DummyRecorder implements SvcLogicRecorder { - - @Override - public void record(Map parmMap) throws SvcLogicException { - return; - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java deleted file mode 100644 index 2f784186e..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * - */ -package org.onap.ccsdk.sli.core.sli.provider; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; - -/** - * @author dt5972 - * - */ -public class DummyResource implements SvcLogicResource { - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#isAvailable(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#exists(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#query(java.lang.String, boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, - String orderBy, SvcLogicContext ctx) throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#reserve(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#save(java.lang.String, boolean, boolean, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map parms, - String prefix, SvcLogicContext ctx) throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#release(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { - - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#delete(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#notify(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) - throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#update(java.lang.String, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus update(String resource, String key, Map parms, String prefix, - SvcLogicContext ctx) throws SvcLogicException { - return QueryStatus.SUCCESS; - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java deleted file mode 100644 index 33ce6f69e..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ExecuteNodeExecutorTest.java +++ /dev/null @@ -1,60 +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.provider; - -import java.util.Map.Entry; - -import org.onap.ccsdk.sli.core.sli.DuplicateValueException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; - -import junit.framework.TestCase; - -public class ExecuteNodeExecutorTest extends TestCase { - public class MockExecuteNodeExecutor extends ExecuteNodeExecutor { - - protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { - return (SvcLogicJavaPlugin) new LunchSelectorPlugin(); - } - - protected String evaluate(SvcLogicExpression expr, SvcLogicNode node, - SvcLogicContext ctx) throws SvcLogicException { - return "selectLunch"; - } - } - - public void testBadPlugin() throws DuplicateValueException, SvcLogicException { - LunchSelectorPlugin p = new LunchSelectorPlugin(); - MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor(); - SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph()); - node.setAttribute("method", "selectLunch"); - SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl(); - execute.execute(new SvcLogicServiceImpl(resourceProvider), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 445df36f6..6d466bc72 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.core.sli.provider; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; - import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; @@ -34,27 +33,46 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Properties; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicParser; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceRegistration; +import org.onap.ccsdk.sli.core.sli.provider.base.BlockNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.BreakNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.CallNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ConfigureNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.DeleteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ExistsNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ForNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.GetResourceNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.IsAvailableNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.NotifyNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.RecordNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ReleaseNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ReserveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ReturnNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SaveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; +import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.WhileNodeExecutor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ITCaseSvcLogicGraphExecutor { private static final Logger LOG = LoggerFactory.getLogger(SvcLogicGraph.class); - private static final Map BUILTIN_NODES = new HashMap() { + private static final Map BUILTIN_NODES = new HashMap() { { put("block", new BlockNodeExecutor()); put("break", new BreakNodeExecutor()); diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java deleted file mode 100644 index b86edb065..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/LunchSelectorPlugin.java +++ /dev/null @@ -1,78 +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.provider; - -import java.util.Map; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - - - -public class LunchSelectorPlugin implements SvcLogicJavaPlugin { - public class UnknownLunchDayException extends Exception{ - - public UnknownLunchDayException(String string) { - super(string); - } - - } - class Sandwhich { - String meat; - String cheese; - - public Sandwhich(String meat, String cheese) { - this.meat = meat; - this.cheese = cheese; - } - } - - public String selectLunch(Map parameters, SvcLogicContext ctx) throws Exception { - String day = parameters.get("day"); - if (day == null || day.length() < 1) { - throw new UnknownLunchDayException("What day is it?"); - } - switch (day) { - case ("monday"): { - return "pizza"; - } - case ("tuesday"): { - return "soup"; - } - case ("wednesday"): { - return "salad"; - } - case ("thursday"): { - return "sushi"; - } - case ("friday"): { - return "bbq"; - } - } - throw new SvcLogicException("Lunch cannot be served"); - } - - public Sandwhich makeLunch(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - return new Sandwhich("ham", "american"); - } -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java deleted file mode 100644 index 98e0753d6..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PluginTest.java +++ /dev/null @@ -1,108 +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.provider; - -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver; - -import junit.framework.TestCase; - -public class PluginTest extends TestCase { - - // The existing plugins work just like a VoidDummyPlugin - // They will return null simply because they are all void - // The attribute emitsOutcome will not be present, the expected outcome is success when no exception is thrown by the plugin - public void testOldPlugin() throws Exception { - ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); - SvcLogicJavaPlugin plugin = new VoidDummyPlugin(); - - Class pluginClass = plugin.getClass(); - Method pluginMethod = pluginClass.getMethod("dummy", Map.class, SvcLogicContext.class); - Map parmMap = new HashMap(); - SvcLogicContext ctx = new SvcLogicContext(); - Object o = pluginMethod.invoke(plugin, parmMap, ctx); - - SvcLogicGraph graph = new SvcLogicGraph(); - SvcLogicNode node = new SvcLogicNode(1, "return", graph); - String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); - String outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("success",outValue); - } - - //Newer plugins can set the attribute emitsOutcome to true, if so they should return a string - //The string represents the outcome value - public void testNewPlugin() throws Exception { - ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); - SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); - - Class pluginClass = plugin.getClass(); - Method pluginMethod = pluginClass.getMethod("selectLunch", Map.class, SvcLogicContext.class); - - Map parmMap = new HashMap(); - SvcLogicContext ctx = new SvcLogicContext(); - - parmMap.put("day", "monday"); - Object o = pluginMethod.invoke(plugin, parmMap, ctx); - SvcLogicGraph graph = new SvcLogicGraph(); - SvcLogicNode node = new SvcLogicNode(1, "return", graph); - node.setAttribute("emitsOutcome", "true"); - String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); - String outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("pizza", outValue); - - parmMap.put("day", "tuesday"); - outValue = (String) pluginMethod.invoke(plugin, parmMap, ctx); - o = pluginMethod.invoke(plugin, parmMap, ctx); - outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("soup",outValue); - - } - - //APPC had some legacy plugins returning objects which should not be treated as outcomes - //The attribute emitsOutcome will not be set - //The outcome should be success as it has always been - public void testObjPlugin() throws Exception{ - ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); - SvcLogicJavaPlugin plugin = new LunchSelectorPlugin(); - - Class pluginClass = plugin.getClass(); - Method pluginMethod = pluginClass.getMethod("makeLunch", Map.class, SvcLogicContext.class); - - Map parmMap = new HashMap(); - SvcLogicContext ctx = new SvcLogicContext(); - Object o = pluginMethod.invoke(plugin, parmMap, ctx); - SvcLogicGraph graph = new SvcLogicGraph(); - SvcLogicNode node = new SvcLogicNode(1, "return", graph); - String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); - String outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("success",outValue); - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java deleted file mode 100755 index 7c6f4ce56..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package org.onap.ccsdk.sli.core.sli.provider; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import java.util.LinkedList; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicParser; - -public class SetNodeExecutorTest { - @Test - public void clearProperties() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/clearValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertNull(ctx.getAttribute("si.field1")); - assertNull(ctx.getAttribute("si.field2")); - assertNull(ctx.getAttribute("si.field3")); - assertNull(ctx.getAttribute("si.subarray[0]")); - assertNull(ctx.getAttribute("si.subarray[1]")); - assertNull(ctx.getAttribute("si.subarray[2]")); - assertNull(ctx.getAttribute("si.subarray_length")); - assertEquals("6", ctx.getAttribute("search1")); - assertEquals("KeepMe!", ctx.getAttribute("simonSays")); - } - - @Test - public void clearMultipleArrayProperties() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/clearMultipleArrayValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertNull(ctx.getAttribute("si[0].field1")); - assertNull(ctx.getAttribute("si[1].field2")); - assertNull(ctx.getAttribute("si[2].field3")); - assertNull(ctx.getAttribute("si_length")); - assertNull(ctx.getAttribute("si[0].subarray[0]")); - assertNull(ctx.getAttribute("si[0].subarray[1]")); - assertNull(ctx.getAttribute("si[0].subarray[2]")); - assertNull(ctx.getAttribute("si[0].subarray_length")); - assertEquals("6", ctx.getAttribute("search1")); - assertEquals("KeepMe!", ctx.getAttribute("simonSays")); - } - - @Test - public void clearSingleArrayProperties() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/clearSingleArrayValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertNull(ctx.getAttribute("si[0].field1")); - assertNull(ctx.getAttribute("si[0].subarray[0]")); - assertNull(ctx.getAttribute("si[0].subarray[1]")); - assertNull(ctx.getAttribute("si[0].subarray[2]")); - assertNull(ctx.getAttribute("si[0].subarray_length")); - - // TODO: This is just setting up elements as null but note reducing the size of Array. - assertEquals("3",ctx.getAttribute("si_length")); - - assertEquals("2",ctx.getAttribute("si[1].field2")); - assertEquals("3", ctx.getAttribute("si[2].field3")); - assertEquals("6", ctx.getAttribute("search1")); - assertEquals("KeepMe!", ctx.getAttribute("simonSays")); - } - - @Test - public void clearSingleSubArrayProperties() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/clearSingleSubArrayValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertEquals("1",ctx.getAttribute("tmp.si[0].field1")); - assertEquals("2",ctx.getAttribute("tmp.si[1].field2")); - assertEquals("3", ctx.getAttribute("tmp.si[2].field3")); - assertEquals("3", ctx.getAttribute("tmp.si_length")); - - assertEquals("a",ctx.getAttribute("tmp.si[0].subarray[0]")); - - // TODO: This is setting up element as Empty instead null - //assertNull(ctx.getAttribute("tmp.si[0].subarray[1]")); - assertEquals("", ctx.getAttribute("tmp.si[0].subarray[1]")); - - assertEquals("c", ctx.getAttribute("tmp.si[0].subarray[2]")); - assertEquals("3", ctx.getAttribute("tmp.si[0].subarray_length")); - - assertEquals("x",ctx.getAttribute("tmp.si[1].subarray[0]")); - assertEquals("y",ctx.getAttribute("tmp.si[1].subarray[1]")); - assertEquals("z", ctx.getAttribute("tmp.si[1].subarray[2]")); - assertEquals("3", ctx.getAttribute("tmp.si[1].subarray_length")); - - assertEquals("6", ctx.getAttribute("search1")); - assertEquals("KeepMe!", ctx.getAttribute("simonSays")); - } - - @Test - public void clearSubArrayProperties() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/clearSubArrayValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertEquals("1", ctx.getAttribute("si[0].field1")); - assertEquals("2",ctx.getAttribute("si[1].field2")); - assertEquals("3", ctx.getAttribute("si[2].field3")); - assertEquals("3", ctx.getAttribute("si_length")); - assertNull(ctx.getAttribute("si[0].subarray[0]")); - assertNull(ctx.getAttribute("si[0].subarray[1]")); - assertNull(ctx.getAttribute("si[0].subarray[2]")); - assertNull(ctx.getAttribute("si[0].subarray_length")); - - assertEquals("6", ctx.getAttribute("search1")); - assertEquals("KeepMe!", ctx.getAttribute("simonSays")); - } - - @Test - public void arrayPattern() { - SetNodeExecutor sne = new SetNodeExecutor(); - String source = "one.two[0].three[0].four"; - assertEquals("one.two.three.four", source.replaceAll(sne.arrayPattern, "")); - } - - @Test - public void subtreeCopy() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/copyValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertEquals("1", ctx.getAttribute("si.field1")); - assertEquals("2", ctx.getAttribute("si.field2")); - assertEquals("3", ctx.getAttribute("si.field3")); - assertEquals("1", ctx.getAttribute("rootTwo.field1")); - assertEquals("2", ctx.getAttribute("rootTwo.field2")); - assertEquals("3", ctx.getAttribute("rootTwo.field3")); - } - - @Test - public void clearNestedSubArrayProperties() throws Exception { - SetNodeExecutor sne = new SetNodeExecutor(); - SvcLogicContext ctx = new SvcLogicContext(); - - SvcLogicParser slp = new SvcLogicParser(); - LinkedList graph = slp.parse("src/test/resources/clearNestedSubArrayValues.xml"); - SvcLogicNode root = graph.getFirst().getRootNode(); - SvcLogicNode nodeOne = root.getOutcomeValue("1"); - SvcLogicNode nodeTwo = root.getOutcomeValue("2"); - - sne.execute(nodeOne, ctx); - sne.execute(nodeTwo, ctx); - - assertEquals("1", ctx.getAttribute("tmp.si[0].field1")); - assertEquals("2",ctx.getAttribute("tmp.si[1].field2")); - assertEquals("3", ctx.getAttribute("tmp.si[2].field3")); - assertEquals("3", ctx.getAttribute("tmp.si_length")); - - assertNull(ctx.getAttribute("tmp.si[0].subarray[0]")); - assertNull(ctx.getAttribute("tmp.si[0].subarray[1]")); - assertNull(ctx.getAttribute("tmp.si[0].subarray[2]")); - assertNull(ctx.getAttribute("tmp.si[0].subarray_length")); - - assertEquals("x", ctx.getAttribute("tmp.si[1].subarray[0]")); - assertEquals("y",ctx.getAttribute("tmp.si[1].subarray[1]")); - assertEquals("z", ctx.getAttribute("tmp.si[1].subarray[2]")); - assertEquals("3", ctx.getAttribute("tmp.si[1].subarray_length")); - - assertEquals("6", ctx.getAttribute("search1")); - assertEquals("KeepMe!", ctx.getAttribute("simonSays")); - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java deleted file mode 100644 index a08144eef..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicExpressionResolverTest.java +++ /dev/null @@ -1,123 +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.provider; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicExprListener; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; -import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import junit.framework.Assert; -import junit.framework.TestCase; - -public class SvcLogicExpressionResolverTest extends TestCase { - - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicExpressionResolver.class); - - public void testEvaluate() - { - InputStream testStr = getClass().getResourceAsStream("/expression.tests"); - BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr)); - - try - { - SvcLogicContext ctx = new SvcLogicContext(); - SvcLogicGraph graph = new SvcLogicGraph(); - SvcLogicNode node = new SvcLogicNode(1, "return", graph); - graph.setRootNode(node); - - String line = null; - int lineNo = 0; - while ((line = testsReader.readLine()) != null) { - ++lineNo; - if (line.startsWith("#")) - { - String testExpr = line.trim().substring(1).trim(); - String[] nameValue = testExpr.split("="); - String name = nameValue[0].trim(); - String value = nameValue[1].trim(); - - if (name.startsWith("$")) - { - LOG.info("Setting context attribute "+name+" = "+value); - ctx.setAttribute(name.substring(1), value); - } - else - { - - LOG.info("Setting node attribute "+name+" = "+value); - node.setAttribute(name, value); - - } - } - else - { - // if the line contains #, what comes before is the expression to evaluate, and what comes after - // is the expected value - String[] substrings = line.split("#"); - String expectedValue = substrings.length > 1 ? substrings[1].trim() : null; - String testExpr = substrings[0].trim(); - - LOG.info("Parsing expression "+testExpr); - SvcLogicExpression expr = SvcLogicExpressionFactory.parse(testExpr); - if (expr == null) - { - fail("Unable to parse expression "+testExpr); - } - else - { - LOG.info("Evaluating parsed expression "+expr.asParsedExpr()); - String exprValue = SvcLogicExpressionResolver.evaluate(expr, node, ctx); - if (exprValue == null) - { - fail("Unable to evaluate expression "+testExpr); - } - else - { - LOG.info("Expression " + testExpr + " evaluates to " + exprValue); - if (expectedValue != null) { - Assert.assertEquals("Line " + lineNo + ": " + testExpr, expectedValue, exprValue); - } - } - } - } - } - } - catch (Exception e) - { - LOG.error("Caught exception", e); - fail("Caught exception"); - } - } - -} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java deleted file mode 100644 index 8c7b0d30d..000000000 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/VoidDummyPlugin.java +++ /dev/null @@ -1,38 +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.provider; - -import java.util.Map; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - - - -public class VoidDummyPlugin implements SvcLogicJavaPlugin { - - public void dummy(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - return; - } - -} diff --git a/sli/provider/src/test/resources/clearMultipleArrayValues.xml b/sli/provider/src/test/resources/clearMultipleArrayValues.xml deleted file mode 100644 index 8f40058f1..000000000 --- a/sli/provider/src/test/resources/clearMultipleArrayValues.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearNestedSubArrayValues.xml b/sli/provider/src/test/resources/clearNestedSubArrayValues.xml deleted file mode 100644 index a80b3e56c..000000000 --- a/sli/provider/src/test/resources/clearNestedSubArrayValues.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearSingleArrayValues.xml b/sli/provider/src/test/resources/clearSingleArrayValues.xml deleted file mode 100644 index 56781a066..000000000 --- a/sli/provider/src/test/resources/clearSingleArrayValues.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearSingleSubArrayValues.xml b/sli/provider/src/test/resources/clearSingleSubArrayValues.xml deleted file mode 100644 index 22f14f37b..000000000 --- a/sli/provider/src/test/resources/clearSingleSubArrayValues.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearSubArrayValues.xml b/sli/provider/src/test/resources/clearSubArrayValues.xml deleted file mode 100644 index cb25f38af..000000000 --- a/sli/provider/src/test/resources/clearSubArrayValues.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/provider/src/test/resources/clearValues.xml b/sli/provider/src/test/resources/clearValues.xml deleted file mode 100644 index dc7f5c8a2..000000000 --- a/sli/provider/src/test/resources/clearValues.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/provider/src/test/resources/copyValues.xml b/sli/provider/src/test/resources/copyValues.xml deleted file mode 100644 index f56f7140a..000000000 --- a/sli/provider/src/test/resources/copyValues.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/provider/src/test/resources/expression.tests b/sli/provider/src/test/resources/expression.tests deleted file mode 100755 index 848a0e7a4..000000000 --- a/sli/provider/src/test/resources/expression.tests +++ /dev/null @@ -1,24 +0,0 @@ -# $uni-circuit-id = abc123 -# $uni-cir-units = 10 -# value = 1 -# $arg1 = 2 -# $network.name = vCE0001.in -# $network.segment[0].provider-segmentation-id = 1212 -# $network.segment[1].provider-segmentation-id = 1213 -# $availability-zone = mtsnj-esx-az01 -length($uni-circuit-id) > 0 # true -$uni-cir-units * 1000 * 100 / 100 # 10000 -$uni-cir-units / 1000 # 0 -$uni-cir-units - 100 # -90 -$uni-cir-units + 100 # 110 -(value * 3 - $arg1 > 0) and (length($uni-circuit-id) == 0) # true -'pg-'+$network.name # pg-vCE0001.in -$network.segment[0].provider-segmentation-id # 1212 -toUpperCase($network.name) # VCE0001.IN -toLowerCase($network.name) # vce0001.in -toUpperCase(substr($availability-zone, 0, 5)) # MTSNJ -convertBase(1234, 10) # 1234 -convertBase(10, 16, 10) # 16 -convertBase(ZZ, 36, 10) # 1295 -convertBase(10, 10, 36) # a -(0 - 1) * $arg1 # -1 diff --git a/sliPluginUtils/provider/testFileName b/sliPluginUtils/provider/testFileName deleted file mode 100644 index 674e20cc7..000000000 --- a/sliPluginUtils/provider/testFileName +++ /dev/null @@ -1 +0,0 @@ -####################################### diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index e6ffaa9d5..efcf321c9 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -61,6 +61,11 @@ sli-provider ${project.version} + + org.onap.ccsdk.sli.core + sli-provider-base + ${project.version} + org.opendaylight.controller sal-core-api diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index 287f2f206..96d619331 100644 --- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -25,28 +25,28 @@ import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicParser; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.onap.ccsdk.sli.core.sli.provider.BlockNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.CallNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ConfigureNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.DeleteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ExistsNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ForNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.GetResourceNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.IsAvailableNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.NotifyNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.RecordNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReleaseNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReserveNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.ReturnNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SaveNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SetNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl; import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; -import org.onap.ccsdk.sli.core.sli.provider.SwitchNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.UpdateNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.WhileNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.BlockNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.CallNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ConfigureNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.DeleteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ExistsNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ForNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.GetResourceNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.IsAvailableNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.NotifyNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.RecordNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ReleaseNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ReserveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.ReturnNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SaveNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor; +import org.onap.ccsdk.sli.core.sli.provider.base.WhileNodeExecutor; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; @@ -67,7 +67,7 @@ public class TestSliapiProvider { private static final String HEALTHCHECK_DG = "sli_healthcheck.xml"; - private static final Map BUILTIN_NODES = new HashMap() { + private static final Map BUILTIN_NODES = new HashMap() { { put("block", new BlockNodeExecutor()); put("call", new CallNodeExecutor()); -- cgit 1.2.3-korg From fca4fd1c891dfece2b1a25f16a78bc1704b0ca62 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 4 Dec 2018 21:57:10 +0000 Subject: clean up legacy files clean up legacy files, these files do not belong in sli-common Change-Id: Iba801e0b8e098fc88d80f8d2d3da47b6184e88af Issue-ID: CCSDK-789 Signed-off-by: Smokowski, Kevin (ks6305) --- sli/common/src/main/resources/crAseNetwork.sql | 82 ---- sli/common/src/main/yang/ase-network.yang | 179 -------- sli/common/src/main/yang/ase-type.yang | 561 ------------------------- sli/common/src/main/yang/ase.yang | 558 ------------------------ sli/common/src/test/resources/svclogic.xsd | 339 --------------- 5 files changed, 1719 deletions(-) delete mode 100644 sli/common/src/main/resources/crAseNetwork.sql delete mode 100755 sli/common/src/main/yang/ase-network.yang delete mode 100755 sli/common/src/main/yang/ase-type.yang delete mode 100755 sli/common/src/main/yang/ase.yang delete mode 100755 sli/common/src/test/resources/svclogic.xsd diff --git a/sli/common/src/main/resources/crAseNetwork.sql b/sli/common/src/main/resources/crAseNetwork.sql deleted file mode 100644 index 83f1dfc82..000000000 --- a/sli/common/src/main/resources/crAseNetwork.sql +++ /dev/null @@ -1,82 +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========================================================= ---- - -CREATE TABLE sdnctl.ASE ( - ase_network_id INT NOT NULL, - topology VARCHAR(25), - CONSTRAINT P_ASE PRIMARY KEY(ase_network_id)); - -CREATE TABLE sdnctl.ASE_PORT ( - esm_name VARCHAR(25), - resource_emt_clli VARCHAR(25) NOT NULL, - resource_emt_ip_addr VARCHAR(25) NOT NULL, - port_action VARCHAR(25), - profile VARCHAR(25) , - port VARCHAR(15) NOT NULL, - state VARCHAR(25), - resource_mode VARCHAR(25), - speed INT, - resource_lldp VARCHAR(1), - resource_mtu VARCHAR(5), - resource_autoneg VARCHAR(10), - resource_twamp VARCHAR(10), - resource_description VARCHAR(80), - uni_circuit_id VARCHAR(45), - CONSTRAINT P_ASE_PORT PRIMARY KEY(resource_emt_clli, port)); - -CREATE TABLE sdnctl.ASE_EVC ( - esm_name VARCHAR(25), - emt_ip_addr VARCHAR(25) NOT NULL, - evc_action VARCHAR(25), - service_id VARCHAR(25), - serv_type VARCHAR(25), - evc_choice VARCHAR(25), - uni_port VARCHAR(25) NOT NULL, - lag_port VARCHAR(25), - mac_onoff VARCHAR(25), - ppcos VARCHAR(25), - cir VARCHAR(25), - cbs VARCHAR(25), - ebs VARCHAR(25), - sgos VARCHAR(25), - pe VARCHAR(25), - unit VARCHAR(25), - qinq VARCHAR(25), - interface VARCHAR(25), - evc_description VARCHAR(80), - bandwidth VARCHAR(10), - svlan VARCHAR(5), - cvlan VARCHAR(5), - routing_instance VARCHAR(25), - rd VARCHAR(25), - rt VARCHAR(25), - evc_limit VARCHAR(25), - label_block_size VARCHAR(25), - site VARCHAR(25), - int_mac_limit VARCHAR(5), - sgos_grade VARCHAR(25), - bum_rate VARCHAR(25), - uni_circuit_id VARCHAR(45), - leg INT, - CONSTRAINT P_ASE_EVC PRIMARY KEY(emt_ip_addr, uni_port,leg)); - - - diff --git a/sli/common/src/main/yang/ase-network.yang b/sli/common/src/main/yang/ase-network.yang deleted file mode 100755 index ae654ae04..000000000 --- a/sli/common/src/main/yang/ase-network.yang +++ /dev/null @@ -1,179 +0,0 @@ -module ase { - namespace "att:ase"; - prefix ase; - revision "2014-06-03" { - description "Example ASE Network Module"; - } - - container ase { - config true; - leaf ase-network-id{ - type uint32; - } - leaf topology { - type string ; // check enum - } - } - - container ase-port { - config true; - // is this really a list of cpe ports one for each uni-ckt - leaf esm-name { - type string; - } - - leaf resource-emt-clli { - type string; - } - - leaf resource-emt-ip-addr{ - type string; - } - leaf port-action { - type string; - } - leaf profile { - type string; - } - leaf port { - type string; - } - leaf state { - type string; - } - leaf resource-mode { - type string; - } - leaf speed { - type string; - } - leaf resource-lldp { - type string; - } - leaf resource-mtu { - type string; - } - leaf resource-autoneg{ - type string; - } - leaf resource-twamp { - type string; - } - leaf resource-description { - type string; - } - leaf uni-circuit-id { - type string; - } - } // ase-port container - - container ase-evc { -// Port contains a list of EVC -// EVCs are either point to point or multipoint (topology) -// EVCs are connected ? what ID is used to connected them ? (network-id) ? - config true; - leaf esm-name { - type string; - } - leaf emt-ip-addr { - type string; - } - leaf evc-action { - type string; - } - leaf service-id { - type string; - } - - leaf serv-type { - type string; - } - leaf evc-choice { - type string; - } - leaf uni-port { - type string; - } - leaf lag-port { - type string; - } - leaf mac-onoff { - type string; - } - - leaf ppcos { - type string; - } - leaf cir { - type string; - } - leaf cbs { - type string; - } - leaf ebs { - type string; - } - leaf sgos { - type string; - } -// ipag Device Data - leaf pe { - type string; - } - leaf unit { - type string; - } - leaf qinq { - type string; - } - leaf interface { - type string; - } - leaf evc-description { - type string; - } - leaf bandwidth { - type string; - } - leaf svlan { - type string; - description "Service VLAN is either outer tag or only tag depending on QinQ"; - } - leaf cvlan { - type string; - description "Customer VLAN is null if not QinQ"; - } - leaf routing-instance { - type string; - } - leaf rd { - type string; - } - leaf rt { - type string; - } - leaf limit { - type string; - } - leaf label-block-size { - type string; - } - leaf site { - type string; - } - leaf int-mac-limit { - type string; - } - leaf sgos-grade { - type string; - } - leaf bum-rate { - type string; - } - leaf uni-circuit-id { - type string; - } - } // ase-evc container - -} // module ase-network - diff --git a/sli/common/src/main/yang/ase-type.yang b/sli/common/src/main/yang/ase-type.yang deleted file mode 100755 index 2de186e69..000000000 --- a/sli/common/src/main/yang/ase-type.yang +++ /dev/null @@ -1,561 +0,0 @@ -module ase-type { - - namespace "att:ase:type"; - prefix ase-type; - - organization "AT&T ASE"; - - revision 2014-06-09 { - description - "Initial version"; - } - - ///////////////////////////////////////////////////// - // ASE Service Model Typedefs & Groupings - ///////////////////////////////////////////////////// - - typedef query-type { - type enumeration { - enum getDevicePortDetails{ - value 0; - } - enum GetServiceDetailsRequest{ - value 1; - } - } - } - - typedef uni-action-type { - type enumeration { - enum PortPreReserveRequest{ - value 0; - } - enum PortReleaseRequest{ - value 1; - } - enum PortDeProvRequest{ - value 2; - } - enum ChangePortProvRequest{ - value 3; - } - enum PortActivateRequest{ - value 4; - } - enum ChangePortActivateRequest{ - value 5; - } - enum DisconnectPortRequest{ - value 6; - } - enum getDevicePortDetails{ - value 7; - } - } - } - - typedef evc-action-type { - type enumeration { - enum ConnectionProvRequest{ - value 0; - } - enum ChangeConnectionProvRequest{ - value 1; - } - enum ConnectionDeProvrequest{ - value 2; - } - enum ConnectionActivateRequest{ - value 3; - } - enum ChangeConnectionActivateRequest{ - value 4; - } - enum DisconnectConnectionRequest{ - value 5; - } - enum GetServiceDetailsRequest{ - value 6; - } - } - } - - typedef evc-gos-type { - type enumeration { - enum "REAL-TIME"{ - value 0; - } - enum "INTERACTIVE"{ - value 1; - } - enum "BUSINESS-CRITICAL-HIGH"{ - value 2; - } - enum "BUSINESS-CRITICAL-MEDIUM"{ - value 3; - } - enum "NON-CRITICAL-HIGH"{ - value 4; - } - enum "NON-CRITICAL-LOW"{ - value 5; - } - } - } - - typedef cir-rate-type { - type enumeration { - enum "Mbps"{ - value 0; - } - enum "Gbps"{ - value 1; - } - } - } - - typedef ase-yes-no-type { - type enumeration { - enum "Y"{ - value 0; - } - enum "N"{ - value 1; - } - } - } - - typedef provisioning-indicator { - type enumeration { - enum "Y"{ - value 0; - } - enum "N"{ - value 1; - } - } - } - - typedef media-type { - type enumeration { - enum "SFP-1GE-SX"{ - value 0; - } - enum "SFP-1GE-LX"{ - value 1; - } - enum "SFP-1GE"{ - value 2; - } - enum "Ethernet-10_100_1000M"{ - value 3; - } - } - } - - typedef media-speed-type { - type enumeration { - enum "100"{ - value 0; - } - enum "1000"{ - value 1; - } - enum "10000"{ - value 2; - } - } - } - - typedef cos-category-type { - type enumeration { - enum "GOS"{ - value 0; - } - enum "PPCOS"{ - value 1; - } - } - } - - typedef uni-gos-type { - type enumeration { - enum "INTERACTIVE"{ - value 0; - } - enum "BUSINESS-CRITICAL-HIGH"{ - value 1; - } - enum "BUSINESS-CRITICAL-MEDIUM"{ - value 2; - } - enum "NON-CRITICAL-HIGH"{ - value 3; - } - } - } - - typedef uni-cir-value-type { - type enumeration { - enum "2"{ - value 0; - } - enum "4"{ - value 1; - } - enum "5"{ - value 2; - } - enum "8"{ - value 3; - } - enum "10"{ - value 4; - } - enum "20"{ - value 5; - } - enum "30"{ - value 6; - } - enum "40"{ - value 7; - } - enum "50"{ - value 8; - } - enum "60"{ - value 9; - } - enum "70"{ - value 10; - } - enum "80"{ - value 11; - } - enum "90"{ - value 12; - } - enum "100"{ - value 13; - } - enum "125"{ - value 14; - } - enum "150"{ - value 15; - } - enum "175"{ - value 16; - } - enum "200"{ - value 17; - } - enum "225"{ - value 18; - } - enum "250"{ - value 19; - } - } - } - - typedef uni-mac-limit-type { - description "MAC address limit for UNI port"; - type enumeration { - enum "Y"{ - value 0; - } - enum "N"{ - value 1; - } - } - } - - typedef port-tagging-type { - type enumeration { - enum "port-based"{ - value 0; - } - enum "vlan-based"{ - value 1; - } - } - } - - typedef port-status { - type enumeration { - enum "Available"{ - value 0; - } - enum "Reserved"{ - value 1; - } - enum "Active" { - value 2; - } - } - } - - grouping uni-common-request-hdr { - leaf request-id { - type string; - mandatory true; - } - leaf source { - description "The source system requesting action or info"; - type string; - mandatory true; - } - leaf request-action { - description "action indicator for this service instance"; - type uni-action-type; - } - leaf undo-indicator { - type provisioning-indicator; - } - leaf notification-url { - description "When this field exists, NCS will return an " - + "acknowledgement that the request is legal " - + "Once the activate is finished (or fails) NCS" - + "will utilize the URL to indicate the status"; - type string; - } - } - - grouping uni-common-return-hdr { - leaf request-action { - description "action indicator for this service instance"; - type uni-action-type; - } - leaf request-id { - description "Identifier for the request from NGO"; - type string; - - } - } - - grouping uni-common-error-format { - leaf error-code { - description "Error code"; - type int32; - } - leaf error-message { - description "Error text describing the API error occurance"; - type string; - } - } - - grouping query-common-hdr { - leaf request-id { - description "Identifier for the request from NGO"; - type string; - } - leaf request-type { - description "action indicator for this service instance"; - type query-type; - } - } - - grouping query-error-format { - leaf error-code { - description "Error code"; - type int32; - } - leaf error-message { - description "Error text describing the API error occurance"; - type string; - } - } - - grouping evc-common-request-hdr { - leaf request-id { - description "Identifier for the request from NGO"; - type string; - } - leaf source { - description "The source system requesting action or info"; - type string; - mandatory true; - } - leaf uni-order-number { - type string; - } - leaf request-action { - description "action indicator for this service instance"; - type evc-action-type; - mandatory true; - } - leaf undo-indicator { - type provisioning-indicator; - } - leaf notification-url { - description "When this field exists, NCS will return an " - + "acknowledgement that the request is legal " - + "Once the activate is finished (or fails) NCS" - + "will utilize the URL to indicate the status"; - type string; - } - leaf evc-name { - type string; - mandatory true; - } - } - - grouping evc-common-error-format { - leaf error-code { - description "Error code"; - type int32; - } - leaf error-message { - description "Error text describing the API error occurance"; - type string; - } - } - - ///////////////////////////////////////// - // UNI-PORTS table contains all circuits - ///////////////////////////////////////// - container uni-ports { - description - "UNI port container"; - list uni-port { - key "uni-circuit-id"; - leaf uni-circuit-id { - type string; - mandatory true; - } - leaf subscriber-name { - type string; - mandatory true; - } - leaf uni-order-number { - type string; - mandatory true; - } - leaf edge-device-clli { - description "Edge device (e.g. EMT) on which port " - + " reservation is needed"; - type string; - mandatory true; - } - leaf uni-location-city { - type string; - mandatory true; - } - leaf uni-location-state { - type string; - mandatory true; - } - leaf media-type { - type media-type; - mandatory true; - } - leaf media-speed { - type media-speed-type; - mandatory true; - } - leaf uni-cir-value { - description "Integer value for the CIR"; - type uni-cir-value-type; - mandatory true; - } - leaf uni-cir-units { - description "Units for the CIR"; - type cir-rate-type; - mandatory true; - } - leaf cos-category { - description "CoS Type"; - type cos-category-type; - mandatory true; - } - leaf gos-profile { - description "GoS tpye"; - type uni-gos-type; - mandatory true; - } - leaf aditional-mac-allowed { - type uni-mac-limit-type; - } - leaf port-tagging { - type port-tagging-type; - mandatory true; - } - leaf port-status { - type port-status; - } - leaf name-value-pair { - type string; - } - } - } - - /////////////////////////////////////////// - // EVCS table contains all evc associations - /////////////////////////////////////////// - container evcs { - list evc { - key "evc-name"; - leaf evc-name { - type string; - mandatory true; - } - leaf topology { - type enumeration { - enum "MultiPoint"{ - value 0; - } - enum "PointToPoint"{ - value 1; - } - } - } - list evc-leg { - key evc-access-name; - leaf evc-access-name { - type string; - } - leaf subscriber-name { - type string; - } - leaf cvlan { - type uint16 { - range "2..4090"; - } - } - leaf connection-cir-value { - type uni-cir-value-type; - } - leaf connection-cir-units-string { - type cir-rate-type; - } - leaf connection-gos-profile { - type evc-gos-type; - } - leaf connection-additional-mac-allowed { - type uni-mac-limit-type; - } - leaf connection-emc-indicator { - type enumeration { - enum "Y"{ - value 0; - } - enum "N"{ - value 1; - } - } - } - leaf connection-emc-speed-value { - type uni-cir-value-type; - } - leaf connection-emc-speed-units-string { - type cir-rate-type; - } - } - leaf name-value-pair { - type string; - } - } - } -} diff --git a/sli/common/src/main/yang/ase.yang b/sli/common/src/main/yang/ase.yang deleted file mode 100755 index 0b36a5610..000000000 --- a/sli/common/src/main/yang/ase.yang +++ /dev/null @@ -1,558 +0,0 @@ -module ase { - - namespace "att:ase"; - prefix ase; - - import ase-type {prefix ase-type; revision-date "2014-06-09";} - - organization "AT&T ASE"; - - description - "This submodule contains a collection of YANG definitions for - defining the ASE service model(s) for UNI and EVC"; - - revision 2014-03-27 { - description - "Additional detail for UNI and EVC API"; - } - revision 2014-03-18 { - description - "Initial version"; - } - - - ///////////////////////////////////////////////////// - // ASE Query Actions - ///////////////////////////////////////////////////// - - //// - // Port Reserve Request - //// - rpc ase-port-reserve { - input { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - mandatory true; - } - leaf edge-device-clli { - description "Edge device (e.g. EMT) on which port " - + " reservation is needed"; - type string; - mandatory true; - } - leaf uni-cir-value { - description "Integer value for the CIR"; - type ase-type:uni-cir-value-type; - mandatory true; - } - leaf uni-cir-units { - description "Units for the CIR"; - type ase-type:cir-rate-type; - mandatory true; - } - } - output { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - } - leaf uni-port-id { - description "Allocated UNI port id"; - type string; - } - - uses ase-type:uni-common-error-format; - } - } - - //// - // Release Port Request - //// - rpc ase-release-port-request { - input { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - mandatory true; - } - } - output { - uses ase-type:uni-common-return-hdr; - uses ase-type:uni-common-error-format; - } - } - - //// - // Port Provisioning Request - //// - rpc ase-port-prov-request { - input { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - mandatory true; - } - leaf subscriber-name { - type string; - mandatory true; - } - leaf uni-order-number { - type string; - mandatory true; - } - leaf edge-device-clli { - description "Edge device (e.g. EMT) on which port " - + " reservation is needed"; - type string; - mandatory true; - } - leaf uni-location-city { - type string; - mandatory true; - } - leaf uni-location-state { - type string; - mandatory true; - } - leaf media-type { - type ase-type:media-type; - mandatory true; - } - leaf media-speed { - type ase-type:media-speed-type; - mandatory true; - } - leaf uni-cir-value { - description "Integer value for the CIR"; - type ase-type:uni-cir-value-type; - mandatory true; - } - leaf uni-cir-units { - description "Units for the CIR"; - type ase-type:cir-rate-type; - mandatory true; - } - leaf cos-category { - description "CoS Type"; - type ase-type:cos-category-type; - mandatory true; - } - leaf gos-profile { - description "GoS tpye"; - type ase-type:uni-gos-type; - mandatory true; - } - leaf aditional-mac-allowed { - type ase-type:uni-mac-limit-type; - } - leaf port-tagging { - type ase-type:port-tagging-type; - mandatory true; - } - leaf name-value-pair { - type string; - } - } - output { - uses ase-type:uni-common-return-hdr; - uses ase-type:uni-common-error-format; - } - } - - //// - // Deprovisioning Port Request - //// - rpc ase-deprov-port-request { - input { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - mandatory true; - } - } - output { - uses ase-type:uni-common-error-format; - } - } - - //// - // Change Port Provisioning Request - //// - rpc ase-change-port-prov-request { - input { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - mandatory true; - } - leaf subscriber-name { - type string; - } - leaf media-speed { - type ase-type:media-speed-type; - } - leaf uni-cir-value { - description "Integer value for the CIR"; - type ase-type:uni-cir-value-type; - } - leaf uni-cir-units { - description "Units for the CIR"; - type ase-type:cir-rate-type; - } - leaf cos-catagory { - type ase-type:cos-category-type; - } - leaf gos-profile { - type ase-type:uni-gos-type; - } - leaf additional-mac-allowed { - type ase-type:uni-mac-limit-type; - } - leaf port-tagging { - type ase-type:port-tagging-type; - mandatory true; - } - leaf name-value-pair { - type string; - } - } - output { - uses ase-type:uni-common-error-format; - } - } - - //// - // Port Activate Request - //// - rpc ase-port-activate-request { - input { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - mandatory true; - } - } - output { - uses ase-type:uni-common-error-format; - } - } - - //// - // Port Change Activation Request - //// - rpc ase-change-port-activation-request { - input { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - mandatory true; - } - } - output { - uses ase-type:uni-common-error-format; - } - } - - //// - // Port Disconnect Request - //// - rpc ase-port-disconnect-request { - input { - uses ase-type:uni-common-request-hdr; - - leaf uni-circuit-id { - type string; - mandatory true; - } - } - output { - uses ase-type:uni-common-error-format; - } - } - - ///////////////////////////////////////////////////// - // EVC API - ///////////////////////////////////////////////////// - - //// - // EVC Provision Request - //// - rpc ase-evc-activation { - input { - uses ase-type:evc-common-request-hdr; - leaf topology { - type enumeration { - enum "MultiPoint"{ - value 0; - } - enum "PointToPoint"{ - value 1; - } - } - } - list evc-leg { - key evc-access-name; - leaf evc-access-name { - type string; - } - leaf subscriber-name { - type string; - } - leaf cvlan { - type uint16 { - range "2..4090"; - } - } - leaf connection-cir-value { - type ase-type:uni-cir-value-type; - } - leaf connection-cir-units-string { - type ase-type:cir-rate-type; - } - leaf connection-gos-profile { - type ase-type:evc-gos-type; - } - leaf connection-additional-mac-allowed { - type ase-type:uni-mac-limit-type; - } - leaf connection-emc-indicator { - type enumeration { - enum "Y"{ - value 0; - } - enum "N"{ - value 1; - } - } - } - leaf connection-emc-speed-value { - type ase-type:uni-cir-value-type; - } - leaf connection-emc-speed-units-string { - type ase-type:cir-rate-type; - } - } - leaf name-value-pair { - type string; - } - } - output { - uses ase-type:evc-common-error-format; - } - } - - //// - // EVC Change Activation Request - //// - rpc ase-evc-change-activation { - input { - uses ase-type:evc-common-request-hdr; - leaf topology { - type enumeration { - enum "MultiPoint"{ - value 0; - } - enum "PointToPoint"{ - value 1; - } - } - } - list evc-leg { - key evc-access-name; - leaf evc-access-name { - type string; - } - leaf connection-cir-value { - type ase-type:uni-cir-value-type; - } - leaf connection-cir-units-string { - type ase-type:cir-rate-type; - } - leaf connection-gos-profile { - type ase-type:evc-gos-type; - } - leaf connection-additional-mac-allowed { - type ase-type:uni-mac-limit-type; - } - - } - leaf name-value-pair { - type string; - } - - } - output { - uses ase-type:evc-common-error-format; - } - } - - //// - // EVC Disconnet Connection Request - //// - rpc ase-evc-disconnect-request { - input { - uses ase-type:evc-common-request-hdr; - leaf topology { - type enumeration { - enum "MultiPoint"{ - value 0; - } - enum "PointToPoint"{ - value 1; - } - } - } - list evc-leg { - key evc-access-name; - leaf evc-access-name { - type string; - } - } - leaf name-value-pair { - type string; - } - - } - output { - uses ase-type:evc-common-error-format; - } - } - - ///////////////////////////////////////////////////// - // ASE Query Actions - ///////////////////////////////////////////////////// - - rpc find-available-ports { - description "Return a count of available ports"; - input { - uses ase-type:query-common-hdr; - leaf edge-device-clli { - type string; - mandatory true; - } - - leaf port-role { - type enumeration { - enum "NETWORK"{ - value 0; - } - enum "ACCESS"{ - value 1; - } - enum "SDN-ACCESS"{ - value 2; - } - } - mandatory true; - } - leaf port-assigned { - type string; - } - } - output { - uses ase-type:query-common-hdr; - container statuss { - leaf edge-device-clli { - type string; - } - container max-cir { - leaf cir-value { - type uint16; - } - leaf cir-type { - type ase-type:cir-rate-type; - } - } - leaf if-count { - type uint16; - } - } - uses ase-type:query-error-format; - } - } - - rpc find-evcs-in-uni { - description "Return EVC instances for a specified UNI"; - input { - uses ase-type:query-common-hdr; - - leaf uni-circuit-id { - type string; //leafref - } - leaf edge-device-clli { - description "Edge device (e.g. EMT) on which port " - + " reservation is needed"; - type string; - } - } - output { - uses ase-type:query-common-hdr; - - leaf uni-leg-name { - description "NGO-proivded named"; - type string; - } - uses ase-type:query-error-format; - } - } - - rpc find-service-details { - description "Return EVC instances for a specified UNI"; - input { - uses ase-type:query-common-hdr; - leaf uni-circuit-id { - type string; //leafref - } - leaf source { - type string; - mandatory true; - } - leaf service-name { - type string; - mandatory true; - } - leaf service-type { - type string; - mandatory true; - } - } - output { - uses ase-type:query-common-hdr; - - leaf service-name { - type string; - mandatory true; - } - leaf service-type { - type string; - mandatory true; - } - leaf service-state { - type enumeration { - enum "Active"{ - value 0; - } - enum "NotActive"{ - value 1; - } - } - } - leaf has-pending-change { - type ase-type:ase-yes-no-type; - } - leaf allowed-connection-count { - type int16; - } - uses ase-type:query-error-format; - } - } -} //module diff --git a/sli/common/src/test/resources/svclogic.xsd b/sli/common/src/test/resources/svclogic.xsd deleted file mode 100755 index 3e109c7c2..000000000 --- a/sli/common/src/test/resources/svclogic.xsd +++ /dev/null @@ -1,339 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit 1.2.3-korg From c09ec873586ca6870dd2764d64a04482197e9759 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 5 Dec 2018 16:16:59 +0530 Subject: fixed sonar issues in CachedDataSourceFactory removed unnecessary cast to object Issue-ID: CCSDK-525 Change-Id: Iccd4430cdbbadfabbdc21820c1f0f962b7635444 Signed-off-by: Sandeep J --- .../java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java index 296fe70f1..15aa7a1d0 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceFactory.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2016 - 2017 ONAP * ================================================================================ + * 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 @@ -38,7 +40,7 @@ public class CachedDataSourceFactory { if(config instanceof JDBCConfiguration) return JdbcDBCachedDataSource.createInstance(config); - return (CachedDataSource)null; + return null; } } -- cgit 1.2.3-korg From 291194ce7f32d15bc37b10fe926ac07189c9c7d4 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 5 Dec 2018 16:29:35 +0530 Subject: fixed sonar issues in DBResourceManager.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: I29b85aa6066c6a940818443602e3e0e02fad59ab Signed-off-by: Sandeep J --- .../java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 9acae340b..047fa297e 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2016 - 2017 ONAP * ================================================================================ + * 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 @@ -68,7 +70,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb transient protected long retryInterval = 10000L; transient boolean recoveryMode = true; - SortedSet dsQueue = new ConcurrentSkipListSet(new DataSourceComparator()); + SortedSet dsQueue = new ConcurrentSkipListSet<>(new DataSourceComparator()); protected final Set broken = Collections.synchronizedSet(new HashSet()); protected final Object monitor = new Object(); protected final Properties configProps; @@ -80,6 +82,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb protected final long monitoringInitialDelay; protected final long expectedCompletionTime; protected final long unprocessedFailoverThreshold; + private static final String LOGGER_ALARM_MSG="Generated alarm: DBResourceManager.getData - No active DB connection pools are available."; public DBResourceManager(final DBLIBResourceProvider configuration) { this(configuration.getProperties()); @@ -393,7 +396,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb // test if there are any connection pools available if(this.dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + LOGGER.error(LOGGER_ALARM_MSG); throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); } @@ -457,7 +460,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { if(dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + LOGGER.error(LOGGER_ALARM_MSG); throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); } CachedDataSource active = this.dsQueue.first(); @@ -533,7 +536,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb private boolean writeDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { if(dsQueue.isEmpty()){ - LOGGER.error("Generated alarm: DBResourceManager.getData - No active DB connection pools are available."); + LOGGER.error(LOGGER_ALARM_MSG); throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); } -- cgit 1.2.3-korg From e232a5607bb89cad0a52524e430b44633c64e270 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 5 Dec 2018 16:34:19 +0530 Subject: fixed sonar issues in DbConfigPool.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: Ibf082dc71b49b8d657dfbb79ac0ef396eb3f4aa8 Signed-off-by: Sandeep J --- .../main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java index 21fdab245..fb94ea0e7 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2016 - 2017 ONAP * ================================================================================ + * 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 @@ -30,7 +32,7 @@ public class DbConfigPool { private final String type; - private ArrayList configurations = new ArrayList(); + private ArrayList configurations = new ArrayList<>(); public DbConfigPool(Properties properties) { LOGGER.debug("Initializing DbConfigType"); @@ -38,7 +40,6 @@ public class DbConfigPool { } public int getTimeout() { - // TODO Auto-generated method stub return 0; } -- cgit 1.2.3-korg From 53e0e685052653bda628dfb316642be35d316c61 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 5 Dec 2018 16:37:42 +0530 Subject: fixed sonar issue in DBConfigFactory fixed sonar issue Issue-ID: CCSDK-525 Change-Id: I64adc9bc11c7e4fcac2c1caec614745ebe6887be Signed-off-by: Sandeep J --- .../java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java index c3503576e..1aa907837 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2016 - 2017 ONAP * ================================================================================ + * 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 @@ -44,7 +46,7 @@ public class DBConfigFactory { static DbConfigPool getConfigparams(Properties properties) { DbConfigPool xmlConfig = new DbConfigPool(properties); - ArrayList propertySets = new ArrayList(); + ArrayList propertySets = new ArrayList<>(); if ("JDBC".equalsIgnoreCase(xmlConfig.getType())) { String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS); -- cgit 1.2.3-korg From 3391f0dd1a9fc05e8529fda806dd48504c9510bd Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 5 Dec 2018 16:49:25 +0530 Subject: fixed sonar issues in LogFilter.java to increase code coverage Issue-ID: CCSDK-525 Change-Id: If9ad798ad5e5fc7b4ad97cb83ad79ff379ccb933 Signed-off-by: Sandeep J --- .../java/org/onap/ccsdk/sli/core/filters/LogFilter.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java index d7a599cb3..4481ab904 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java @@ -5,6 +5,8 @@ * 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 @@ -84,6 +86,7 @@ public class LogFilter implements Filter { private static final Logger AUDIT = LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.audit"); @Override public void destroy() { + // this method does nothing } @Override @@ -111,6 +114,7 @@ public class LogFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { + // this method does nothing } @@ -134,11 +138,7 @@ public class LogFilter implements Filter { String userName="unknown"; - /* below returning org.opendaylight.aaa.shiro.realm.TokenAuthRealm$ODLPrincipal@745dfcfe - if ( request.getUserPrincipal() != null) { - userName = request.getUserPrincipal().getName(); - } - */ + // going directly after Authorization header if (request.getHeader("Authorization") != null) { String authzHeader = request.getHeader("Authorization"); @@ -164,12 +164,8 @@ public class LogFilter implements Filter { private void post(HttpServletRequest request,HttpServletResponse response,long startTime) { - //AUDIT.info("{}|{}|{}{}",request.getRemoteHost(),request.getMethod(),request.getRequestURL().toString(),request.getQueryString()); - //AUDIT.info(request.getRemoteHost() + D + request.getMethod() + D + request.getRequestURL().toString() + D + request.getQueryString()); - //METRIC.info(request.getMethod() + D + response.getStatus() + D + request.getRequestURL().toString() + D + (System.currentTimeMillis() - startTime) + " ms"); MDC.put(BEGIN_TIMESTAMP,asIso8601(startTime)); MDC.put(END_TIMESTAMP,asIso8601(System.currentTimeMillis())); - //MDC.put(REQUEST_ID,"already done above"); MDC.put(SERVICE_NAME,request.getRequestURL().toString()); int idx = request.getPathInfo().lastIndexOf(':'); String instance = ""; @@ -179,7 +175,6 @@ public class LogFilter implements Filter { MDC.put(SERVICE_INSTANCE,instance); MDC.put(THREAD_ID,""); MDC.put(PHYSICAL_SERVER_NAME,""); - //MDC.put(PARTNER_NAME,"already done above"); if ( response.getStatus() >= 400 ) { MDC.put(STATUS_CODE,"ERROR"); } else { -- cgit 1.2.3-korg From 72504e5853929bd0d649fc3bc42d3e91fc60c079 Mon Sep 17 00:00:00 2001 From: ezhil Date: Wed, 5 Dec 2018 20:33:08 +0530 Subject: Fixed sonar issues in PollingWorker.java Fixed logger issues Issue-ID: CCSDK-791 Change-Id: Ie1759c8778ff896b2cff3e187308e6a10265e966 Signed-off-by: ezhil --- .../ccsdk/sli/core/dblib/pm/PollingWorker.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java index 4bfa058a8..b44e2f89d 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java @@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicLong; public class PollingWorker implements Runnable { - private Logger LOGGER = LoggerFactory.getLogger(PollingWorker.class); + private Logger logger = LoggerFactory.getLogger(PollingWorker.class); private static PollingWorker self = null; @@ -47,17 +47,6 @@ public class PollingWorker implements Runnable { private static boolean enabled = false; private Timer timer = null; - public static void post(long starttime){ - PollingWorker temp = self; - if(temp != null && enabled) { - temp.register(new TestSample(starttime)); - } - } - - public static void createInistance(Properties props){ - self = new PollingWorker(props); - } - private PollingWorker(Properties ctxprops){ if(ctxprops==null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm") == null){ enabled = false; @@ -89,6 +78,18 @@ public class PollingWorker implements Runnable { timer.schedule(new MyTimerTask(), interval*1000L, interval*1000L); } } + public static void post(long starttime){ + PollingWorker temp = self; + if(temp != null && enabled) { + temp.register(new TestSample(starttime)); + } + } + + public static void createInistance(Properties props){ + self = new PollingWorker(props); + } + + private void register(TestSample object){ try { @@ -113,12 +114,14 @@ public class PollingWorker implements Runnable { consume((TestSample)next); } else { System.out.println(next.getClass().getName()); + logger.error(next.getClass().getName()); } } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); + } } @@ -146,7 +149,7 @@ public class PollingWorker implements Runnable { } sb.append(tmp2[i].get()).append("\t"); } - LOGGER.info(sb.toString()); + logger.info(sb.toString()); } class MyTimerTask extends TimerTask{ -- cgit 1.2.3-korg From 7db11491f101ed834da2f73958647240502677df Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Wed, 5 Dec 2018 17:37:36 -0800 Subject: Update INFO.yaml file Remove Ryan Goulding Change-Id: I5af561ecade10cfe299d524848e0bbec57d1d37d Issue-ID: CIMAN-134 Signed-off-by: Jessica Wagantall --- INFO.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index 070df112b..e15dda3ae 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -33,10 +33,9 @@ committers: company: 'ATT' id: 'jh245g' timezone: 'America/New York' - - name: 'Ryan Goulding' - email: 'ryandgoulding@gmail.com' - company: 'Inocybe Technologies' - id: 'rgoulding' - timezone: 'America/New York' tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' + changes: + - type: 'Deletion' + name: 'Ryan Goulding' + link: 'https://lists.onap.org/g/onap-tsc/message/4261' -- cgit 1.2.3-korg From 86a5baf7014d426b7026288c9ddf55e79608d11a Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 7 Dec 2018 00:16:43 +0530 Subject: fixed sonar issues in RequestResponseLoggingFilter fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Icaccda30e0386614dd7cd601a8c93fd32597c213 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/filters/RequestResponseLoggingFilter.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java index f5510b9ab..7b48a2361 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -5,6 +5,8 @@ * 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 @@ -70,7 +72,7 @@ public class RequestResponseLoggingFilter implements Filter { @Override public void setWriteListener(WriteListener arg0) { - + //this method does nothing } } @@ -131,7 +133,7 @@ public class RequestResponseLoggingFilter implements Filter { @Override public void setReadListener(ReadListener arg0) { - + // this method does nothing } } @@ -151,7 +153,7 @@ public class RequestResponseLoggingFilter implements Filter { InputStream is = req.getInputStream(); baos = new ByteArrayOutputStream(); - byte buf[] = new byte[1024]; + byte[] buf = new byte[1024]; int letti; while ((letti = is.read(buf)) > 0) { baos.write(buf, 0, letti); @@ -180,6 +182,7 @@ public class RequestResponseLoggingFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { + //this method does nothing } @Override @@ -259,6 +262,7 @@ public class RequestResponseLoggingFilter implements Filter { @Override public void destroy() { + //this method does nothing } private String decompressGZIPByteArray(byte[] bytes) { -- cgit 1.2.3-korg From 2a9b46ef39b1717ed055f1f80a3bba532b3f64d9 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 7 Dec 2018 15:59:45 +0530 Subject: fixed sonar issues in PrintYangToProp.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Ie44b6710411605e262fd74fa7e4947eb3bd05a90 Signed-off-by: Sandeep J --- .../onap/ccsdk/sli/core/sli/PrintYangToProp.java | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java index 2e2910235..e22f39258 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java @@ -5,6 +5,8 @@ * 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 @@ -53,9 +55,11 @@ public class PrintYangToProp { private static final Logger LOG = LoggerFactory.getLogger(PrintYangToProp.class); public static final String PROPERTIES_FILE=""; private static Properties properties; + private static final String BUILDER="-builder"; + private static final String IMPL="-impl"; public static Properties prop = new Properties(); - public static ArrayList propList = new ArrayList(); + public static ArrayList propList = new ArrayList<>(); public static Properties toProperties(Properties props, Object fromObj) { @@ -115,14 +119,14 @@ public class PrintYangToProp { propNamePfx = toLowerHyphen(fromClass.getSimpleName()); } - if (propNamePfx.endsWith("-builder")) { + if (propNamePfx.endsWith(BUILDER)) { propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - "-builder".length()); + - BUILDER.length()); } - if (propNamePfx.endsWith("-impl")) { + if (propNamePfx.endsWith(IMPL)) { propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - "-impl".length()); + - IMPL.length()); } } @@ -486,14 +490,14 @@ public class PrintYangToProp { propNamePfx = toLowerHyphen(toClass.getSimpleName()); } - if (propNamePfx.endsWith("-builder")) { + if (propNamePfx.endsWith(BUILDER)) { propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - "-builder".length()); + - BUILDER.length()); } - if (propNamePfx.endsWith("-impl")) { + if (propNamePfx.endsWith(IMPL)) { propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - "-impl".length()); + - IMPL.length()); } } @@ -999,14 +1003,14 @@ public class PrintYangToProp { propNamePfx = toLowerHyphen(toClass.getSimpleName()); } - if (propNamePfx.endsWith("-builder")) { + if (propNamePfx.endsWith(BUILDER)) { propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - "-builder".length()); + - BUILDER.length()); } - if (propNamePfx.endsWith("-impl")) { + if (propNamePfx.endsWith(IMPL)) { propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - "-impl".length()); + - IMPL.length()); } } -- cgit 1.2.3-korg From d43c10e65a6e12da041f0b47f26a3e28e0d0fa5a Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 7 Dec 2018 16:06:55 +0530 Subject: fixed sonar issue in SvcLogicBinaryExpression fixed sonar issue Issue-ID: CCSDK-525 Change-Id: Iea683bb51d07daa0f7f3b48b4c83642a427edfbd Signed-off-by: Sandeep J --- .../java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java index 45458e8d6..a990dd950 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicBinaryExpression.java @@ -5,6 +5,8 @@ * 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 @@ -81,7 +83,7 @@ public class SvcLogicBinaryExpression extends SvcLogicExpression { public SvcLogicBinaryExpression() { - operators = new LinkedList(); + operators = new LinkedList<>(); } public void addOperator(String operator) -- cgit 1.2.3-korg From 45cdc54762d8c45ddae9ad6c3ecf289abd2d0661 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 7 Dec 2018 16:15:32 +0530 Subject: fixed sonar issues in SvcLogicDblibStore.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: Ia1ddf9787311b786c71b19e651730b65c2c0835e Signed-off-by: Sandeep J --- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 3ade88f4f..87e8f1a4d 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -302,7 +302,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { throws SvcLogicException { String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?"; - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(module); args.add(rpc); @@ -320,7 +320,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?"; String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(graph.getModule()); args.add(graph.getRpc()); @@ -437,7 +437,7 @@ public class SvcLogicDblibStore implements SvcLogicStore { String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?"; - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(module); args.add(rpc); -- cgit 1.2.3-korg From cc93ca92ff6391d04e939c7b83fc99d7b100e5c3 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 7 Dec 2018 16:24:21 +0530 Subject: fixed sonar issue in SvcLogicGraoh.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: If14288410ad7be50d8fdfb942f11383a9f58eab0 Signed-off-by: Sandeep J --- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java index cbac15442..97f2bd7ab 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicGraph.java @@ -1,10 +1,13 @@ /*- - * ============LICENSE_START======================================================= +x * ============LICENSE_START======================================================= * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * Modifications 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 @@ -46,8 +49,8 @@ public class SvcLogicGraph implements Serializable { public SvcLogicGraph() { - attributes = new HashMap(); - namedNodes = new HashMap(); + attributes = new HashMap<>(); + namedNodes = new HashMap<>(); rootNode = null; } -- cgit 1.2.3-korg From 3178bbc132b403e7c3ee7317df2362e0a8f0059e Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 7 Dec 2018 16:32:26 +0530 Subject: fixed sonar issue in SvcLogicLoader.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I515fcdbae28518e0a25f1370173b1dd4f77b816e Signed-off-by: Sandeep J --- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java index d50c371c0..433b723e7 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java @@ -5,6 +5,8 @@ * 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 @@ -62,7 +64,7 @@ public class SvcLogicLoader { } protected List processActivationFiles(List activationPaths) { - List activationEntries = new ArrayList(); + List activationEntries = new ArrayList<>(); for (Path activationFile : activationPaths) { activationEntries.addAll(getActivationEntries(activationFile)); } @@ -104,7 +106,7 @@ public class SvcLogicLoader { return activationEntries; } catch (IOException ioe) { LOGGER.error("Couldn't read the activation file at " + activationFilePath, ioe); - return null; + return new ArrayList<>(); } } @@ -167,7 +169,7 @@ public class SvcLogicLoader { public void bulkActivate() { Path activationFile = Paths.get(directoryRoot); - List pathList = new ArrayList(1); + List pathList = new ArrayList<>(1); pathList.add(activationFile); List activationEntries = processActivationFiles(pathList); activateGraphs(activationEntries); -- cgit 1.2.3-korg From ae126c693fc024d83fcba7504955aa5156c0b986 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 7 Dec 2018 16:39:13 +0530 Subject: fixed sonar issues in SvcLogicNode.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I2f7e33601cac898069836bc5461e92dc5fe5d442 Signed-off-by: Sandeep J --- .../org/onap/ccsdk/sli/core/sli/SvcLogicNode.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java index 45f683516..72cfea500 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java @@ -5,6 +5,8 @@ * 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 @@ -31,6 +33,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.HashSet; import java.util.TreeMap; import org.apache.commons.lang3.StringEscapeUtils; @@ -61,8 +64,8 @@ public class SvcLogicNode implements Serializable { nodeName = ""; this.nodeType = nodeType; this.graph = graph; - attributes = new HashMap (); - parameters = new HashMap (); + attributes = new HashMap<> (); + parameters = new HashMap<> (); outcomes = null; } @@ -73,8 +76,8 @@ public class SvcLogicNode implements Serializable { this.nodeName = nodeName; this.nodeType = nodeType; this.graph = graph; - attributes = new HashMap (); - parameters = new HashMap (); + attributes = new HashMap<> (); + parameters = new HashMap<> (); outcomes = null; graph.setNamedNode(nodeName, this); } @@ -224,7 +227,7 @@ public class SvcLogicNode implements Serializable { { if (outcomes == null) { - outcomes = new HashMap(); + outcomes = new HashMap<>(); } if (outcomeValue.length() == 0) { @@ -242,7 +245,7 @@ public class SvcLogicNode implements Serializable { { if (outcomes == null) { - return null; + return new HashSet<>(); } return outcomes.entrySet(); @@ -253,7 +256,7 @@ public class SvcLogicNode implements Serializable { { if (parameters == null) { - return null; + return new HashSet<>(); } return parameters.entrySet(); @@ -307,7 +310,7 @@ public class SvcLogicNode implements Serializable { if (outcomes != null) { - TreeMap sortedOutcomes = new TreeMap(outcomes); + TreeMap sortedOutcomes = new TreeMap<>(outcomes); Set> outcomeSet = sortedOutcomes.entrySet(); for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) -- cgit 1.2.3-korg From 03167d7e9486c1d201de9752e8e629f8654d31e0 Mon Sep 17 00:00:00 2001 From: ezhil Date: Fri, 7 Dec 2018 23:40:29 +0530 Subject: Sonar issues fix in SVcLogicPropertiesProviderImpl Fixed critical and minor issues Issue-ID: CCSDK-798 Change-Id: I86ae8741b3eda5729d2c6169d0342b585cea68ad Signed-off-by: ezhil --- .../core/sli/provider/SvcLogicPropertiesProviderImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java index c4680cce5..aad7a5a6d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java @@ -3,6 +3,7 @@ * onap * ================================================================================ * Copyright (C) 2016 - 2017 ONAP + * 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. @@ -24,12 +25,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.util.Optional; import java.util.Properties; import java.util.Vector; -import org.onap.ccsdk.sli.core.dblib.DblibConfigurationException; import org.onap.ccsdk.sli.core.sli.ConfigurationException; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; import org.onap.ccsdk.sli.core.utils.JREFileResolver; @@ -57,7 +56,7 @@ import org.slf4j.LoggerFactory; */ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvider { - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicPropertiesProviderImpl.class); + private static final Logger log = LoggerFactory.getLogger(SvcLogicPropertiesProviderImpl.class); /** * The name of the properties file for database configuration @@ -95,7 +94,7 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide properties = new Properties(); properties.load(fileInputStream); } catch (final IOException e) { - LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), + log.error("Failed to load properties for file: {}", propertiesFile.toString(), new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(), e)); } @@ -109,6 +108,7 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide properties.load(propStr); propStr.close(); } catch (IOException e) { + log.error("IO Exception",e); properties = null; } } @@ -143,7 +143,7 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide private static File reportSuccess(final String message, final Optional fileOptional) { if (fileOptional.isPresent()) { final File file = fileOptional.get(); - LOG.info("{} {}", message, file.getPath()); + log.info("{} {}", message, file.getPath()); return file; } return null; @@ -160,7 +160,7 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide */ private static void reportFailure(final String message, final ConfigurationException configurationException) { - LOG.error("{}", message, configurationException); + log.error("{}", message, configurationException); } /** -- cgit 1.2.3-korg From cac89a460fc2bf0c7e4f736371f98adaf5718fb7 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 5 Dec 2018 21:56:41 +0000 Subject: minor changes to sli minor changes to sli, move around classes to avoid classnotfound in junit suite Change-Id: Ie7eeb023c46644ee03e05a6bef7817eec27a7ea3 Issue-ID: CCSDK-792 Signed-off-by: Smokowski, Kevin (ks6305) --- .../base/AbstractSvcLogicNodeExecutor.java | 2 + .../sli/provider/base/SvcLogicServiceImplBase.java | 5 -- .../sli/core/sli/provider/base/DummyAdaptor.java | 54 ------------ .../sli/core/sli/provider/base/DummyRecorder.java | 14 ---- .../sli/core/sli/provider/base/DummyResource.java | 97 ---------------------- .../sli/core/sli/provider/base/PluginTest.java | 7 +- .../core/sli/provider/base/VoidDummyPlugin.java | 38 --------- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 5 -- 8 files changed, 8 insertions(+), 214 deletions(-) delete mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyAdaptor.java delete mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyRecorder.java delete mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyResource.java delete mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/VoidDummyPlugin.java diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java index a51accbb9..3574b88f6 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -69,6 +70,7 @@ public abstract class AbstractSvcLogicNodeExecutor { } protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) { + MetricLogger.resetContext(); SvcLogicNode nextNode = node.getOutcomeValue(outValue); if (nextNode != null) { if (LOG.isDebugEnabled()) { diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java index 92fdb9a30..f850bc4c8 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java @@ -114,7 +114,6 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { LOG.info("About to execute graph {}", graph.toString()); try { while (curNode != null) { - resetContext(); SvcLogicNode nextNode = executeNode(curNode, ctx); curNode = nextNode; } @@ -125,10 +124,6 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { MDC.remove(CURRENT_GRAPH); return (ctx); - } - - protected void resetContext() { - } public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyAdaptor.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyAdaptor.java deleted file mode 100644 index 58582e0e6..000000000 --- a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyAdaptor.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - */ -package org.onap.ccsdk.sli.core.sli.provider.base; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -/** - * @author dt5972 - * - */ - -public class DummyAdaptor implements SvcLogicAdaptor { - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#configure(java.lang.String, java.util.Map, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public ConfigStatus configure(String key, Map parameters, SvcLogicContext ctx) { - - if ("ALREADY_ACTIVE".equalsIgnoreCase(key)) { - return ConfigStatus.ALREADY_ACTIVE; - } else if ("NOT_FOUND".equalsIgnoreCase(key)) { - return ConfigStatus.NOT_FOUND; - }else if ("NOT_READY".equalsIgnoreCase(key)) { - return ConfigStatus.NOT_READY; - } else if ("FAILURE".equalsIgnoreCase(key)) { - return ConfigStatus.FAILURE; - } else if ("SUCCESS".equalsIgnoreCase(key)) { - return ConfigStatus.SUCCESS; - } - - return ConfigStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#activate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public ConfigStatus activate(String key, SvcLogicContext ctx) { - return ConfigStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#deactivate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public ConfigStatus deactivate(String key, SvcLogicContext ctx) { - return ConfigStatus.SUCCESS; - } - -} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyRecorder.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyRecorder.java deleted file mode 100644 index 52bc123a4..000000000 --- a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyRecorder.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.onap.ccsdk.sli.core.sli.provider.base; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; - -public class DummyRecorder implements SvcLogicRecorder { - - @Override - public void record(Map parmMap) throws SvcLogicException { - return; - } - -} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyResource.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyResource.java deleted file mode 100644 index 2e15f3fb7..000000000 --- a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/DummyResource.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * - */ -package org.onap.ccsdk.sli.core.sli.provider.base; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; - -/** - * @author dt5972 - * - */ -public class DummyResource implements SvcLogicResource { - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#isAvailable(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#exists(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#query(java.lang.String, boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, - String orderBy, SvcLogicContext ctx) throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#reserve(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#save(java.lang.String, boolean, boolean, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map parms, - String prefix, SvcLogicContext ctx) throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#release(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { - - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#delete(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#notify(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) - throws SvcLogicException { - return QueryStatus.SUCCESS; - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#update(java.lang.String, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) - */ - @Override - public QueryStatus update(String resource, String key, Map parms, String prefix, - SvcLogicContext ctx) throws SvcLogicException { - return QueryStatus.SUCCESS; - } - -} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java index cbeb59715..8eb5755e9 100644 --- a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.Map; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; @@ -41,7 +42,11 @@ public class PluginTest extends TestCase { // The attribute emitsOutcome will not be present, the expected outcome is success when no exception is thrown by the plugin public void testOldPlugin() throws Exception { ExecuteNodeExecutor executor = new ExecuteNodeExecutor(); - SvcLogicJavaPlugin plugin = new VoidDummyPlugin(); + SvcLogicJavaPlugin plugin = new SvcLogicJavaPlugin() { + public void dummy(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + return; + } + }; Class pluginClass = plugin.getClass(); Method pluginMethod = pluginClass.getMethod("dummy", Map.class, SvcLogicContext.class); diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/VoidDummyPlugin.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/VoidDummyPlugin.java deleted file mode 100644 index b2332e056..000000000 --- a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/VoidDummyPlugin.java +++ /dev/null @@ -1,38 +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.provider.base; - -import java.util.Map; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - - - -public class VoidDummyPlugin implements SvcLogicJavaPlugin { - - public void dummy(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - return; - } - -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 23d703c2f..b4059ed25 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -114,11 +114,6 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL return (ctx.toProperties()); } - @Override - protected void resetContext() { - MetricLogger.resetContext(); - } - @Override public SvcLogicStore getStore() throws SvcLogicException { // Create and initialize SvcLogicStore object - used to access -- cgit 1.2.3-korg From 6dd2c1b07cc306750dd9ee93cf8bb2f615f076aa Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Tue, 11 Dec 2018 12:23:59 -0800 Subject: Update INFO.yaml file - Add Gaurav Agrawal as committer - Add missing info sections - Fix indentation to pass verify Change-Id: I83ec11ca571678342b31fc6004741d7446498018 Issue-ID: CIMAN-134 Signed-off-by: Jessica Wagantall --- INFO.yaml | 62 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index e15dda3ae..f3793623b 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -2,6 +2,7 @@ project: 'ccsdk-sli-core' project_creation_date: '2017-06-27' lifecycle_state: 'Incubation' +project_category: '' project_lead: &onap_releng_ptl name: 'Dan Timoney' email: 'dtimoney@att.com' @@ -13,29 +14,58 @@ issue_tracking: type: 'jira' url: 'https://jira.onap.org/projects/CCSDK' key: 'CCDSK' +mailing_list: + type: 'groups.io' + url: 'lists.onap.org' + tag: '<[sub-project_name]>' +realtime_discussion: '' meetings: - type: 'zoom' - agenda: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' - url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project#CommonControllerSDKProject-MeetingMinutes' - server: 'n/a' - channel: 'n/a' - repeats: 'weekly' - time: '13:00 UTC' + agenda: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' + url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project#CommonControllerSDKProject-MeetingMinutes' + server: 'n/a' + channel: 'n/a' + repeats: 'weekly' + time: '13:00 UTC' committers: - <<: *onap_releng_ptl - name: 'Jack Lucas' - email: 'jflucas@research.att.com' - company: 'ATT' - id: 'jackl' - timezone: 'America/New York' + email: 'jflucas@research.att.com' + company: 'ATT' + id: 'jackl' + timezone: 'America/New York' - name: 'Jun (Nicolas) Hu' - email: 'jh245g@att.com' - company: 'ATT' - id: 'jh245g' - timezone: 'America/New York' + email: 'jh245g@att.com' + company: 'ATT' + id: 'jh245g' + timezone: 'America/New York' + - name: 'Gaurav Agrawal' + email: 'gaurav.agrawal@huawei.com' + company: 'Huawei' + id: 'agrawalgaurav' + timezone: 'Asia/Kolkata' +repositories: + - ccsdk-apps + - ccsdk-cds + - ccsdk-distribution + - ccsdk-features + - ccsdk-parent + - ccsdk-platform-blueprints + - ccsdk-platform-plugins + - ccsdk-sli-adaptors + - ccsdk-sli-core + - ccsdk-sli-northbound + - ccsdk-sli-plugins + - ccsdk-storage-esaas + - ccsdk-utils tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: - type: 'Deletion' - name: 'Ryan Goulding' - link: 'https://lists.onap.org/g/onap-tsc/message/4261' + name: 'Ryan Goulding' + link: 'https://lists.onap.org/g/onap-tsc/message/4261' + changes: + - type: 'Addition' + name: 'Gaurav Agrawal' + link: 'https://lists.onap.org/g/onap-tsc/message/4324' + -- cgit 1.2.3-korg From 05102065e87889d6d4a8b8690d9ee6cdd4faf61d Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Thu, 13 Dec 2018 17:31:51 -0500 Subject: fixed sonar issue in JdbcCachedDataSource Changes made: * fixed sonar issue Change-Id: I2112b202f8b7eb628fc21c3a972e35704dc827f9 Issue-ID: CCSDK-525 Signed-off-by: Rich Tabedzki --- .../sli/core/dblib/config/BaseDBConfiguration.java | 6 ++-- .../core/dblib/jdbc/JdbcDBCachedDataSource.java | 39 ++++++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java index 5f0209b67..967059a31 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java @@ -209,7 +209,7 @@ public abstract class BaseDBConfiguration { * Integer. */ public int getDbMinLimit() throws NumberFormatException { - String value = properties.getProperty(MIN_LIMIT); + String value = properties.getProperty(MIN_LIMIT, "-1"); return Integer.parseInt(value); } @@ -222,7 +222,7 @@ public abstract class BaseDBConfiguration { * Integer. */ public int getDbMaxLimit() throws NumberFormatException { - String value = properties.getProperty(MAX_LIMIT); + String value = properties.getProperty(MAX_LIMIT, "-1"); return Integer.parseInt(value); } @@ -235,7 +235,7 @@ public abstract class BaseDBConfiguration { * Integer. */ public int getDbInitialLimit() throws NumberFormatException { - String value = properties.getProperty(INIT_LIMIT); + String value = properties.getProperty(INIT_LIMIT, "-1"); return Integer.parseInt(value); } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java index 80ca577cf..09c1c202b 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java @@ -42,6 +42,9 @@ public class JdbcDBCachedDataSource extends CachedDataSource { private int initialLimit; private static final String AS_CONF_ERROR = "AS_CONF_ERROR: "; + private static final int MIN_LIMIT = 5; + private static final int MAX_LIMIT = 10; + private static final int INITIAL_LIMIT = 10; private static final Logger LOGGER = LoggerFactory.getLogger(JdbcDBCachedDataSource.class); @@ -88,26 +91,26 @@ public class JdbcDBCachedDataSource extends CachedDataSource { } minLimit = jdbcConfig.getDbMinLimit(); -// if (minLimit == null) -// { -// String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); -// } + if (minLimit == -1) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + minLimit = MIN_LIMIT; + } maxLimit = jdbcConfig.getDbMaxLimit(); -// if (maxLimit == null) -// { -// String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); -// } + if (maxLimit == -1) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + maxLimit = MAX_LIMIT; + } initialLimit = jdbcConfig.getDbInitialLimit(); -// if (initialLimit == null) -// { -// String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; -// LOGGER.error(AS_CONF_ERROR + errorMsg); -// throw new DBConfigException(errorMsg); -// } + if (initialLimit == -1) + { + String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute"; + LOGGER.error(AS_CONF_ERROR + errorMsg); + initialLimit = INITIAL_LIMIT; + } dbUrl = jdbcConfig.getDbUrl(); if (dbUrl == null) { -- cgit 1.2.3-korg From f8dc076322e07ea8689c05b96aac28a917ad914b Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 14 Dec 2018 17:21:47 +0530 Subject: fixed sonar issues in PrintYangToProp.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Icd98cabe0f1322abbfb580ee37c8c15bbc315463 Signed-off-by: Sandeep J --- .../onap/ccsdk/sli/core/sli/PrintYangToProp.java | 37 +++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java index e22f39258..c4b76793e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java @@ -57,7 +57,8 @@ public class PrintYangToProp { private static Properties properties; private static final String BUILDER="-builder"; private static final String IMPL="-impl"; - + private static final String TO_PROPERTIES_STRING="() to Properties entry"; + private static final String CAUGHT_EXCEPTION_MSG="Caught exception trying to convert value returned by "; public static Properties prop = new Properties(); public static ArrayList propList = new ArrayList<>(); @@ -178,7 +179,7 @@ public class PrintYangToProp { "Caught exception trying to convert Yang-generated enum returned by " + fromClass.getName() + "." + m.getName() - + "() to Properties entry", e); + + TO_PROPERTIES_STRING, e); } } else if (isIpv4Address(returnType)) { // Save its value @@ -194,7 +195,7 @@ public class PrintYangToProp { } if (retValue != null) { - String propVal = retValue.getValue().toString(); + String propVal = retValue.getValue(); //LOG.debug("Setting property " + propName // + " to " + propVal); props.setProperty(propName, propVal); @@ -202,10 +203,10 @@ public class PrintYangToProp { } } catch (Exception e) { LOG.error( - "Caught exception trying to convert value returned by " + CAUGHT_EXCEPTION_MSG + fromClass.getName() + "." + m.getName() - + "() to Properties entry", e); + + TO_PROPERTIES_STRING, e); } } else if (isIpv6Address(returnType)) { // Save its value @@ -229,10 +230,10 @@ public class PrintYangToProp { } } catch (Exception e) { LOG.error( - "Caught exception trying to convert value returned by " + CAUGHT_EXCEPTION_MSG + fromClass.getName() + "." + m.getName() - + "() to Properties entry", e); + + TO_PROPERTIES_STRING, e); } } else if (isIpv4Prefix(returnType)) { //System.out.println("isIpv4Prefix"); @@ -257,10 +258,10 @@ public class PrintYangToProp { } } catch (Exception e) { LOG.error( - "Caught exception trying to convert value returned by " + CAUGHT_EXCEPTION_MSG + fromClass.getName() + "." + m.getName() - + "() to Properties entry", e); + + TO_PROPERTIES_STRING, e); } } else if (isIpv6Prefix(returnType)) { //System.out.println("isIpv6Prefix"); @@ -285,10 +286,10 @@ public class PrintYangToProp { } } catch (Exception e) { LOG.error( - "Caught exception trying to convert value returned by " + CAUGHT_EXCEPTION_MSG + fromClass.getName() + "." + m.getName() - + "() to Properties entry", e); + + TO_PROPERTIES_STRING, e); } } else { try { @@ -308,7 +309,7 @@ public class PrintYangToProp { "Caught exception trying to convert Yang-generated class returned by" + fromClass.getName() + "." + m.getName() - + "() to Properties entry", e); + + TO_PROPERTIES_STRING, e); } } } else if (returnType.equals(Class.class)) { @@ -339,7 +340,7 @@ public class PrintYangToProp { "Caught exception trying to convert List returned by " + fromClass.getName() + "." + m.getName() - + "() to Properties entry", e); + + TO_PROPERTIES_STRING, e); } } else { @@ -367,10 +368,10 @@ public class PrintYangToProp { } } catch (Exception e) { LOG.error( - "Caught exception trying to convert value returned by " + CAUGHT_EXCEPTION_MSG + fromClass.getName() + "." + m.getName() - + "() to Properties entry", e); + + TO_PROPERTIES_STRING, e); } } @@ -783,7 +784,7 @@ public class PrintYangToProp { + toClass.getName() + "." + m.getName() - + "() to Properties entry", + + TO_PROPERTIES_STRING, e); } } @@ -835,7 +836,7 @@ public class PrintYangToProp { "Caught exception trying to convert List returned by" + toClass.getName() + "." + m.getName() - + "() to Properties entry", + + TO_PROPERTIES_STRING, e); } } @@ -925,7 +926,7 @@ public class PrintYangToProp { + toClass.getName() + "." + m.getName() - + "() to Properties entry", + + TO_PROPERTIES_STRING, e); } } -- cgit 1.2.3-korg From 4885b852981cb9ae9f565d3034ec38673e11d1d0 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 14 Dec 2018 18:58:18 +0530 Subject: fixed sonar issues in SvcLogicCrawler.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I4d5e95cfac8bb04d03752015d64f7c3b61495f1a Signed-off-by: Sandeep J --- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java index 5ee138a3e..c6fd8b6a2 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicCrawler.java @@ -5,6 +5,8 @@ * 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 @@ -37,8 +39,8 @@ public class SvcLogicCrawler extends SimpleFileVisitor { private List activationFilePathList; public SvcLogicCrawler() { - xmlGraphPathList = new ArrayList(); - activationFilePathList = new ArrayList(); + xmlGraphPathList = new ArrayList<>(); + activationFilePathList = new ArrayList<>(); } @Override -- cgit 1.2.3-korg From e45a7de109d710b86e9ab86fd5d10c6c6d27137b Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 14 Dec 2018 19:01:33 +0530 Subject: fixed sonar issue in SvCLogicExprListener.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: I59cfc4c94fe3cb1690ffecc92f10e2543ca645fe Signed-off-by: Sandeep J --- .../main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java index 2a40e7a1d..e96b702ef 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java @@ -5,6 +5,8 @@ * 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 @@ -55,7 +57,7 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener public SvcLogicExprListener() { - exprStack = new LinkedList(); + exprStack = new LinkedList<>(); } public SvcLogicExpression getParsedExpr() -- cgit 1.2.3-korg From 57be9d28ec29c029fc72e9fac13da98764252ece Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 14 Dec 2018 19:06:56 +0530 Subject: fixed sonar issue in SvcLogicExpression.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: Ie7d170334ea0c704bf67ee175ef3cd1932171418 Signed-off-by: Sandeep J --- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java index 26783e70f..81aeb6c37 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpression.java @@ -5,6 +5,8 @@ * 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 @@ -28,7 +30,7 @@ import java.util.List; public abstract class SvcLogicExpression implements Serializable { - private List operands = new LinkedList(); + private List operands = new LinkedList<>(); public void addOperand(SvcLogicExpression expr) -- cgit 1.2.3-korg From a7fb3924adfa577f718882a7455db34dcfb6fdbb Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 14 Dec 2018 19:22:21 +0530 Subject: fixed sonar issue in MdsalHelper.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Iba12983579e9c608ffd3c615f3d3450353724602 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index bfbe9f974..48bb754ec 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -5,6 +5,8 @@ * 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 @@ -23,7 +25,6 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.lang.reflect.Constructor; @@ -50,6 +51,8 @@ public class MdsalHelper { private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); private static Properties yangMappingProperties = new Properties(); + private static final String IP_ADDRESS="IpAddress"; + private static final String IP_PREFIX="IpPrefix"; @Deprecated public static void setProperties(Properties input) { @@ -131,7 +134,7 @@ public class MdsalHelper { Object retValue = m.invoke(fromObj); if (retValue != null) { String propVal = null; - if ("IpAddress".equals(simpleTypeName) || "IpPrefix".equals(simpleTypeName)) { + if (IP_ADDRESS.equals(simpleTypeName) || IP_PREFIX.equals(simpleTypeName)) { propVal = String.valueOf((char[]) retValue); } else if ("Ipv4Address".equals(simpleTypeName) || "Ipv6Address".equals(simpleTypeName)) { propVal = (String) retValue; @@ -632,7 +635,7 @@ public class MdsalHelper { String simpleName = paramClass.getSimpleName(); if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || "IpAddress".equals(simpleName)) { + || IP_ADDRESS.equals(simpleName)) { if ((paramValue != null) && (paramValue.length() > 0)) { try { @@ -671,7 +674,7 @@ public class MdsalHelper { + m.getName() + "() with Properties entry", e); } } - } else if ("IpPrefix".equals(simpleName)) { + } else if (IP_PREFIX.equals(simpleName)) { if ((paramValue != null) && (paramValue.length() > 0)) { try { IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); @@ -993,8 +996,8 @@ public class MdsalHelper { } private static boolean classHasSpecialHandling(String simpleName) { - if ("IpAddress".equals(simpleName) || "Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || "IpPrefix".equals(simpleName) || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { + if (IP_ADDRESS.equals(simpleName) || "Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) + || IP_PREFIX.equals(simpleName) || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { return true; } return false; @@ -1068,7 +1071,7 @@ public class MdsalHelper { String simpleName = returnClass.getSimpleName(); if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || "IpAddress".equals(simpleName) || "IpPrefix".equals(simpleName) + || IP_ADDRESS.equals(simpleName) || IP_PREFIX.equals(simpleName) || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { LOG.trace(m.getName() + " is an " + simpleName); pstr.print("\n\n * " + propName); @@ -1131,7 +1134,7 @@ public class MdsalHelper { return (false); } String simpleName = c.getSimpleName(); - return ("IpPrefix".equals(simpleName)); + return (IP_PREFIX.equals(simpleName)); } public static boolean isIpv4Address(Class c) { @@ -1167,7 +1170,7 @@ public class MdsalHelper { return (false); } String simpleName = c.getSimpleName(); - return ("IpAddress".equals(simpleName)); + return (IP_ADDRESS.equals(simpleName)); } public static boolean isPortNumber(Class c) { -- cgit 1.2.3-korg From 3bb4eca7a3ff58766c847bcd0818fcb05e1a2445 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 14 Dec 2018 19:29:22 +0530 Subject: fixed sonar issue in CallNodeExecutor.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: Ia45c546b9301571c70f80fd5b9dfdd7efdd8f6d5 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java index 284795bd0..fd052ada2 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java @@ -5,6 +5,8 @@ * 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 @@ -34,6 +36,7 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory .getLogger(CallNodeExecutor.class); + private static final String CURRENT_GRAPH="currentGraph"; @Override public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) @@ -114,7 +117,7 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { version = SvcLogicExpressionResolver.evaluate(moduleExpr, node, ctx); } - String parentGraph = ctx.getAttribute("currentGraph"); + String parentGraph = ctx.getAttribute(CURRENT_GRAPH); ctx.setAttribute("parentGraph", parentGraph); SvcLogicStore store = svc.getStore(); @@ -124,7 +127,7 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode); if (calledGraph != null) { LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString()); - ctx.setAttribute("currentGraph", calledGraph.toString()); + ctx.setAttribute(CURRENT_GRAPH, calledGraph.toString()); svc.execute(calledGraph, ctx); outValue = ctx.getStatus(); graphWasCalled = true; @@ -140,7 +143,7 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { if (LOG.isDebugEnabled()) { LOG.debug("about to execute " + outValue + " branch"); } - ctx.setAttribute("currentGraph", parentGraph); + ctx.setAttribute(CURRENT_GRAPH, parentGraph); return (nextNode); } @@ -165,7 +168,7 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { } } - ctx.setAttribute("currentGraph", parentGraph); + ctx.setAttribute(CURRENT_GRAPH, parentGraph); ctx.setAttribute("parentGraph", null); return (nextNode); -- cgit 1.2.3-korg From 730601eb8281b7ad6aade500b8a54e6273dc5e53 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 14 Dec 2018 19:36:07 +0530 Subject: fixed sonar issues in ConfigureNodeExecutor.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: Iec7548e3ab6480589cd80118730d0478cd71d707 Signed-off-by: Sandeep J --- .../sli/core/sli/provider/base/ConfigureNodeExecutor.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java index 5b1d9efe9..7ffdfcaf7 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java @@ -5,6 +5,8 @@ * 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 @@ -37,6 +39,7 @@ import org.slf4j.LoggerFactory; public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory .getLogger(ConfigureNodeExecutor.class); + private static final String CAUGHT_EXCEPTION_MSG="Caught exception from "; public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { @@ -58,7 +61,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { String key = SvcLogicExpressionResolver.evaluate( node.getAttribute("key"), node, ctx); - Map parmMap = new HashMap(); + Map parmMap = new HashMap<>(); Set> parmSet = node .getParameterSet(); @@ -83,7 +86,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { try { confStatus = adaptor.configure(key, parmMap, ctx); } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".configure", e); + LOG.warn(CAUGHT_EXCEPTION_MSG+adaptorName+".configure", e); confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; } @@ -98,7 +101,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { activateStatus = adaptor.activate(key, ctx); } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".activate", e); + LOG.warn(CAUGHT_EXCEPTION_MSG+adaptorName+".activate", e); activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; } switch (activateStatus) { @@ -124,7 +127,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { deactivateStatus = adaptor.deactivate(key, ctx); } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".deactivate", e); + LOG.warn(CAUGHT_EXCEPTION_MSG+adaptorName+".deactivate", e); deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; } switch (deactivateStatus) { @@ -166,7 +169,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { try { activateStatus = adaptor.activate(key, ctx); } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".activate", e); + LOG.warn(CAUGHT_EXCEPTION_MSG+adaptorName+".activate", e); activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; } switch (activateStatus) { @@ -192,7 +195,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { try { deactivateStatus = adaptor.deactivate(key, ctx); } catch (Exception e) { - LOG.warn("Caught exception from "+adaptorName+".deactivate", e); + LOG.warn(CAUGHT_EXCEPTION_MSG+adaptorName+".deactivate", e); deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; } switch (deactivateStatus) { -- cgit 1.2.3-korg From 3c2340d43215dee18382cd4a1d45904fad539422 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 14 Dec 2018 19:40:00 +0530 Subject: fixed sonar issues in ExecuteNodeExecutor.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I94f1141f291ee356742f1cd220fc1acc07c6932b Signed-off-by: Sandeep J --- .../core/sli/provider/base/ExecuteNodeExecutor.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java index 357f11d02..e9fe78e88 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java @@ -5,6 +5,8 @@ * 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 @@ -39,6 +41,7 @@ import org.slf4j.LoggerFactory; public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory .getLogger(ExecuteNodeExecutor.class); + private static final String FAILURE="failure"; private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure."; public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, @@ -46,7 +49,7 @@ public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { String pluginName = SvcLogicExpressionResolver.evaluate( node.getAttribute("plugin"), node, ctx); - String outValue = "failure"; + String outValue = FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("execute node encountered - looking for plugin " @@ -76,7 +79,7 @@ public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { } else { try { - Map parmMap = new HashMap(); + Map parmMap = new HashMap<>(); Set> parmSet = node .getParameterSet(); @@ -104,16 +107,16 @@ public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { }else{ LOG.error(pluginErrorMessage, e); } - outValue = "failure"; - ctx.setStatus("failure"); + outValue = FAILURE; + ctx.setStatus(FAILURE); } catch (IllegalAccessException e) { LOG.error(pluginErrorMessage, e); - outValue = "failure"; - ctx.setStatus("failure"); + outValue = FAILURE; + ctx.setStatus(FAILURE); } catch (IllegalArgumentException e) { LOG.error(pluginErrorMessage, e); - outValue = "failure"; - ctx.setStatus("failure"); + outValue = FAILURE; + ctx.setStatus(FAILURE); } } -- cgit 1.2.3-korg From 9b99ab7c977888767dfdad22b3e239c78eca6135 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 17 Dec 2018 11:40:14 +0530 Subject: fixed sonar issue in RecordNodeExecutor.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: I88fe482edbfd8ce9881b14e6223ed2c52480e2f3 Signed-off-by: Sandeep J --- .../org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java index 3522c0a79..be5462bdc 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java @@ -5,6 +5,8 @@ * 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 @@ -48,7 +50,7 @@ public class RecordNodeExecutor extends AbstractSvcLogicNodeExecutor { LOG.trace(node.getNodeType() + " node encountered - looking for recorder class " + plugin); } - Map parmMap = new HashMap(); + Map parmMap = new HashMap<>(); Set> parmSet = node.getParameterSet(); boolean hasParms = false; -- cgit 1.2.3-korg From 58ccd061d4f20bd16f45530e8ff64c7950748f5b Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 17 Dec 2018 11:46:04 +0530 Subject: fixed sonar issues in SaveNodeExecutor.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I7b1ad4167f84da2820eb81f8951237428353612a Signed-off-by: Sandeep J --- .../ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java index 2dfc4074b..f8595fff2 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java @@ -5,6 +5,8 @@ * 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 @@ -36,6 +38,7 @@ import org.slf4j.LoggerFactory; public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class); + private static final String FAILURE= "failure"; @Override public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) @@ -51,7 +54,7 @@ public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor { boolean force = "true".equalsIgnoreCase(forceStr); boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); - Map parmMap = new HashMap(); + Map parmMap = new HashMap<>(); Set> parmSet = node.getParameterSet(); boolean hasParms = false; @@ -70,7 +73,7 @@ public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor { } } - String outValue = "failure"; + String outValue = FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("save node encountered - looking for resource class " + plugin); @@ -92,11 +95,11 @@ public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor { break; case FAILURE: default: - outValue = "failure"; + outValue = FAILURE; } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); -- cgit 1.2.3-korg From 8b03cbd27ea58435077e8887d4de74dc5e2ac998 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 17 Dec 2018 11:50:00 +0530 Subject: fixed sonar issues in SetNodeExecutor.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I58252cf9acb9eb1c5b70d6137e7b725f036d114f Signed-off-by: Sandeep J --- .../onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java index 8bebb336e..caf0015ba 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java @@ -5,6 +5,8 @@ * 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 @@ -111,7 +113,7 @@ public class SetNodeExecutor extends AbstractSvcLogicNodeExecutor { lhsPrefix = lhsPrefix.substring(0, lhsPrefix.length() - 1); } - HashMap parmsToAdd = new HashMap(); + HashMap parmsToAdd = new HashMap<>(); for (String sourceVarName : ctx.getAttributeKeySet()) { if (sourceVarName.startsWith(rhsRoot)) { @@ -125,7 +127,7 @@ public class SetNodeExecutor extends AbstractSvcLogicNodeExecutor { } } else { // If RHS is empty, unset attributes in LHS - LinkedList parmsToRemove = new LinkedList(); + LinkedList parmsToRemove = new LinkedList<>(); String prefix = lhsVarName + "."; String arrayPrefix = lhsVarName + "["; //Clear length value in case an array exists with this prefix @@ -143,10 +145,10 @@ public class SetNodeExecutor extends AbstractSvcLogicNodeExecutor { LOG.debug("Unsetting {} because matching value {} starts with the prefix {}", curCtxVarname, curCtxVarnameMatchingValue, prefix); parmsToRemove.add(curCtxVarname); }else if (curCtxVarnameMatchingValue.startsWith(lengthParamName)) { - LOG.debug("Unsetting {} because matching value {} starts with the lengthParamName {}", curCtxVarname, curCtxVarnameMatchingValue, lengthParamName); + LOG.debug("Unsetting {} because matching value {} starts with the lengthParamName {}", curCtxVarname, curCtxVarnameMatchingValue, lengthParamName); parmsToRemove.add(curCtxVarname); }else if (curCtxVarnameMatchingValue.startsWith(arrayPrefix)) { - LOG.debug("Unsetting {} because matching value {} starts with the arrayPrefix {}", curCtxVarname, curCtxVarnameMatchingValue, arrayPrefix); + LOG.debug("Unsetting {} because matching value {} starts with the arrayPrefix {}", curCtxVarname, curCtxVarnameMatchingValue, arrayPrefix); parmsToRemove.add(curCtxVarname); } } -- cgit 1.2.3-korg From e2646080e47df8d68e0327d964194a2b6ce04d33 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 17 Dec 2018 17:03:30 +0530 Subject: fixed sonar issues in SvcLogicExpressionResolver fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I2859ef1de0fe36ee5bac46fe5adec6142333ba50 Signed-off-by: Sandeep J --- .../sli/core/sli/provider/base/SvcLogicExpressionResolver.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java index 779be9e9e..0e502035b 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java @@ -5,6 +5,8 @@ * 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 @@ -41,6 +43,7 @@ public class SvcLogicExpressionResolver { private static final Logger LOG = LoggerFactory .getLogger(SvcLogicExpressionResolver.class); + private static final String INVALID_EXPRESSION_MSG= "Invalid expression ("; public static String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { @@ -150,7 +153,7 @@ public class SvcLogicExpressionResolver { List operators = binExpr.getOperators(); if (operands.size() != (operators.size()+1)) { - throw new SvcLogicException("Invalid expression ("+binExpr+")"); + throw new SvcLogicException(INVALID_EXPRESSION_MSG+binExpr+")"); } String retval = evaluate(operands.get(0), node, ctx); String retsval = retval; @@ -303,7 +306,7 @@ public class SvcLogicExpressionResolver { if (operands.size() != (operators.size()+1)) { - throw new SvcLogicException("Invalid expression ("+expr+")"); + throw new SvcLogicException(INVALID_EXPRESSION_MSG+expr+")"); } try @@ -326,7 +329,7 @@ public class SvcLogicExpressionResolver { } catch (Exception e) { - throw new SvcLogicException("Invalid expression ("+expr+")"); + throw new SvcLogicException(INVALID_EXPRESSION_MSG+expr+")"); } -- cgit 1.2.3-korg From c157d989c9e8634ad7d2d4456a235fa8ce34da81 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 18 Dec 2018 14:56:29 +0530 Subject: fixed sonar issues and formatted code formatted code and added equals and hashcode method as per sonar standards Issue-ID: CCSDK-525 Change-Id: Idaa0a6a0a82315189a9365064d4f196e4689ee57 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/dblib/pm/PollingWorker.java | 127 +++++++++++++-------- 1 file changed, 78 insertions(+), 49 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java index b44e2f89d..905944b1c 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2016 - 2017 ONAP * ================================================================================ + * 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 @@ -26,13 +28,12 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; import java.util.TreeSet; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.atomic.AtomicLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.atomic.AtomicLong; - public class PollingWorker implements Runnable { private Logger logger = LoggerFactory.getLogger(PollingWorker.class); @@ -47,71 +48,72 @@ public class PollingWorker implements Runnable { private static boolean enabled = false; private Timer timer = null; - private PollingWorker(Properties ctxprops){ - if(ctxprops==null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm") == null){ + private PollingWorker(Properties ctxprops) { + if (ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm") == null) { enabled = false; } else { - if("true".equalsIgnoreCase((String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm"))){ + if ("true".equalsIgnoreCase((String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm"))) { enabled = true; } else { enabled = false; } } - interval = Long.parseLong(( ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval") == null) ? "60" : (String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval")); + interval = Long.parseLong((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval") == null) + ? "60" : (String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval")); // '0' bucket is to count exceptions - String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")==null) ? "0,2,5,10,20,50,100" : (String)ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")).split(","); + String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling") == null) + ? "0,2,5,10,20,50,100" : (String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")).split(","); - if(enabled){ + if (enabled) { bucketUnit = new int[sampling.length]; - for(int i=0, max = bucketUnit.length; i propList = new ArrayList<>(); - - - public static Properties toProperties(Properties props, Object fromObj) { - Class fromClass = null; - - if (fromObj != null) - { - fromClass = fromObj.getClass(); - } - return (toProperties(props, "", fromObj, fromClass)); - } - - public static Properties toProperties(Properties props, String pfx, Object fromObj) - { - Class fromClass = null; - - if (fromObj != null) - { - fromClass = fromObj.getClass(); - } - - return(toProperties(props, pfx, fromObj, fromClass)); - } - - public static Properties toProperties(Properties props, String pfx, - Object fromObj, Class fromClass) { - - if (fromObj == null) { - return (props); - } - - - String simpleName = fromClass.getSimpleName(); - - if (fromObj instanceof List) { - - - List fromList = (List) fromObj; - - for (int i = 0; i < fromList.size(); i++) { - toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); - } - props.setProperty(pfx + "_length", "" + fromList.size()); - - } else if (isYangGenerated(fromClass)) { - - String propNamePfx = null; - - // If called from a list (so prefix ends in ']'), don't - // add class name again - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx ; - } else { - propNamePfx = toLowerHyphen(fromClass.getSimpleName()); - } - - if (propNamePfx.endsWith(BUILDER)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - BUILDER.length()); - } - - if (propNamePfx.endsWith(IMPL)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - IMPL.length()); - } - } - - // Iterate through getter methods to figure out values we need to - // save from - - for (Method m : fromClass.getMethods()) { - - if (isGetter(m)) { - - Class returnType = m.getReturnType(); - String fieldName = toLowerHyphen(m.getName().substring(3)); - if(m != null && m.getName().matches("^is[A-Z].*")){ - fieldName = toLowerHyphen(m.getName().substring(2)); - } - - fieldName = fieldName.substring(0, 1).toLowerCase() - + fieldName.substring(1); - - // Is the return type a yang generated class? - if (isYangGenerated(returnType)) { - - // Is it an enum? - if (returnType.isEnum()) { - // Return type is a typedef. Save its value. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - Object retValue = m.invoke(fromObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - String propName = propNamePfx + "." - + fieldName; - String propVal = retValue.toString(); - String yangProp = "yang." + fieldName + "." + propVal; - if ( properties.containsKey(yangProp)) { - propVal = properties.getProperty(yangProp); - } - props.setProperty(propName, propVal); - } - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert Yang-generated enum returned by " - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else if (isIpv4Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - String propVal = retValue.getValue(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else if (isIpv6Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - String propVal = retValue.getValue().toString(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else if (isIpv4Prefix(returnType)) { - //System.out.println("isIpv4Prefix"); - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv4Prefix retValue = (Ipv4Prefix) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - String propVal = retValue.getValue().toString(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else if (isIpv6Prefix(returnType)) { - //System.out.println("isIpv6Prefix"); - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv6Prefix retValue = (Ipv6Prefix) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - String propVal = retValue.getValue().toString(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retValue = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); - } - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert Yang-generated class returned by" - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } - } else if (returnType.equals(Class.class)) { - - //LOG.debug(m.getName() - // + " returns a Class object - not interested"); - - } else if (List.class.isAssignableFrom(returnType)) { - - // This getter method returns a list. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retList = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - // Figure out what type of elements are stored in this array. - Type paramType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) paramType) - .getActualTypeArguments()[0]; - toProperties(props, propNamePfx + "." + fieldName, - retList, (Class)elementType); - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert List returned by " - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - - } else { - - // Method returns something that is not a List and not - // yang-generated. - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object propValObj = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (propValObj != null) { - String propVal = propValObj.toString(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } - - } - } - - } else { - // Class is not yang generated and not a list - // Do nothing. - - } - - return (props); - } - - public static Object toBuilder(Properties props, Object toObj) { - - return (toBuilder(props, "", toObj)); - } - - public static List toList(Properties props, String pfx, List toObj, - Class elemType) { - - int maxIdx = -1; - boolean foundValue = false; - - //LOG.debug("Saving properties to List<" + elemType.getName() - // + "> from " + pfx); - - // Figure out array size - for (Object pNameObj : props.keySet()) { - String key = (String) pNameObj; - - if (key.startsWith(pfx + "[")) { - String idxStr = key.substring(pfx.length() + 1); - int endloc = idxStr.indexOf("]"); - if (endloc != -1) { - idxStr = idxStr.substring(0, endloc); - } - - try { - int curIdx = Integer.parseInt(idxStr); - if (curIdx > maxIdx) { - maxIdx = curIdx; - } - } catch (Exception e) { - LOG.error("Illegal subscript in property " + key); - } - - } - } - - //LOG.debug(pfx + " has max index of " + maxIdx); - for (int i = 0; i <= maxIdx; i++) { - - String curBase = pfx + "[" + i + "]"; - - if (isYangGenerated(elemType)) { - String builderName = elemType.getName() + "Builder"; - try { - Class builderClass = Class.forName(builderName); - Object builderObj = builderClass.newInstance(); - Method buildMethod = builderClass.getMethod("build"); - builderObj = toBuilder(props, curBase, builderObj, true); - if (builderObj != null) { - //LOG.debug("Calling " + builderObj.getClass().getName() - // + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(builderObj); - toObj.add(builtObj); - foundValue = true; - } - - } catch (ClassNotFoundException e) { - LOG.warn("Could not find builder class " + builderName, e); - } catch (Exception e) { - LOG.error("Caught exception trying to populate list from " - + pfx); - } - } - - } - - if (foundValue) { - return (toObj); - } else { - return (null); - } - - } - - public static Object toBuilder(Properties props, String pfx, Object toObj) { - return(toBuilder(props, pfx, toObj, false)); - } - - public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { - Class toClass = toObj.getClass(); - boolean foundValue = false; - - //LOG.debug("Saving properties to " + toClass.getName() + " class from " - // + pfx); - - Ipv4Address addr; - - if (isYangGenerated(toClass)) { - // Class is yang generated. - //LOG.debug(toClass.getName() + " is a Yang-generated class"); - - String propNamePfx = null; - if (preservePfx) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." - + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith(BUILDER)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - BUILDER.length()); - } - - if (propNamePfx.endsWith(IMPL)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - IMPL.length()); - } - } - - if (toObj instanceof Identifier) { - //LOG.debug(toClass.getName() + " is a Key - skipping"); - return (toObj); - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - // LOG.debug("Is " + m.getName() + " method a setter?"); - if (isSetter(m)) { - // LOG.debug(m.getName() + " is a setter"); - Class paramTypes[] = m.getParameterTypes(); - Class paramClass = paramTypes[0]; - - String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() - + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - - String paramValue = props.getProperty(propName); - if (paramValue == null) { - //LOG.debug(propName + " is unset"); - } else { - //LOG.debug(propName + " = " + paramValue); - } - - // Is the return type a yang generated class? - if (isYangGenerated(paramClass)) { - // Is it an enum? - if (paramClass.isEnum()) { - - //LOG.debug(m.getName() + " expects an Enum"); - // Param type is a typedef. - if (paramValue != null) { - Object paramObj = null; - - try { - paramObj = Enum.valueOf(paramClass, - toUpperCamelCase(paramValue)); - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert field " - + propName + " to enum " - + paramClass.getName(), e); - } - - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - //LOG.debug("Calling " - // + toObj.getClass().getName() + "." - // + m.getName() + "(" + paramValue - // + ")"); - m.invoke(toObj, paramObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to create Yang-generated enum expected by" - + toClass.getName() - + "." - + m.getName() - + "() from Properties entry", - e); - } - } - } else { - - String simpleName = paramClass.getSimpleName(); - LOG.info("simpleName:" + simpleName); - - if ("Ipv4Address".equals(simpleName) - || "Ipv6Address".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName)) { - - if (paramValue != null) { - if("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName)){ - try { - IpAddress ipAddr = IpAddressBuilder - .getDefaultInstance(paramValue); - - - if ("Ipv4Address".equals(simpleName)) - { - m.invoke(toObj, ipAddr.getIpv4Address()); - } - else - { - m.invoke(toObj, ipAddr.getIpv6Address()); - - } - foundValue = true; - } catch (Exception e) { - LOG.error( - "Caught exception calling " - + toClass.getName() + "." - + m.getName() + "(" - + paramValue + ")", e); - - } - }else if("Ipv4Prefix".equals(simpleName)|| "Ipv6Prefix".equals(simpleName)){ - try { - IpPrefix ipPrefix = IpPrefixBuilder - .getDefaultInstance(paramValue); - - - if ("Ipv4Prefix".equals(simpleName)) - { - m.invoke(toObj, ipPrefix.getIpv4Prefix()); - } - else - { - m.invoke(toObj, ipPrefix.getIpv6Prefix()); - - } - foundValue = true; - } catch (Exception e) { - LOG.error( - "Caught exception calling " - + toClass.getName() + "." - + m.getName() + "(" - + paramValue + ")", e); - - } - } - } - - } else { - // setter expects a yang-generated class. Need - // to - // create a builder to set it. - - String builderName = paramClass.getName() - + "Builder"; - Class builderClass = null; - Object builderObj = null; - Object paramObj = null; - - //LOG.debug(m.getName() - // + " expects a yang-generated class - looking for builder " - // + builderName); - try { - builderClass = Class.forName(builderName); - builderObj = builderClass.newInstance(); - paramObj = toBuilder(props, propNamePfx, - builderObj); - } catch (ClassNotFoundException e) { - Object constObj = null; - try { - // See if I can find a constructor I can - // use - Constructor[] constructors = paramClass - .getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c - .getParameterTypes(); - if ((cParms != null) - && (cParms.length == 1)) { - if (String.class - .isAssignableFrom(cParms[0])) { - constObj = c - .newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c - .getParameterTypes(); - if ((cParms != null) - && (cParms.length == 1)) { - if (Long.class - .isAssignableFrom(cParms[0])) { - constObj = c - .newInstance(Long - .parseLong(paramValue)); - } - } - } - - } - - if (constObj != null) { - try { - m.invoke(toObj, constObj); - foundValue = true; - } catch (Exception e2) { - LOG.error( - "Caught exception trying to call " - + m.getName(), - e2); - } - } - } catch (Exception e1) { - LOG.warn( - "Could not find a suitable constructor for " - + paramClass.getName(), - e1); - } - - if (paramObj == null) { - LOG.warn("Could not find builder class " - + builderName - + " and could not find a String or Long constructor - trying just to set passing paramValue"); - - } - - } catch (Exception e) { - LOG.error( - "Caught exception trying to create builder " - + builderName, e); - } - - if (paramObj != null) { - - try { - - Method buildMethod = builderClass - .getMethod("build"); - //LOG.debug("Calling " - // + paramObj.getClass().getName() - // + "." + buildMethod.getName() - // + "()"); - Object builtObj = buildMethod - .invoke(paramObj); - - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - //LOG.debug("Calling " - // + toObj.getClass().getName() - // + "." + m.getName() + "()"); - m.invoke(toObj, builtObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to set Yang-generated class expected by" - + toClass.getName() - + "." - + m.getName() - + "() from Properties entry", - e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - //LOG.debug("Calling " - // + toObj.getClass().getName() - // + "." + m.getName() + "(" - // + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by" - + toClass.getName() - + "." - + m.getName() - + TO_PROPERTIES_STRING, - e); - } - } - } - } - }else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(paramClass)) { - - //LOG.debug("Parameter class " + paramClass.getName() - // + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type paramType = m.getGenericParameterTypes()[0]; - Type elementType = ((ParameterizedType) paramType) - .getActualTypeArguments()[0]; - Object paramObj = new LinkedList(); - try { - paramObj = toList(props, propName, - (List) paramObj, (Class) elementType); - } catch (Exception e) { - LOG.error("Caught exception trying to create list expected as argument to " - + toClass.getName() + "." + m.getName()); - } - - if (paramObj != null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - //LOG.debug("Calling " - // + toObj.getClass().getName() + "." - // + m.getName() + "(" + paramValue - // + ")"); - m.invoke(toObj, paramObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert List returned by" - + toClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, - e); - } - } - } else { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - //LOG.debug("Parameter class " - // + paramClass.getName() - // + " is not a yang-generated class or a List"); - - if (paramValue != null) { - - Object constObj = null; - - try { - // See if I can find a constructor I can use - Constructor[] constructors = paramClass - .getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) - && (cParms.length == 1)) { - if (String.class - .isAssignableFrom(cParms[0])) { - constObj = c - .newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c - .getParameterTypes(); - if ((cParms != null) - && (cParms.length == 1)) { - if (Long.class - .isAssignableFrom(cParms[0])) { - constObj = c - .newInstance(Long - .parseLong(paramValue)); - } - } - } - - } - - if (constObj != null) { - try { - //LOG.debug("Calling " - // + toObj.getClass() - // .getName() + "." - // + m.getName() + "(" - // + constObj + ")"); - m.invoke(toObj, constObj); - foundValue = true; - } catch (Exception e2) { - LOG.error( - "Caught exception trying to call " - + m.getName(), e2); - } - } else { - try { - boolean isAccessible = m - .isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - //LOG.debug("Calling " - // + toObj.getClass() - // .getName() + "." - // + m.getName() + "(" - // + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by" - + toClass.getName() - + "." - + m.getName() - + TO_PROPERTIES_STRING, - e); - } - } - } catch (Exception e1) { - LOG.warn( - "Could not find a suitable constructor for " - + paramClass.getName(), e1); - } - - /* - * try { boolean isAccessible = - * m.isAccessible(); if (!isAccessible) { - * m.setAccessible(true); } LOG.debug("Calling " - * + toObj.getClass().getName() + "." + - * m.getName() + "(" + paramValue + ")"); - * m.invoke(toObj, paramValue); if - * (!isAccessible) { - * m.setAccessible(isAccessible); } foundValue = - * true; - * - * } catch (Exception e) { LOG.error( - * "Caught exception trying to convert value returned by" - * + toClass.getName() + "." + m.getName() + - * "() to Properties entry", e); } - */ - } - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - if (foundValue) { - return (toObj); - } else { - return (null); - } - } - - public static Properties getProperties(PrintStream pstr, String pfx, - Class toClass) { - boolean foundValue = false; - - //LOG.debug("Analyzing " + toClass.getName() + " class : pfx " + pfx); - - if (isYangGenerated(toClass) - && (!Identifier.class.isAssignableFrom(toClass))) { - // Class is yang generated. - //LOG.debug(toClass.getName() + " is a Yang-generated class"); - - if (toClass.getName().endsWith("Key")) { - if (Identifier.class.isAssignableFrom(toClass)) { - //LOG.debug(Identifier.class.getName() - // + " is assignable from " + toClass.getName()); - } else { - - //LOG.debug(Identifier.class.getName() - // + " is NOT assignable from " + toClass.getName()); - } - } - - String propNamePfx = null; - if (pfx.endsWith("]")) { - propNamePfx = pfx; - }else if(pfx.indexOf(".CLASS_FOUND") != -1){ - pfx = pfx.replace(".CLASS_FOUND",""); - propNamePfx = pfx + "." - + toLowerHyphen(toClass.getSimpleName()); - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." - + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith(BUILDER)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - BUILDER.length()); - } - - if (propNamePfx.endsWith(IMPL)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - IMPL.length()); - } - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - //LOG.debug("Is " + m.getName() + " method a getter?"); - if (isGetter(m)) { - // LOG.debug(m.getName() + " is a getter"); - Class returnClass = m.getReturnType(); - - String fieldName = toLowerHyphen(m.getName().substring(3)); - if(m != null && m.getName().matches("^is[A-Z].*")){ - fieldName = toLowerHyphen(m.getName().substring(2)); - } - fieldName = fieldName.substring(0, 1).toLowerCase() - + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - //System.out.println("****" + propName); - - // Is the return type a yang generated class? - if (isYangGenerated(returnClass)) { - // Is it an enum? - if (returnClass.isEnum()) { - - //LOG.debug(m.getName() + " is an Enum"); - //pstr.print("\n" + propName); - //pstr.print("\n" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\n"); - pstr.print("\"" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\","); - prop.setProperty(propName,""); - propList.add(propName); - - } else { - - String simpleName = returnClass.getSimpleName(); - //System.out.println("simpleName:" + simpleName); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName) || "IpPrefix".equals(simpleName)) { - //LOG.debug(m.getName()+" is an "+simpleName); - //pstr.print("\n" + propName); - //pstr.print("\n" + propName + ":" + simpleName + "\n"); - pstr.print("\"" + propName + ":" + simpleName + "\","); - prop.setProperty(propName,""); - propList.add(propName); - } else { - boolean isString = false; - boolean isNumber = false; - boolean isBoolean = false; - boolean isIdentifier = false; - //System.out.println("simpleName:" + simpleName); - //System.out.println("propName:" + propName); - for(Method mthd : returnClass.getMethods()){ - String methodName = mthd.getName(); - //System.out.println("methodName:" + methodName); - if(methodName.equals("getValue")){ - Class retType = mthd.getReturnType(); - //System.out.println("retType:" + retType); - isString = String.class.isAssignableFrom(retType); - isNumber = Number.class.isAssignableFrom(retType); - isBoolean = Boolean.class.isAssignableFrom(retType); - isIdentifier = Identifier.class.isAssignableFrom(retType); - //System.out.println("isString:" + isString); - //System.out.println("isNumber:" + isNumber); - //System.out.println("isNumber:" + isNumber); - break; - } - } - - if(isString){ - pstr.print("\"" + propName + ":String\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(isNumber){ - pstr.print("\"" + propName + ":Number\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(isBoolean){ - pstr.print("\"" + propName + ":Boolean\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(isIdentifier){ - //System.out.println("isIdentifier"); - //isIdentifer so skipping - continue; - }else{ - /* - System.out.println("fieldName:" + fieldName); - System.out.println("simpleName:" + simpleName); - System.out.println("returnClass:" + returnClass); - System.out.println("pstr:" + pstr); - System.out.println("propNamePfx:" + propNamePfx); - */ - getProperties(pstr, propNamePfx + ".CLASS_FOUND", returnClass); - } - } - - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(returnClass)) { - - //LOG.debug("Parameter class " - // + returnClass.getName() + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type returnType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) returnType) - .getActualTypeArguments()[0]; - Class elementClass = (Class) elementType; - //LOG.debug("Calling printPropertyList on list type (" - //+ elementClass.getName() - // + "), pfx is (" - // + pfx - // + "), toClass is (" - // + toClass.getName() + ")"); - //System.out.println("List propNamePfx:" + propNamePfx+ "." + toLowerHyphen(elementClass.getSimpleName()) + "[]"); - if(String.class.isAssignableFrom(elementClass)){ - pstr.print("\"" + propName + ":[String,String,...]\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(Number.class.isAssignableFrom(elementClass)){ - pstr.print("\"" + propName + ":[Number,Number,...]\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(Boolean.class.isAssignableFrom(elementClass)){ - pstr.print("\"" + propName + ":[Boolean,Boolean,...]\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(Identifier.class.isAssignableFrom(elementClass)){ - continue; - }else{ - getProperties( - pstr, - propNamePfx - + "." - + toLowerHyphen(elementClass - .getSimpleName()) + "[]", - elementClass); - } - - } else if (!returnClass.equals(Class.class)) { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - //LOG.debug("Parameter class " - // + returnClass.getName() - // + " is not a yang-generated class or a List"); - - //pstr.print("\n" + propName); - String className=returnClass.getName(); - int nClassNameIndex = className.lastIndexOf('.'); - String nClassName = className; - if(nClassNameIndex != -1){ - nClassName=className.substring(nClassNameIndex+1); - } - boolean isString = String.class.isAssignableFrom(returnClass); - boolean isNumber = Number.class.isAssignableFrom(returnClass); - boolean isBoolean = Boolean.class.isAssignableFrom(returnClass); - //pstr.print("\n" + propName +":" + nClassName +"\n"); - boolean isIdentifier = Identifier.class.isAssignableFrom(returnClass); - if(!isIdentifier && !nClassName.equals("[C")){ - if(isNumber){ - pstr.print("\"" + propName +":Number\","); - }else if(isBoolean){ - pstr.print("\"" + propName +":Boolean\","); - }else{ - if(nClassName.equals("[B")){ - pstr.print("\"" + propName +":Binary\","); - }else{ - pstr.print("\"" + propName +":" + nClassName +"\","); - } - } - prop.setProperty(propName,""); - propList.add(propName); - } - - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - return prop; - } - - public static boolean isYangGenerated(Class c) { - if (c == null) { - return (false); - } else { - //System.out.println(c.getName()); - return (c.getName().startsWith("org.opendaylight.yang.gen.")); - } - } - - public static boolean isIpv4Address(Class c) { - - if (c == null ) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv4Address".equals(simpleName)) ; - } - - public static boolean isIpv6Address(Class c) { - - if (c == null ) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv6Address".equals(simpleName)) ; - } - public static boolean isIpv4Prefix(Class c) { - - if (c == null ) { - return (false); - } - String simpleName = c.getSimpleName(); - //System.out.println("simpleName:" + simpleName); - return ("Ipv4Prefix".equals(simpleName)) ; - } - - public static boolean isIpv6Prefix(Class c) { - - if (c == null ) { - return (false); - } - String simpleName = c.getSimpleName(); - //System.out.println("simpleName:" + simpleName); - return ("Ipv6Prefix".equals(simpleName)) ; - } - - public static String toLowerHyphen(String inStr) { - if (inStr == null) { - return (null); - } - - String str = inStr.substring(0, 1).toLowerCase(); - if (inStr.length() > 1) { - str = str + inStr.substring(1); - } - - String regex = "(([a-z0-9])([A-Z]))"; - String replacement = "$2-$3"; - - String retval = str.replaceAll(regex, replacement).toLowerCase(); - - //LOG.debug("Converting " + inStr + " => " + str + " => " + retval); - return (retval); - } - - public static String toUpperCamelCase(String inStr) { - if (inStr == null) { - return (null); - } - - String[] terms = inStr.split("-"); - StringBuffer sbuff = new StringBuffer(); - // Check if string begins with a digit - if (Character.isDigit(inStr.charAt(0))) { - sbuff.append('_'); - } - for (String term : terms) { - sbuff.append(term.substring(0, 1).toUpperCase()); - if (term.length() > 1) { - sbuff.append(term.substring(1)); - } - } - return (sbuff.toString()); - - } - - public static boolean isGetter(Method m) { - //System.out.println(m); - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) - && (m.getParameterTypes().length == 0)) { - if ((m.getName().matches("^is[A-Z].*") || m.getName().matches("^get[A-Z].*")) - && m.getReturnType().equals(Boolean.class)) { - return (true); - } - if (m.getName().matches("^get[A-Z].*") - && !m.getReturnType().equals(void.class)) { - return (true); - } - - } - - return (false); - } - - public static boolean isSetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) - && (m.getParameterTypes().length == 1)) { - if (m.getName().matches("^set[A-Z].*")) { - Class[] paramTypes = m.getParameterTypes(); - if (paramTypes[0].isAssignableFrom(Identifier.class) - || Identifier.class.isAssignableFrom(paramTypes[0])) { - return (false); - } else { - return (true); - } - } - - } - - return (false); - } - - public static void main(String[] args){ - + private static final Logger LOG = LoggerFactory.getLogger(PrintYangToProp.class); + public static final String PROPERTIES_FILE=""; + private static Properties properties; + private static final String BUILDER="-builder"; + private static final String IMPL="-impl"; + private static final String TO_PROPERTIES_STRING="() to Properties entry"; + private static final String CAUGHT_EXCEPTION_MSG="Caught exception trying to convert value returned by "; + public static Properties prop = new Properties(); + public static ArrayList propList = new ArrayList<>(); + + + public static Properties toProperties(Properties props, Object fromObj) { + Class fromClass = null; + + if (fromObj != null) + { + fromClass = fromObj.getClass(); + } + return (toProperties(props, "", fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj) + { + Class fromClass = null; + + if (fromObj != null) + { + fromClass = fromObj.getClass(); + } + + return(toProperties(props, pfx, fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, + Object fromObj, Class fromClass) { + + if (fromObj == null) { + return (props); + } + + + String simpleName = fromClass.getSimpleName(); + + if (fromObj instanceof List) { + + + List fromList = (List) fromObj; + + for (int i = 0; i < fromList.size(); i++) { + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); + } + props.setProperty(pfx + "_length", "" + fromList.size()); + + } else if (isYangGenerated(fromClass)) { + + String propNamePfx = null; + + // If called from a list (so prefix ends in ']'), don't + // add class name again + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx ; + } else { + propNamePfx = toLowerHyphen(fromClass.getSimpleName()); + } + + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - BUILDER.length()); + } + + if (propNamePfx.endsWith(IMPL)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - IMPL.length()); + } + } + + // Iterate through getter methods to figure out values we need to + // save from + + for (Method m : fromClass.getMethods()) { + + if (isGetter(m)) { + + Class returnType = m.getReturnType(); + String fieldName = toLowerHyphen(m.getName().substring(3)); + if(m != null && m.getName().matches("^is[A-Z].*")){ + fieldName = toLowerHyphen(m.getName().substring(2)); + } + + if(fieldName!= null && fieldName.length() >0 ) fieldName = fieldName.substring(0, 1).toLowerCase() + + fieldName.substring(1); + + // Is the return type a yang generated class? + if (isYangGenerated(returnType)) { + + // Is it an enum? + if (returnType.isEnum()) { + // Return type is a typedef. Save its value. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + Object retValue = m.invoke(fromObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + String propName = propNamePfx + "." + + fieldName; + String propVal = retValue.toString(); + String yangProp = "yang." + fieldName + "." + propVal; + if ( properties.containsKey(yangProp)) { + propVal = properties.getProperty(yangProp); + } + props.setProperty(propName, propVal); + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated enum returned by " + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else if (isIpv4Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else if (isIpv6Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else if (isIpv4Prefix(returnType)) { + //System.out.println("isIpv4Prefix"); + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Prefix retValue = (Ipv4Prefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue().toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else if (isIpv6Prefix(returnType)) { + //System.out.println("isIpv6Prefix"); + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Prefix retValue = (Ipv6Prefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue().toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated class returned by" + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } + } else if (returnType.equals(Class.class)) { + + //LOG.debug(m.getName() + // + " returns a Class object - not interested"); + + } else if (List.class.isAssignableFrom(returnType)) { + + // This getter method returns a list. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retList = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + // Figure out what type of elements are stored in this array. + Type paramType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) paramType) + .getActualTypeArguments()[0]; + toProperties(props, propNamePfx + "." + fieldName, + retList, (Class)elementType); + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert List returned by " + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + + } else { + + // Method returns something that is not a List and not + // yang-generated. + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object propValObj = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (propValObj != null) { + String propVal = propValObj.toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } + + } + } + + } else { + // Class is not yang generated and not a list + // Do nothing. + + } + + return (props); + } + + public static Object toBuilder(Properties props, Object toObj) { + + return (toBuilder(props, "", toObj)); + } + + public static List toList(Properties props, String pfx, List toObj, + Class elemType) { + + int maxIdx = -1; + boolean foundValue = false; + + //LOG.debug("Saving properties to List<" + elemType.getName() + // + "> from " + pfx); + + // Figure out array size + for (Object pNameObj : props.keySet()) { + String key = (String) pNameObj; + + if (key.startsWith(pfx + "[")) { + String idxStr = key.substring(pfx.length() + 1); + int endloc = idxStr.indexOf("]"); + if (endloc != -1) { + idxStr = idxStr.substring(0, endloc); + } + + try { + int curIdx = Integer.parseInt(idxStr); + if (curIdx > maxIdx) { + maxIdx = curIdx; + } + } catch (Exception e) { + LOG.error("Illegal subscript in property " + key); + } + + } + } + + //LOG.debug(pfx + " has max index of " + maxIdx); + for (int i = 0; i <= maxIdx; i++) { + + String curBase = pfx + "[" + i + "]"; + + if (isYangGenerated(elemType)) { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + //LOG.debug("Calling " + builderObj.getClass().getName() + // + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class " + builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from " + + pfx); + } + } + + } + + if (foundValue) { + return (toObj); + } else { + return (null); + } + + } + + public static Object toBuilder(Properties props, String pfx, Object toObj) { + return(toBuilder(props, pfx, toObj, false)); + } + + public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { + Class toClass = toObj.getClass(); + boolean foundValue = false; + + //LOG.debug("Saving properties to " + toClass.getName() + " class from " + // + pfx); + + Ipv4Address addr; + + if (isYangGenerated(toClass)) { + // Class is yang generated. + //LOG.debug(toClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + if (preservePfx) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - BUILDER.length()); + } + + if (propNamePfx.endsWith(IMPL)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - IMPL.length()); + } + } + + if (toObj instanceof Identifier) { + //LOG.debug(toClass.getName() + " is a Key - skipping"); + return (toObj); + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + // LOG.debug("Is " + m.getName() + " method a setter?"); + if (isSetter(m)) { + // LOG.debug(m.getName() + " is a setter"); + Class paramTypes[] = m.getParameterTypes(); + Class paramClass = paramTypes[0]; + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + String paramValue = props.getProperty(propName); + if (paramValue == null) { + //LOG.debug(propName + " is unset"); + } else { + //LOG.debug(propName + " = " + paramValue); + } + + // Is the return type a yang generated class? + if (isYangGenerated(paramClass)) { + // Is it an enum? + if (paramClass.isEnum()) { + + //LOG.debug(m.getName() + " expects an Enum"); + // Param type is a typedef. + if (paramValue != null) { + Object paramObj = null; + + try { + paramObj = Enum.valueOf(paramClass, + toUpperCamelCase(paramValue)); + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert field " + + propName + " to enum " + + paramClass.getName(), e); + } + + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + //LOG.debug("Calling " + // + toObj.getClass().getName() + "." + // + m.getName() + "(" + paramValue + // + ")"); + m.invoke(toObj, paramObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to create Yang-generated enum expected by" + + toClass.getName() + + "." + + m.getName() + + "() from Properties entry", + e); + } + } + } else { + + String simpleName = paramClass.getSimpleName(); + LOG.info("simpleName:" + simpleName); + + if ("Ipv4Address".equals(simpleName) + || "Ipv6Address".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName)) { + + if (paramValue != null) { + if("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName)){ + try { + IpAddress ipAddr = IpAddressBuilder + .getDefaultInstance(paramValue); + + + if ("Ipv4Address".equals(simpleName)) + { + m.invoke(toObj, ipAddr.getIpv4Address()); + } + else + { + m.invoke(toObj, ipAddr.getIpv6Address()); + + } + foundValue = true; + } catch (Exception e) { + LOG.error( + "Caught exception calling " + + toClass.getName() + "." + + m.getName() + "(" + + paramValue + ")", e); + + } + }else if("Ipv4Prefix".equals(simpleName)|| "Ipv6Prefix".equals(simpleName)){ + try { + IpPrefix ipPrefix = IpPrefixBuilder + .getDefaultInstance(paramValue); + + + if ("Ipv4Prefix".equals(simpleName)) + { + m.invoke(toObj, ipPrefix.getIpv4Prefix()); + } + else + { + m.invoke(toObj, ipPrefix.getIpv6Prefix()); + + } + foundValue = true; + } catch (Exception e) { + LOG.error( + "Caught exception calling " + + toClass.getName() + "." + + m.getName() + "(" + + paramValue + ")", e); + + } + } + } + + } else { + // setter expects a yang-generated class. Need + // to + // create a builder to set it. + + String builderName = paramClass.getName() + + "Builder"; + Class builderClass = null; + Object builderObj = null; + Object paramObj = null; + + //LOG.debug(m.getName() + // + " expects a yang-generated class - looking for builder " + // + builderName); + try { + builderClass = Class.forName(builderName); + builderObj = builderClass.newInstance(); + paramObj = toBuilder(props, propNamePfx, + builderObj); + } catch (ClassNotFoundException e) { + Object constObj = null; + try { + // See if I can find a constructor I can + // use + Constructor[] constructors = paramClass + .getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (String.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (Long.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(Long + .parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error( + "Caught exception trying to call " + + m.getName(), + e2); + } + } + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + + paramClass.getName(), + e1); + } + + if (paramObj == null) { + LOG.warn("Could not find builder class " + + builderName + + " and could not find a String or Long constructor - trying just to set passing paramValue"); + + } + + } catch (Exception e) { + LOG.error( + "Caught exception trying to create builder " + + builderName, e); + } + + if (paramObj != null) { + + try { + + Method buildMethod = builderClass + .getMethod("build"); + //LOG.debug("Calling " + // + paramObj.getClass().getName() + // + "." + buildMethod.getName() + // + "()"); + Object builtObj = buildMethod + .invoke(paramObj); + + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + //LOG.debug("Calling " + // + toObj.getClass().getName() + // + "." + m.getName() + "()"); + m.invoke(toObj, builtObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to set Yang-generated class expected by" + + toClass.getName() + + "." + + m.getName() + + "() from Properties entry", + e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass().getName() + // + "." + m.getName() + "(" + // + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by" + + toClass.getName() + + "." + + m.getName() + + TO_PROPERTIES_STRING, + e); + } + } + } + } + }else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(paramClass)) { + + //LOG.debug("Parameter class " + paramClass.getName() + // + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type paramType = m.getGenericParameterTypes()[0]; + Type elementType = ((ParameterizedType) paramType) + .getActualTypeArguments()[0]; + Object paramObj = new LinkedList(); + try { + paramObj = toList(props, propName, + (List) paramObj, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to create list expected as argument to " + + toClass.getName() + "." + m.getName()); + } + + if (paramObj != null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass().getName() + "." + // + m.getName() + "(" + paramValue + // + ")"); + m.invoke(toObj, paramObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert List returned by" + + toClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, + e); + } + } + } else { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + //LOG.debug("Parameter class " + // + paramClass.getName() + // + " is not a yang-generated class or a List"); + + if (paramValue != null) { + + Object constObj = null; + + try { + // See if I can find a constructor I can use + Constructor[] constructors = paramClass + .getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (String.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (Long.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(Long + .parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + //LOG.debug("Calling " + // + toObj.getClass() + // .getName() + "." + // + m.getName() + "(" + // + constObj + ")"); + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error( + "Caught exception trying to call " + + m.getName(), e2); + } + } else { + try { + boolean isAccessible = m + .isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass() + // .getName() + "." + // + m.getName() + "(" + // + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by" + + toClass.getName() + + "." + + m.getName() + + TO_PROPERTIES_STRING, + e); + } + } + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + + paramClass.getName(), e1); + } + + /* + * try { boolean isAccessible = + * m.isAccessible(); if (!isAccessible) { + * m.setAccessible(true); } LOG.debug("Calling " + * + toObj.getClass().getName() + "." + + * m.getName() + "(" + paramValue + ")"); + * m.invoke(toObj, paramValue); if + * (!isAccessible) { + * m.setAccessible(isAccessible); } foundValue = + * true; + * + * } catch (Exception e) { LOG.error( + * "Caught exception trying to convert value returned by" + * + toClass.getName() + "." + m.getName() + + * "() to Properties entry", e); } + */ + } + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + if (foundValue) { + return (toObj); + } else { + return (null); + } + } + + public static Properties getProperties(PrintStream pstr, String pfx, + Class toClass) { + boolean foundValue = false; + + //LOG.debug("Analyzing " + toClass.getName() + " class : pfx " + pfx); + + if (isYangGenerated(toClass) + && (!Identifier.class.isAssignableFrom(toClass))) { + // Class is yang generated. + //LOG.debug(toClass.getName() + " is a Yang-generated class"); + + if (toClass.getName().endsWith("Key")) { + if (Identifier.class.isAssignableFrom(toClass)) { + //LOG.debug(Identifier.class.getName() + // + " is assignable from " + toClass.getName()); + } else { + + //LOG.debug(Identifier.class.getName() + // + " is NOT assignable from " + toClass.getName()); + } + } + + String propNamePfx = null; + if (pfx.endsWith("]")) { + propNamePfx = pfx; + }else if(pfx.indexOf(".CLASS_FOUND") != -1){ + pfx = pfx.replace(".CLASS_FOUND",""); + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - BUILDER.length()); + } + + if (propNamePfx.endsWith(IMPL)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - IMPL.length()); + } + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + //LOG.debug("Is " + m.getName() + " method a getter?"); + if (isGetter(m)) { + // LOG.debug(m.getName() + " is a getter"); + Class returnClass = m.getReturnType(); + + String fieldName = toLowerHyphen(m.getName().substring(3)); + if(m != null && m.getName().matches("^is[A-Z].*")){ + fieldName = toLowerHyphen(m.getName().substring(2)); + } + fieldName = fieldName.substring(0, 1).toLowerCase() + + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + //System.out.println("****" + propName); + + // Is the return type a yang generated class? + if (isYangGenerated(returnClass)) { + // Is it an enum? + if (returnClass.isEnum()) { + + //LOG.debug(m.getName() + " is an Enum"); + //pstr.print("\n" + propName); + //pstr.print("\n" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\n"); + pstr.print("\"" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\","); + prop.setProperty(propName,""); + propList.add(propName); + + } else { + + String simpleName = returnClass.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName) || "IpPrefix".equals(simpleName)) { + //LOG.debug(m.getName()+" is an "+simpleName); + //pstr.print("\n" + propName); + //pstr.print("\n" + propName + ":" + simpleName + "\n"); + pstr.print("\"" + propName + ":" + simpleName + "\","); + prop.setProperty(propName,""); + propList.add(propName); + } else { + boolean isString = false; + boolean isNumber = false; + boolean isBoolean = false; + boolean isIdentifier = false; + //System.out.println("simpleName:" + simpleName); + //System.out.println("propName:" + propName); + for(Method mthd : returnClass.getMethods()){ + String methodName = mthd.getName(); + //System.out.println("methodName:" + methodName); + if(methodName.equals("getValue")){ + Class retType = mthd.getReturnType(); + //System.out.println("retType:" + retType); + isString = String.class.isAssignableFrom(retType); + isNumber = Number.class.isAssignableFrom(retType); + isBoolean = Boolean.class.isAssignableFrom(retType); + isIdentifier = Identifier.class.isAssignableFrom(retType); + //System.out.println("isString:" + isString); + //System.out.println("isNumber:" + isNumber); + //System.out.println("isNumber:" + isNumber); + break; + } + } + + if(isString){ + pstr.print("\"" + propName + ":String\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isNumber){ + pstr.print("\"" + propName + ":Number\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isBoolean){ + pstr.print("\"" + propName + ":Boolean\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isIdentifier){ + //System.out.println("isIdentifier"); + //isIdentifer so skipping + continue; + }else{ + /* + System.out.println("fieldName:" + fieldName); + System.out.println("simpleName:" + simpleName); + System.out.println("returnClass:" + returnClass); + System.out.println("pstr:" + pstr); + System.out.println("propNamePfx:" + propNamePfx); + */ + getProperties(pstr, propNamePfx + ".CLASS_FOUND", returnClass); + } + } + + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(returnClass)) { + + //LOG.debug("Parameter class " + // + returnClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type returnType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) returnType) + .getActualTypeArguments()[0]; + Class elementClass = (Class) elementType; + //LOG.debug("Calling printPropertyList on list type (" + //+ elementClass.getName() + // + "), pfx is (" + // + pfx + // + "), toClass is (" + // + toClass.getName() + ")"); + //System.out.println("List propNamePfx:" + propNamePfx+ "." + toLowerHyphen(elementClass.getSimpleName()) + "[]"); + if(String.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[String,String,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Number.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[Number,Number,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Boolean.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[Boolean,Boolean,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Identifier.class.isAssignableFrom(elementClass)){ + continue; + }else{ + getProperties( + pstr, + propNamePfx + + "." + + toLowerHyphen(elementClass + .getSimpleName()) + "[]", + elementClass); + } + + } else if (!returnClass.equals(Class.class)) { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + //LOG.debug("Parameter class " + // + returnClass.getName() + // + " is not a yang-generated class or a List"); + + //pstr.print("\n" + propName); + String className=returnClass.getName(); + int nClassNameIndex = className.lastIndexOf('.'); + String nClassName = className; + if(nClassNameIndex != -1){ + nClassName=className.substring(nClassNameIndex+1); + } + boolean isString = String.class.isAssignableFrom(returnClass); + boolean isNumber = Number.class.isAssignableFrom(returnClass); + boolean isBoolean = Boolean.class.isAssignableFrom(returnClass); + //pstr.print("\n" + propName +":" + nClassName +"\n"); + boolean isIdentifier = Identifier.class.isAssignableFrom(returnClass); + if(!isIdentifier && !nClassName.equals("[C")){ + if(isNumber){ + pstr.print("\"" + propName +":Number\","); + }else if(isBoolean){ + pstr.print("\"" + propName +":Boolean\","); + }else{ + if(nClassName.equals("[B")){ + pstr.print("\"" + propName +":Binary\","); + }else{ + pstr.print("\"" + propName +":" + nClassName +"\","); + } + } + prop.setProperty(propName,""); + propList.add(propName); + } + + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + return prop; + } + + public static boolean isYangGenerated(Class c) { + if (c == null) { + return (false); + } else { + //System.out.println(c.getName()); + return (c.getName().startsWith("org.opendaylight.yang.gen.")); + } + } + + public static boolean isIpv4Address(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv4Address".equals(simpleName)) ; + } + + public static boolean isIpv6Address(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv6Address".equals(simpleName)) ; + } + public static boolean isIpv4Prefix(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + return ("Ipv4Prefix".equals(simpleName)) ; + } + + public static boolean isIpv6Prefix(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + return ("Ipv6Prefix".equals(simpleName)) ; + } + + public static String toLowerHyphen(String inStr) { + if (inStr == null) { + return (null); + } + + String str = inStr.substring(0, 1).toLowerCase(); + if (inStr.length() > 1) { + str = str + inStr.substring(1); + } + + String regex = "(([a-z0-9])([A-Z]))"; + String replacement = "$2-$3"; + + String retval = str.replaceAll(regex, replacement).toLowerCase(); + + //LOG.debug("Converting " + inStr + " => " + str + " => " + retval); + return (retval); + } + + public static String toUpperCamelCase(String inStr) { + if (inStr == null) { + return (null); + } + + String[] terms = inStr.split("-"); + StringBuffer sbuff = new StringBuffer(); + // Check if string begins with a digit + if (Character.isDigit(inStr.charAt(0))) { + sbuff.append('_'); + } + for (String term : terms) { + sbuff.append(term.substring(0, 1).toUpperCase()); + if (term.length() > 1) { + sbuff.append(term.substring(1)); + } + } + return (sbuff.toString()); + + } + + public static boolean isGetter(Method m) { + //System.out.println(m); + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) + && (m.getParameterTypes().length == 0)) { + if ((m.getName().matches("^is[A-Z].*") || m.getName().matches("^get[A-Z].*")) + && m.getReturnType().equals(Boolean.class)) { + return (true); + } + if (m.getName().matches("^get[A-Z].*") + && !m.getReturnType().equals(void.class)) { + return (true); + } + + } + + return (false); + } + + public static boolean isSetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) + && (m.getParameterTypes().length == 1)) { + if (m.getName().matches("^set[A-Z].*")) { + Class[] paramTypes = m.getParameterTypes(); + if (paramTypes[0].isAssignableFrom(Identifier.class) + || Identifier.class.isAssignableFrom(paramTypes[0])) { + return (false); + } else { + return (true); + } + } + + } + + return (false); + } + + public static void main(String[] args){ + try(PrintStream ps = new PrintStream(new FileOutputStream(FileDescriptor.out))){ - PrintYangToProp printYangToProp = new PrintYangToProp(); - String className = args[0]; - //ClassLoader classLoader = PrintYangToProp.class.getClassLoader(); - //Class aClass = classLoader.loadClass(className); - Class cl = Class.forName(className); - //printPropertyList(ps,"",cl); - //JsonObject jsonObj = Json.createObjectBuilder().build(); - Properties p = getProperties(ps,"",cl); - //System.out.println(p); - - }catch(Exception e){ - e.printStackTrace(); - } - } + PrintYangToProp printYangToProp = new PrintYangToProp(); + String className = args[0]; + //ClassLoader classLoader = PrintYangToProp.class.getClassLoader(); + //Class aClass = classLoader.loadClass(className); + Class cl = Class.forName(className); + //printPropertyList(ps,"",cl); + //JsonObject jsonObj = Json.createObjectBuilder().build(); + Properties p = getProperties(ps,"",cl); + //System.out.println(p); + + }catch(Exception e){ + e.printStackTrace(); + } + } } -- cgit 1.2.3-korg From 5bef5de1bb8484aeaca0a0d37aea38efb0367599 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Tue, 18 Dec 2018 15:21:19 +0530 Subject: fixed sonar issues in MdsalHelper.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Ia9ae47fea8ea0964b052416a7f2330e7dab5c0d1 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 2507 ++++++++++---------- 1 file changed, 1255 insertions(+), 1252 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 48bb754ec..eeea80bc7 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -3,7 +3,7 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. * ================================================================================ @@ -49,1281 +49,1284 @@ import org.slf4j.LoggerFactory; public class MdsalHelper { - private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); - private static Properties yangMappingProperties = new Properties(); - private static final String IP_ADDRESS="IpAddress"; - private static final String IP_PREFIX="IpPrefix"; - - @Deprecated - public static void setProperties(Properties input) { - setYangMappingProperties(input); - } - - @Deprecated - public static void setYangMappingProperties(Properties properties) { - for (Object propNameObj : properties.keySet()) { - String propName = (String) propNameObj; - MdsalHelper.yangMappingProperties.setProperty(propName, properties.getProperty(propName)); - } - } - - @Deprecated - public static void loadProperties(String propertiesFile) { - File file = new File(propertiesFile); - Properties properties = new Properties(); - if (file.isFile() && file.canRead()) { - try (InputStream input = new FileInputStream(file)) { - properties.load(input); - MdsalHelper.setYangMappingProperties(properties); - LOG.info("Loaded properties from " + propertiesFile); - } catch (Exception e) { - LOG.error("Failed to load properties " + propertiesFile + "\n", e); - } - } else { - LOG.error("Failed to load the properties file " + propertiesFile + "\n"); - LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); - } - } - - public static Properties toProperties(Properties props, Object fromObj) { - return toProperties(props, fromObj, false); - } - - public static Properties toProperties(Properties props, Object fromObj, Boolean useLegacyEnumerationMapping) { - Class fromClass = null; - - if (fromObj != null) { - fromClass = fromObj.getClass(); - } - return toProperties(props, "", fromObj, fromClass, useLegacyEnumerationMapping); - } - - public static Properties toProperties(Properties props, String pfx, Object fromObj) { - return toProperties(props, pfx, fromObj, false); - } + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class); + private static Properties yangMappingProperties = new Properties(); + private static final String IP_ADDRESS="IpAddress"; + private static final String IPV4_ADDRESS="Ipv4Address"; + private static final String IPV6_ADDRESS="Ipv6Address"; + + private static final String IP_PREFIX="IpPrefix"; + + @Deprecated + public static void setProperties(Properties input) { + setYangMappingProperties(input); + } + + @Deprecated + public static void setYangMappingProperties(Properties properties) { + for (Object propNameObj : properties.keySet()) { + String propName = (String) propNameObj; + MdsalHelper.yangMappingProperties.setProperty(propName, properties.getProperty(propName)); + } + } + + @Deprecated + public static void loadProperties(String propertiesFile) { + File file = new File(propertiesFile); + Properties properties = new Properties(); + if (file.isFile() && file.canRead()) { + try (InputStream input = new FileInputStream(file)) { + properties.load(input); + MdsalHelper.setYangMappingProperties(properties); + LOG.info("Loaded properties from " + propertiesFile); + } catch (Exception e) { + LOG.error("Failed to load properties " + propertiesFile + "\n", e); + } + } else { + LOG.error("Failed to load the properties file " + propertiesFile + "\n"); + LOG.error("Either isFile or canRead returned false for " + propertiesFile + "\n"); + } + } + + public static Properties toProperties(Properties props, Object fromObj) { + return toProperties(props, fromObj, false); + } + + public static Properties toProperties(Properties props, Object fromObj, Boolean useLegacyEnumerationMapping) { + Class fromClass = null; + + if (fromObj != null) { + fromClass = fromObj.getClass(); + } + return toProperties(props, "", fromObj, fromClass, useLegacyEnumerationMapping); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj) { + return toProperties(props, pfx, fromObj, false); + } public static Properties toProperties(Properties props, String pfx, Object fromObj, Boolean useLegacyEnumerationMapping) { - Class fromClass = null; + Class fromClass = null; - if (fromObj != null) { - fromClass = fromObj.getClass(); - } + if (fromObj != null) { + fromClass = fromObj.getClass(); + } - return toProperties(props, pfx, fromObj, fromClass, useLegacyEnumerationMapping); - } + return toProperties(props, pfx, fromObj, fromClass, useLegacyEnumerationMapping); + } - public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { - return toProperties(props, pfx, fromObj, fromClass, false); - } + public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass) { + return toProperties(props, pfx, fromObj, fromClass, false); + } public static Properties toProperties(Properties props, String pfx, Object fromObj, Class fromClass, Boolean useLegacyEnumerationMapping) { - if (fromObj == null) { - return props; - } - String simpleTypeName = fromObj.getClass().getTypeName(); - simpleTypeName = simpleTypeName.substring(simpleTypeName.lastIndexOf(".") + 1); - LOG.trace("Extracting properties from " + fromClass.getName() + " class"); - if (classHasSpecialHandling(simpleTypeName)) { - try { - Method m = fromClass.getMethod("getValue", null); - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retValue = m.invoke(fromObj); - if (retValue != null) { - String propVal = null; - if (IP_ADDRESS.equals(simpleTypeName) || IP_PREFIX.equals(simpleTypeName)) { - propVal = String.valueOf((char[]) retValue); - } else if ("Ipv4Address".equals(simpleTypeName) || "Ipv6Address".equals(simpleTypeName)) { - propVal = (String) retValue; - } else if ("Dscp".equals(simpleTypeName)) { - propVal = String.valueOf((short) retValue); - } else if ("PortNumber".equals(simpleTypeName)) { - propVal = String.valueOf((Integer) retValue); - } - LOG.debug("Setting property " + pfx + " to " + propVal); - props.setProperty(pfx, propVal); - } - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() - + ".getValue() to Properties entry", e); - } - } else if (fromObj instanceof List) { - - // Class is a List. List should contain yang-generated classes. - LOG.trace(fromClass.getName() + " is a List"); - - List fromList = (List) fromObj; - - for (int i = 0; i < fromList.size(); i++) { - toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass, useLegacyEnumerationMapping); - } - props.setProperty(pfx + "_length", Integer.toString(fromList.size())); - - } else if (isYangGenerated(fromClass)) { - // Class is yang generated. - LOG.trace(fromClass.getName() + " is a Yang-generated class"); - - String propNamePfx = null; - - // If called from a list (so prefix ends in ']'), don't - // add class name again - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx; - } else { - propNamePfx = toLowerHyphen(fromClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - // Iterate through getter methods to figure out values we need to - // save from - - int numGetters = 0; - String lastGetterName = null; - String propVal = null; - - for (Method m : fromClass.getMethods()) { - if (isGetter(m)) { - - numGetters++; - lastGetterName = m.getName(); - - Class returnType = m.getReturnType(); - String fieldName; - if (m.getName().startsWith("get")) { - fieldName = toLowerHyphen(m.getName().substring(3)); - } else { - - fieldName = toLowerHyphen(m.getName().substring(2)); - } - - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - // Is the return type a yang generated class? - if (isYangGenerated(returnType)) { - // Is it an enum? - if (returnType.isEnum()) { - // Return type is a typedef. Save its value. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - Object retValue = m.invoke(fromObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - String propName = propNamePfx + "." + fieldName; - if (useLegacyEnumerationMapping) { - propVal = retValue.toString(); - props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); - } else { - Method method = retValue.getClass().getMethod("getName"); - String yangValue = (String) method.invoke(retValue); - props.setProperty(propName, yangValue); - } - - } - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert Yang-generated enum returned by " - + fromClass.getName() + "." + m.getName() + "() to Properties entry", - e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retValue = m.invoke(fromObj); - - if (retValue instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); - retValue = new String((byte[]) retValue, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " - + retValue); - } - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { + if (fromObj == null) { + return props; + } + String simpleTypeName = fromObj.getClass().getTypeName(); + simpleTypeName = simpleTypeName.substring(simpleTypeName.lastIndexOf(".") + 1); + LOG.trace("Extracting properties from " + fromClass.getName() + " class"); + if (classHasSpecialHandling(simpleTypeName)) { + try { + Method m = fromClass.getMethod("getValue", null); + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + if (retValue != null) { + String propVal = null; + if (IP_ADDRESS.equals(simpleTypeName) || IP_PREFIX.equals(simpleTypeName)) { + propVal = String.valueOf((char[]) retValue); + } else if (IPV4_ADDRESS.equals(simpleTypeName) || IPV6_ADDRESS.equals(simpleTypeName)) { + propVal = (String) retValue; + } else if ("Dscp".equals(simpleTypeName)) { + propVal = String.valueOf((short) retValue); + } else if ("PortNumber".equals(simpleTypeName)) { + propVal = String.valueOf((Integer) retValue); + } + LOG.debug("Setting property " + pfx + " to " + propVal); + props.setProperty(pfx, propVal); + } + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by " + fromClass.getName() + + ".getValue() to Properties entry", e); + } + } else if (fromObj instanceof List) { + + // Class is a List. List should contain yang-generated classes. + LOG.trace(fromClass.getName() + " is a List"); + + List fromList = (List) fromObj; + + for (int i = 0; i < fromList.size(); i++) { + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass, useLegacyEnumerationMapping); + } + props.setProperty(pfx + "_length", Integer.toString(fromList.size())); + + } else if (isYangGenerated(fromClass)) { + // Class is yang generated. + LOG.trace(fromClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + + // If called from a list (so prefix ends in ']'), don't + // add class name again + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx; + } else { + propNamePfx = toLowerHyphen(fromClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // save from + + int numGetters = 0; + String lastGetterName = null; + String propVal = null; + + for (Method m : fromClass.getMethods()) { + if (isGetter(m)) { + + numGetters++; + lastGetterName = m.getName(); + + Class returnType = m.getReturnType(); + String fieldName; + if (m.getName().startsWith("get")) { + fieldName = toLowerHyphen(m.getName().substring(3)); + } else { + + fieldName = toLowerHyphen(m.getName().substring(2)); + } + + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + // Is the return type a yang generated class? + if (isYangGenerated(returnType)) { + // Is it an enum? + if (returnType.isEnum()) { + // Return type is a typedef. Save its value. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + Object retValue = m.invoke(fromObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + String propName = propNamePfx + "." + fieldName; + if (useLegacyEnumerationMapping) { + propVal = retValue.toString(); + props.setProperty(propName, mapEnumeratedValue(fieldName, propVal)); + } else { + Method method = retValue.getClass().getMethod("getName"); + String yangValue = (String) method.invoke(retValue); + props.setProperty(propName, yangValue); + } + + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated enum returned by " + + fromClass.getName() + "." + m.getName() + "() to Properties entry", + e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + + if (retValue instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + retValue = new String((byte[]) retValue, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + + retValue); + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { toProperties(props, propNamePfx + "." + fieldName, retValue, returnType, useLegacyEnumerationMapping); - } - } catch (Exception e) { - - if (m.getName().equals("getKey")) { - LOG.trace("Caught " + e.getClass().getName() - + " exception trying to convert results from getKey() - ignoring"); - } else { - LOG.error("Caught exception trying to convert Yang-generated class returned by" - + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - } else if (returnType.equals(Class.class)) { - - LOG.trace(m.getName() + " returns a Class object - not interested"); - - } else if (List.class.isAssignableFrom(returnType)) { - - // This getter method returns a list. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retList = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - // Figure out what type of elements are stored in - // this array. - Type paramType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + } + } catch (Exception e) { + + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert Yang-generated class returned by" + + fromClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } else if (returnType.equals(Class.class)) { + + LOG.trace(m.getName() + " returns a Class object - not interested"); + + } else if (List.class.isAssignableFrom(returnType)) { + + // This getter method returns a list. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retList = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + // Figure out what type of elements are stored in + // this array. + Type paramType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; toProperties(props, propNamePfx + "." + fieldName, retList, (Class) elementType, useLegacyEnumerationMapping); - } catch (Exception e) { - LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." - + m.getName() + "() to Properties entry", e); - } - - } else { - - // Method returns something that is not a List and not - // yang-generated. - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object propValObj = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (propValObj != null) { - if (propValObj instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); - propVal = new String((byte[]) propValObj, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " - + propVal); - - } else { - propVal = propValObj.toString(); - } - LOG.debug("Setting property " + propName + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - if (m.getName().equals("getKey")) { - LOG.trace("Caught " + e.getClass().getName() - + " exception trying to convert results from getKey() - ignoring"); - } else { - LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } - } - - } - } - - // End of method loop. If there was only one getter, named - // "getValue", then - // set value identified by "prefix" to that one value. - if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { - LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx - + " = " + propVal); - props.setProperty(propNamePfx, propVal); - } else { - LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " - + lastGetterName); - - } - - } else { - // Class is not yang generated and not a list - // It must be an element of a leaf list - set "prefix" to value - String fromVal = null; - if (fromObj instanceof byte[]) { - try { - fromVal = new String((byte[]) fromObj, "UTF-8"); - LOG.trace("Converted byte array " + pfx + "to string " + fromVal); - } catch (Exception e) { - LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); - fromVal = fromObj.toString(); - } - - } else { - fromVal = fromObj.toString(); - } - LOG.debug("Setting property " + pfx + " to " + fromVal); - props.setProperty(pfx, fromVal); - } - - return (props); - } - - public static Object toBuilder(Properties props, Object toObj) { - - return (toBuilder(props, "", toObj)); - } - - public static List toList(Properties props, String pfx, List toObj, Class elemType) { - - int maxIdx = -1; - boolean foundValue = false; - - LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); - - if (props.contains(pfx + "_length")) { - try { - int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); - - if (listLength > 0) { - maxIdx = listLength - 1; - } - } catch (NumberFormatException e) { - LOG.info("Invalid input for length ", e); - } - } - - if (maxIdx == -1) { - // Figure out array size - for (Object pNameObj : props.keySet()) { - String key = (String) pNameObj; - - if (key.startsWith(pfx + "[")) { - String idxStr = key.substring(pfx.length() + 1); - int endloc = idxStr.indexOf("]"); - if (endloc != -1) { - idxStr = idxStr.substring(0, endloc); - } - - try { - int curIdx = Integer.parseInt(idxStr); - if (curIdx > maxIdx) { - maxIdx = curIdx; - } - } catch (Exception e) { - LOG.error("Illegal subscript in property {}", key, e); - } - - } - } - } - - LOG.trace(pfx + " has max index of " + maxIdx); - for (int i = 0; i <= maxIdx; i++) { - - String curBase = pfx + "[" + i + "]"; - - if (isYangGenerated(elemType)) { - - if (isIpAddress(elemType)) { - - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(IpAddressBuilder.getDefaultInstance(curValue)); - foundValue = true; - } - } else if (isIpv4Address(elemType)) { - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(new Ipv4Address(curValue)); - foundValue = true; - } - - } else if (isIpv6Address(elemType)) { - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(new Ipv6Address(curValue)); - foundValue = true; - } - } else if (isIpPrefix(elemType)) { - - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(IpPrefixBuilder.getDefaultInstance(curValue)); - foundValue = true; - } - } else if (isPortNumber(elemType)) { - - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(PortNumber.getDefaultInstance(curValue)); - foundValue = true; - } - } else if (isDscp(elemType)) { - - String curValue = props.getProperty(curBase, ""); - - if ((curValue != null) && (curValue.length() > 0)) { - toObj.add(Dscp.getDefaultInstance(curValue)); - foundValue = true; - } - } else { - String builderName = elemType.getName() + "Builder"; - try { - Class builderClass = Class.forName(builderName); - Object builderObj = builderClass.newInstance(); - Method buildMethod = builderClass.getMethod("build"); - builderObj = toBuilder(props, curBase, builderObj, true); - if (builderObj != null) { - LOG.trace( - "Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(builderObj); - toObj.add(builtObj); - foundValue = true; - } - - } catch (ClassNotFoundException e) { - LOG.warn("Could not find builder class {}", builderName, e); - } catch (Exception e) { - LOG.error("Caught exception trying to populate list from {}", pfx, e); - } - } - } else { - // Must be a leaf list - String curValue = props.getProperty(curBase, ""); - - toObj.add(curValue); - - if ((curValue != null) && (curValue.length() > 0)) { - foundValue = true; - } - } - - } - - if (foundValue) { - return (toObj); - } else { - return (null); - } - - } - - public static Object toBuilder(Properties props, String pfx, Object toObj) { - return (toBuilder(props, pfx, toObj, false)); - } - - public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { - - Class toClass = toObj.getClass(); - boolean foundValue = false; - - LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); + } catch (Exception e) { + LOG.error("Caught exception trying to convert List returned by " + fromClass.getName() + "." + + m.getName() + "() to Properties entry", e); + } + + } else { + + // Method returns something that is not a List and not + // yang-generated. + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object propValObj = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (propValObj != null) { + if (propValObj instanceof byte[]) { + LOG.trace(m.getName() + " returns a byte[]"); + propVal = new String((byte[]) propValObj, "UTF-8"); + LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " + + propVal); + + } else { + propVal = propValObj.toString(); + } + LOG.debug("Setting property " + propName + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + if (m.getName().equals("getKey")) { + LOG.trace("Caught " + e.getClass().getName() + + " exception trying to convert results from getKey() - ignoring"); + } else { + LOG.error("Caught exception trying to convert value returned by" + fromClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } + } + } + + } + } + + // End of method loop. If there was only one getter, named + // "getValue", then + // set value identified by "prefix" to that one value. + if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { + LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx + + " = " + propVal); + props.setProperty(propNamePfx, propVal); + } else { + LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " + + lastGetterName); + + } + + } else { + // Class is not yang generated and not a list + // It must be an element of a leaf list - set "prefix" to value + String fromVal = null; + if (fromObj instanceof byte[]) { + try { + fromVal = new String((byte[]) fromObj, "UTF-8"); + LOG.trace("Converted byte array " + pfx + "to string " + fromVal); + } catch (Exception e) { + LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); + fromVal = fromObj.toString(); + } + + } else { + fromVal = fromObj.toString(); + } + LOG.debug("Setting property " + pfx + " to " + fromVal); + props.setProperty(pfx, fromVal); + } + + return (props); + } + + public static Object toBuilder(Properties props, Object toObj) { + + return (toBuilder(props, "", toObj)); + } + + public static List toList(Properties props, String pfx, List toObj, Class elemType) { + + int maxIdx = -1; + boolean foundValue = false; + + LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); + + if (props.contains(pfx + "_length")) { + try { + int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); + + if (listLength > 0) { + maxIdx = listLength - 1; + } + } catch (NumberFormatException e) { + LOG.info("Invalid input for length ", e); + } + } + + if (maxIdx == -1) { + // Figure out array size + for (Object pNameObj : props.keySet()) { + String key = (String) pNameObj; + + if (key.startsWith(pfx + "[")) { + String idxStr = key.substring(pfx.length() + 1); + int endloc = idxStr.indexOf("]"); + if (endloc != -1) { + idxStr = idxStr.substring(0, endloc); + } + + try { + int curIdx = Integer.parseInt(idxStr); + if (curIdx > maxIdx) { + maxIdx = curIdx; + } + } catch (Exception e) { + LOG.error("Illegal subscript in property {}", key, e); + } + + } + } + } + + LOG.trace(pfx + " has max index of " + maxIdx); + for (int i = 0; i <= maxIdx; i++) { + + String curBase = pfx + "[" + i + "]"; + + if (isYangGenerated(elemType)) { + + if (isIpAddress(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(IpAddressBuilder.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isIpv4Address(elemType)) { + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(new Ipv4Address(curValue)); + foundValue = true; + } + + } else if (isIpv6Address(elemType)) { + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(new Ipv6Address(curValue)); + foundValue = true; + } + } else if (isIpPrefix(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(IpPrefixBuilder.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isPortNumber(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(PortNumber.getDefaultInstance(curValue)); + foundValue = true; + } + } else if (isDscp(elemType)) { + + String curValue = props.getProperty(curBase, ""); + + if ((curValue != null) && (curValue.length() > 0)) { + toObj.add(Dscp.getDefaultInstance(curValue)); + foundValue = true; + } + } else { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + LOG.trace( + "Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class {}", builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from {}", pfx, e); + } + } + } else { + // Must be a leaf list + String curValue = props.getProperty(curBase, ""); + + toObj.add(curValue); + + if ((curValue != null) && (curValue.length() > 0)) { + foundValue = true; + } + } + + } + + if (foundValue) { + return (toObj); + } else { + return (null); + } + + } + + public static Object toBuilder(Properties props, String pfx, Object toObj) { + return (toBuilder(props, pfx, toObj, false)); + } + + public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { + + Class toClass = toObj.getClass(); + boolean foundValue = false; + + LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); Ipv4Address addr; if (isYangGenerated(toClass)) { - // Class is yang generated. + // Class is yang generated. LOG.trace(toClass.getName() + " is a Yang-generated class"); - String propNamePfx = null; - if (preservePfx) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - if (toObj instanceof Identifier) { - LOG.trace(toClass.getName() + " is a Key - skipping"); - return (toObj); - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - if (isSetter(m)) { - Class paramTypes[] = m.getParameterTypes(); - Class paramClass = paramTypes[0]; - - String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - - String paramValue = props.getProperty(propName); - if (paramValue == null) { - LOG.trace(propName + " is unset"); - } else if ("".equals(paramValue)) { - LOG.trace(propName + " was set to the empty string, setting it to null"); - paramValue = null; - } else { - LOG.trace(propName + " = " + paramValue); - } - - // Is the return type a yang generated class? - if (isYangGenerated(paramClass)) { - // Is it an enum? - if (paramClass.isEnum()) { - - LOG.trace(m.getName() + " expects an Enum"); - // Param type is a typedef. - if ((paramValue != null) && (paramValue.length() > 0)) { - Object paramObj = null; - - try { - paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); - } catch (Exception e) { - LOG.error("Caught exception trying to convert field " + propName + " to enum " - + paramClass.getName(), e); - } - - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to create Yang-generated enum expected by" - + toClass.getName() + "." + m.getName() + "() from Properties entry", e); - } - } - } else { - - String simpleName = paramClass.getSimpleName(); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || IP_ADDRESS.equals(simpleName)) { - - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); - - if ("Ipv4Address".equals(simpleName)) { - m.invoke(toObj, ipAddr.getIpv4Address()); - } else if ("Ipv6Address".equals(simpleName)) { - m.invoke(toObj, ipAddr.getIpv6Address()); - - } else { - m.invoke(toObj, ipAddr); - } - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to call " + toClass.getName() + "." - + m.getName() + "() with Properties entry", e); - } - } - } else if (IP_PREFIX.equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); - m.invoke(toObj, ipPrefix); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - } - } - } else if ("PortNumber".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - PortNumber portNumber = PortNumber.getDefaultInstance(paramValue); - m.invoke(toObj, portNumber); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - } - } - } else if ("Dscp".equals(simpleName)) { - if ((paramValue != null) && (paramValue.length() > 0)) { - try { - Dscp dscp = Dscp.getDefaultInstance(paramValue); - m.invoke(toObj, dscp); - foundValue = true; - } catch (Exception e) { - LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() - + "(" + paramValue + ")", e); - } - } - } else { - // setter expects a yang-generated class. Need - // to - // create a builder to set it. - - String builderName = paramClass.getName() + "Builder"; - Class builderClass = null; - Object builderObj = null; - Object paramObj = null; - - Object constObj = null; - - LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " - + builderName); - try { - builderClass = Class.forName(builderName); - builderObj = builderClass.newInstance(); - paramObj = toBuilder(props, propNamePfx, builderObj); - } catch (ClassNotFoundException e) { - LOG.info("Builder class {} not found ", builderName, e); - if (paramValue == null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() - + "(null)"); - m.invoke(toObj, new Object[] { null }); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e1) { - LOG.error("Caught exception trying to cally" + toClass.getName() + "." - + m.getName() + "() with Properties entry", e1); - } - } else { - try { - // See if I can find a constructor I - // can - // use - Constructor[] constructors = paramClass.getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (String.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (Long.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(Long.parseLong(paramValue)); - } - } - } - - } - - if (constObj == null) { - - // Last chance - see if - // parameter class has a static - // method - // getDefaultInstance(String) - try { + String propNamePfx = null; + if (preservePfx) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + if (toObj instanceof Identifier) { + LOG.trace(toClass.getName() + " is a Key - skipping"); + return (toObj); + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + if (isSetter(m)) { + Class paramTypes[] = m.getParameterTypes(); + Class paramClass = paramTypes[0]; + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + String paramValue = props.getProperty(propName); + if (paramValue == null) { + LOG.trace(propName + " is unset"); + } else if ("".equals(paramValue)) { + LOG.trace(propName + " was set to the empty string, setting it to null"); + paramValue = null; + } else { + LOG.trace(propName + " = " + paramValue); + } + + // Is the return type a yang generated class? + if (isYangGenerated(paramClass)) { + // Is it an enum? + if (paramClass.isEnum()) { + + LOG.trace(m.getName() + " expects an Enum"); + // Param type is a typedef. + if ((paramValue != null) && (paramValue.length() > 0)) { + Object paramObj = null; + + try { + paramObj = Enum.valueOf(paramClass, toJavaEnum(paramValue)); + } catch (Exception e) { + LOG.error("Caught exception trying to convert field " + propName + " to enum " + + paramClass.getName(), e); + } + + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to create Yang-generated enum expected by" + + toClass.getName() + "." + m.getName() + "() from Properties entry", e); + } + } + } else { + + String simpleName = paramClass.getSimpleName(); + + if (IPV4_ADDRESS.equals(simpleName) || IPV6_ADDRESS.equals(simpleName) + || IP_ADDRESS.equals(simpleName)) { + + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpAddress ipAddr = IpAddressBuilder.getDefaultInstance(paramValue); + + if (IPV4_ADDRESS.equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv4Address()); + } else if (IPV6_ADDRESS.equals(simpleName)) { + m.invoke(toObj, ipAddr.getIpv6Address()); + + } else { + m.invoke(toObj, ipAddr); + } + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to call " + toClass.getName() + "." + + m.getName() + "() with Properties entry", e); + } + } + } else if (IP_PREFIX.equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(paramValue); + m.invoke(toObj, ipPrefix); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } else if ("PortNumber".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + PortNumber portNumber = PortNumber.getDefaultInstance(paramValue); + m.invoke(toObj, portNumber); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } else if ("Dscp".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + Dscp dscp = Dscp.getDefaultInstance(paramValue); + m.invoke(toObj, dscp); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } else { + // setter expects a yang-generated class. Need + // to + // create a builder to set it. + + String builderName = paramClass.getName() + "Builder"; + Class builderClass = null; + Object builderObj = null; + Object paramObj = null; + + Object constObj = null; + + LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " + + builderName); + try { + builderClass = Class.forName(builderName); + builderObj = builderClass.newInstance(); + paramObj = toBuilder(props, propNamePfx, builderObj); + } catch (ClassNotFoundException e) { + LOG.info("Builder class {} not found ", builderName, e); + if (paramValue == null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + + "(null)"); + m.invoke(toObj, new Object[] { null }); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e1) { + LOG.error("Caught exception trying to cally" + toClass.getName() + "." + + m.getName() + "() with Properties entry", e1); + } + } else { + try { + // See if I can find a constructor I + // can + // use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj == null) { + + // Last chance - see if + // parameter class has a static + // method + // getDefaultInstance(String) + try { Method gm = paramClass.getMethod("getDefaultInstance", String.class); - int gmodifier = gm.getModifiers(); - if (Modifier.isStatic(gmodifier)) { - // Invoke static - // getDefaultInstance(String) - paramObj = gm.invoke(null, paramValue); - } - - } catch (Exception gme) { - LOG.info("Unable to find static method getDefaultInstance for " - + "class {}", paramClass.getSimpleName(), gme); - } - } - - } catch (Exception e1) { - LOG.warn( - "Could not find a suitable constructor for " + paramClass.getName(), - e1); - } - - if (constObj == null) { - LOG.warn("Could not find builder class " + builderName - + " and could not find a String or Long constructor or static " - + "getDefaultInstance(String) - trying just to set passing paramValue"); - - } - } - } catch (Exception e) { - LOG.error("Caught exception trying to create builder " + builderName, e); - } - - if (paramObj != null && builderClass != null) { - - try { - Method buildMethod = builderClass.getMethod("build"); - LOG.trace("Calling " + paramObj.getClass().getName() + "." - + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(paramObj); - - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); - m.invoke(toObj, builtObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to set Yang-generated class expected by" - + toClass.getName() + "." + m.getName() + "() from Properties entry", - e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - if (constObj != null) { - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + constObj.toString() + ")"); - m.invoke(toObj, constObj); - } else { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramValue); - - } - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" - + toClass.getName() + "." + m.getName() + "() to Properties entry", e); - } - } - } - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(paramClass)) { + int gmodifier = gm.getModifiers(); + if (Modifier.isStatic(gmodifier)) { + // Invoke static + // getDefaultInstance(String) + paramObj = gm.invoke(null, paramValue); + } + + } catch (Exception gme) { + LOG.info("Unable to find static method getDefaultInstance for " + + "class {}", paramClass.getSimpleName(), gme); + } + } + + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + paramClass.getName(), + e1); + } + + if (constObj == null) { + LOG.warn("Could not find builder class " + builderName + + " and could not find a String or Long constructor or static " + + "getDefaultInstance(String) - trying just to set passing paramValue"); + + } + } + } catch (Exception e) { + LOG.error("Caught exception trying to create builder " + builderName, e); + } + + if (paramObj != null && builderClass != null) { + + try { + Method buildMethod = builderClass.getMethod("build"); + LOG.trace("Calling " + paramObj.getClass().getName() + "." + + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(paramObj); + + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); + m.invoke(toObj, builtObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to set Yang-generated class expected by" + + toClass.getName() + "." + m.getName() + "() from Properties entry", + e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + if (constObj != null) { + + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + constObj.toString() + ")"); + m.invoke(toObj, constObj); + } else { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + + } + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + + toClass.getName() + "." + m.getName() + "() to Properties entry", e); + } + } + } + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(paramClass)) { LOG.trace("Parameter class " + paramClass.getName() + " is a List"); - // Figure out what type of args are in List and pass - // that to toList(). - - Type paramType = m.getGenericParameterTypes()[0]; - Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; - Object paramObj = new LinkedList(); - try { - paramObj = toList(props, propName, (List) paramObj, (Class) elementType); - } catch (Exception e) { - LOG.error("Caught exception trying to create list expected as argument to {}.{}", - toClass.getName(), m.getName(), e); - } - - if (paramObj != null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert List returned by" + toClass.getName() - + "." + m.getName() + "() to Properties entry", e); - } - } - } else { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + paramClass.getName() - + " is not a yang-generated class or a List"); - - if ((paramValue != null) && (paramValue.length() > 0)) { - - Object constObj = null; - - try { - // See if I can find a constructor I can use - Constructor[] constructors = paramClass.getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (String.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) && (cParms.length == 1)) { - if (Long.class.isAssignableFrom(cParms[0])) { - constObj = c.newInstance(Long.parseLong(paramValue)); - } - } - } - - } - - if (constObj != null) { - try { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + constObj + ")"); - m.invoke(toObj, constObj); - foundValue = true; - } catch (Exception e2) { - LOG.error("Caught exception trying to call " + m.getName(), e2); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error("Caught exception trying to convert value returned by" - + toClass.getName() + "." + m.getName() + "() to Properties entry", - e); - } - } - } catch (Exception e1) { - LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); - } - - } - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - if (foundValue) { - return (toObj); - } else { - return (null); - } - } - - private static boolean classHasSpecialHandling(String simpleName) { - if (IP_ADDRESS.equals(simpleName) || "Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || IP_PREFIX.equals(simpleName) || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { - return true; - } - return false; - } - - public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { - boolean foundValue = false; - - LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); - - if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { - // Class is yang generated. - LOG.trace(toClass.getName() + " is a Yang-generated class"); - - if (toClass.getName().endsWith("Key")) { - if (Identifier.class.isAssignableFrom(toClass)) { - LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); - } else { - - LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); - } - } - - String propNamePfx = null; - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); - } - - if (propNamePfx.endsWith("-impl")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); - } - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - LOG.trace("Is " + m.getName() + " method a getter?"); - if (isGetter(m)) { - LOG.trace(m.getName() + " is a getter"); - Class returnClass = m.getReturnType(); - - String fieldName = toLowerHyphen(m.getName().substring(3)); - if (fieldName != null) { - fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); - } else { - fieldName = ""; - } - String propName = propNamePfx + "." + fieldName; - - // Is the return type a yang generated class? - if (isYangGenerated(returnClass)) { - // Is it an enum? - if (returnClass.isEnum()) { - - LOG.trace(m.getName() + " is an Enum"); - pstr.print("\n\n * " + propName); - - } else { - - String simpleName = returnClass.getSimpleName(); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) - || IP_ADDRESS.equals(simpleName) || IP_PREFIX.equals(simpleName) - || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { - LOG.trace(m.getName() + " is an " + simpleName); - pstr.print("\n\n * " + propName); - } else { - printPropertyList(pstr, propNamePfx, returnClass); - } - - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(returnClass)) { - - LOG.trace("Parameter class " + returnClass.getName() + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type returnType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; - Class elementClass = (Class) elementType; - LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() - + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); - printPropertyList(pstr, - propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", - elementClass); - - } else if (!returnClass.equals(Class.class)) { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + returnClass.getName() - + " is not a yang-generated class or a List"); - - pstr.print("\n\n * " + propName); - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - } - - public static boolean isYangGenerated(Class c) { - if (c != null) { - return (c.getName().startsWith("org.opendaylight.yang.gen.")); - } - return false; - } - - public static boolean isIpPrefix(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return (IP_PREFIX.equals(simpleName)); - } - - public static boolean isIpv4Address(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv4Address".equals(simpleName)); - } - - public static boolean isIpv6Address(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv6Address".equals(simpleName)); - } - - public static boolean isIpAddress(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return (IP_ADDRESS.equals(simpleName)); - } - - public static boolean isPortNumber(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - - String simpleName = c.getSimpleName(); - return ("PortNumber".equals(simpleName)); - } - - public static boolean isDscp(Class c) { - - if (c == null) { - return (false); - } - if (!isIetfInet(c)) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Dscp".equals(simpleName)); - } - - public static boolean isIetfInet(Class c) { - - Package p = c.getPackage(); - if (p != null) { - String pkgName = p.getName(); - - if ((pkgName != null) && (pkgName.indexOf("yang.ietf.inet.types") > -1)) { - return (true); - } - } - - return (false); - } - - public static String toLowerHyphen(String inStr) { - if (inStr == null) { - return (null); - } - - String str = inStr.substring(0, 1).toLowerCase(); - if (inStr.length() > 1) { - str = str + inStr.substring(1); - } - - String regex = "(([a-z0-9])([A-Z]))"; - String replacement = "$2-$3"; - - String retval = str.replaceAll(regex, replacement).toLowerCase(); - - LOG.trace("Converting " + inStr + " => " + str + " => " + retval); - return (retval); - } - - // This is called when mapping the yang value back to a valid java enumeration - public static String toJavaEnum(String inStr) { - if (inStr == null) { - return (null); - } else if (inStr.length() == 0) { - return (inStr); - } - - // This will strip out all periods, which cannot be in a java enum - inStr = inStr.replaceAll("\\.", ""); - - // This is needed for enums containing spaces - inStr = inStr.replaceAll(" ", ""); - - String[] terms = inStr.split("-"); - StringBuffer sbuff = new StringBuffer(); - - // appends an _ if the string starts with a digit to make it a valid java enum - if (Character.isDigit(inStr.charAt(0))) { - sbuff.append('_'); - } + // Figure out what type of args are in List and pass + // that to toList(). + + Type paramType = m.getGenericParameterTypes()[0]; + Type elementType = ((ParameterizedType) paramType).getActualTypeArguments()[0]; + Object paramObj = new LinkedList(); + try { + paramObj = toList(props, propName, (List) paramObj, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to create list expected as argument to {}.{}", + toClass.getName(), m.getName(), e); + } + + if (paramObj != null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert List returned by" + toClass.getName() + + "." + m.getName() + "() to Properties entry", e); + } + } + } else { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace("Parameter class " + paramClass.getName() + + " is not a yang-generated class or a List"); + + if ((paramValue != null) && (paramValue.length() > 0)) { + + Object constObj = null; + + try { + // See if I can find a constructor I can use + Constructor[] constructors = paramClass.getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (String.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) && (cParms.length == 1)) { + if (Long.class.isAssignableFrom(cParms[0])) { + constObj = c.newInstance(Long.parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + constObj + ")"); + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error("Caught exception trying to call " + m.getName(), e2); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" + + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error("Caught exception trying to convert value returned by" + + toClass.getName() + "." + m.getName() + "() to Properties entry", + e); + } + } + } catch (Exception e1) { + LOG.warn("Could not find a suitable constructor for " + paramClass.getName(), e1); + } + + } + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + if (foundValue) { + return (toObj); + } else { + return (null); + } + } + + private static boolean classHasSpecialHandling(String simpleName) { + if (IP_ADDRESS.equals(simpleName) || IPV4_ADDRESS.equals(simpleName) || IPV6_ADDRESS.equals(simpleName) + || IP_PREFIX.equals(simpleName) || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { + return true; + } + return false; + } + + public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { + boolean foundValue = false; + + LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); + + if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { + // Class is yang generated. + LOG.trace(toClass.getName() + " is a Yang-generated class"); + + if (toClass.getName().endsWith("Key")) { + if (Identifier.class.isAssignableFrom(toClass)) { + LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); + } else { + + LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); + } + } + + String propNamePfx = null; + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith("-builder")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + } + + if (propNamePfx.endsWith("-impl")) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-impl".length()); + } + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + LOG.trace("Is " + m.getName() + " method a getter?"); + if (isGetter(m)) { + LOG.trace(m.getName() + " is a getter"); + Class returnClass = m.getReturnType(); + + String fieldName = toLowerHyphen(m.getName().substring(3)); + if (fieldName != null) { + fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1); + } else { + fieldName = ""; + } + String propName = propNamePfx + "." + fieldName; + + // Is the return type a yang generated class? + if (isYangGenerated(returnClass)) { + // Is it an enum? + if (returnClass.isEnum()) { + + LOG.trace(m.getName() + " is an Enum"); + pstr.print("\n\n * " + propName); + + } else { + + String simpleName = returnClass.getSimpleName(); + + if (IPV4_ADDRESS.equals(simpleName) || IPV6_ADDRESS.equals(simpleName) + || IP_ADDRESS.equals(simpleName) || IP_PREFIX.equals(simpleName) + || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { + LOG.trace(m.getName() + " is an " + simpleName); + pstr.print("\n\n * " + propName); + } else { + printPropertyList(pstr, propNamePfx, returnClass); + } + + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(returnClass)) { + + LOG.trace("Parameter class " + returnClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type returnType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; + Class elementClass = (Class) elementType; + LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() + + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); + printPropertyList(pstr, + propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", + elementClass); + + } else if (!returnClass.equals(Class.class)) { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + LOG.trace("Parameter class " + returnClass.getName() + + " is not a yang-generated class or a List"); + + pstr.print("\n\n * " + propName); + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + } + + public static boolean isYangGenerated(Class c) { + if (c != null) { + return (c.getName().startsWith("org.opendaylight.yang.gen.")); + } + return false; + } + + public static boolean isIpPrefix(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return (IP_PREFIX.equals(simpleName)); + } + + public static boolean isIpv4Address(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return (IPV4_ADDRESS.equals(simpleName)); + } + + public static boolean isIpv6Address(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return (IPV6_ADDRESS.equals(simpleName)); + } + + public static boolean isIpAddress(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return (IP_ADDRESS.equals(simpleName)); + } + + public static boolean isPortNumber(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + + String simpleName = c.getSimpleName(); + return ("PortNumber".equals(simpleName)); + } + + public static boolean isDscp(Class c) { + + if (c == null) { + return (false); + } + if (!isIetfInet(c)) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Dscp".equals(simpleName)); + } + + public static boolean isIetfInet(Class c) { + + Package p = c.getPackage(); + if (p != null) { + String pkgName = p.getName(); + + if ((pkgName != null) && (pkgName.indexOf("yang.ietf.inet.types") > -1)) { + return (true); + } + } + + return (false); + } + + public static String toLowerHyphen(String inStr) { + if (inStr == null) { + return (null); + } + + String str = inStr.substring(0, 1).toLowerCase(); + if (inStr.length() > 1) { + str = str + inStr.substring(1); + } + + String regex = "(([a-z0-9])([A-Z]))"; + String replacement = "$2-$3"; + + String retval = str.replaceAll(regex, replacement).toLowerCase(); + + LOG.trace("Converting " + inStr + " => " + str + " => " + retval); + return (retval); + } + + // This is called when mapping the yang value back to a valid java enumeration + public static String toJavaEnum(String inStr) { + if (inStr == null) { + return (null); + } else if (inStr.length() == 0) { + return (inStr); + } + + // This will strip out all periods, which cannot be in a java enum + inStr = inStr.replaceAll("\\.", ""); + + // This is needed for enums containing spaces + inStr = inStr.replaceAll(" ", ""); + + String[] terms = inStr.split("-"); + StringBuffer sbuff = new StringBuffer(); + + // appends an _ if the string starts with a digit to make it a valid java enum + if (Character.isDigit(inStr.charAt(0))) { + sbuff.append('_'); + } // If the string contains hyphens it will convert the string to upperCamelCase without hyphens - for (String term : terms) { - sbuff.append(term.substring(0, 1).toUpperCase()); - if (term.length() > 1) { - sbuff.append(term.substring(1)); - } - } - return (sbuff.toString()); - - } - - public static boolean isGetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { - if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { - if (!"getClass".equals(m.getName())) { - return (true); - } - } - - if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { - return (true); - } - - if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { - return (true); - } - } - - return (false); - } - - public static boolean isSetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { - if (m.getName().matches("^set[A-Z].*")) { - Class[] paramTypes = m.getParameterTypes(); - if (paramTypes[0].isAssignableFrom(Identifier.class) - || Identifier.class.isAssignableFrom(paramTypes[0])) { - return (false); - } else { - return (true); - } - } - - } - - return (false); - } - - @Deprecated - public static String getFullPropertiesPath(String propertiesFileName) { - return "/opt/bvc/controller/configuration/" + propertiesFileName; - } + for (String term : terms) { + sbuff.append(term.substring(0, 1).toUpperCase()); + if (term.length() > 1) { + sbuff.append(term.substring(1)); + } + } + return (sbuff.toString()); + + } + + public static boolean isGetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 0)) { + if (m.getName().matches("^get[A-Z].*") && !m.getReturnType().equals(void.class)) { + if (!"getClass".equals(m.getName())) { + return (true); + } + } + + if (m.getName().matches("^get[A-Z].*") && m.getReturnType().equals(boolean.class)) { + return (true); + } + + if (m.getName().matches("^is[A-Z].*") && m.getReturnType().equals(Boolean.class)) { + return (true); + } + } + + return (false); + } + + public static boolean isSetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) && (m.getParameterTypes().length == 1)) { + if (m.getName().matches("^set[A-Z].*")) { + Class[] paramTypes = m.getParameterTypes(); + if (paramTypes[0].isAssignableFrom(Identifier.class) + || Identifier.class.isAssignableFrom(paramTypes[0])) { + return (false); + } else { + return (true); + } + } + + } + + return (false); + } + + @Deprecated + public static String getFullPropertiesPath(String propertiesFileName) { + return "/opt/bvc/controller/configuration/" + propertiesFileName; + } // This is called when mapping a valid java enumeration back to the yang model value - @Deprecated - public static String mapEnumeratedValue(String propertyName, String propertyValue) { - LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); - String mappingKey = "yang." + propertyName + "." + propertyValue; - if (yangMappingProperties.containsKey(mappingKey)) { - return (yangMappingProperties.getProperty(mappingKey)); - } else { - LOG.info("yangMappingProperties did not contain the key " + mappingKey + " returning the original value."); - return propertyValue; - } - } + @Deprecated + public static String mapEnumeratedValue(String propertyName, String propertyValue) { + LOG.info("mapEnumeratedValue called with propertyName=" + propertyName + " and value=" + propertyValue); + String mappingKey = "yang." + propertyName + "." + propertyValue; + if (yangMappingProperties.containsKey(mappingKey)) { + return (yangMappingProperties.getProperty(mappingKey)); + } else { + LOG.info("yangMappingProperties did not contain the key " + mappingKey + " returning the original value."); + return propertyValue; + } + } } -- cgit 1.2.3-korg From 5a6695160eca5208d181bb4e817703762edfb9d0 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 18 Dec 2018 09:20:58 -0500 Subject: Add BOM for sli/core Add BOM for sli/core for ease of dependency specification. Change-Id: I0832df313c093624ab3c71c5188ed557f954cd5c Issue-ID: CCSDK-856 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 1 + 2 files changed, 155 insertions(+) create mode 100755 artifacts/pom.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml new file mode 100755 index 000000000..213f6273b --- /dev/null +++ b/artifacts/pom.xml @@ -0,0 +1,154 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.core + sli-core-artifacts + 0.4.0-SNAPSHOT + pom + + ccsdk-sli-core :: sli-core-artifacts + CCSDK core components Bill of Materials (BOM) + https://wiki.onap.org + + ONAP + + + + org.onap.ccsdk.parent + parent + 1.2.0-SNAPSHOT + + + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-filters + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-sli-core-all + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-sliapi + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-slicore-utils + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-sliPluginUtils + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-installer + ${project.version} + + + org.onap.ccsdk.sli.core + filters-provider + ${project.version} + + + org.onap.ccsdk.sli.core + filters-installer + ${project.version} + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider-base + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-model + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-installer + ${project.version} + + + org.onap.ccsdk.sli.core + sliPluginUtils-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sliPluginUtils-installer + ${project.version} + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + + + org.onap.ccsdk.sli.core + utils-installer + ${project.version} + + + + + diff --git a/pom.xml b/pom.xml index aa05c6481..3c9ea2599 100755 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ sliPluginUtils sliapi features + artifacts -- cgit 1.2.3-korg From 06eec44b6c2a3456d3a417af0740a7085612b615 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 19 Dec 2018 12:44:43 +0530 Subject: fixed sonar issue in UpdateNodeExecutor.java to increase code coverage Issue-ID: CCSDK-525 Change-Id: I217ef3ac414ce2c57ba10e99c071ea91d4ae3904 Signed-off-by: Sandeep J --- .../org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java index c4c8faa83..3d93a37ee 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java @@ -5,6 +5,8 @@ * 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 @@ -47,7 +49,7 @@ public class UpdateNodeExecutor extends AbstractSvcLogicNodeExecutor { String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - Map parmMap = new HashMap(); + Map parmMap = new HashMap<>(); Set> parmSet = node.getParameterSet(); boolean hasParms = false; -- cgit 1.2.3-korg From e2658052130acb19ee0ed042e5a0895ba4d1f1c5 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 19 Dec 2018 12:51:57 +0530 Subject: fixed sonar issues in sliapiProvider.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Ia021b4b3d46251e5316e72cabae75a38cb0b00bc Signed-off-by: Sandeep J --- .../main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index e9a2b8eb2..667bae9bf 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -40,7 +40,6 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; @@ -135,6 +134,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ private static QName TEST_RESULT_QNAME = null; private static QName TEST_ID_QNAME = null; private static QName RESULTS_QNAME = null; + private static final String NON_NULL= "non-null"; static { @@ -195,7 +195,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ domDataBroker = ((AbstractForwardedDataBroker) dataBroker).getDelegate(); } if( LOG.isDebugEnabled() ){ - LOG.debug( "DataBroker set to " + (dataBroker==null?"null":"non-null") + "." ); + LOG.debug( "DataBroker set to " + (dataBroker==null?"null":NON_NULL) + "." ); } } @@ -203,14 +203,14 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ NotificationPublishService notificationService) { this.notificationService = notificationService; if( LOG.isDebugEnabled() ){ - LOG.debug( "Notification Service set to " + (notificationService==null?"null":"non-null") + "." ); + LOG.debug( "Notification Service set to " + (notificationService==null?"null":NON_NULL) + "." ); } } public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { this.rpcRegistry = rpcRegistry; if( LOG.isDebugEnabled() ){ - LOG.debug( "RpcRegistry set to " + (rpcRegistry==null?"null":"non-null") + "." ); + LOG.debug( "RpcRegistry set to " + (rpcRegistry==null?"null":NON_NULL) + "." ); } } -- cgit 1.2.3-korg From c293b7bb06ee40199514efb3ba5ba7533afcaf54 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 19 Dec 2018 12:59:00 +0530 Subject: fixed sonar issues in DME2.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Ib6858f2ed802ca979f9098bf87c5536ba223ff5a Signed-off-by: Sandeep J --- .../src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java index 5b3c2a623..65b597e11 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java @@ -5,6 +5,8 @@ * 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 @@ -132,7 +134,7 @@ public class DME2 implements SvcLogicJavaPlugin { // Support optional parameters in a flexible way for (Entry param : parameters.entrySet()) { if (!incompleteUrl.contains(param.getKey() + "=") && param.getValue() != null - && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey()) && !"partner".equals(param.getKey())) { + && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey()) && !PARTNER_KEY.equals(param.getKey())) { sb.append("&" + param.getKey() + "=" + param.getValue()); } } @@ -157,7 +159,7 @@ public class DME2 implements SvcLogicJavaPlugin { // Support legacy direct java call public String constructUrl(String service, String version, String subContext) { - Map parameters = new HashMap(); + Map parameters = new HashMap<>(); parameters.put(SERVICE_KEY, service); if (version != null) { parameters.put(VERSION_KEY, version); -- cgit 1.2.3-korg From 69e82097f57e8994be98e5262b5ca9fb8d9c6c53 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 19 Dec 2018 13:04:02 +0530 Subject: fixed sonar issues in SliPluginUtils.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I672eb667887af1d5d25de4da7429299b414ef79f Signed-off-by: Sandeep J --- .../ccsdk/sli/core/slipluginutils/SliPluginUtils.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 0eb53199c..ebfe81718 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -5,6 +5,8 @@ * 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 @@ -61,6 +63,8 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { } private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils.class); + private static final String LOG_MSG="extracting list from context memory"; + private static final String LOG_MSG1="removing elements from list"; // ========== CONSTRUCTORS ========== @@ -116,9 +120,9 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { } // Extract list from context memory & remove object @ index - LOG.trace("extracting list from context memory"); + LOG.trace(LOG_MSG); list = SvcLogicContextList.extract(ctx, list_pfx); - LOG.trace("removing elements from list"); + LOG.trace(LOG_MSG1); list.remove(index); } else if( param_value != null ) { @@ -127,9 +131,9 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { // Extract list from context memory & remove objects with // key-value pair LOG.trace("executing remove by key-value pair logic"); - LOG.trace("extracting list from context memory"); + LOG.trace(LOG_MSG); list = SvcLogicContextList.extract(ctx, list_pfx); - LOG.trace("removing elements from list"); + LOG.trace(LOG_MSG1); list.remove( param_key, param_value ); } else if( param_keys_length != null ) { @@ -152,9 +156,9 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { // Extract list from context memory & remove objects with all // key-value pairs matching - LOG.trace("extracting list from context memory"); + LOG.trace(LOG_MSG); list = SvcLogicContextList.extract(ctx, list_pfx); - LOG.trace("removing elements from list"); + LOG.trace(LOG_MSG1); list.remove(keys_values); } else { -- cgit 1.2.3-korg From 76782813b60a90ffa20d225f501208f6ae100e44 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Wed, 19 Dec 2018 13:09:06 +0530 Subject: fixed sonar issues in SliStringUtils.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Id1326402bca7207518ba35cf3f5139cef249c5e5 Signed-off-by: Sandeep J --- .../sli/core/slipluginutils/SliStringUtils.java | 54 +++++++++++----------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index 63c750cb8..574178e39 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -5,6 +5,8 @@ * 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 @@ -38,8 +40,8 @@ import org.slf4j.LoggerFactory; public class SliStringUtils implements SvcLogicJavaPlugin { private static final Logger LOG = LoggerFactory.getLogger(SliStringUtils.class); - public static String INPUT_PARAM_SOURCE = "source"; - public static String INPUT_PARAM_TARGET = "target"; + public static final String INPUT_PARAM_SOURCE = "source"; + public static final String INPUT_PARAM_TARGET = "target"; public SliStringUtils() {} @@ -123,8 +125,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static String equalsIgnoreCase(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); - if(parameters.get("source").equalsIgnoreCase(parameters.get("target"))){ + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"target"}, LOG); + if(parameters.get(INPUT_PARAM_SOURCE).equalsIgnoreCase(parameters.get("target"))){ return "true"; } return "false"; @@ -146,8 +148,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void toUpper(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").toUpperCase()); + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get(INPUT_PARAM_SOURCE).toUpperCase()); } /** @@ -166,8 +168,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void toLower(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").toLowerCase()); + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get(INPUT_PARAM_SOURCE).toLowerCase()); } /** @@ -187,8 +189,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static String contains(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); - if(parameters.get("source").contains(parameters.get("target"))){ + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"target"}, LOG); + if(parameters.get(INPUT_PARAM_SOURCE).contains(parameters.get("target"))){ return "true"; } return "false"; @@ -211,8 +213,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static String endsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); - if(parameters.get("source").endsWith(parameters.get("target"))){ + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"target"}, LOG); + if(parameters.get(INPUT_PARAM_SOURCE).endsWith(parameters.get("target"))){ return "true"; } return "false"; @@ -235,8 +237,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static String startsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","target"}, LOG); - if(parameters.get("source").startsWith(parameters.get("target"))){ + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"target"}, LOG); + if(parameters.get(INPUT_PARAM_SOURCE).startsWith(parameters.get("target"))){ return "true"; } return "false"; @@ -258,8 +260,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void trim(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").trim()); + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get(INPUT_PARAM_SOURCE).trim()); } /** @@ -278,8 +280,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void getLength(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), String.valueOf(parameters.get("source").length())); + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"outputPath"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), String.valueOf(parameters.get(INPUT_PARAM_SOURCE).length())); } /** @@ -300,8 +302,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void replace(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath","target","replacement"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), (parameters.get("source").replace(parameters.get("target"), parameters.get("replacement")))); + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"outputPath","target","replacement"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), (parameters.get(INPUT_PARAM_SOURCE).replace(parameters.get("target"), parameters.get("replacement")))); } /** @@ -322,8 +324,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void replaceAll(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{"source","outputPath","target","replacement"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), parameters.get("source").replaceAll(parameters.get("target"), parameters.get("replacement"))); + SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"outputPath","target","replacement"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get(INPUT_PARAM_SOURCE).replaceAll(parameters.get("target"), parameters.get("replacement"))); } /** @@ -383,8 +385,8 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void concat( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - SliPluginUtils.checkParameters( parameters, new String[]{"source","target","outputPath"}, LOG ); - String result = parameters.get("source").concat(parameters.get("target")); + SliPluginUtils.checkParameters( parameters, new String[]{INPUT_PARAM_SOURCE,"target","outputPath"}, LOG ); + String result = parameters.get(INPUT_PARAM_SOURCE).concat(parameters.get("target")); ctx.setAttribute(parameters.get("outputPath"), result); } @@ -405,13 +407,13 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @throws SvcLogicException */ public static void urlEncode(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[] { "source", "outputPath" }, LOG); + SliPluginUtils.checkParameters(parameters, new String[] { INPUT_PARAM_SOURCE, "outputPath" }, LOG); String encoding = parameters.get("encoding"); if (encoding == null) { encoding = "UTF-8"; } try { - String result = URLEncoder.encode(parameters.get("source"), encoding); + String result = URLEncoder.encode(parameters.get(INPUT_PARAM_SOURCE), encoding); ctx.setAttribute(parameters.get("outputPath"), result); } catch (UnsupportedEncodingException e) { throw new SvcLogicException("Url encode failed.", e); -- cgit 1.2.3-korg From e767eee707210d661b98a851046775001623989c Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Thu, 20 Dec 2018 12:55:00 +0530 Subject: fixed sonar issues in DBResourceManager.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I169df48b14e1288271356a972c36e678da1ffa04 Signed-off-by: Sandeep J --- .../java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 047fa297e..85acd272b 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -83,6 +83,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb protected final long expectedCompletionTime; protected final long unprocessedFailoverThreshold; private static final String LOGGER_ALARM_MSG="Generated alarm: DBResourceManager.getData - No active DB connection pools are available."; + private static final String EXCEPTION_MSG= "No active DB connection pools are available in RequestDataNoRecovery call."; public DBResourceManager(final DBLIBResourceProvider configuration) { this(configuration.getProperties()); @@ -461,7 +462,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { if(dsQueue.isEmpty()){ LOGGER.error(LOGGER_ALARM_MSG); - throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); + throw new DBLibException(EXCEPTION_MSG); } CachedDataSource active = this.dsQueue.first(); long time = System.currentTimeMillis(); @@ -475,8 +476,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } return active.getData(statement, arguments); -// } catch(SQLDataException exc){ -// throw exc; + } catch(Throwable exc){ String message = exc.getMessage(); if(message == null) @@ -537,7 +537,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb private boolean writeDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { if(dsQueue.isEmpty()){ LOGGER.error(LOGGER_ALARM_MSG); - throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call."); + throw new DBLibException(EXCEPTION_MSG); } boolean initialRequest = true; @@ -665,7 +665,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb SQLException exception = new DBLibException(lastException.getMessage()); exception.setStackTrace(lastException.getStackTrace()); if(lastException.getCause() instanceof SQLException) { -// exception.setNextException((SQLException)lastException.getCause()); + throw (SQLException)lastException.getCause(); } throw exception; -- cgit 1.2.3-korg From 93a61abf96ac8f4432a19f99ca5ab7a92e22d368 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Thu, 20 Dec 2018 12:59:36 +0530 Subject: fixed sonar issue in PollingWorker.java fixed sonar issue Issue-ID: CCSDK-525 Change-Id: If242b9995469c0b0a25b1285db1536ff52adce2c Signed-off-by: Sandeep J --- .../src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java index 905944b1c..454af02bb 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java @@ -62,7 +62,7 @@ public class PollingWorker implements Runnable { interval = Long.parseLong((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval") == null) ? "60" : (String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval")); // '0' bucket is to count exceptions - String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling") == null) + String[] sampling = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling") == null) ? "0,2,5,10,20,50,100" : (String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")).split(","); if (enabled) { -- cgit 1.2.3-korg From 3fd1ec5d2cc60c29434a9d604ffe4debe3417d22 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Thu, 20 Dec 2018 13:21:21 +0530 Subject: fixed sonar issues in SvcLogicServiceImpl.java fixed sonar issues and formatted code Issue-ID: CCSDK-525 Change-Id: I8fd20f55e225aeac37a5c763857c00228ef5a58a Signed-off-by: Sandeep J --- .../org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index b4059ed25..d5c7f3bfe 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -3,7 +3,7 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. * ================================================================================ @@ -27,7 +27,6 @@ import java.util.Properties; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -44,7 +43,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; -public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService { +public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService { private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImpl.class); protected BundleContext bctx = null; @@ -113,7 +112,7 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL execute(graph, ctx); return (ctx.toProperties()); } - + @Override public SvcLogicStore getStore() throws SvcLogicException { // Create and initialize SvcLogicStore object - used to access -- cgit 1.2.3-korg From ba4b7898676ec01cbab2f4b72ab92683626a9b40 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Thu, 20 Dec 2018 13:18:09 +0530 Subject: fixed sonar issues in MdsalHelper.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I0b77ad983305da8b19fa6e3587da8ea3fe1bca95 Signed-off-by: Sandeep J --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index eeea80bc7..eb4e15e9e 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -56,7 +56,9 @@ public class MdsalHelper { private static final String IPV6_ADDRESS="Ipv6Address"; private static final String IP_PREFIX="IpPrefix"; - + private static final String SETTING_PROPERTY="Setting property "; + private static final String BUILDER="-builder"; + @Deprecated public static void setProperties(Properties input) { setYangMappingProperties(input); @@ -146,7 +148,7 @@ public class MdsalHelper { } else if ("PortNumber".equals(simpleTypeName)) { propVal = String.valueOf((Integer) retValue); } - LOG.debug("Setting property " + pfx + " to " + propVal); + LOG.debug(SETTING_PROPERTY + pfx + " to " + propVal); props.setProperty(pfx, propVal); } } catch (Exception e) { @@ -182,8 +184,8 @@ public class MdsalHelper { propNamePfx = toLowerHyphen(fromClass.getSimpleName()); } - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - BUILDER.length()); } if (propNamePfx.endsWith("-impl")) { @@ -332,7 +334,7 @@ public class MdsalHelper { } else { propVal = propValObj.toString(); } - LOG.debug("Setting property " + propName + " to " + propVal); + LOG.debug(SETTING_PROPERTY + propName + " to " + propVal); props.setProperty(propName, propVal); } @@ -379,7 +381,7 @@ public class MdsalHelper { } else { fromVal = fromObj.toString(); } - LOG.debug("Setting property " + pfx + " to " + fromVal); + LOG.debug(SETTING_PROPERTY + pfx + " to " + fromVal); props.setProperty(pfx, fromVal); } @@ -559,8 +561,8 @@ public class MdsalHelper { propNamePfx = toLowerHyphen(toClass.getSimpleName()); } - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - BUILDER.length()); } if (propNamePfx.endsWith("-impl")) { @@ -1035,8 +1037,8 @@ public class MdsalHelper { propNamePfx = toLowerHyphen(toClass.getSimpleName()); } - if (propNamePfx.endsWith("-builder")) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length()); + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() - BUILDER.length()); } if (propNamePfx.endsWith("-impl")) { -- cgit 1.2.3-korg From 1aed4dcc66c754d6ee031aba47acad8faa7fb3f6 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 21 Dec 2018 17:37:26 +0530 Subject: fixed sonar issues in ConfigureNodeExecutor.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I14e357eeab5aaa2736f6c6492925e860e9029f80 Signed-off-by: Sandeep J --- .../sli/provider/base/ConfigureNodeExecutor.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java index 7ffdfcaf7..5d6a08391 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java @@ -40,6 +40,8 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory .getLogger(ConfigureNodeExecutor.class); private static final String CAUGHT_EXCEPTION_MSG="Caught exception from "; + private static final String ALREADY_ACTIVE= "already-active"; + private static final String NOT_FOUND= "not-found"; public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { @@ -108,10 +110,10 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { case SUCCESS: break; case ALREADY_ACTIVE: - outValue = "already-active"; + outValue = ALREADY_ACTIVE; break; case NOT_FOUND: - outValue = "not-found"; + outValue = NOT_FOUND; break; case NOT_READY: outValue = "not-ready"; @@ -134,10 +136,10 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { case SUCCESS: break; case ALREADY_ACTIVE: - outValue = "already-active"; + outValue = ALREADY_ACTIVE; break; case NOT_FOUND: - outValue = "not-found"; + outValue = NOT_FOUND; break; case NOT_READY: outValue = "not-ready"; @@ -150,10 +152,10 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { } break; case ALREADY_ACTIVE: - outValue = "already-active"; + outValue = ALREADY_ACTIVE; break; case NOT_FOUND: - outValue = "not-found"; + outValue = NOT_FOUND; break; case NOT_READY: outValue = "not-ready"; @@ -177,10 +179,10 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { outValue = "success"; break; case ALREADY_ACTIVE: - outValue = "already-active"; + outValue = ALREADY_ACTIVE; break; case NOT_FOUND: - outValue = "not-found"; + outValue = NOT_FOUND; break; case NOT_READY: outValue = "not-ready"; @@ -203,10 +205,10 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { outValue = "success"; break; case ALREADY_ACTIVE: - outValue = "already-active"; + outValue = ALREADY_ACTIVE; break; case NOT_FOUND: - outValue = "not-found"; + outValue = NOT_FOUND; break; case NOT_READY: outValue = "not-ready"; -- cgit 1.2.3-korg From 66298e15540602d69a30f0c389764f43dd91586a Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 21 Dec 2018 17:42:53 +0530 Subject: fixed sonar issues in sliapiProvider.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I4f2c19ea603782730866772687f338757e72612e Signed-off-by: Sandeep J --- .../src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index 667bae9bf..4817a95a0 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -566,7 +566,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME).node(TEST_RESULT_QNAME).build(); // Construct results list - LinkedList> entryList = new LinkedList>(); + LinkedList> entryList = new LinkedList<>(); for (String result : testResult.getResults()) { LeafSetEntryNode leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create() .withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result)) -- cgit 1.2.3-korg From 8a72139cd40e1fd6353b6c535c2ba3bd1e7290f1 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 21 Dec 2018 17:46:01 +0530 Subject: fixed sonar issues in SliPluginUtils.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: I6d48ed028e98c2fc9ce0cf6ae215dfd3fcc6c871 Signed-off-by: Sandeep J --- .../onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index ebfe81718..fd3364ca4 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -65,6 +65,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils.class); private static final String LOG_MSG="extracting list from context memory"; private static final String LOG_MSG1="removing elements from list"; + private static final String LENGTH="_length"; // ========== CONSTRUCTORS ========== @@ -216,7 +217,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { i++; } // Reset list length (removed by ctxBulkErase above) - ctx.setAttribute(ctx_list_str+"_length", Integer.toString(listSz)); + ctx.setAttribute(ctx_list_str+LENGTH, Integer.toString(listSz)); } /** @@ -492,7 +493,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { * @since 1.0 */ public static final int getArrayLength( SvcLogicContext ctx, String key, Logger log, LogLevel logLevel, String log_message ) { - String ctxKey = key.endsWith("_length") ? key : key + "_length"; + String ctxKey = key.endsWith(LENGTH) ? key : key + LENGTH; try { return Integer.parseInt(ctx.getAttribute(ctxKey)); } @@ -829,7 +830,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { writeJsonObject(entry.getValue().getAsJsonObject(), ctx, root + entry.getKey() + "."); } else if (entry.getValue().isJsonArray()) { JsonArray array = entry.getValue().getAsJsonArray(); - ctx.setAttribute(root + entry.getKey() + "_length", String.valueOf(array.size())); + ctx.setAttribute(root + entry.getKey() + LENGTH, String.valueOf(array.size())); Integer arrayIdx = 0; for (JsonElement element : array) { if (element.isJsonObject()) { @@ -873,7 +874,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { try { String ctxList = parameters.get("list"); - ctxList = (ctxList.endsWith("_length")) ? ctxList : ctxList + "_length"; + ctxList = (ctxList.endsWith(LENGTH)) ? ctxList : ctxList + LENGTH; int listLength = getArrayLength(ctx, ctxList); if (listLength == 0) { @@ -1063,9 +1064,9 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { setParametersToCtxList(parameters, ctx, prefixKeyWithIndex, valuePrefixKey); // set length of list - String ListLengthKeyName = prefixKey + "_length"; + String ListLengthKeyName = prefixKey + LENGTH; - ctxSetAttribute(ctx, prefixKey + "_length", listLength + 1); + ctxSetAttribute(ctx, prefixKey + LENGTH, listLength + 1); LOG.debug("Updated _length: " + prefixKey + "_length is now " + ctx.getAttribute(ListLengthKeyName)); } -- cgit 1.2.3-korg From b264dee1ac60671ce6174bdd6d4e067219dc48b3 Mon Sep 17 00:00:00 2001 From: ezhil Date: Wed, 26 Dec 2018 16:49:07 +0530 Subject: Fixed sonar fix in DbConfigPool.java Fixed major sonar issue Issue-ID: CCSDK-796 Change-Id: Id8a655875c972bb3df1f12f211b6a0068922b21d Signed-off-by: ezhil --- .../java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java index fb94ea0e7..6cb1d9c33 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java @@ -28,19 +28,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DbConfigPool { - private static Logger LOGGER = LoggerFactory.getLogger(DbConfigPool.class); - + private static Logger log = LoggerFactory.getLogger(DbConfigPool.class); private final String type; - + private static final int timeOut=0; private ArrayList configurations = new ArrayList<>(); public DbConfigPool(Properties properties) { - LOGGER.debug("Initializing DbConfigType"); + log.debug("Initializing DbConfigType"); type = properties.getProperty(BaseDBConfiguration.DATABASE_TYPE, "JDBC").toUpperCase(); } public int getTimeout() { - return 0; + return timeOut; } public String getType() { -- cgit 1.2.3-korg From 28c3abf558b0697f063e792fc08e1b1b0a9c561b Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Thu, 20 Dec 2018 13:08:04 +0530 Subject: fixed sonar issues in PrintYangToProp.java fixed sonar issues Issue-ID: CCSDK-525 Change-Id: Ifb7328c8b3cf40d412a0efffad6cb55673cf83dc Signed-off-by: Sandeep J --- .../org/onap/ccsdk/sli/core/sli/PrintYangToProp.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java index 861352106..3e8983bbf 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java @@ -48,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Strings; public class PrintYangToProp { @@ -144,8 +145,8 @@ public class PrintYangToProp { fieldName = toLowerHyphen(m.getName().substring(2)); } - if(fieldName!= null && fieldName.length() >0 ) fieldName = fieldName.substring(0, 1).toLowerCase() - + fieldName.substring(1); + if(Strings.isNullOrEmpty(fieldName)) fieldName = fieldName.substring(0, 1).toLowerCase()+ fieldName.substring(1); + // Is the return type a yang generated class? if (isYangGenerated(returnType)) { @@ -196,8 +197,7 @@ public class PrintYangToProp { if (retValue != null) { String propVal = retValue.getValue(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); + props.setProperty(propName, propVal); } @@ -223,8 +223,7 @@ public class PrintYangToProp { if (retValue != null) { String propVal = retValue.getValue(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); + props.setProperty(propName, propVal); } @@ -236,7 +235,7 @@ public class PrintYangToProp { + TO_PROPERTIES_STRING, e); } } else if (isIpv4Prefix(returnType)) { - //System.out.println("isIpv4Prefix"); + // Save its value try { String propName = propNamePfx + "." + fieldName; @@ -250,9 +249,8 @@ public class PrintYangToProp { } if (retValue != null) { - String propVal = retValue.getValue().toString(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); + String propVal = retValue.getValue(); + props.setProperty(propName, propVal); } -- cgit 1.2.3-korg From c62fdd3be263bdb4543aba980780df642af67313 Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Mon, 7 Jan 2019 15:10:11 -0500 Subject: fixed sonar issue in JdbcCachedDataSource Changes made: * updated cleanup code * added TerminatingConfiguration class Change-Id: Iee16116a5fc419065915b9f84488874dd192af7c Issue-ID: CCSDK-913 Signed-off-by: Rich Tabedzki --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 5 ++-- .../core/dblib/TerminatingCachedDataSource.java | 10 +++++-- .../sli/core/dblib/config/BaseDBConfiguration.java | 14 +++++++-- .../dblib/config/TerminatingConfiguration.java | 33 ++++++++++++++++++++++ .../core/dblib/jdbc/JdbcDBCachedDataSource.java | 5 ++++ 5 files changed, 60 insertions(+), 7 deletions(-) create mode 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/TerminatingConfiguration.java diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index f3ecfa279..0f1674f90 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -94,6 +94,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } protected abstract DataSource configure(BaseDBConfiguration jdbcElem) throws DBConfigException; + protected abstract int getAvailableConnections(); /* * (non-Javadoc) @@ -488,9 +489,9 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito isSlave = true; } if (isSlave) { - LOGGER.debug("SQL SLAVE : {} on server {}", connectionName, hostname); + LOGGER.debug("SQL SLAVE : {} on server {}, pool {}", connectionName, getDbConnectionName(), getAvailableConnections()); } else { - LOGGER.debug("SQL MASTER : {} on server {}", connectionName, hostname); + LOGGER.debug("SQL MASTER : {} on server {}, pool {}", connectionName, getDbConnectionName(), getAvailableConnections()); } return isSlave; } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java index e1afcc22e..884f88825 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java @@ -7,9 +7,9 @@ * 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. @@ -29,6 +29,8 @@ import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; public class TerminatingCachedDataSource extends CachedDataSource implements SQLExecutionMonitorObserver { + private static final int DEFAULT_AVAILABLE_CONNECTIONS = 0; + public TerminatingCachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { super(jdbcElem); } @@ -43,4 +45,8 @@ public class TerminatingCachedDataSource extends CachedDataSource implements SQL return null; } + @Override + protected int getAvailableConnections() { + return DEFAULT_AVAILABLE_CONNECTIONS; + } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java index 967059a31..ea6bc450d 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java @@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory; */ public abstract class BaseDBConfiguration { - private Logger logger = LoggerFactory.getLogger(BaseDBConfiguration.class); + private static final Logger LOGGER = LoggerFactory.getLogger(BaseDBConfiguration.class); /** * Property key within a properties configuration File for db type */ @@ -134,7 +134,7 @@ public abstract class BaseDBConfiguration { String value = properties.getProperty(CONNECTION_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE); return Integer.parseInt(value); } catch (Exception exc) { - logger.error("Exception",exc); + LOGGER.error("Exception",exc); return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE); } } @@ -150,7 +150,7 @@ public abstract class BaseDBConfiguration { String value = properties.getProperty(REQUEST_TIMEOUT, DEFAULT_REJECT_CHANGE_VALUE); return Integer.parseInt(value); } catch (Exception exc) { - logger.error("Exception",exc); + LOGGER.error("Exception",exc); return Integer.parseInt(DEFAULT_REJECT_CHANGE_VALUE); } } @@ -247,4 +247,12 @@ public abstract class BaseDBConfiguration { public String getDbUrl() { return properties.getProperty(DATABASE_URL); } + + public boolean containsKey(String propertyname) { + return properties.containsKey(propertyname); + } + + public String getProperty(String propertyname) { + return properties.getProperty(propertyname); + } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/TerminatingConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/TerminatingConfiguration.java new file mode 100755 index 000000000..1ebd1441f --- /dev/null +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/TerminatingConfiguration.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib.config; + +import java.util.Properties; + +public class TerminatingConfiguration extends BaseDBConfiguration { + + public TerminatingConfiguration() { + super(new Properties()); + } + +} diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java index 09c1c202b..a53d18639 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java @@ -193,4 +193,9 @@ public class JdbcDBCachedDataSource extends CachedDataSource { dataSource.close(true); super.cleanUp(); } + + @Override + protected int getAvailableConnections() { + return org.apache.tomcat.jdbc.pool.DataSource.class.cast(ds).getSize(); + } } -- cgit 1.2.3-korg From 3beadc23c627911abac35dd5afd5b942c073188b Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 8 Jan 2019 10:55:33 -0500 Subject: Prepare for release build Prepare for release of early ODL-Oxygen based CCSDK Dublin Change-Id: Ia1fb4b7211619be726857b0333c1f75985ff1a64 Issue-ID: CCSDK-870 Signed-off-by: Timoney, Dan (dt5972) --- .gitignore | 3 + artifacts/pom.xml | 292 ++++++++++---------- dblib/features/ccsdk-dblib/pom.xml | 115 ++++---- dblib/features/features-dblib/pom.xml | 6 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 7 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 153 +++++------ features/ccsdk-sli-core-all/pom.xml | 188 ++++++------- features/features-sli-core/pom.xml | 6 +- features/installer/pom.xml | 247 +++++++++-------- features/pom.xml | 26 +- filters/features/ccsdk-filters/pom.xml | 116 ++++---- filters/features/features-filters/pom.xml | 6 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 296 ++++++++++----------- filters/pom.xml | 7 +- filters/provider/pom.xml | 7 +- pom.xml | 2 +- sli/common/pom.xml | 13 +- sli/features/features-sli/pom.xml | 6 +- sli/features/odl-sli/pom.xml | 138 +++++----- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 7 +- sli/model/pom.xml | 6 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 120 +++++---- sli/provider/pom.xml | 195 +++++++------- sli/recording/pom.xml | 141 +++++----- .../features/ccsdk-sliPluginUtils/pom.xml | 6 +- .../features/features-sliPluginUtils/pom.xml | 46 ++-- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 129 ++++----- sliapi/features/ccsdk-sliapi/pom.xml | 46 ++-- sliapi/features/features-sliapi/pom.xml | 46 ++-- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 48 ++-- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 29 +- utils/features/ccsdk-slicore-utils/pom.xml | 6 +- utils/features/features-util/pom.xml | 6 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 8 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 8 +- version.properties | 2 +- 49 files changed, 1290 insertions(+), 1219 deletions(-) diff --git a/.gitignore b/.gitignore index b45dfca41..6a9d9826d 100755 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ blackDuckHubProjectVersionName.txt # Derby log derby.log + +# Generated file +sliPluginUtils/provider/testFileName diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 213f6273b..b518958d1 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -1,154 +1,152 @@ - - 4.0.0 + + 4.0.0 - org.onap.ccsdk.sli.core - sli-core-artifacts - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + sli-core-artifacts + 0.4.0-SNAPSHOT + pom - ccsdk-sli-core :: sli-core-artifacts - CCSDK core components Bill of Materials (BOM) - https://wiki.onap.org - - ONAP - + ccsdk-sli-core :: sli-core-artifacts + CCSDK core components Bill of Materials (BOM) + https://wiki.onap.org + + ONAP + - - org.onap.ccsdk.parent - parent - 1.2.0-SNAPSHOT - + + org.onap.ccsdk.parent + parent + 1.2.0 + - - - - org.onap.ccsdk.sli.core - ccsdk-dblib - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-filters - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-sli - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-sli-core-all - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-sliapi - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-slicore-utils - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-sliPluginUtils - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-installer - ${project.version} - - - org.onap.ccsdk.sli.core - filters-provider - ${project.version} - - - org.onap.ccsdk.sli.core - filters-installer - ${project.version} - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-model - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider-base - ${project.version} - - - org.onap.ccsdk.sli.core - sliapi-model - ${project.version} - - - org.onap.ccsdk.sli.core - sliapi-provider - ${project.version} - - - org.onap.ccsdk.sli.core - sliapi-installer - ${project.version} - - - org.onap.ccsdk.sli.core - sliPluginUtils-provider - ${project.version} - - - org.onap.ccsdk.sli.core - sliPluginUtils-installer - ${project.version} - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - - - org.onap.ccsdk.sli.core - utils-installer - ${project.version} - - - + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-filters + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-sli-core-all + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-sliapi + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-slicore-utils + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + ccsdk-sliPluginUtils + ${project.version} + xml + feature + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-installer + ${project.version} + + + org.onap.ccsdk.sli.core + filters-provider + ${project.version} + + + org.onap.ccsdk.sli.core + filters-installer + ${project.version} + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider-base + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-model + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-installer + ${project.version} + + + org.onap.ccsdk.sli.core + sliPluginUtils-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sliPluginUtils-installer + ${project.version} + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + + + org.onap.ccsdk.sli.core + utils-installer + ${project.version} + + + diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 23bf11704..e4de0b436 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -1,67 +1,70 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + single-feature-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - ccsdk-dblib - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + ccsdk-dblib + 0.4.0-SNAPSHOT + feature - ccsdk-sli-core :: dblib :: ${project.artifactId} + ccsdk-sli-core :: dblib :: ${project.artifactId} + + + ${project.version} + - + - - ${project.groupId} - dblib-provider - ${project.version} - + + ${project.groupId} + dblib-provider + ${project.version} + - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + - - org.apache.derby - derby - - + + org.apache.derby + derby + + - - - - org.apache.karaf.tooling - karaf-maven-plugin - true - - - slf4j-api - tomcat-jdbc - tomcat-juli - - - - - + + + + org.apache.karaf.tooling + karaf-maven-plugin + true + + + slf4j-api + tomcat-jdbc + tomcat-juli + + + + + diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 456822ca0..976fdfe86 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,10 @@ feature ccsdk-sli-core :: dblib :: ${project.artifactId} + + + ${project.version} + diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 738fdb08b..3e89746c9 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 78099e730..f9d2e051d 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -1,13 +1,12 @@ - + 4.0.0 org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT - + 1.2.0 + org.onap.ccsdk.sli.core diff --git a/dblib/pom.xml b/dblib/pom.xml index d71f35a89..3e9d49f9f 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 55e5619c6..406b5b75b 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -1,85 +1,86 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - dblib-provider - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + dblib-provider + 0.4.0-SNAPSHOT + bundle - ccsdk-sli-core :: dblib :: ${project.artifactId} - http://maven.apache.org + ccsdk-sli-core :: dblib :: ${project.artifactId} + http://maven.apache.org - - UTF-8 - + + UTF-8 + ${project.version} + - - - junit - junit - test - - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - - - org.osgi - org.osgi.core - provided - - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - - - org.slf4j - slf4j-simple - test - - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - com.google.guava - guava - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - + + + junit + junit + test + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + org.osgi + org.osgi.core + provided + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + + + org.slf4j + slf4j-simple + test + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + com.google.guava + guava + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + - - - org.mockito - mockito-core - test - - - org.apache.karaf.shell - org.apache.karaf.shell.console - - + + + org.mockito + mockito-core + test + + + org.apache.karaf.shell + org.apache.karaf.shell.console + + diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 447b2034c..6e3480e5a 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -1,100 +1,102 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + single-feature-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - ccsdk-sli-core-all - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + ccsdk-sli-core-all + 0.4.0-SNAPSHOT + feature - ccsdk-sli-core :: features :: ${project.artifactId} + ccsdk-sli-core :: features :: ${project.artifactId} - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - + + + ${project.version} + + + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + - - - ${project.groupId} - ccsdk-slicore-utils - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-dblib - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-filters - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-sli - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-sliapi - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-sliPluginUtils - ${project.version} - xml - features - - + + + ${project.groupId} + ccsdk-slicore-utils + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-dblib + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-filters + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sliapi + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sliPluginUtils + ${project.version} + xml + features + + diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 38d2715e1..29619f90f 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,10 @@ feature ccsdk-sli-core :: features :: ${project.artifactId} + + + ${project.version} + diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 3eb283378..fba408469 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -1,138 +1,137 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0 + + - org.onap.ccsdk.sli.core - slicore-features-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + slicore-features-installer + 0.4.0-SNAPSHOT + pom - ccsdk-sli-core :: features :: ${project.artifactId} + ccsdk-sli-core :: features :: ${project.artifactId} - - ccsdk-sli-core-all - ${application.name} - mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features - false - + + ccsdk-sli-core-all + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features + false + - + - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.core + ${application.name} + ${project.version} + xml + features + + + * + * + + + - + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false org.onap.ccsdk.sli.core,org.apache.tomcat,org.slf4j - utils-provider,slf4j-api - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + utils-provider,slf4j-api + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/features/pom.xml b/features/pom.xml index 2c098434a..529d24262 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -1,22 +1,22 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0 + + - org.onap.ccsdk.sli.core - slicore-feature-aggregator - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + slicore-feature-aggregator + 0.4.0-SNAPSHOT + pom - ccsdk-sli-core :: features + ccsdk-sli-core :: features - + ccsdk-sli-core-all features-sli-core installer diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index a56f27341..0c883a364 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -1,58 +1,62 @@ - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-filters - 0.4.0-SNAPSHOT - feature - - ccsdk-sli-core :: filters :: ${project.artifactId} - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - - - ${project.groupId} - ccsdk-sli - ${project.version} - xml - features - - - - ${project.groupId} - filters-provider - ${project.version} - - - + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.2.0 + + + + org.onap.ccsdk.sli.core + ccsdk-filters + 0.4.0-SNAPSHOT + feature + + ccsdk-sli-core :: filters :: ${project.artifactId} + + + ${project.version} + + + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + + ${project.groupId} + filters-provider + ${project.version} + + + diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index a8c0e7550..76250baa1 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,10 @@ feature ccsdk-sli-core :: filters :: ${project.artifactId} + + + ${project.version} + diff --git a/filters/features/pom.xml b/filters/features/pom.xml index d3f9ecd8d..622b6ab55 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 7fe64220e..0d35aedbf 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -1,165 +1,165 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.0 + + - org.onap.ccsdk.sli.core - filters-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + filters-installer + 0.4.0-SNAPSHOT + pom - ccsdk-sli-core :: filters :: ${project.artifactId} + ccsdk-sli-core :: filters :: ${project.artifactId} - - ccsdk-filters - ${application.name} + + ccsdk-filters + ${application.name} mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features - false - + false + - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + - + - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.core + ${application.name} + ${project.version} + xml + features + + + * + * + + + - - org.onap.ccsdk.sli.core - filters-provider - ${project.version} - + + org.onap.ccsdk.sli.core + filters-provider + ${project.version} + - + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli.core - sli-common,sli-provider,utils-provider,dblib-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.core + sli-common,sli-provider,utils-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/filters/pom.xml b/filters/pom.xml index 1182f2bd7..150fee3b7 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,11 @@ pom ccsdk-sli-core :: filters + + + + ${project.version} + Servlet filter to implement ONAP logging spec ONAP diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 76898e2f9..d2df92e31 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -19,8 +19,9 @@ UTF-8 - - **/RequestResponseDbLoggingFilter.java + + **/RequestResponseDbLoggingFilter.java + ${project.version} diff --git a/pom.xml b/pom.xml index 3c9ea2599..4504ece0e 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index a8bb2f6b9..17ee4751e 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -1,13 +1,12 @@ - + 4.0.0 org.onap.ccsdk.parent binding-parent - 1.2.0-SNAPSHOT - + 1.2.0 + org.onap.ccsdk.sli.core @@ -19,9 +18,9 @@ The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter - - **/MessageWriter.java - + + **/MessageWriter.java + ${project.version} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 2d29070ea..9bb3612de 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -16,6 +16,10 @@ ccsdk-sli-core :: sli :: ${project.artifactId} + + ${project.version} + + ${project.groupId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 8d50d8b84..9e88969ce 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -1,82 +1,84 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + single-feature-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - ccsdk-sli - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + ccsdk-sli + 0.4.0-SNAPSHOT + feature - ccsdk-sli-core :: sli :: ${project.artifactId} + ccsdk-sli-core :: sli :: ${project.artifactId} + + + ${project.version} + - - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - + + + + org.opendaylight.controller + mdsal-artifacts + ${odl.mdsal.version} + pom + import + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${odl.mdsal.model.version} + pom + import + - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - + + org.onap.ccsdk.sli.core + sli-recording + ${project.version} + - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - provided - + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + provided + - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + - - org.onap.ccsdk.sli.core - ccsdk-dblib - ${project.version} - xml - features - + + org.onap.ccsdk.sli.core + ccsdk-dblib + ${project.version} + xml + features + - + diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 445e917f5..9c0451d54 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 99b4a400c..77f460316 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -1,13 +1,12 @@ - + 4.0.0 org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT - + 1.2.0 + org.onap.ccsdk.sli.core diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 5a60ce2bd..fab849e85 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,10 @@ bundle ccsdk-sli-core :: sli :: ${project.artifactId} + + + ${project.version} + diff --git a/sli/pom.xml b/sli/pom.xml index 7060541aa..54fd5cff3 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 63cba8307..6680fce66 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -1,61 +1,63 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.2.0-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sli-provider-base - 0.4.0-SNAPSHOT - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - 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 - - - + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.2.0 + + + + org.onap.ccsdk.sli.core + sli-provider-base + 0.4.0-SNAPSHOT + + + ${project.version} + + + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + 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/provider/pom.xml b/sli/provider/pom.xml index 0a090282a..f3d368970 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -1,111 +1,110 @@ - - - 4.0.0 + + + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - sli-provider - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sli-provider + 0.4.0-SNAPSHOT + bundle - ccsdk-sli-core :: sli :: ${project.artifactId} - SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. - - UTF-8 - + + UTF-8 + ${project.version} + - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - org.onap.ccsdk.sli.core - sli-model - ${project.version} - test - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - compile - - - org.onap.ccsdk.sli.core - sli-provider-base - ${project.version} - compile - - - org.slf4j - slf4j-api - - - commons-lang - commons-lang - compile - + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider-base + ${project.version} + compile + + + org.slf4j + slf4j-api + + + commons-lang + commons-lang + compile + - - org.osgi - org.osgi.core - provided - - - org.opendaylight.controller - sal-binding-api - + + org.osgi + org.osgi.core + provided + + + org.opendaylight.controller + sal-binding-api + - - - junit - junit - test - + + + junit + junit + test + - - org.mockito - mockito-core - test - - - org.apache.derby - derby - test - - + + org.mockito + mockito-core + test + + + org.apache.derby + derby + test + + - - - - org.apache.felix - maven-bundle-plugin - true - - - * - - + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + - - + + - + diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 593db5b87..27acbbcee 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -1,82 +1,81 @@ - - - 4.0.0 + + + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - sli-recording - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sli-recording + 0.4.0-SNAPSHOT + bundle - ccsdk-sli-core :: sli :: ${project.artifactId} - SLI Recording is an OSGi bundle that implements recording service for the service logic record node. + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Recording is an OSGi bundle that implements recording service for the service logic record node. - - UTF-8 - + + UTF-8 + ${project.version} + - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - compile - - - org.osgi - org.osgi.core - provided - - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + compile + + + org.osgi + org.osgi.core + provided + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + - - commons-lang - commons-lang - compile - + + commons-lang + commons-lang + compile + - - org.opendaylight.controller - sal-binding-api - + + org.opendaylight.controller + sal-binding-api + - - - junit - junit - test - + + + junit + junit + test + - - org.mockito - mockito-core - test - + + org.mockito + mockito-core + test + - + diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 18fd8c3ca..79042b42d 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,10 @@ feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + + + ${project.version} + diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 7aaa53e02..d38db864c 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -1,29 +1,33 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - features-sliPluginUtils - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + features-sliPluginUtils + 0.4.0-SNAPSHOT + feature - ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + + + ${project.version} + - - - ${project.groupId} - ccsdk-sliPluginUtils - ${project.version} - xml - features - + + + ${project.groupId} + ccsdk-sliPluginUtils + ${project.version} + xml + features + - + diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index fb90b9ec9..991ac7990 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 5d38c0283..13ef49cdb 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 244767d7e..bebc8a8d7 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 5f7be7605..7e00ef3f0 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -1,72 +1,73 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - sliPluginUtils-provider - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sliPluginUtils-provider + 0.4.0-SNAPSHOT + bundle - ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - http://maven.apache.org + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + http://maven.apache.org - - UTF-8 - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - junit - junit - test - - - ${project.groupId} - sli-common - ${project.version} - compile - + + UTF-8 + ${project.version} + + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + junit + junit + test + + + ${project.groupId} + sli-common + ${project.version} + compile + - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - - - org.apache.commons - commons-lang3 - - - org.hamcrest - hamcrest-library - test - - - com.google.code.gson - gson - - - org.apache.commons - commons-text - 1.1 - - + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + + + org.apache.commons + commons-lang3 + + + org.hamcrest + hamcrest-library + test + + + com.google.code.gson + gson + + + org.apache.commons + commons-text + 1.1 + + diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index fe7625a04..9c7e51539 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,10 +15,14 @@ feature ccsdk-sli-core :: sliapi :: ${project.artifactId} + + + ${project.version} + - - - + + + org.opendaylight.mdsal.model mdsal-model-artifacts ${odl.mdsal.model.version} @@ -33,24 +37,24 @@ import - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + - - - + + + diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 2cf38447b..fb1931d8a 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -1,29 +1,33 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - features-sliapi - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + features-sliapi + 0.4.0-SNAPSHOT + feature - ccsdk-sli-core :: sliapi :: ${project.artifactId} + ccsdk-sli-core :: sliapi :: ${project.artifactId} + + + ${project.version} + - - - ${project.groupId} - ccsdk-sliapi - ${project.version} - xml - features - + + + ${project.groupId} + ccsdk-sliapi + ${project.version} + xml + features + - + diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index fb267583d..9ef65fc4e 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index d8a56b8dd..48bfee66b 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index bb84b87db..913e8ecdc 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -1,29 +1,33 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0-SNAPSHOT - - + + org.onap.ccsdk.parent + binding-parent + 1.2.0 + + - org.onap.ccsdk.sli.core - sliapi-model - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sliapi-model + 0.4.0-SNAPSHOT + bundle - ccsdk-sli-core :: sliapi :: ${project.artifactId} + ccsdk-sli-core :: sliapi :: ${project.artifactId} + + + ${project.version} + - - - org.opendaylight.mdsal.model - ietf-inet-types - - - org.opendaylight.mdsal.model - ietf-yang-types - - + + + org.opendaylight.mdsal.model + ietf-inet-types + + + org.opendaylight.mdsal.model + ietf-yang-types + + diff --git a/sliapi/pom.xml b/sliapi/pom.xml index eb02ee850..5c8b68f6d 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index efcf321c9..0bcf7f75d 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -1,13 +1,12 @@ - + 4.0.0 org.onap.ccsdk.parent binding-parent - 1.2.0-SNAPSHOT - + 1.2.0 + org.onap.ccsdk.sli.core @@ -17,15 +16,19 @@ ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - + + ${project.version} + + + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index c019687d2..7ff4d7682 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,10 @@ feature ccsdk-sli-core :: utils :: ${project.artifactId} + + + ${project.version} + diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 5b038695b..9981b2cd2 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,10 @@ feature ccsdk-sli-core :: utils :: ${project.artifactId} + + + ${project.version} + diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 301173993..33277b88f 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 902120ae3..b0c1d4a37 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -1,14 +1,12 @@ - + 4.0.0 org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT - + 1.2.0 + org.onap.ccsdk.sli.core diff --git a/utils/pom.xml b/utils/pom.xml index 68f20cb7a..be130eb50 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0-SNAPSHOT + 1.2.0 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index e4c446b59..88983bd84 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.0-SNAPSHOT + 1.2.0 @@ -15,6 +15,12 @@ bundle ccsdk-sli-core :: utils :: ${project.artifactId} + + + + ${project.version} + + The SLI Core Utilities Package provides common functionality for setting up SLI connectivity. diff --git a/version.properties b/version.properties index aa6328e0e..ffee02fc4 100644 --- a/version.properties +++ b/version.properties @@ -10,6 +10,6 @@ feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -release_version=${base_version}-STAGING +release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg From 742aa5d00edbb6bee2ed6c2e710a1f5203305354 Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Tue, 8 Jan 2019 12:21:23 -0500 Subject: Fix sonar issues in ccsdk-sli-core Changes made: * Updated message template handling in CachedDataSource Change-Id: I9a082753d80f790b77448a5b3de957b404d737fb Issue-ID: CCSDK-647 Signed-off-by: Rich Tabedzki --- .../onap/ccsdk/sli/core/dblib/CachedDataSource.java | 18 ++++++++---------- .../onap/ccsdk/sli/core/dblib/DBResourceManager.java | 3 ++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 0f1674f90..bc466d931 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -59,10 +59,11 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito private static final Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); private static final String SQL_FAILURE = "SQL FAILURE. time(ms): "; - private static final String FAILED_TO_EXECUTE = "> Failed to execute: "; + private static final String FAILED_TO_EXECUTE = "> failed to execute: "; private static final String WITH_ARGUMENTS = " with arguments: "; private static final String WITH_NO_ARGUMENTS = " with no arguments. "; - private static final String SQL_DATA_SOURCE = "SQL DataSource <"; + private static final String DATA_SOURCE_CONNECT_SUCCESS = "SQL DataSource < {} > connected to {}, read-only is {}, tested successfully"; + private static final String DATA_SOURCE_CONNECT_FAILURE = "SQL DataSource < {} > test failed. Cause : {}> test failed. Cause : {}"; protected long connReqTimeout = 30L; protected long dataReqTimeout = 100L; @@ -356,17 +357,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito hostname = rs.getString(2); if (LOGGER.isDebugEnabled()) { - LOGGER.debug(SQL_DATA_SOURCE + getDbConnectionName() + "> connected to " + hostname - + ", read-only is " + readOnly + ", tested successfully "); + LOGGER.debug(DATA_SOURCE_CONNECT_SUCCESS,getDbConnectionName(),hostname,readOnly); } } } catch (Exception exc) { if (errorLevel) { - LOGGER.error( - SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + LOGGER.error(DATA_SOURCE_CONNECT_FAILURE, this.getDbConnectionName(),exc.getMessage()); } else { - LOGGER.info( - SQL_DATA_SOURCE + this.getDbConnectionName() + "> test failed. Cause : " + exc.getMessage()); + LOGGER.info(DATA_SOURCE_CONNECT_FAILURE, this.getDbConnectionName(),exc.getMessage()); } return false; } finally { @@ -489,9 +487,9 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito isSlave = true; } if (isSlave) { - LOGGER.debug("SQL SLAVE : {} on server {}, pool {}", connectionName, getDbConnectionName(), getAvailableConnections()); + LOGGER.debug("SQL SLAVE : {} on server {}, pool {}", connectionName, hostname, getAvailableConnections()); } else { - LOGGER.debug("SQL MASTER : {} on server {}, pool {}", connectionName, getDbConnectionName(), getAvailableConnections()); + LOGGER.debug("SQL MASTER : {} on server {}, pool {}", connectionName, hostname, getAvailableConnections()); } return isSlave; } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 85acd272b..9d797d096 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -50,6 +50,7 @@ import javax.sql.rowset.CachedRowSet; import org.apache.tomcat.jdbc.pool.PoolExhaustedException; import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.onap.ccsdk.sli.core.dblib.config.TerminatingConfiguration; import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; @@ -755,7 +756,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb if(broken != null) { try { - broken.add( new TerminatingCachedDataSource(null)); + broken.add( new TerminatingCachedDataSource(new TerminatingConfiguration())); } catch(Exception exc){ LOGGER.error("Waiting for Worker to stop", exc); } -- cgit 1.2.3-korg From 1efd16dce0ecedb81039b26b81d1490cadeb3395 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 20 Dec 2018 13:44:40 -0500 Subject: Code changes to sli/core for ODL Fluorine Code changes needed to support port to ODL Fluorine. Change-Id: I539aeaabeab1056cd109b6bee12046d91d61cab1 Issue-ID: CCSDK-870 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 288 ++++++++++---------- dblib/features/ccsdk-dblib/pom.xml | 112 ++++---- dblib/features/features-dblib/pom.xml | 8 +- dblib/features/pom.xml | 4 +- dblib/installer/pom.xml | 4 +- dblib/pom.xml | 4 +- dblib/provider/pom.xml | 153 ++++++----- features/ccsdk-sli-core-all/pom.xml | 170 ++++++------ features/features-sli-core/pom.xml | 8 +- features/installer/pom.xml | 244 ++++++++--------- features/pom.xml | 26 +- filters/features/ccsdk-filters/pom.xml | 113 ++++---- filters/features/features-filters/pom.xml | 8 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 296 ++++++++++----------- filters/pom.xml | 9 +- filters/provider/pom.xml | 9 +- pom.xml | 4 +- sli/common/pom.xml | 14 +- .../onap/ccsdk/sli/core/sli/PrintYangToProp.java | 16 +- .../ccsdk/sli/core/sli/PrintYangToPropTest.java | 7 +- sli/features/features-sli/pom.xml | 8 +- sli/features/odl-sli/pom.xml | 140 ++++------ sli/features/pom.xml | 4 +- sli/installer/pom.xml | 4 +- sli/model/pom.xml | 12 +- sli/model/src/main/yang/sliapi.yang | 2 +- sli/pom.xml | 4 +- sli/provider-base/pom.xml | 114 ++++---- sli/provider/pom.xml | 189 +++++++------ .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 34 ++- .../sli/core/sli/provider/MdsalHelperTest.java | 24 +- .../opendaylight/yang/gen/v1/test/TestObject.java | 6 +- .../yang/gen/v1/test/TestObjectBuilder.java | 6 +- sli/recording/pom.xml | 135 +++++----- .../features/ccsdk-sliPluginUtils/pom.xml | 42 +-- .../features/features-sliPluginUtils/pom.xml | 46 ++-- sliPluginUtils/features/pom.xml | 4 +- sliPluginUtils/installer/pom.xml | 4 +- sliPluginUtils/pom.xml | 4 +- sliPluginUtils/provider/pom.xml | 129 +++++---- sliapi/features/ccsdk-sliapi/pom.xml | 44 +-- sliapi/features/features-sliapi/pom.xml | 46 ++-- sliapi/features/pom.xml | 4 +- sliapi/installer/pom.xml | 4 +- sliapi/model/pom.xml | 48 ++-- sliapi/model/src/main/yang/sliapi.yang | 2 +- sliapi/pom.xml | 4 +- sliapi/provider/pom.xml | 56 ++-- .../onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 133 +++++---- .../src/main/yang/sliapi-provider-impl.yang | 61 ----- .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 6 +- utils/features/ccsdk-slicore-utils/pom.xml | 26 +- utils/features/features-util/pom.xml | 8 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 4 +- utils/pom.xml | 4 +- utils/provider/pom.xml | 10 +- version.properties | 2 +- 59 files changed, 1335 insertions(+), 1539 deletions(-) delete mode 100755 sliapi/provider/src/main/yang/sliapi-provider-impl.yang diff --git a/artifacts/pom.xml b/artifacts/pom.xml index b518958d1..9777c8085 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -1,152 +1,152 @@ - 4.0.0 + 4.0.0 - org.onap.ccsdk.sli.core - sli-core-artifacts - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + sli-core-artifacts + 0.4.1-SNAPSHOT + pom - ccsdk-sli-core :: sli-core-artifacts - CCSDK core components Bill of Materials (BOM) - https://wiki.onap.org - - ONAP - + ccsdk-sli-core :: sli-core-artifacts + CCSDK core components Bill of Materials (BOM) + https://wiki.onap.org + + ONAP + - - org.onap.ccsdk.parent - parent - 1.2.0 - + + org.onap.ccsdk.parent + parent + 1.2.1-SNAPSHOT + - - - - org.onap.ccsdk.sli.core - ccsdk-dblib - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-filters - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-sli - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-sli-core-all - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-sliapi - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-slicore-utils - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - ccsdk-sliPluginUtils - ${project.version} - xml - feature - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-installer - ${project.version} - - - org.onap.ccsdk.sli.core - filters-provider - ${project.version} - - - org.onap.ccsdk.sli.core - filters-installer - ${project.version} - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-model - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider-base - ${project.version} - - - org.onap.ccsdk.sli.core - sliapi-model - ${project.version} - - - org.onap.ccsdk.sli.core - sliapi-provider - ${project.version} - - - org.onap.ccsdk.sli.core - sliapi-installer - ${project.version} - - - org.onap.ccsdk.sli.core - sliPluginUtils-provider - ${project.version} - - - org.onap.ccsdk.sli.core - sliPluginUtils-installer - ${project.version} - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - - - org.onap.ccsdk.sli.core - utils-installer - ${project.version} - - - + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + ${project.version} + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-filters + ${project.version} + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${project.version} + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-sli-core-all + ${project.version} + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-sliapi + ${project.version} + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-slicore-utils + ${project.version} + xml + features + + + org.onap.ccsdk.sli.core + ccsdk-sliPluginUtils + ${project.version} + xml + features + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-installer + ${project.version} + + + org.onap.ccsdk.sli.core + filters-provider + ${project.version} + + + org.onap.ccsdk.sli.core + filters-installer + ${project.version} + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider-base + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-model + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-installer + ${project.version} + + + org.onap.ccsdk.sli.core + sliPluginUtils-provider + ${project.version} + + + org.onap.ccsdk.sli.core + sliPluginUtils-installer + ${project.version} + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + + + org.onap.ccsdk.sli.core + utils-installer + ${project.version} + + + diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index e4de0b436..4fd1bc785 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -1,70 +1,66 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0 - - + + org.onap.ccsdk.parent + single-feature-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - ccsdk-dblib - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + ccsdk-dblib + 0.4.1-SNAPSHOT + feature - ccsdk-sli-core :: dblib :: ${project.artifactId} + ccsdk-sli-core :: dblib :: ${project.artifactId} - - - ${project.version} - - + - - ${project.groupId} - dblib-provider - ${project.version} - + + ${project.groupId} + dblib-provider + ${project.version} + - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + - - org.apache.derby - derby - - + + org.apache.derby + derby + + - - - - org.apache.karaf.tooling - karaf-maven-plugin - true - - - slf4j-api - tomcat-jdbc - tomcat-juli - - - - - + + + + org.apache.karaf.tooling + karaf-maven-plugin + true + + + slf4j-api + tomcat-jdbc + tomcat-juli + + + + + diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 976fdfe86..011e99040 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,20 +5,16 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} - - - ${project.version} - diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 3e89746c9..103f8fe85 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index f9d2e051d..d094a0e95 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 3e9d49f9f..753f6aff5 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 406b5b75b..9cda7ab1f 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -1,86 +1,85 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0 - - + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - dblib-provider - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + dblib-provider + 0.4.1-SNAPSHOT + bundle - ccsdk-sli-core :: dblib :: ${project.artifactId} - http://maven.apache.org + ccsdk-sli-core :: dblib :: ${project.artifactId} + http://maven.apache.org - - UTF-8 - ${project.version} - + + UTF-8 + - - - junit - junit - test - - - ch.vorburger.mariaDB4j - mariaDB4j - 2.2.3 - test - - - org.osgi - org.osgi.core - provided - - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - - - org.slf4j - slf4j-simple - test - - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - - - org.apache.tomcat - tomcat-jdbc - ${tomcat-jdbc.version} - - - com.google.guava - guava - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - + + + junit + junit + test + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + org.osgi + org.osgi.core + provided + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + + + org.slf4j + slf4j-simple + test + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + org.apache.tomcat + tomcat-jdbc + ${tomcat-jdbc.version} + + + com.google.guava + guava + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + - - - org.mockito - mockito-core - test - - - org.apache.karaf.shell - org.apache.karaf.shell.console - - + + + org.mockito + mockito-core + test + + + org.apache.karaf.shell + org.apache.karaf.shell.console + + diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 6e3480e5a..584a579d9 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -1,102 +1,84 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0 - - + + org.onap.ccsdk.parent + single-feature-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - ccsdk-sli-core-all - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + ccsdk-sli-core-all + 0.4.1-SNAPSHOT + feature - ccsdk-sli-core :: features :: ${project.artifactId} + ccsdk-sli-core :: features :: ${project.artifactId} - - - ${project.version} - - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + - - - ${project.groupId} - ccsdk-slicore-utils - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-dblib - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-filters - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-sli - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-sliapi - ${project.version} - xml - features - - - ${project.groupId} - ccsdk-sliPluginUtils - ${project.version} - xml - features - - + + + ${project.groupId} + ccsdk-slicore-utils + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-dblib + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-filters + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sliapi + ${project.version} + xml + features + + + ${project.groupId} + ccsdk-sliPluginUtils + ${project.version} + xml + features + + diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 29619f90f..583bafb44 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,20 +5,16 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} - - - ${project.version} - diff --git a/features/installer/pom.xml b/features/installer/pom.xml index fba408469..e839272fc 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -1,137 +1,137 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0 - - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - slicore-features-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + slicore-features-installer + 0.4.1-SNAPSHOT + pom - ccsdk-sli-core :: features :: ${project.artifactId} + ccsdk-sli-core :: features :: ${project.artifactId} - - ccsdk-sli-core-all - ${application.name} - mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features - false - + + ccsdk-sli-core-all + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features + false + - + - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.core + ${application.name} + ${project.version} + xml + features + + + * + * + + + - + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false org.onap.ccsdk.sli.core,org.apache.tomcat,org.slf4j - utils-provider,slf4j-api - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + utils-provider,slf4j-api + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/features/pom.xml b/features/pom.xml index 529d24262..255c84c19 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -1,22 +1,22 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0 - - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - slicore-feature-aggregator - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + slicore-feature-aggregator + 0.4.1-SNAPSHOT + pom - ccsdk-sli-core :: features + ccsdk-sli-core :: features - + ccsdk-sli-core-all features-sli-core installer diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 0c883a364..e032c735f 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -1,62 +1,57 @@ - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0 - - - - org.onap.ccsdk.sli.core - ccsdk-filters - 0.4.0-SNAPSHOT - feature - - ccsdk-sli-core :: filters :: ${project.artifactId} - - - ${project.version} - - - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - - - ${project.groupId} - ccsdk-sli - ${project.version} - xml - features - - - - ${project.groupId} - filters-provider - ${project.version} - - - + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.2.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-filters + 0.4.1-SNAPSHOT + feature + + ccsdk-sli-core :: filters :: ${project.artifactId} + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + + ${project.groupId} + filters-provider + ${project.version} + + + diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 76250baa1..393ddbae3 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,20 +5,16 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} - - - ${project.version} - diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 622b6ab55..0eec257f3 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 0d35aedbf..91c932c08 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -1,165 +1,165 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 1.2.0 - - + + org.onap.ccsdk.parent + odlparent-lite + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - filters-installer - 0.4.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + filters-installer + 0.4.1-SNAPSHOT + pom - ccsdk-sli-core :: filters :: ${project.artifactId} + ccsdk-sli-core :: filters :: ${project.artifactId} - - ccsdk-filters - ${application.name} + + ccsdk-filters + ${application.name} mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features - false - + false + - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + - + - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + org.onap.ccsdk.sli.core + ${application.name} + ${project.version} + xml + features + + + * + * + + + - - org.onap.ccsdk.sli.core - filters-provider - ${project.version} - + + org.onap.ccsdk.sli.core + filters-provider + ${project.version} + - + - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli.core - sli-common,sli-provider,utils-provider,dblib-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli.core + sli-common,sli-provider,utils-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/filters/pom.xml b/filters/pom.xml index 150fee3b7..486d63019 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,21 +5,16 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: filters - - - - ${project.version} - Servlet filter to implement ONAP logging spec ONAP diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index d2df92e31..fb8d2b9ad 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} @@ -19,9 +19,8 @@ UTF-8 - - **/RequestResponseDbLoggingFilter.java - ${project.version} + + **/RequestResponseDbLoggingFilter.java diff --git a/pom.xml b/pom.xml index 4504ece0e..353623266 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 17ee4751e..4d1440064 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,22 +5,22 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter - - **/MessageWriter.java - ${project.version} + + **/MessageWriter.java + @@ -73,11 +73,11 @@ org.opendaylight.mdsal.model - ietf-inet-types + ietf-inet-types-2013-07-15 org.opendaylight.mdsal.model - ietf-yang-types + ietf-yang-types-20130715 org.opendaylight.controller diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java index 3e8983bbf..5df136fd9 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java @@ -37,14 +37,14 @@ import java.util.Arrays; import java.util.ArrayList; import java.io.*; import org.opendaylight.yangtools.yang.binding.Identifier; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java index fb6eaf70b..d639c28dc 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java @@ -3,8 +3,6 @@ */ package org.onap.ccsdk.sli.core.sli; -import static org.junit.Assert.*; - import java.util.Enumeration; import java.util.LinkedList; import java.util.List; @@ -15,9 +13,8 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.Exe import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 9bb3612de..85860a77a 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,21 +5,17 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} - - ${project.version} - - ${project.groupId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 9e88969ce..31ef0dde4 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -1,84 +1,62 @@ - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.2.0 - - - - org.onap.ccsdk.sli.core - ccsdk-sli - 0.4.0-SNAPSHOT - feature - - ccsdk-sli-core :: sli :: ${project.artifactId} - - - ${project.version} - - - - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - provided - - - - org.mariadb.jdbc - mariadb-java-client - ${mariadb.connector.version} - - - - org.onap.ccsdk.sli.core - ccsdk-dblib - ${project.version} - xml - features - - - - + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.2.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-sli + 0.4.1-SNAPSHOT + feature + + ccsdk-sli-core :: sli :: ${project.artifactId} + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + + org.onap.ccsdk.sli.core + sli-recording + ${project.version} + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + provided + + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.connector.version} + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + ${project.version} + xml + features + + + + diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 9c0451d54..f19d363bf 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 77f460316..d8b62a3f3 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index fab849e85..cae0a483a 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,29 +5,25 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} - - - ${project.version} - org.opendaylight.mdsal.model - ietf-inet-types + ietf-inet-types-2013-07-15 org.opendaylight.mdsal.model - ietf-yang-types + ietf-yang-types-20130715 diff --git a/sli/model/src/main/yang/sliapi.yang b/sli/model/src/main/yang/sliapi.yang index 5d91ba2d5..19adecca9 100755 --- a/sli/model/src/main/yang/sliapi.yang +++ b/sli/model/src/main/yang/sliapi.yang @@ -6,7 +6,7 @@ module SLI-API { prefix sample; - import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; } + import ietf-inet-types { prefix "inet"; revision-date 2013-07-15; } organization "ONAP"; diff --git a/sli/pom.xml b/sli/pom.xml index 54fd5cff3..db20f5656 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 6680fce66..0b6dfff44 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -1,63 +1,59 @@ - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.2.0 - - - - org.onap.ccsdk.sli.core - sli-provider-base - 0.4.0-SNAPSHOT - - - ${project.version} - - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - 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 - - - + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + sli-provider-base + 0.4.1-SNAPSHOT + + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + 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/provider/pom.xml b/sli/provider/pom.xml index f3d368970..f367cd83f 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -1,110 +1,109 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0 - - + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - sli-provider - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sli-provider + 0.4.1-SNAPSHOT + bundle - ccsdk-sli-core :: sli :: ${project.artifactId} - SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service. - - UTF-8 - ${project.version} - + + UTF-8 + - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - org.onap.ccsdk.sli.core - sli-model - ${project.version} - test - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - compile - - - org.onap.ccsdk.sli.core - sli-provider-base - ${project.version} - compile - - - org.slf4j - slf4j-api - - - commons-lang - commons-lang - compile - + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + org.onap.ccsdk.sli.core + sli-model + ${project.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider-base + ${project.version} + compile + + + org.slf4j + slf4j-api + + + commons-lang + commons-lang + compile + - - org.osgi - org.osgi.core - provided - - - org.opendaylight.controller - sal-binding-api - + + org.osgi + org.osgi.core + provided + + + org.opendaylight.controller + sal-binding-api + - - - junit - junit - test - + + + junit + junit + test + - - org.mockito - mockito-core - test - - - org.apache.derby - derby - test - - + + org.mockito + mockito-core + test + + + org.apache.derby + derby + test + + - - - - org.apache.felix - maven-bundle-plugin - true - - - * - - + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + - - + + - + diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index eb4e15e9e..818077fb7 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -35,14 +35,14 @@ import java.lang.reflect.Type; import java.util.LinkedList; import java.util.List; import java.util.Properties; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yangtools.yang.binding.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -129,9 +129,11 @@ public class MdsalHelper { String simpleTypeName = fromObj.getClass().getTypeName(); simpleTypeName = simpleTypeName.substring(simpleTypeName.lastIndexOf(".") + 1); LOG.trace("Extracting properties from " + fromClass.getName() + " class"); + if (classHasSpecialHandling(simpleTypeName)) { try { - Method m = fromClass.getMethod("getValue", null); + + Method m = fromClass.getMethod(getStringValueMethod(simpleTypeName), null); boolean isAccessible = m.isAccessible(); if (!isAccessible) { m.setAccessible(true); @@ -139,9 +141,8 @@ public class MdsalHelper { Object retValue = m.invoke(fromObj); if (retValue != null) { String propVal = null; - if (IP_ADDRESS.equals(simpleTypeName) || IP_PREFIX.equals(simpleTypeName)) { - propVal = String.valueOf((char[]) retValue); - } else if (IPV4_ADDRESS.equals(simpleTypeName) || IPV6_ADDRESS.equals(simpleTypeName)) { + if (IP_ADDRESS.equals(simpleTypeName) || IP_PREFIX.equals(simpleTypeName) + || IPV4_ADDRESS.equals(simpleTypeName) || IPV6_ADDRESS.equals(simpleTypeName)) { propVal = (String) retValue; } else if ("Dscp".equals(simpleTypeName)) { propVal = String.valueOf((short) retValue); @@ -641,6 +642,7 @@ public class MdsalHelper { if (IPV4_ADDRESS.equals(simpleName) || IPV6_ADDRESS.equals(simpleName) || IP_ADDRESS.equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { try { @@ -1007,6 +1009,14 @@ public class MdsalHelper { } return false; } + + private static String getStringValueMethod(String simpleName){ + if (IP_ADDRESS.equals(simpleName) || IP_PREFIX.equals(simpleName)) { + return("stringValue"); + } else { + return("getValue"); + } + } public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { boolean foundValue = false; diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index cf27f9b93..939777597 100755 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -35,14 +35,14 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.exe import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; import org.opendaylight.yang.gen.v1.test.TestObjectBuilder; import org.opendaylight.yang.gen.v1.test.WrapperObj; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -187,13 +187,13 @@ public class MdsalHelperTest extends TestCase { TestObjectBuilder b = new TestObjectBuilder(); MdsalHelper.toBuilder(props, b); - assertEquals(ipAddress,String.valueOf(b.getSingleIp().getValue())); + assertEquals(ipAddress,String.valueOf(b.getSingleIp().stringValue())); ipAddress = "cafe::8888"; props.setProperty("test-object.single-ip", ipAddress); b = new TestObjectBuilder(); MdsalHelper.toBuilder(props, b); - assertEquals(ipAddress,String.valueOf(b.getSingleIp().getValue())); + assertEquals(ipAddress,String.valueOf(b.getSingleIp().stringValue())); } public void testIpAddressListToProperties() throws Exception { @@ -215,7 +215,7 @@ public class MdsalHelperTest extends TestCase { props.setProperty("test-object.floating-ip[0]", ipaddress); TestObjectBuilder b = new TestObjectBuilder(); MdsalHelper.toBuilder(props, b); - assertEquals(ipaddress,String.valueOf(b.getFloatingIp().get(0).getValue())); + assertEquals(ipaddress,String.valueOf(b.getFloatingIp().get(0).stringValue())); props = new Properties(); ipaddress = "cafe::8888"; @@ -223,7 +223,7 @@ public class MdsalHelperTest extends TestCase { props.setProperty("test-object.floating-ip[0]", ipaddress); b = new TestObjectBuilder(); MdsalHelper.toBuilder(props, b); - assertEquals(ipaddress,String.valueOf(b.getFloatingIp().get(0).getValue())); + assertEquals(ipaddress,String.valueOf(b.getFloatingIp().get(0).stringValue())); } diff --git a/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObject.java b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObject.java index d9feaf634..eacfc9f63 100755 --- a/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObject.java +++ b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObject.java @@ -2,9 +2,9 @@ package org.opendaylight.yang.gen.v1.test; import java.util.List; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; public interface TestObject { List getFloatingIp(); diff --git a/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObjectBuilder.java b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObjectBuilder.java index c15615519..8301a0f05 100755 --- a/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObjectBuilder.java +++ b/sli/provider/src/test/java/org/opendaylight/yang/gen/v1/test/TestObjectBuilder.java @@ -2,9 +2,9 @@ package org.opendaylight.yang.gen.v1.test; import java.util.List; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yangtools.concepts.Builder; public class TestObjectBuilder implements Builder { diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 27acbbcee..e8fc29f01 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -1,81 +1,80 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0 - - + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - sli-recording - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sli-recording + 0.4.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. + ccsdk-sli-core :: sli :: ${project.artifactId} + SLI Recording is an OSGi bundle that implements recording service for the service logic record node. - - UTF-8 - ${project.version} - + + UTF-8 + - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - compile - - - org.osgi - org.osgi.core - provided - - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + compile + + + org.osgi + org.osgi.core + provided + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + - - commons-lang - commons-lang - compile - + + commons-lang + commons-lang + compile + - - org.opendaylight.controller - sal-binding-api - + + org.opendaylight.controller + sal-binding-api + - - - junit - junit - test - + + + junit + junit + test + - - org.mockito - mockito-core - test - + + org.mockito + mockito-core + test + - + diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 79042b42d..1f5fd79c9 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,54 +5,18 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - - - ${project.version} - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - + diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index d38db864c..e95a5bab6 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -1,33 +1,29 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0 - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - features-sliPluginUtils - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + features-sliPluginUtils + 0.4.1-SNAPSHOT + feature - ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - - - ${project.version} - + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - - - ${project.groupId} - ccsdk-sliPluginUtils - ${project.version} - xml - features - + + + ${project.groupId} + ccsdk-sliPluginUtils + ${project.version} + xml + features + - + diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 991ac7990..917cc83c4 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 13ef49cdb..b928758b4 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index bebc8a8d7..1857cd1af 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 7e00ef3f0..da5829e09 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -1,73 +1,72 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0 - - + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - sliPluginUtils-provider - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sliPluginUtils-provider + 0.4.1-SNAPSHOT + bundle - ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - http://maven.apache.org + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + http://maven.apache.org - - UTF-8 - ${project.version} - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - junit - junit - test - - - ${project.groupId} - sli-common - ${project.version} - compile - + + UTF-8 + + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + junit + junit + test + + + ${project.groupId} + sli-common + ${project.version} + compile + - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - - - org.apache.commons - commons-lang3 - - - org.hamcrest - hamcrest-library - test - - - com.google.code.gson - gson - - - org.apache.commons - commons-text - 1.1 - - + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + + + org.apache.commons + commons-lang3 + + + org.hamcrest + hamcrest-library + test + + + com.google.code.gson + gson + + + org.apache.commons + commons-text + 1.1 + + diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 9c7e51539..e92fdd004 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,56 +5,18 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - ${project.version} - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - + diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index fb1931d8a..3f925dd28 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -1,33 +1,29 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0 - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - features-sliapi - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + features-sliapi + 0.4.1-SNAPSHOT + feature - ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - ${project.version} - + ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - ${project.groupId} - ccsdk-sliapi - ${project.version} - xml - features - + + + ${project.groupId} + ccsdk-sliapi + ${project.version} + xml + features + - + diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 9ef65fc4e..703d6d1e5 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 48bfee66b..0bd4de3eb 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 913e8ecdc..e7372bf23 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -1,33 +1,29 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0 - - + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - sliapi-model - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sliapi-model + 0.4.1-SNAPSHOT + bundle - ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - ${project.version} - + ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - org.opendaylight.mdsal.model - ietf-inet-types - - - org.opendaylight.mdsal.model - ietf-yang-types - - + + + org.opendaylight.mdsal.model + ietf-inet-types-2013-07-15 + + + org.opendaylight.mdsal.model + ietf-yang-types-20130715 + + diff --git a/sliapi/model/src/main/yang/sliapi.yang b/sliapi/model/src/main/yang/sliapi.yang index f0e79c068..98cbb2aa7 100755 --- a/sliapi/model/src/main/yang/sliapi.yang +++ b/sliapi/model/src/main/yang/sliapi.yang @@ -6,7 +6,7 @@ module SLI-API { prefix sample; - import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; } + import ietf-inet-types { prefix "inet"; revision-date 2013-07-15; } organization "ONAP"; diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 5c8b68f6d..aa04e9cc6 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 0bcf7f75d..fea02dbcf 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,30 +5,26 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} - - ${project.version} - - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + @@ -37,22 +33,40 @@ ${project.version} - - org.opendaylight.controller - sal-binding-config + org.opendaylight.mdsal + mdsal-binding-api - + org.opendaylight.controller sal-binding-api - + + + org.opendaylight.controller + sal-binding-broker-impl + + + + org.opendaylight.mdsal + mdsal-binding-dom-adapter + + + + org.opendaylight.mdsal + yang-binding + + org.opendaylight.controller sal-common-util - + + org.osgi + org.osgi.core + provided + org.onap.ccsdk.sli.core diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index 4817a95a0..7db5941f8 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -29,6 +29,7 @@ import java.util.Enumeration; import java.util.LinkedList; import java.util.Properties; import java.util.concurrent.Future; + import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; @@ -46,10 +47,12 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.Exe import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckInput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckInput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; @@ -75,7 +78,9 @@ import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; /** @@ -215,7 +220,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } @Override - public Future> executeGraph(ExecuteGraphInput input) { + public ListenableFuture> executeGraph(ExecuteGraphInput input) { RpcResult rpcResult = null; SvcLogicService svcLogic = getSvcLogicService(); @@ -395,7 +400,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } @Override - public Future> healthcheck() { + public ListenableFuture> healthcheck(HealthcheckInput healthcheckInput) { RpcResult rpcResult = null; SvcLogicService svcLogic = getSvcLogicService(); @@ -469,6 +474,80 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ return (Futures.immediateFuture(rpcResult)); } + public ListenableFuture> vlbcheck(VlbcheckInput vlbInput) { + + RpcResult rpcResult = null; + SvcLogicService svcLogic = getSvcLogicService(); + + VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder(); + + String calledModule = "sli"; + String calledRpc = "vlbcheck"; + String modeStr = "sync"; + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. failed().withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + respBuilder.setResponseCode("404"); + respBuilder.setResponseMessage("Directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr+" not found"); + + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + } catch (Exception e) { + LOG.error("Caught exception looking for directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr, e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder. failed().withResult(respBuilder.build()).build(); + return(Futures.immediateFuture(rpcResult)); + } + + try { + LOG.info("Calling directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr); + + Properties parms = new Properties(); + + Properties respProps = svcLogic.execute(calledModule, calledRpc, + null, modeStr, parms); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + + calledModule + ":" + calledRpc + "," + modeStr + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder + .setResponseMessage("Internal error : caught exception executing directed graph " + + calledModule + + "/" + + calledRpc + + "/" + + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder. status(true) + .withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + private void DomSaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) { @@ -529,10 +608,11 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException { // Each entry will be identifiable by a unique key, we have to create that identifier + InstanceIdentifier.InstanceIdentifierBuilder testResultIdBuilder = InstanceIdentifier.builder(TestResults.class) - .child(TestResult.class, entry.getKey()); - InstanceIdentifier path = testResultIdBuilder.toInstance(); + .child(TestResult.class, entry.key()); + InstanceIdentifier path = testResultIdBuilder.build(); int tries = 2; while(true) { try { @@ -590,50 +670,5 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } - @Override - public Future> vlbcheck() { - RpcResult rpcResult = null; - VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder(); - boolean suspended = false; - BufferedReader br = null; - String line = ""; - - // check the state based on the config file - - if (sdncStatusFile != null) { - try { - br = new BufferedReader(new FileReader(sdncStatusFile)); - while((line = br.readLine()) != null) - { - if ("ODL_STATE=SUSPENDED".equals(line)) { - suspended = true; - LOG.debug("vlbcheck: server is suspended"); - } - } - br.close(); - } catch (FileNotFoundException e) { - LOG.trace("Caught File not found exception " + sdncStatusFile +"\n",e); - } catch (Exception e) { - LOG.trace("Failed to read status file " + sdncStatusFile +"\n",e); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - LOG.warn("Failed to close status file " + sdncStatusFile +"\n",e); - } - } - } - } - if (suspended) { - rpcResult = RpcResultBuilder.failed().withError(ErrorType.APPLICATION, - "resource-denied", "Server Suspended").build(); - } else { - respBuilder.setResponseMessage("server is normal"); - rpcResult = RpcResultBuilder. status(true) - .withResult(respBuilder.build()).build(); - } - return (Futures.immediateFuture(rpcResult)); - } } diff --git a/sliapi/provider/src/main/yang/sliapi-provider-impl.yang b/sliapi/provider/src/main/yang/sliapi-provider-impl.yang deleted file mode 100755 index 0421ad0c4..000000000 --- a/sliapi/provider/src/main/yang/sliapi-provider-impl.yang +++ /dev/null @@ -1,61 +0,0 @@ -module sliapi-provider-impl { - - yang-version 1; - namespace "org:onap:ccsdk:sli:core:sliapi:provider:impl"; - prefix "sliapi-provider-impl"; - - import config { prefix config; revision-date 2013-04-05; } - import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } - - description - "This module contains the base YANG definitions for - sliapi-provider impl implementation."; - - revision "2014-05-23" { - description - "Initial revision."; - } - - // This is the definition of the service implementation as a module identity. - identity sliapi-provider-impl { - base config:module-type; - - // Specifies the prefix for generated java classes. - config:java-name-prefix sliapiProvider; - } - - // Augments the 'configuration' choice node under modules/module. - // We consume the three main services, RPCs, DataStore, and Notifications - augment "/config:modules/config:module/config:configuration" { - case sliapi-provider-impl { - when "/config:modules/config:module/config:type = 'sliapi-provider-impl'"; - - container rpc-registry { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-rpc-registry; - } - } - } - - container notification-service { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-notification-service; - } - } - } - - container data-broker { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity mdsal:binding-async-data-broker; - } - } - } - } - } -} diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index 96d619331..5106d6fc2 100644 --- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -53,7 +53,9 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckInput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckInput; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; @@ -161,7 +163,7 @@ public class TestSliapiProvider { inputBuilder.setSliParameter(pList); provider.executeGraph(inputBuilder.build()); - assertTrue(provider.vlbcheck() instanceof Future); + assertTrue(provider.vlbcheck(mock(VlbcheckInput.class)) instanceof Future); } /** @@ -170,7 +172,7 @@ public class TestSliapiProvider { */ @Test public void testHealthcheck() { - provider.healthcheck(); + provider.healthcheck(mock(HealthcheckInput.class)); } } diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 7ff4d7682..a4d568805 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,39 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} - - - ${project.version} - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 9981b2cd2..e6adfbc85 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,20 +5,16 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} - - - ${project.version} - diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 33277b88f..daa5cafd0 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index b0c1d4a37..4d2574b2b 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index be130eb50..44b8e9880 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 88983bd84..0ff0efd8c 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,22 +5,16 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} - - - - ${project.version} - - The SLI Core Utilities Package provides common functionality for setting up SLI connectivity. diff --git a/version.properties b/version.properties index ffee02fc4..b1967d0a1 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=4 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 58982ce3d08ed1510daada7d0ecb0792990248d6 Mon Sep 17 00:00:00 2001 From: Driptaroop Das Date: Fri, 1 Feb 2019 12:42:36 +0530 Subject: Junit for EncShellCommand.java Junit for EncShellCommand.java Issue-ID: CCSDK-1016 Change-Id: I7cbdb49b6e04ce6a69a48f9a507c7db959698140 Signed-off-by: Driptaroop Das --- .../ccsdk/sli/core/dblib/EncShellCommandTest.java | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java new file mode 100644 index 000000000..740e69dba --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java @@ -0,0 +1,41 @@ +package org.onap.ccsdk.sli.core.dblib; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Arrays; + +import static org.junit.Assert.*; + +public class EncShellCommandTest { + + private final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + private final ByteArrayOutputStream errContent = new ByteArrayOutputStream(); + private final PrintStream originalOut = System.out; + private final PrintStream originalErr = System.err; + + @Before + public void setUp() { + System.setOut(new PrintStream(outContent)); + System.setErr(new PrintStream(errContent)); + } + + @After + public void tearDown() { + System.setOut(originalOut); + System.setErr(originalErr); + } + + @Test + public void testDoExecute() throws Exception { + String expected = "Original value: test" + System.getProperty("line.separator") + + "Encrypted value: test"; + EncShellCommand encShellCommand = new EncShellCommand(); + encShellCommand.arg = "test"; + encShellCommand.doExecute(); + assertEquals(expected.trim(), outContent.toString().trim()); + } +} \ No newline at end of file -- cgit 1.2.3-korg From 66879d0c4c73b9cd371cdffec3a56f25c340a100 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 1 Feb 2019 15:45:52 -0500 Subject: Hack to force classloader t find mariadb driver Container is not coming up because dblib is getting ClassNotFoundException for mariadb driver, even though it is installed. To correct this temporarily, updated code to explicitly create a driver object. Change-Id: I210d042be2c71a4392781ad26f858c916dbd7364 Issue-ID: CCSDK-489 Signed-off-by: Timoney, Dan (dt5972) --- .../main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 9d797d096..0b8c565f1 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -24,6 +24,7 @@ package org.onap.ccsdk.sli.core.dblib; import java.io.PrintWriter; import java.sql.Connection; +import java.sql.Driver; import java.sql.SQLDataException; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; @@ -92,6 +93,12 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb public DBResourceManager(final Properties properties) { this.configProps = properties; + + // TODO : hack to force classloader to cache mariadb driver. This shouldnt be necessary, + // but for some reason it is (without this, dblib throws ClassNotFound on mariadb driver + // and fails to load). + Driver dvr = new org.mariadb.jdbc.Driver(); + dvr = null; // get retry interval value retryInterval = getLongFromProperties(properties, "org.onap.dblib.connection.retry", 10000L); -- cgit 1.2.3-korg From 484f1b32f1ef9cfcf74189b701ebb9078ddb0ab8 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 5 Feb 2019 11:17:44 -0500 Subject: Add dummy input Fluorine version of restconf does not handle RPCs with no input correctly. So, need to work around that by defining dummy input for SLI-API vlbcheck and healthcheck APIs Change-Id: I6a78a899937e1bb9bd7674530166a493875ca3bf Issue-ID: CCSDK-1035 Signed-off-by: Timoney, Dan (dt5972) --- .../org/onap/ccsdk/sli/core/dblib/DBResourceManager.java | 1 + sliapi/model/src/main/yang/sliapi.yang | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 0b8c565f1..236bce6e3 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -97,6 +97,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb // TODO : hack to force classloader to cache mariadb driver. This shouldnt be necessary, // but for some reason it is (without this, dblib throws ClassNotFound on mariadb driver // and fails to load). + LOGGER.info("Creating dummy instance of org.mariadb.jdbc.Driver"); Driver dvr = new org.mariadb.jdbc.Driver(); dvr = null; diff --git a/sliapi/model/src/main/yang/sliapi.yang b/sliapi/model/src/main/yang/sliapi.yang index 98cbb2aa7..b3272be80 100755 --- a/sliapi/model/src/main/yang/sliapi.yang +++ b/sliapi/model/src/main/yang/sliapi.yang @@ -103,12 +103,25 @@ module SLI-API { } rpc healthcheck { + // OpenDaylight Fluorine version of restconf cannot handle RPCs with no input + input { + leaf dummy { + type string; + } + } output { uses response-fields; } } rpc vlbcheck { + // OpenDaylight Fluorine version of restconf cannot handle RPCs with no input + input { + leaf dummy + { + type string; + } + } output { uses response-fields; } -- cgit 1.2.3-korg From 3a545c5661231298ca2b62a96001294174b12835 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 13 Feb 2019 12:07:44 -0500 Subject: Restore default vlbcheck RPC Restore default implementation of vlbcheck in case where no DG exists. Change-Id: I6371e8e26e14e66bf252ee8d1f08d18101b290f5 Issue-ID: CCSDK-1064 Signed-off-by: Timoney, Dan (dt5972) --- .../onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 553 +++++++++++---------- 1 file changed, 278 insertions(+), 275 deletions(-) diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java index 7db5941f8..20cbc2e0f 100644 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java @@ -82,51 +82,51 @@ import org.slf4j.LoggerFactory; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; - /** - * Defines a base implementation for your provider. This class extends from a helper class - * which provides storage for the most commonly used components of the MD-SAL. Additionally the - * base class provides some basic logging and initialization / clean up methods. + * Defines a base implementation for your provider. This class extends from a + * helper class which provides storage for the most commonly used components of + * the MD-SAL. Additionally the base class provides some basic logging and + * initialization / clean up methods. * - * To use this, copy and paste (overwrite) the following method into the TestApplicationProviderModule - * class which is auto generated under src/main/java in this project - * (created only once during first compilation): + * To use this, copy and paste (overwrite) the following method into the + * TestApplicationProviderModule class which is auto generated under + * src/main/java in this project (created only once during first compilation): * *
    -
    -    @Override
    -    public java.lang.AutoCloseable createInstance() {
    -
    -         final sliapiProvider provider = new sliapiProvider();
    -         provider.setDataBroker( getDataBrokerDependency() );
    -         provider.setNotificationService( getNotificationServiceDependency() );
    -         provider.setRpcRegistry( getRpcRegistryDependency() );
    -         provider.initialize();
    -         return new AutoCloseable() {
    -
    -            @Override
    -            public void close() throws Exception {
    -                //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION
    -                //SERVIE/RPC REGISTRY
    -                provider.close();
    -            }
    -        };
    -    }
    -
    -
    -    
    + * + * @Override + * public java.lang.AutoCloseable createInstance() { + * + * final sliapiProvider provider = new sliapiProvider(); + * provider.setDataBroker(getDataBrokerDependency()); + * provider.setNotificationService(getNotificationServiceDependency()); + * provider.setRpcRegistry(getRpcRegistryDependency()); + * provider.initialize(); + * return new AutoCloseable() { + * + * @Override + * public void close() throws Exception { + * // TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE + * // BROKER/NOTIFICATION + * // SERVIE/RPC REGISTRY + * provider.close(); + * } + * }; + * } + * + * */ -public class sliapiProvider implements AutoCloseable, SLIAPIService{ +public class sliapiProvider implements AutoCloseable, SLIAPIService { - private static final Logger LOG = LoggerFactory.getLogger( sliapiProvider.class ); - private static final String appName = "slitester"; + private static final Logger LOG = LoggerFactory.getLogger(sliapiProvider.class); + private static final String appName = "slitester"; - protected DataBroker dataBroker; - protected DOMDataBroker domDataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; + protected DataBroker dataBroker; + protected DOMDataBroker domDataBroker; + protected NotificationPublishService notificationService; + protected RpcProviderRegistry rpcRegistry; - private SvcLogicService svcLogic; + private SvcLogicService svcLogic; protected BindingAwareBroker.RpcRegistration rpcRegistration; @@ -139,7 +139,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ private static QName TEST_RESULT_QNAME = null; private static QName TEST_ID_QNAME = null; private static QName RESULTS_QNAME = null; - private static final String NON_NULL= "non-null"; + private static final String NON_NULL = "non-null"; static { @@ -149,75 +149,67 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ RESULTS_QNAME = QName.create(TEST_RESULT_QNAME, "results"); } - public sliapiProvider( - DataBroker dataBroker, - NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry) { - this(dataBroker, notificationPublishService, rpcProviderRegistry, findSvcLogicService()); - } - - public sliapiProvider( - DataBroker dataBroker, - NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry, - SvcLogicService svcLogic) { - this.LOG.info( "Creating provider for " + appName ); - this.dataBroker = dataBroker; - this.notificationService = notificationPublishService; - this.rpcRegistry = rpcProviderRegistry; - this.svcLogic = svcLogic; - initialize(); - } - - - - public void initialize(){ - LOG.info( "Initializing provider for " + appName ); - //initialization code goes here. - rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); - - sdncStatusFile = System.getenv(SDNC_STATUS_FILE); - LOG.info( "SDNC STATUS FILE = " + sdncStatusFile ); - LOG.info( "Initialization complete for " + appName ); - } - - protected void initializeChild() { - //Override if you have custom initialization intelligence - } - - @Override - public void close() throws Exception { - LOG.info( "Closing provider for " + appName ); - //closing code goes here - - rpcRegistration.close(); - LOG.info( "Successfully closed provider for " + appName ); - } - - public void setDataBroker(DataBroker dataBroker) { - this.dataBroker = dataBroker; + public sliapiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry) { + this(dataBroker, notificationPublishService, rpcProviderRegistry, findSvcLogicService()); + } + + public sliapiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry, SvcLogicService svcLogic) { + this.LOG.info("Creating provider for " + appName); + this.dataBroker = dataBroker; + this.notificationService = notificationPublishService; + this.rpcRegistry = rpcProviderRegistry; + this.svcLogic = svcLogic; + initialize(); + } + + public void initialize() { + LOG.info("Initializing provider for " + appName); + // initialization code goes here. + rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); + + sdncStatusFile = System.getenv(SDNC_STATUS_FILE); + LOG.info("SDNC STATUS FILE = " + sdncStatusFile); + LOG.info("Initialization complete for " + appName); + } + + protected void initializeChild() { + // Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + LOG.info("Closing provider for " + appName); + // closing code goes here + + rpcRegistration.close(); + LOG.info("Successfully closed provider for " + appName); + } + + public void setDataBroker(DataBroker dataBroker) { + this.dataBroker = dataBroker; if (dataBroker instanceof AbstractForwardedDataBroker) { domDataBroker = ((AbstractForwardedDataBroker) dataBroker).getDelegate(); } - if( LOG.isDebugEnabled() ){ - LOG.debug( "DataBroker set to " + (dataBroker==null?"null":NON_NULL) + "." ); - } - } - - public void setNotificationService( - NotificationPublishService notificationService) { - this.notificationService = notificationService; - if( LOG.isDebugEnabled() ){ - LOG.debug( "Notification Service set to " + (notificationService==null?"null":NON_NULL) + "." ); - } - } - - public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { - this.rpcRegistry = rpcRegistry; - if( LOG.isDebugEnabled() ){ - LOG.debug( "RpcRegistry set to " + (rpcRegistry==null?"null":NON_NULL) + "." ); - } - } + if (LOG.isDebugEnabled()) { + LOG.debug("DataBroker set to " + (dataBroker == null ? "null" : NON_NULL) + "."); + } + } + + public void setNotificationService(NotificationPublishService notificationService) { + this.notificationService = notificationService; + if (LOG.isDebugEnabled()) { + LOG.debug("Notification Service set to " + (notificationService == null ? "null" : NON_NULL) + "."); + } + } + + public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { + this.rpcRegistry = rpcRegistry; + if (LOG.isDebugEnabled()) { + LOG.debug("RpcRegistry set to " + (rpcRegistry == null ? "null" : NON_NULL) + "."); + } + } @Override public ListenableFuture> executeGraph(ExecuteGraphInput input) { @@ -240,29 +232,31 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); respBuilder.setAckFinalIndicator("Y"); - rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); } - try { if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { respBuilder.setResponseCode("404"); - respBuilder.setResponseMessage("Directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr+" not found"); + respBuilder.setResponseMessage( + "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); respBuilder.setAckFinalIndicator("Y"); - rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); } } catch (Exception e) { - LOG.error("Caught exception looking for directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr, e); + LOG.error( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); respBuilder.setResponseCode("500"); respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); respBuilder.setAckFinalIndicator("Y"); - rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); } // Load properties @@ -297,7 +291,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ SliapiHelper.toProperties(parms, "input", inputBuilder); try { - LOG.info("Calling directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr); + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); if (LOG.isTraceEnabled()) { StringBuffer argList = new StringBuffer(); @@ -305,24 +299,22 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ Enumeration e = parms.propertyNames(); while (e.hasMoreElements()) { String propName = (String) e.nextElement(); - argList.append(" ("+propName+","+parms.getProperty(propName)+") "); + argList.append(" (" + propName + "," + parms.getProperty(propName) + ") "); } argList.append("}"); LOG.trace(argList.toString()); argList = null; } - - - Properties respProps = svcLogic.execute(calledModule, calledRpc, - null, modeStr, parms, domDataBroker); + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms, domDataBroker); StringBuilder sb = new StringBuilder("{"); for (Object key : respProps.keySet()) { String keyValue = (String) key; if (keyValue != null && !"".equals(keyValue) && !keyValue.contains("input.sli-parameter")) { - sb.append("\"").append(keyValue).append("\": \"").append(respProps.getProperty(keyValue)).append("\","); + sb.append("\"").append(keyValue).append("\": \"").append(respProps.getProperty(keyValue)) + .append("\","); } } @@ -330,7 +322,9 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ sb.append("}"); respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); - respBuilder.setResponseMessage(respProps.getProperty("error-message", ""));// TODO change response-text to response-message to match other BVC APIs + respBuilder.setResponseMessage(respProps.getProperty("error-message", ""));// TODO change response-text to + // response-message to match + // other BVC APIs respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); respBuilder.setContextMemoryJson(sb.toString()); @@ -343,60 +337,51 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ if ((testIdentifier != null) && (testIdentifier.length() > 0)) { // Add test results to config tree - LOG.debug("Saving test results for test id "+testIdentifier); + LOG.debug("Saving test results for test id " + testIdentifier); DomSaveTestResult(testResultBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); } } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" - + calledModule + ":" + calledRpc + "," + modeStr + ">", e); + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr + + ">", e); respBuilder.setResponseCode("500"); - respBuilder - .setResponseMessage("Internal error : caught exception executing directed graph " - + calledModule - + "/" - + calledRpc - + "/" - + modeStr); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule + + "/" + calledRpc + "/" + modeStr); respBuilder.setAckFinalIndicator("Y"); } - rpcResult = RpcResultBuilder. status(true) - .withResult(respBuilder.build()).build(); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); return (Futures.immediateFuture(rpcResult)); } - private SvcLogicService getSvcLogicService() { - if (svcLogic == null) { - svcLogic = findSvcLogicService(); - } + if (svcLogic == null) { + svcLogic = findSvcLogicService(); + } - return(svcLogic); + return (svcLogic); } + private static SvcLogicService findSvcLogicService() { BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext(); SvcLogicService svcLogic = null; - // Get SvcLogicService reference + // Get SvcLogicService reference ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME); - if (sref != null) - { - svcLogic = (SvcLogicService) bctx.getService(sref); + if (sref != null) { + svcLogic = (SvcLogicService) bctx.getService(sref); - } - else - { - LOG.warn("Cannot find service reference for "+SvcLogicService.NAME); + } else { + LOG.warn("Cannot find service reference for " + SvcLogicService.NAME); } - return(svcLogic); + return (svcLogic); } @Override @@ -416,61 +401,57 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); respBuilder.setAckFinalIndicator("Y"); - rpcResult = RpcResultBuilder. failed().withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); } try { if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { respBuilder.setResponseCode("404"); - respBuilder.setResponseMessage("Directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr+" not found"); + respBuilder.setResponseMessage( + "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); respBuilder.setAckFinalIndicator("Y"); - rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); } } catch (Exception e) { - LOG.error("Caught exception looking for directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr, e); + LOG.error( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); respBuilder.setResponseCode("500"); respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); respBuilder.setAckFinalIndicator("Y"); - rpcResult = RpcResultBuilder. failed().withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); } try { - LOG.info("Calling directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr); + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); Properties parms = new Properties(); - Properties respProps = svcLogic.execute(calledModule, calledRpc, - null, modeStr, parms); + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" - + calledModule + ":" + calledRpc + "," + modeStr + ">", e); + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr + + ">", e); respBuilder.setResponseCode("500"); - respBuilder - .setResponseMessage("Internal error : caught exception executing directed graph " - + calledModule - + "/" - + calledRpc - + "/" - + modeStr); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule + + "/" + calledRpc + "/" + modeStr); respBuilder.setAckFinalIndicator("Y"); } - rpcResult = RpcResultBuilder. status(true) - .withResult(respBuilder.build()).build(); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); return (Futures.immediateFuture(rpcResult)); } @@ -490,67 +471,93 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); respBuilder.setAckFinalIndicator("Y"); - rpcResult = RpcResultBuilder. failed().withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); } + boolean dgExists = true; try { if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { - respBuilder.setResponseCode("404"); - respBuilder.setResponseMessage("Directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr+" not found"); - - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder. status(true).withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + dgExists = false; } } catch (Exception e) { - LOG.error("Caught exception looking for directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr, e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); - respBuilder.setAckFinalIndicator("Y"); + LOG.warn( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); - rpcResult = RpcResultBuilder. failed().withResult(respBuilder.build()).build(); - return(Futures.immediateFuture(rpcResult)); + dgExists = false; } - try { - LOG.info("Calling directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr); + if (dgExists) { + try { + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); - Properties parms = new Properties(); + Properties parms = new Properties(); - Properties respProps = svcLogic.execute(calledModule, calledRpc, - null, modeStr, parms); + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); - respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); - respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); - respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); - } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" - + calledModule + ":" + calledRpc + "," + modeStr + ">", e); + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + + modeStr + ">", e); - respBuilder.setResponseCode("500"); - respBuilder - .setResponseMessage("Internal error : caught exception executing directed graph " - + calledModule - + "/" - + calledRpc - + "/" - + modeStr); - respBuilder.setAckFinalIndicator("Y"); + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + + calledModule + "/" + calledRpc + "/" + modeStr); + respBuilder.setAckFinalIndicator("Y"); - } + } - rpcResult = RpcResultBuilder. status(true) - .withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } else { + // check the state based on the config file + + boolean suspended = false; + BufferedReader br = null; + String line = ""; + + if (sdncStatusFile != null) { + try { + br = new BufferedReader(new FileReader(sdncStatusFile)); + while ((line = br.readLine()) != null) { + if ("ODL_STATE=SUSPENDED".equals(line)) { + suspended = true; + LOG.debug("vlbcheck: server is suspended"); + } + } + br.close(); + } catch (FileNotFoundException e) { + LOG.trace("Caught File not found exception " + sdncStatusFile + "\n", e); + } catch (Exception e) { + LOG.trace("Failed to read status file " + sdncStatusFile + "\n", e); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + LOG.warn("Failed to close status file " + sdncStatusFile + "\n", e); + } + } + } + } + + if (suspended) { + rpcResult = RpcResultBuilder.failed() + .withError(ErrorType.APPLICATION, "resource-denied", "Server Suspended").build(); + } else { + respBuilder.setResponseMessage("server is normal"); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + } + return (Futures.immediateFuture(rpcResult)); + } } private void DomSaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) { - if (domDataBroker == null) { LOG.error("domDataBroker unset - cannot save test result using DOMDataBroker"); return; @@ -569,29 +576,28 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ return; } - - YangInstanceIdentifier testResultsPid = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME).node(QName.create(TEST_RESULTS_QNAME, "test-result")).build(); - YangInstanceIdentifier testResultPid = testResultsPid.node(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, resultNode.getIdentifier().getKeyValues())); - - + YangInstanceIdentifier testResultsPid = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) + .node(QName.create(TEST_RESULTS_QNAME, "test-result")).build(); + YangInstanceIdentifier testResultPid = testResultsPid + .node(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, resultNode.getIdentifier().getKeyValues())); int tries = 2; - while(true) { + while (true) { try { DOMDataWriteTransaction wtx = domDataBroker.newWriteOnlyTransaction(); if (merge) { - LOG.info("Merging test identifier "+entry.getTestIdentifier()); + LOG.info("Merging test identifier " + entry.getTestIdentifier()); wtx.merge(storeType, testResultPid, resultNode); } else { - LOG.info("Putting test identifier "+entry.getTestIdentifier()); - wtx.put(storeType, testResultPid, resultNode); + LOG.info("Putting test identifier " + entry.getTestIdentifier()); + wtx.put(storeType, testResultPid, resultNode); } wtx.submit().checkedGet(); LOG.trace("Update DataStore succeeded"); break; } catch (final TransactionCommitFailedException e) { - if(e instanceof OptimisticLockFailedException) { - if(--tries <= 0) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { LOG.trace("Got OptimisticLockFailedException on last try - failing "); throw new IllegalStateException(e); } @@ -605,70 +611,67 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } - private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException - { - // Each entry will be identifiable by a unique key, we have to create that identifier - - InstanceIdentifier.InstanceIdentifierBuilder testResultIdBuilder = - InstanceIdentifier.builder(TestResults.class) - .child(TestResult.class, entry.key()); - InstanceIdentifier path = testResultIdBuilder.build(); - int tries = 2; - while(true) { - try { - WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); - if (merge) { - tx.merge(storeType, path, entry); - } else { - tx.put(storeType, path, entry); - } - tx.submit().checkedGet(); - LOG.trace("Update DataStore succeeded"); - break; - } catch (final TransactionCommitFailedException e) { - if(e instanceof OptimisticLockFailedException) { - if(--tries <= 0) { - LOG.trace("Got OptimisticLockFailedException on last try - failing "); - throw new IllegalStateException(e); - } - LOG.trace("Got OptimisticLockFailedException - trying again "); - } else { - LOG.trace("Update DataStore failed"); + private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) + throws IllegalStateException { + // Each entry will be identifiable by a unique key, we have to create that + // identifier + + InstanceIdentifier.InstanceIdentifierBuilder testResultIdBuilder = InstanceIdentifier + .builder(TestResults.class).child(TestResult.class, entry.key()); + InstanceIdentifier path = testResultIdBuilder.build(); + int tries = 2; + while (true) { + try { + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); + if (merge) { + tx.merge(storeType, path, entry); + } else { + tx.put(storeType, path, entry); + } + tx.submit().checkedGet(); + LOG.trace("Update DataStore succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + LOG.trace("Got OptimisticLockFailedException on last try - failing "); throw new IllegalStateException(e); } + LOG.trace("Got OptimisticLockFailedException - trying again "); + } else { + LOG.trace("Update DataStore failed"); + throw new IllegalStateException(e); } } } + } - private MapEntryNode toMapEntryNode(TestResult testResult) { - - - YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME).node(TEST_RESULT_QNAME).build(); - - // Construct results list - LinkedList> entryList = new LinkedList<>(); - for (String result : testResult.getResults()) { - LeafSetEntryNode leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create() - .withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result)) - .withValue(result) - .build(); - entryList.add(leafSetEntryNode); - } - // Construct results LeafSetNode - LeafSetNode resultsNode = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(RESULTS_QNAME)).withValue(entryList).build(); - + private MapEntryNode toMapEntryNode(TestResult testResult) { + YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) + .node(TEST_RESULT_QNAME).build(); - // Construct test result ContainerNode with 2 children - test-identifier leaf and results leaf-set - MapEntryNode testResultNode = ImmutableNodes.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, TEST_ID_QNAME, testResult.getTestIdentifier())) - .withChild(ImmutableNodes.leafNode(TEST_ID_QNAME, testResult.getTestIdentifier())) - .withChild(resultsNode) - .build(); + // Construct results list + LinkedList> entryList = new LinkedList<>(); + for (String result : testResult.getResults()) { + LeafSetEntryNode leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create() + .withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result)).withValue(result).build(); + entryList.add(leafSetEntryNode); + } + // Construct results LeafSetNode + LeafSetNode resultsNode = ImmutableLeafSetNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(RESULTS_QNAME)).withValue(entryList).build(); - return(testResultNode); + // Construct test result ContainerNode with 2 children - test-identifier leaf + // and results leaf-set + MapEntryNode testResultNode = ImmutableNodes.mapEntryBuilder() + .withNodeIdentifier(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, TEST_ID_QNAME, + testResult.getTestIdentifier())) + .withChild(ImmutableNodes.leafNode(TEST_ID_QNAME, testResult.getTestIdentifier())) + .withChild(resultsNode).build(); - } + return (testResultNode); + } } -- cgit 1.2.3-korg From 23ff887d1e61e490b48f735a49c434d50efa1639 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 20 Feb 2019 20:10:35 -0500 Subject: Increase code coverage Added junit test cases, and updated jacoco config in provider/base to include provider tests as well Change-Id: I8f384b3a4dd7362f004eaa959cd0c634edf0ddbe Issue-ID: CCSDK-1096 Signed-off-by: Timoney, Dan (dt5972) --- .../sli/core/dblib/TestDBResourceManager2.java | 95 ++++++++++++++++++++++ .../ccsdk/sli/core/sli/PrintYangToPropTest.java | 59 +++++++++++++- sli/model/src/main/yang/sliapi.yang | 6 ++ sli/provider-base/pom.xml | 7 +- .../sli/core/sli/provider/MdsalHelperTest.java | 15 ++++ 5 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager2.java diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager2.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager2.java new file mode 100644 index 000000000..a3cb8d914 --- /dev/null +++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager2.java @@ -0,0 +1,95 @@ +/*- + 2 * ============LICENSE_START======================================================= + 3 * ONAP CCSDK + 4 * ================================================================================ + 5 * Copyright (C) 2019 AT&T Intellectual Property. All rights + 6 * reserved. + 7 * ================================================================================ + 8 * Licensed under the Apache License, Version 2.0 (the "License"); + 9 * you may not use this file except in compliance with the License. + 10 * You may obtain a copy of the License at + 11 * + 12 * http://www.apache.org/licenses/LICENSE-2.0 + 13 * + 14 * Unless required by applicable law or agreed to in writing, software + 15 * distributed under the License is distributed on an "AS IS" BASIS, + 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + 17 * See the License for the specific language governing permissions and + 18 * limitations under the License. + 19 * ============LICENSE_END============================================ + 20 * =================================================================== + 21 * + 22 */ +package org.onap.ccsdk.sli.core.dblib; + +import static org.junit.Assert.*; + +import java.io.InputStream; +import java.net.URL; +import java.sql.SQLException; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; + +import ch.vorburger.mariadb4j.DB; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; + +public class TestDBResourceManager2 { + + DbLibService dblibSvc; + DBResourceManager dbm; + + @Before + public void setUp() throws Exception { + URL propUrl = getClass().getResource("/dblib.properties"); + + InputStream propStr = getClass().getResourceAsStream("/dblib.properties"); + + Properties props = new Properties(); + + props.load(propStr); + + // Start MariaDB4j database + DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder(); + config.setPort(0); // 0 => autom. detect free port + DB db = DB.newEmbeddedDB(config.build()); + db.start(); + + // Override jdbc URL, database name, and recovery + props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test"); + props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test")); + props.setProperty("org.onap.dblib.connection.recovery", "true"); + + + dblibSvc = new DBResourceManager(props); + dbm = new DBResourceManager(props); + dblibSvc.writeData("CREATE TABLE DBLIB_TEST2 (name varchar(20));", null, null); + dblibSvc.getData("SELECT * FROM DBLIB_TEST2", null, null); + + + } + + @Test + public void testForceRecovery() { + dbm.testForceRecovery(); + } + + @Test + public void testGetConnection() throws SQLException { + assertNotNull(dbm.getConnection()); + assertNotNull(dbm.getConnection("testUser", "testPaswd")); + } + + @Test + public void testCleanup() { + dbm.cleanUp(); + + } + + @Test + public void testGetLogWriter() throws SQLException { + assertNull(dbm.getLogWriter()); + } + +} diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java index d639c28dc..14b4dcb76 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java @@ -1,6 +1,25 @@ -/** - * - */ +/*- + 2 * ============LICENSE_START======================================================= + 3 * ONAP CCSDK + 4 * ================================================================================ + 5 * Copyright (C) 2019 AT&T Intellectual Property. All rights + 6 * reserved. + 7 * ================================================================================ + 8 * Licensed under the Apache License, Version 2.0 (the "License"); + 9 * you may not use this file except in compliance with the License. + 10 * You may obtain a copy of the License at + 11 * + 12 * http://www.apache.org/licenses/LICENSE-2.0 + 13 * + 14 * Unless required by applicable law or agreed to in writing, software + 15 * distributed under the License is distributed on an "AS IS" BASIS, + 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + 17 * See the License for the specific language governing permissions and + 18 * limitations under the License. + 19 * ============LICENSE_END============================================ + 20 * =================================================================== + 21 * + 22 */ package org.onap.ccsdk.sli.core.sli; import java.util.Enumeration; @@ -11,8 +30,11 @@ import java.util.Properties; import org.junit.Test; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResultsBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; import org.slf4j.Logger; @@ -82,7 +104,38 @@ public class PrintYangToPropTest { // Generate builder from properties just generated PrintYangToProp.toBuilder(props, pBuilder); + } + + @Test + public void testWithList() { + TestResultsBuilder resultsBuilder = new TestResultsBuilder(); + TestResultBuilder resultBuilder = new TestResultBuilder(); + + // Set builder with values + List resultList = new LinkedList<>(); + resultBuilder.setTestIdentifier("test1"); + List results = new LinkedList<>(); + results.add("pass"); + resultBuilder.setResults(results); + resultList.add(resultBuilder.build()); + resultsBuilder.setTestResult(resultList); + + // Generate properties + Properties props = new Properties(); + props = PrintYangToProp.toProperties(props, resultsBuilder); + + Enumeration propNames = props.propertyNames(); + + while (propNames.hasMoreElements()) { + String propName = (String) propNames.nextElement(); + LOG.info("Property {} = {}", propName, props.getProperty(propName)); + } + + // Generate builder from properties just generated + PrintYangToProp.toBuilder(props, resultsBuilder); + + } } diff --git a/sli/model/src/main/yang/sliapi.yang b/sli/model/src/main/yang/sliapi.yang index 19adecca9..a7d52928b 100755 --- a/sli/model/src/main/yang/sliapi.yang +++ b/sli/model/src/main/yang/sliapi.yang @@ -45,6 +45,12 @@ module SLI-API { leaf ipprefix-value { type inet:ip-prefix; } + leaf port-number { + type inet:port-number; + } + leaf dscp { + type inet:dscp; + } } grouping response-fields { diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 0b6dfff44..856ee238a 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -12,6 +12,11 @@ org.onap.ccsdk.sli.core sli-provider-base 0.4.1-SNAPSHOT + + + + target/code-coverage/jacoco-ut.exec,target/code-coverage/jacoco-it.exec,../provider/target/code-coverage/jacoco-ut.exec,../provider/target/code-coverage/jacoco-it.exec + @@ -30,7 +35,6 @@ ${project.version} compile - org.slf4j slf4j-api @@ -56,4 +60,5 @@ + diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index 939777597..56d0369e2 100755 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -94,6 +94,21 @@ public class MdsalHelperTest extends TestCase { parmBuilder.setParameterName("ipaddress6-parm"); parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1")); params.add(parmBuilder.build()); + + parmBuilder.setParameterName("ipprefix-parm"); + parmBuilder.setIpaddressValue(null); + parmBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("10.0.0.0/24")); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("portnumber-parm"); + parmBuilder.setIpprefixValue(null); + parmBuilder.setPortNumber(PortNumber.getDefaultInstance("8080")); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("dcsp-parm"); + parmBuilder.setPortNumber(null); + parmBuilder.setDscp(Dscp.getDefaultInstance("57")); + params.add(parmBuilder.build()); execBuilder.setMode(Mode.Sync); execBuilder.setModuleName("my-module"); -- cgit 1.2.3-korg From 76cd2593032c578b0af9fe089cf6431c7a2060d4 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 5 Mar 2019 12:06:50 -0500 Subject: Add junit test cases Add junit test cases for sli/core repository. Change-Id: Ifcec596cf9f835249a7967c9c7830253b53d2ef6 Issue-ID: CCSDK-1128 Signed-off-by: Timoney, Dan (dt5972) --- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 15 ++++++++++ .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 32 +++++++++++++++++++++- .../src/test/resources/simplelogger.properties | 23 ++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 sliapi/provider/src/test/resources/simplelogger.properties diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index f5cbf50b0..6f303a598 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -112,6 +112,21 @@ public class ITCaseSvcLogicParser { if (testCaseUrl == null) { fail("Could not resolve test case file " + testCaseFile); } + + // Test parsing and printing + try { + SvcLogicParser parser = new SvcLogicParser(); + + for (SvcLogicGraph graph : parser.parse(testCaseUrl.getPath())) { + System.out.println("XML for graph "+graph.getModule()+":"+graph.getRpc()); + graph.printAsXml(System.out); + System.out.println("GV for graph "+graph.getModule()+":"+graph.getRpc()); + graph.printAsGv(System.out); + } + } catch (Exception e) { + + fail("Validation failure [" + e.getMessage() + "]"); + } try { SvcLogicParser.load(testCaseUrl.getPath(), store); diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index 5106d6fc2..0326429c9 100644 --- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -152,6 +152,7 @@ public class TestSliapiProvider { public void testExecuteGraph() { ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder(); + // Valid test - graph exists inputBuilder.setMode(ExecuteGraphInput.Mode.Sync); inputBuilder.setModuleName("sli"); inputBuilder.setRpcName("healthcheck"); @@ -160,9 +161,38 @@ public class TestSliapiProvider { pBuilder.setParameterName("int-parameter"); pBuilder.setIntValue(1); pList.add(pBuilder.build()); + pBuilder.setParameterName("bool-parameter"); + pBuilder.setIntValue(null); + pBuilder.setBooleanValue(true); + pList.add(pBuilder.build()); + pBuilder.setParameterName("str-parameter"); + pBuilder.setBooleanValue(null); + pBuilder.setStringValue("value"); + pList.add(pBuilder.build()); + inputBuilder.setSliParameter(pList); + provider.executeGraph(inputBuilder.build()); + + + // Invalid test - graph does not exist + inputBuilder.setMode(ExecuteGraphInput.Mode.Sync); + inputBuilder.setModuleName("sli"); + inputBuilder.setRpcName("no-such-graph"); + pList = new LinkedList<>(); + pBuilder = new SliParameterBuilder(); + pBuilder.setParameterName("int-parameter"); + pBuilder.setIntValue(1); + pList.add(pBuilder.build()); + pBuilder.setParameterName("bool-parameter"); + pBuilder.setIntValue(null); + pBuilder.setBooleanValue(true); + pList.add(pBuilder.build()); + pBuilder.setParameterName("str-parameter"); + pBuilder.setBooleanValue(null); + pBuilder.setStringValue("value"); + pList.add(pBuilder.build()); inputBuilder.setSliParameter(pList); - provider.executeGraph(inputBuilder.build()); + assertTrue(provider.vlbcheck(mock(VlbcheckInput.class)) instanceof Future); } diff --git a/sliapi/provider/src/test/resources/simplelogger.properties b/sliapi/provider/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..417c4d143 --- /dev/null +++ b/sliapi/provider/src/test/resources/simplelogger.properties @@ -0,0 +1,23 @@ +### +# ============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.slf4j.simpleLogger.defaultLogLevel=info +org.slf4j.simplelogger.log.org.onap.ccsdk.sli.core.sliapi.sliapiProvider=debug -- cgit 1.2.3-korg From a0a84c54fb9f3ba8f0f7a6b501fa8b4f8eb9c3bc Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 14 Mar 2019 10:35:03 -0400 Subject: Prepare for release 0.4.1 Prepare to create release version 0.4.1 by using released version of parent pom Change-Id: If211c26cdbb7caa9033b511a9719851f9edcfcdc Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/ccsdk-slicore-utils/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 47 files changed, 47 insertions(+), 47 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 9777c8085..b9ac33953 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 4fd1bc785..9cfa6cf55 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 011e99040..bfe8e6bf0 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 103f8fe85..c71dfd57c 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index d094a0e95..331b8691a 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/dblib/pom.xml b/dblib/pom.xml index 753f6aff5..05032631a 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 9cda7ab1f..f90c475ec 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 584a579d9..594849bae 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 583bafb44..510caa190 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index e839272fc..4009313b3 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/features/pom.xml b/features/pom.xml index 255c84c19..88c08b00f 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index e032c735f..bcbc220ac 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 393ddbae3..36346b687 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 0eec257f3..77c42bc4d 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 91c932c08..c720fa69e 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/filters/pom.xml b/filters/pom.xml index 486d63019..2ebfd1f64 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index fb8d2b9ad..a840505c6 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/pom.xml b/pom.xml index 353623266..f66f391f6 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 4d1440064..fa160010d 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 85860a77a..bb092cff1 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 31ef0dde4..542237526 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index f19d363bf..b2a1bc9f8 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index d8b62a3f3..da03897a9 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index cae0a483a..2781ce44b 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/pom.xml b/sli/pom.xml index db20f5656..02505f1e5 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 856ee238a..8e4d36c27 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index f367cd83f..d06fc62ae 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index e8fc29f01..b5df586ec 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 1f5fd79c9..026934711 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index e95a5bab6..836f9c923 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 917cc83c4..ded3817ef 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index b928758b4..3a8dbd5e6 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 1857cd1af..b8dfa2a29 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index da5829e09..f7cc0fffd 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index e92fdd004..9ea68b262 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 3f925dd28..62f668aab 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 703d6d1e5..762a1e9f3 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 0bd4de3eb..78706d9f1 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index e7372bf23..a30b93d5f 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index aa04e9cc6..3dd25ec40 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index fea02dbcf..ce4233b45 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index a4d568805..2edeb0176 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index e6adfbc85..e035223fe 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/utils/features/pom.xml b/utils/features/pom.xml index daa5cafd0..0a325cd24 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 4d2574b2b..2b91a439c 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/utils/pom.xml b/utils/pom.xml index 44b8e9880..67013033f 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1-SNAPSHOT + 1.2.1 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 0ff0efd8c..66cd08918 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.1-SNAPSHOT + 1.2.1 -- cgit 1.2.3-korg From 8957d8eadb42547acdc4235cbfcf7468b4e2e876 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 15 Mar 2019 14:34:26 -0400 Subject: Compile against Fluorine SR2 Compile against ODL Fluorine SR2 Change-Id: I9554aaa76d76f7ba7efb961e5ee1cbbb2b1768d5 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/ccsdk-slicore-utils/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 2 +- 48 files changed, 93 insertions(+), 93 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index b9ac33953..f087c9d7c 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 9cfa6cf55..2fbb6e0dc 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index bfe8e6bf0..989be63e7 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index c71dfd57c..94828fed4 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 331b8691a..a73cd8227 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 05032631a..98b01ac11 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index f90c475ec..eef007d0b 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 594849bae..be3dfb0a0 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 510caa190..4ec16e8f4 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 4009313b3..7ba73f9bc 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 88c08b00f..0cd08025f 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index bcbc220ac..9080243aa 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 36346b687..8a0140794 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 77c42bc4d..eaf582f99 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index c720fa69e..3f563f4f9 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 2ebfd1f64..ac2394b6f 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index a840505c6..c91044359 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index f66f391f6..f3cbd9dbd 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index fa160010d..e36289af5 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index bb092cff1..5c4f05a21 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 542237526..649df32df 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index b2a1bc9f8..5a288089f 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index da03897a9..87e8c7846 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 2781ce44b..fa5d16287 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 02505f1e5..d77a3a3bd 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 8e4d36c27..c2ff457d4 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index d06fc62ae..166ea4778 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index b5df586ec..153c5edd4 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 026934711..186dac3ed 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 836f9c923..06c430847 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index ded3817ef..0beb5a8d5 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 3a8dbd5e6..2799c392a 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index b8dfa2a29..cd5deacc5 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index f7cc0fffd..53fea8b1c 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 9ea68b262..041ae41b9 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 62f668aab..9ee363b29 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 762a1e9f3..2a063a568 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 78706d9f1..d77e072e6 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index a30b93d5f..0dfee2c44 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 3dd25ec40..8fdf06963 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index ce4233b45..913baa14e 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 2edeb0176..cf80396ab 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index e035223fe..363f5c8c8 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 0a325cd24..89e5e952e 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 2b91a439c..3fe754810 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 67013033f..682c1e393 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 66cd08918..62238d712 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.1 + 1.2.2-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index b1967d0a1..1c98ae9b3 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=4 -feature_revision=1 +feature_revision=2 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 88c5e41c5d3115521b24800b7be4e8bd77a27fc1 Mon Sep 17 00:00:00 2001 From: Rich Tabedzki Date: Fri, 22 Mar 2019 11:01:50 -0400 Subject: Support system variables in property values Changes made: * Added code in DBResourceManager to replace with its value * Expanded debug statement by adding processing time Change-Id: I22748daed50063e8e0ac7201e88d69a2609c1788 Issue-ID: CCSDK-1133 Signed-off-by: Rich Tabedzki --- .../ccsdk/sli/core/dblib/CachedDataSource.java | 41 +++++++- .../ccsdk/sli/core/dblib/DBResourceManager.java | 104 ++++++++++++++++----- .../core/dblib/TerminatingCachedDataSource.java | 7 ++ 3 files changed, 127 insertions(+), 25 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index bc466d931..b9a0f071b 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -33,6 +33,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Observer; import javax.sql.DataSource; @@ -59,7 +60,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito private static final Logger LOGGER = LoggerFactory.getLogger(CachedDataSource.class); private static final String SQL_FAILURE = "SQL FAILURE. time(ms): "; - private static final String FAILED_TO_EXECUTE = "> failed to execute: "; + private static final String FAILED_TO_EXECUTE = "> Failed to execute: "; private static final String WITH_ARGUMENTS = " with arguments: "; private static final String WITH_NO_ARGUMENTS = " with no arguments. "; private static final String DATA_SOURCE_CONNECT_SUCCESS = "SQL DataSource < {} > connected to {}, read-only is {}, tested successfully"; @@ -82,12 +83,13 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito private long nextErrorReportTime = 0L; private String globalHostName = null; + private final int index; private boolean isDerby = false; public CachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { ds = configure(jdbcElem); - + index = initializeIndex(jdbcElem); if ("org.apache.derby.jdbc.EmbeddedDriver".equals(jdbcElem.getDriverName())) { isDerby = true; } @@ -97,6 +99,16 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito protected abstract DataSource configure(BaseDBConfiguration jdbcElem) throws DBConfigException; protected abstract int getAvailableConnections(); + protected int initializeIndex(BaseDBConfiguration jdbcElem) { + if(jdbcElem.containsKey(BaseDBConfiguration.DATABASE_HOSTS)) { + String hosts = jdbcElem.getProperty(BaseDBConfiguration.DATABASE_HOSTS); + String name = jdbcElem.getProperty(BaseDBConfiguration.CONNECTION_NAME); + List numbers = Arrays.asList(hosts.split(",")); + return numbers.indexOf(name); + } else + return -1; + } + /* * (non-Javadoc) * @@ -104,7 +116,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito */ @Override public Connection getConnection() throws SQLException { + LapsedTimer lt = new LapsedTimer(); + try { return ds.getConnection(); + } finally { + if(LOGGER.isTraceEnabled()) { + LOGGER.trace(String.format("SQL Connection aquisition time : %s", lt.lapsedTime())); + } + } } public CachedRowSet getData(String statement, List arguments) throws SQLException { @@ -397,6 +416,10 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito monitor.deleteObserver(observer); } + public int getIndex() { + return index; + } + @Override public long getInterval() { return interval; @@ -487,9 +510,9 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito isSlave = true; } if (isSlave) { - LOGGER.debug("SQL SLAVE : {} on server {}, pool {}", connectionName, hostname, getAvailableConnections()); + LOGGER.debug("SQL SLAVE : {} on server {}, pool {}", connectionName, getDbConnectionName(), getAvailableConnections()); } else { - LOGGER.debug("SQL MASTER : {} on server {}, pool {}", connectionName, hostname, getAvailableConnections()); + LOGGER.debug("SQL MASTER : {} on server {}, pool {}", connectionName, getDbConnectionName(), getAvailableConnections()); } return isSlave; } @@ -557,4 +580,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito public String getGlobalHostName() { return globalHostName; } + + static class LapsedTimer { + private final long msTime = System.currentTimeMillis(); + + public String lapsedTime() { + double timediff = System.currentTimeMillis() - msTime; + timediff = timediff/1000; + return String.valueOf( timediff)+"s"; + } + } } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java index 236bce6e3..7c71bcc81 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.Map; import java.util.HashSet; import java.util.Iterator; import java.util.Observable; @@ -44,6 +45,7 @@ import java.util.SortedSet; import java.util.TimerTask; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentSkipListSet; +import java.util.stream.Collectors; import javax.sql.DataSource; import javax.sql.rowset.CachedRowSet; @@ -66,7 +68,8 @@ import org.slf4j.LoggerFactory; * Rich Tabedzki */ public class DBResourceManager implements DataSource, DataAccessor, DBResourceObserver, DbLibService { - private static Logger LOGGER = LoggerFactory.getLogger(DBResourceManager.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DBResourceManager.class); + private static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url"; transient boolean terminating = false; transient protected long retryInterval = 10000L; @@ -92,8 +95,8 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } public DBResourceManager(final Properties properties) { - this.configProps = properties; - + this.configProps = processSystemVariables(properties); + // TODO : hack to force classloader to cache mariadb driver. This shouldnt be necessary, // but for some reason it is (without this, dblib throws ClassNotFound on mariadb driver // and fails to load). @@ -102,26 +105,26 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb dvr = null; // get retry interval value - retryInterval = getLongFromProperties(properties, "org.onap.dblib.connection.retry", 10000L); + retryInterval = getLongFromProperties(configProps, "org.onap.dblib.connection.retry", 10000L); // get recovery mode flag - recoveryMode = getBooleanFromProperties(properties, "org.onap.dblib.connection.recovery", true); + recoveryMode = getBooleanFromProperties(configProps, "org.onap.dblib.connection.recovery", true); if(!recoveryMode) { recoveryMode = false; LOGGER.info("Recovery Mode disabled"); } // get time out value for thread cleanup - terminationTimeOut = getLongFromProperties(properties, "org.onap.dblib.termination.timeout", 300000L); + terminationTimeOut = getLongFromProperties(configProps, "org.onap.dblib.termination.timeout", 300000L); // get properties for monitoring - monitorDbResponse = getBooleanFromProperties(properties, "org.onap.dblib.connection.monitor", false); - monitoringInterval = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.interval", 1000L); - monitoringInitialDelay = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.startdelay", 5000L); - expectedCompletionTime = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); - unprocessedFailoverThreshold = getLongFromProperties(properties, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); + monitorDbResponse = getBooleanFromProperties(configProps, "org.onap.dblib.connection.monitor", false); + monitoringInterval = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.interval", 1000L); + monitoringInitialDelay = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.startdelay", 5000L); + expectedCompletionTime = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); + unprocessedFailoverThreshold = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); // initialize performance monitor - PollingWorker.createInistance(properties); + PollingWorker.createInistance(configProps); // initialize recovery thread worker = new RecoveryMgr(); @@ -130,13 +133,49 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb worker.start(); try { - this.config(properties); + this.config(configProps); } catch (final Exception e) { // TODO: config throws Exception which is poor practice. Eliminate this in a separate patch. LOGGER.error("Fatal Exception encountered while configuring DBResourceManager", e); } } + public static Properties processSystemVariables(Properties properties) { + Map hmap = new Properties(); + hmap.putAll(properties); + + Map result = hmap.entrySet().stream() + .filter(map -> map.getValue().toString().startsWith("${")) + .filter(map -> map.getValue().toString().endsWith("}")) + .collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue())); + + result.forEach((name, propEntries) -> { + hmap.put(name, replace(propEntries.toString())); + }); + + if(hmap.containsKey(DATABASE_URL) && hmap.get(DATABASE_URL).toString().contains("${")) { + String url = hmap.get(DATABASE_URL).toString(); + String[] innerChunks = url.split("\\$\\{"); + for(String chunk : innerChunks) { + if(chunk.contains("}")) { + String subChunk = chunk.substring(0, chunk.indexOf("}")); + String varValue = System.getenv(subChunk); + url = url.replace("${"+subChunk+"}", varValue); + } + } + hmap.put(DATABASE_URL, url); + } + return Properties.class.cast(hmap); + } + + + private static String replace(String value) { + String globalVariable = value.substring(2, value.length() -1); + String varValue = System.getenv(globalVariable); + return (varValue != null) ? varValue : value; + } + + private void config(Properties configProps) throws Exception { final ConcurrentLinkedQueue semaphore = new ConcurrentLinkedQueue<>(); final DbConfigPool dbConfig = DBConfigFactory.createConfig(configProps); @@ -204,11 +243,33 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb return -1; } - if(!left.isSlave()) + boolean leftMaster = !left.isSlave(); + if(leftMaster) { + if(left.getIndex() <= right.getIndex()) + return -1; + else { + boolean rightMaster = !right.isSlave(); + if(rightMaster) { + if(left.getIndex() <= right.getIndex()) + return -1; +// if(left.getIndex() > right.getIndex()) + else { + return 1; + } + } else { return -1; + } + } + } if(!right.isSlave()) return 1; + if(left.getIndex() <= right.getIndex()) + return -1; + if(left.getIndex() > right.getIndex()) + return 1; + + } catch (Throwable e) { LOGGER.warn("", e); } @@ -440,12 +501,12 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } } lastException = exc; - LOGGER.error("Generated alarm: "+active.getDbConnectionName(), exc); + LOGGER.error("Generated alarm: {}", active.getDbConnectionName(), exc); handleGetConnectionException(active, exc); } finally { if(LOGGER.isDebugEnabled()){ time = System.currentTimeMillis() - time; - LOGGER.debug("getData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + LOGGER.debug("getData processing time : {} {} miliseconds.", active.getDbConnectionName(), time); } } } @@ -490,7 +551,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb String message = exc.getMessage(); if(message == null) message = exc.getClass().getName(); - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + LOGGER.error("Generated alarm: {} - {}",active.getDbConnectionName(), message); if(exc instanceof SQLException) throw (SQLException)exc; else { @@ -501,7 +562,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } finally { if(LOGGER.isDebugEnabled()){ time = System.currentTimeMillis() - time; - LOGGER.debug(">> getData : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + LOGGER.debug(">> getData : {} {} miliseconds.", active.getDbConnectionName(), time); } } } @@ -570,12 +631,12 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb String message = exc.getMessage(); if(message == null) message = exc.getClass().getName(); - LOGGER.error("Generated alarm: "+active.getDbConnectionName()+" - "+message); + LOGGER.error("Generated alarm: {} - {}", active.getDbConnectionName(), message); if(exc instanceof SQLException) { SQLException sqlExc = SQLException.class.cast(exc); // handle read-only exception if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { - LOGGER.warn("retrying due to: " + sqlExc.getMessage()); + LOGGER.warn("retrying due to: {}", sqlExc.getMessage()); this.findMaster(); if(retryAllowed){ retryAllowed = false; @@ -592,7 +653,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb } finally { if(LOGGER.isDebugEnabled()){ time = System.currentTimeMillis() - time; - LOGGER.debug("writeData processing time : "+ active.getDbConnectionName()+" "+time+" miliseconds."); + LOGGER.debug("writeData processing time : {} {} miliseconds.", active.getDbConnectionName(), time); } } } @@ -626,6 +687,7 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb if(!active.isFabric()) { if(this.dsQueue.size() > 1 && active.isSlave()) { + LOGGER.debug("Forcing reorder on: {}", dsQueue.toString()); CachedDataSource master = findMaster(); if(master != null) { active = master; diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java index 884f88825..852dda3c7 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/TerminatingCachedDataSource.java @@ -30,6 +30,7 @@ import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitorObserver; public class TerminatingCachedDataSource extends CachedDataSource implements SQLExecutionMonitorObserver { private static final int DEFAULT_AVAILABLE_CONNECTIONS = 0; + private static final int DEFAULT_INDEX = -1; public TerminatingCachedDataSource(BaseDBConfiguration jdbcElem) throws DBConfigException { super(jdbcElem); @@ -49,4 +50,10 @@ public class TerminatingCachedDataSource extends CachedDataSource implements SQL protected int getAvailableConnections() { return DEFAULT_AVAILABLE_CONNECTIONS; } + + @Override + protected int initializeIndex(BaseDBConfiguration jdbcElem) { + return DEFAULT_INDEX; + } + } -- cgit 1.2.3-korg From 59779f3301d3a8fcb2b44b90c962ed55f9cea16e Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Wed, 3 Apr 2019 18:24:45 -0400 Subject: Fixing Log Filter Exception in Finally Block sli-core filters: Fixing RequestResponseLoggingFilter.java which throws Exception in Finally Block Change-Id: Id5beb4ed320b85a4ffcaff603bacb4b1789d501e Issue-ID: CCSDK-1198 Signed-off-by: Singal, Kapil (ks220y) --- .../core/filters/RequestResponseLoggingFilter.java | 471 ++++++++++----------- 1 file changed, 231 insertions(+), 240 deletions(-) diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java index 7b48a2361..c49729595 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -3,7 +3,7 @@ * ONAP : CCSDK * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. + * reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. * ================================================================================ @@ -32,7 +32,6 @@ import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Enumeration; import java.util.zip.GZIPInputStream; - import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -50,272 +49,264 @@ import javax.servlet.http.HttpServletResponseWrapper; public class RequestResponseLoggingFilter implements Filter { - private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.request.response"); - - private static class ByteArrayServletStream extends ServletOutputStream { - - ByteArrayOutputStream baos; - - ByteArrayServletStream(ByteArrayOutputStream baos) { - this.baos = baos; - } - - @Override - public void write(int param) throws IOException { - baos.write(param); - } - - @Override - public boolean isReady() { - return true; - } - - @Override - public void setWriteListener(WriteListener arg0) { - //this method does nothing - - } - } - - private static class ByteArrayPrintWriter { - - private ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - private PrintWriter pw = new PrintWriter(baos); + private static org.slf4j.Logger log = + org.slf4j.LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.request.response"); - private ServletOutputStream sos = new ByteArrayServletStream(baos); + private static class ByteArrayServletStream extends ServletOutputStream { - public PrintWriter getWriter() { - return pw; - } + ByteArrayOutputStream baos; - public ServletOutputStream getStream() { - return sos; - } + ByteArrayServletStream(ByteArrayOutputStream baos) { + this.baos = baos; + } - byte[] toByteArray() { - return baos.toByteArray(); - } - } + @Override + public void write(int param) throws IOException { + baos.write(param); + } - private class BufferedServletInputStream extends ServletInputStream { + @Override + public boolean isReady() { + return true; + } - ByteArrayInputStream bais; + @Override + public void setWriteListener(WriteListener arg0) { + // this method does nothing - public BufferedServletInputStream(ByteArrayInputStream bais) { - this.bais = bais; - } + } + } - @Override - public int available() { - return bais.available(); - } + private static class ByteArrayPrintWriter extends PrintWriter { + private ByteArrayOutputStream baos; - @Override - public int read() { - return bais.read(); - } + public ByteArrayPrintWriter(ByteArrayOutputStream out) { + super(out); + this.baos = out; + } - @Override - public int read(byte[] buf, int off, int len) { - return bais.read(buf, off, len); - } + public ServletOutputStream getStream() { + return new ByteArrayServletStream(baos); + } - @Override - public boolean isFinished() { - return available() < 1; - } + } - @Override - public boolean isReady() { - return true; - } + private class BufferedServletInputStream extends ServletInputStream { - @Override - public void setReadListener(ReadListener arg0) { - // this method does nothing - } + ByteArrayInputStream bais; - } + public BufferedServletInputStream(ByteArrayInputStream bais) { + this.bais = bais; + } - private class BufferedRequestWrapper extends HttpServletRequestWrapper { + @Override + public int available() { + return bais.available(); + } - ByteArrayInputStream bais; + @Override + public int read() { + return bais.read(); + } - ByteArrayOutputStream baos; + @Override + public int read(byte[] buf, int off, int len) { + return bais.read(buf, off, len); + } - BufferedServletInputStream bsis; + @Override + public boolean isFinished() { + return available() < 1; + } - byte[] buffer; + @Override + public boolean isReady() { + return true; + } - public BufferedRequestWrapper(HttpServletRequest req) throws IOException { - super(req); + @Override + public void setReadListener(ReadListener arg0) { + // this method does nothing + } - InputStream is = req.getInputStream(); - baos = new ByteArrayOutputStream(); - byte[] buf = new byte[1024]; - int letti; - while ((letti = is.read(buf)) > 0) { - baos.write(buf, 0, letti); - } - buffer = baos.toByteArray(); + } - } + private class BufferedRequestWrapper extends HttpServletRequestWrapper { - @Override - public ServletInputStream getInputStream() { - try { - bais = new ByteArrayInputStream(buffer); - bsis = new BufferedServletInputStream(bais); - } catch (Exception ex) { - log.error("Exception in getInputStream",ex); - } + ByteArrayInputStream bais; - return bsis; - } + ByteArrayOutputStream baos; - public byte[] getBuffer() { - return buffer; - } + BufferedServletInputStream bsis; - } + byte[] buffer; - @Override - public void init(FilterConfig filterConfig) throws ServletException { - //this method does nothing - } + public BufferedRequestWrapper(HttpServletRequest req) throws IOException { + super(req); - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) - throws IOException, ServletException { + InputStream is = req.getInputStream(); + baos = new ByteArrayOutputStream(); + byte[] buf = new byte[1024]; + int letti; + while ((letti = is.read(buf)) > 0) { + baos.write(buf, 0, letti); + } + buffer = baos.toByteArray(); - final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; - BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); + } + + @Override + public ServletInputStream getInputStream() { + try { + bais = new ByteArrayInputStream(buffer); + bsis = new BufferedServletInputStream(bais); + } catch (Exception ex) { + log.error("Exception in getInputStream", ex); + } + + return bsis; + } + + public byte[] getBuffer() { + return buffer; + } + + } - StringBuilder requestHeaders = new StringBuilder("REQUEST|"); - requestHeaders.append(httpRequest.getMethod()); - requestHeaders.append(":"); - requestHeaders.append(httpRequest.getRequestURL().toString()); - requestHeaders.append("|"); - String header; - for (Enumeration e = httpRequest.getHeaderNames(); e.hasMoreElements();) { - header = e.nextElement(); - requestHeaders.append(header); - requestHeaders.append(":"); - requestHeaders.append(httpRequest.getHeader(header)); - requestHeaders.append(";"); - - } - log.info(requestHeaders.toString()); - - log.info("REQUEST BODY|" + new String(bufferedRequest.getBuffer())); - - final HttpServletResponse response = (HttpServletResponse) servletResponse; - - final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(); - HttpServletResponse wrappedResp = new HttpServletResponseWrapper(response) { - @Override - public PrintWriter getWriter() { - return pw.getWriter(); - } - - @Override - public ServletOutputStream getOutputStream() { - return pw.getStream(); - } - - }; - - try { - - filterChain.doFilter(bufferedRequest, wrappedResp); - - }catch (Exception e){ - log.error("Chain Exception",e); - throw e; - } finally { - byte[] bytes = pw.toByteArray(); - response.getOutputStream().write(bytes); - response.getOutputStream().flush(); - - StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|"); - - for (String headerName : response.getHeaderNames()) { - responseHeaders.append(headerName); - responseHeaders.append(":"); - responseHeaders.append(response.getHeader(headerName)); - responseHeaders.append(";"); - - } - log.info(responseHeaders.toString()); - - if ("gzip".equals(response.getHeader("Content-Encoding"))) { - - log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes)); - - } else { - - log.info("RESPONSE BODY|" + new String(bytes)); - } - } - } - - @Override - public void destroy() { - //this method does nothing - } - - private String decompressGZIPByteArray(byte[] bytes) { - - BufferedReader in = null; - InputStreamReader inR = null; - ByteArrayInputStream byteS = null; - GZIPInputStream gzS = null; - StringBuilder str = new StringBuilder(); - try { - byteS = new ByteArrayInputStream(bytes); - gzS = new GZIPInputStream(byteS); - inR = new InputStreamReader(gzS); - in = new BufferedReader(inR); - - if (in != null) { - - String content; - - while ((content = in.readLine()) != null) { - str.append(content); - } - } - - } catch (Exception e) { - log.error("Failed get read GZIPInputStream", e); - } finally { - - if (byteS != null) - try { - byteS.close(); - } catch (IOException e1) { - log.error("Failed to close ByteStream", e1); - } - if (gzS != null) - try { - gzS.close(); - } catch (IOException e2) { - log.error("Failed to close GZStream", e2); - } - if (inR != null) - try { - inR.close(); - } catch (IOException e3) { - log.error("Failed to close InputReader", e3); - } - if (in != null) - try { - in.close(); - } catch (IOException e) { - log.error("Failed to close BufferedReader", e); - } - } - return str.toString(); - } + @Override + public void init(FilterConfig filterConfig) throws ServletException { + // this method does nothing + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + + final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; + BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); + + StringBuilder requestHeaders = new StringBuilder("REQUEST|"); + requestHeaders.append(httpRequest.getMethod()); + requestHeaders.append(":"); + requestHeaders.append(httpRequest.getRequestURL().toString()); + requestHeaders.append("|"); + String header; + for (Enumeration e = httpRequest.getHeaderNames(); e.hasMoreElements();) { + header = e.nextElement(); + requestHeaders.append(header); + requestHeaders.append(":"); + requestHeaders.append(httpRequest.getHeader(header)); + requestHeaders.append(";"); + + } + log.info(requestHeaders.toString()); + + log.info("REQUEST BODY|" + new String(bufferedRequest.getBuffer())); + + final HttpServletResponse response = (HttpServletResponse) servletResponse; + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(baos); + + HttpServletResponse wrappedResp = new HttpServletResponseWrapper(response) { + @Override + public PrintWriter getWriter() { + return pw; + } + + @Override + public ServletOutputStream getOutputStream() { + return pw.getStream(); + } + }; + + try { + filterChain.doFilter(bufferedRequest, wrappedResp); + } catch (Exception e) { + log.error("Chain Exception", e); + throw e; + } finally { + byte[] bytes = baos.toByteArray(); + response.getOutputStream().write(bytes); + response.getOutputStream().flush(); + + StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|"); + + for (String headerName : response.getHeaderNames()) { + responseHeaders.append(headerName); + responseHeaders.append(":"); + responseHeaders.append(response.getHeader(headerName)); + responseHeaders.append(";"); + + } + log.info(responseHeaders.toString()); + + if ("gzip".equals(response.getHeader("Content-Encoding"))) { + + log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes)); + + } else { + + log.info("RESPONSE BODY|" + new String(bytes)); + } + } + } + + @Override + public void destroy() { + // this method does nothing + } + + private String decompressGZIPByteArray(byte[] bytes) { + + BufferedReader in = null; + InputStreamReader inR = null; + ByteArrayInputStream byteS = null; + GZIPInputStream gzS = null; + StringBuilder str = new StringBuilder(); + try { + byteS = new ByteArrayInputStream(bytes); + gzS = new GZIPInputStream(byteS); + inR = new InputStreamReader(gzS); + in = new BufferedReader(inR); + + if (in != null) { + + String content; + + while ((content = in.readLine()) != null) { + str.append(content); + } + } + + } catch (Exception e) { + log.error("Failed get read GZIPInputStream", e); + } finally { + + if (byteS != null) + try { + byteS.close(); + } catch (IOException e1) { + log.error("Failed to close ByteStream", e1); + } + if (gzS != null) + try { + gzS.close(); + } catch (IOException e2) { + log.error("Failed to close GZStream", e2); + } + if (inR != null) + try { + inR.close(); + } catch (IOException e3) { + log.error("Failed to close InputReader", e3); + } + if (in != null) + try { + in.close(); + } catch (IOException e) { + log.error("Failed to close BufferedReader", e); + } + } + return str.toString(); + } } -- cgit 1.2.3-korg From 6737dde71f6cdec79904c219efdf4aa348e158e4 Mon Sep 17 00:00:00 2001 From: "Agarwal, Ruchira (ra1926)" Date: Tue, 9 Apr 2019 00:08:10 +0000 Subject: add support for SendError in LoggingFilter Fix for illegalStateException in loggingFilter Change-Id: I357266468a3a9ed11c1d1aeeeb31b52dc653c432 Issue-ID: CCSDK-1198 Signed-off-by: Agarwal, Ruchira (ra1926) --- .../core/filters/RequestResponseLoggingFilter.java | 85 +++++++++++++++++----- 1 file changed, 68 insertions(+), 17 deletions(-) diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java index c49729595..e24a75274 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java @@ -79,6 +79,9 @@ public class RequestResponseLoggingFilter implements Filter { private static class ByteArrayPrintWriter extends PrintWriter { private ByteArrayOutputStream baos; + private int errorCode = -1; + private String errorMsg = ""; + private boolean errored = false; public ByteArrayPrintWriter(ByteArrayOutputStream out) { super(out); @@ -88,6 +91,27 @@ public class RequestResponseLoggingFilter implements Filter { public ServletOutputStream getStream() { return new ByteArrayServletStream(baos); } + + public Boolean hasErrored() { + return errored; + } + public int getErrorCode() { + return errorCode; + } + public String getErrorMsg() { + return errorMsg; + } + + public void setError(int code) { + errorCode = code; + errored = true; + } + + public void setError(int code, String msg) { + errorMsg = msg; + errorCode = code; + errored = true; + } } @@ -217,6 +241,18 @@ public class RequestResponseLoggingFilter implements Filter { public ServletOutputStream getOutputStream() { return pw.getStream(); } + + @Override + public void sendError(int sc) throws IOException { + super.sendError(sc); + pw.setError(sc); + + } + @Override + public void sendError(int sc, String msg) throws IOException { + super.sendError(sc, msg); + pw.setError(sc, msg); + } }; try { @@ -225,29 +261,44 @@ public class RequestResponseLoggingFilter implements Filter { log.error("Chain Exception", e); throw e; } finally { - byte[] bytes = baos.toByteArray(); - response.getOutputStream().write(bytes); - response.getOutputStream().flush(); - - StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|"); - - for (String headerName : response.getHeaderNames()) { - responseHeaders.append(headerName); - responseHeaders.append(":"); - responseHeaders.append(response.getHeader(headerName)); - responseHeaders.append(";"); + try { + byte[] bytes = baos.toByteArray(); + StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|"); + + for (String headerName : response.getHeaderNames()) { + responseHeaders.append(headerName); + responseHeaders.append(":"); + responseHeaders.append(response.getHeader(headerName)); + responseHeaders.append(";"); + } + responseHeaders.append("Status:"); + responseHeaders.append(response.getStatus()); + responseHeaders.append(";IsCommited:" + wrappedResp.isCommitted()); + + log.info(responseHeaders.toString()); + + if ("gzip".equals(response.getHeader("Content-Encoding"))) { - } - log.info(responseHeaders.toString()); + log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes)); - if ("gzip".equals(response.getHeader("Content-Encoding"))) { + } else { - log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes)); + log.info("RESPONSE BODY|" + new String(bytes)); + } - } else { + if (pw.hasErrored()) { + log.info("ERROR RESPONSE|" + pw.getErrorCode() + ":" + pw.getErrorMsg()); + } else { + if (!wrappedResp.isCommitted()){ + response.getOutputStream().write(bytes); + response.getOutputStream().flush(); + } + } - log.info("RESPONSE BODY|" + new String(bytes)); + } catch (Exception e) { + log.error("Exception in response filter", e); } + } } -- cgit 1.2.3-korg From 77bd831346293f92c41ca3144fff3e9183b3b755 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 24 Apr 2019 12:03:12 -0400 Subject: Update to use released 1.2.2 parent Update to use released 1.2.2 version of parent poms. Change-Id: I2edaa726e871ec3ad3bf1aa1cc3d592c79ca6c92 Issue-ID: CCSDK-1222 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/ccsdk-slicore-utils/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 47 files changed, 47 insertions(+), 47 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index f087c9d7c..50a6efec2 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 2fbb6e0dc..9e645cab8 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 989be63e7..ae8923e7c 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 94828fed4..0b6cbb4d6 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index a73cd8227..d9584eef4 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/dblib/pom.xml b/dblib/pom.xml index 98b01ac11..64ab330c1 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index eef007d0b..08b3d3207 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index be3dfb0a0..0d9dbbfde 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 4ec16e8f4..b390df624 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 7ba73f9bc..b405e5e51 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/features/pom.xml b/features/pom.xml index 0cd08025f..2fd4acaf1 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 9080243aa..821266268 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 8a0140794..86ef75b9d 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/filters/features/pom.xml b/filters/features/pom.xml index eaf582f99..c2fb17897 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 3f563f4f9..fb24bbc57 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/filters/pom.xml b/filters/pom.xml index ac2394b6f..5fb9c28c7 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index c91044359..1df4661f3 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/pom.xml b/pom.xml index f3cbd9dbd..4b474c0a4 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index e36289af5..a298eec3b 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 5c4f05a21..2ebeceae7 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 649df32df..9eb5f01d7 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 5a288089f..ed1de8e1a 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 87e8c7846..6a774e40c 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index fa5d16287..2a64aacf9 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/pom.xml b/sli/pom.xml index d77a3a3bd..2eeaa9174 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index c2ff457d4..dc8f91c68 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 166ea4778..413f609a8 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 153c5edd4..46dbf231c 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 186dac3ed..5c1b378cb 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 06c430847..6b94d9798 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 0beb5a8d5..4d15ed834 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 2799c392a..b61482355 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index cd5deacc5..749c2aaee 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 53fea8b1c..9397a8104 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 041ae41b9..4c42fe79b 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 9ee363b29..1716be3a8 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 2a063a568..66d84b003 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index d77e072e6..3f88d86b8 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 0dfee2c44..8605e3f8e 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 8fdf06963..5cfd396c0 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 913baa14e..f714e7505 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index cf80396ab..e3c857562 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 363f5c8c8..39f4c6761 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 89e5e952e..db8592f45 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 3fe754810..7a2c9c72e 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/utils/pom.xml b/utils/pom.xml index 682c1e393..2c3fa9483 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 62238d712..910f1b701 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.2.2-SNAPSHOT + 1.2.2 -- cgit 1.2.3-korg From e38215fcb0e981a751dccec87608df7011e2397f Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 30 Apr 2019 09:57:41 -0400 Subject: Roll master to El Alto Roll master version to El Alto versions Change-Id: If761a69b069ab05a6aa598cd583ac4275665e425 Issue-ID: CCSDK-1222 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/ccsdk-slicore-utils/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- 47 files changed, 92 insertions(+), 92 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 50a6efec2..ac6bf073a 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.2.2 + 1.3.0-SNAPSHOT diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 9e645cab8..dd26fe87e 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index ae8923e7c..5adff72f9 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 0b6cbb4d6..b2d55cea3 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index d9584eef4..f6122e038 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 64ab330c1..547294144 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 08b3d3207..245b19691 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 0d9dbbfde..d2e50a00a 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index b390df624..fe458ce39 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index b405e5e51..4ca4cc989 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 2fd4acaf1..606dbda3d 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 821266268..a390f967d 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 86ef75b9d..3436e06ea 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index c2fb17897..69304b3b0 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index fb24bbc57..64069bf8e 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 5fb9c28c7..8a8b8b249 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 1df4661f3..05dac2db9 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 4b474c0a4..b05886e08 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index a298eec3b..50e26d49a 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 2ebeceae7..b3293233a 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 9eb5f01d7..59f14feab 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index ed1de8e1a..a960763e5 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 6a774e40c..a45a030ea 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 2a64aacf9..d6deac83a 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 2eeaa9174..933bd3cc7 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index dc8f91c68..ff01e75d2 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 413f609a8..00f69c8e7 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 46dbf231c..405bfabe3 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 5c1b378cb..64dd98ff7 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 6b94d9798..cfa0e4dbe 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 4d15ed834..77f9ed9fa 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index b61482355..907a76056 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 749c2aaee..684537bdb 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 9397a8104..2b05d93d2 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 4c42fe79b..e65fd23b1 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 1716be3a8..9b6ced5de 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 66d84b003..22cfdf7a7 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 3f88d86b8..99b4a78b1 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 8605e3f8e..47e3b5abe 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 5cfd396c0..817413113 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index f714e7505..c91e792c0 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index e3c857562..3bc78983b 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 39f4c6761..497f1c246 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index db8592f45..92ce899c6 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 7a2c9c72e..34859ffce 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 2c3fa9483..7a6aabb82 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 910f1b701..ab54f1304 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.2.2 + 1.3.0-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.4.2-SNAPSHOT + 0.5.0-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} -- cgit 1.2.3-korg From f175ecd3ba0a785ac1737ab3a4196d5141c05045 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 10 May 2019 18:41:59 +0000 Subject: Remove DME2 plugin dme2 plugin was used to create dme2ingress proxy urls. This class is not generic enough to be useful to a wide audience. Change-Id: Iadc68d8f22393c3a9a5d21754137cae22b23fafe Issue-ID: CCSDK-1323 Signed-off-by: Smokowski, Kevin (ks6305) --- .../onap/ccsdk/sli/core/slipluginutils/DME2.java | 171 ------------ .../ccsdk/sli/core/slipluginutils/Dme2Factory.java | 109 -------- .../provider/src/main/resources/dme2.properties | 7 - .../blueprint/slipluginutils-blueprint.xml | 9 +- .../ccsdk/sli/core/slipluginutils/Dme2Test.java | 302 --------------------- .../src/test/resources/dme2.e2e.properties | 7 - .../src/test/resources/dme2.prod.properties | 7 - 7 files changed, 1 insertion(+), 611 deletions(-) delete mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java delete mode 100644 sliPluginUtils/provider/src/main/resources/dme2.properties delete mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java delete mode 100644 sliPluginUtils/provider/src/test/resources/dme2.e2e.properties delete mode 100644 sliPluginUtils/provider/src/test/resources/dme2.prod.properties diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java deleted file mode 100644 index 65b597e11..000000000 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ /dev/null @@ -1,171 +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.slipluginutils; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A SvcLogicJavaPlugin that generates DME2 proxy urls (for calling the DME2 ingress proxy) using - * parameters from context memory. - */ -public class DME2 implements SvcLogicJavaPlugin { - - private static final Logger LOG = LoggerFactory.getLogger(DME2.class); - // the key for proxyUrl, which represents a CSV list of urls - public static final String PROXY_URL_KEY = "proxyUrl"; - public static final String PROXY_URLS_VALUE_SEPARATOR = ","; - public static final String AAF_USERNAME_KEY = "aafUserName"; - public static final String AAF_PASSWORD_KEY = "aafPassword"; - public static final String ENV_CONTEXT_KEY = "envContext"; - public static final String ROUTE_OFFER_KEY = "routeOffer"; - public static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; - public static final String PARTNER_KEY = "partner"; - public static final String VERSION_KEY = "version"; - public static final String SERVICE_KEY = "service"; - public static final String SUBCONTEXT_KEY = "subContext"; - public static final String ENDPOINT_READ_TIMEOUT_KEY = "endpointReadTimeout"; - public static final String OUTPUT_PATH_KEY = "outputPath"; - - final String aafUserName; - final String aafPassword; - final String envContext; - final String routeOffer; - final String[] proxyUrls; - final String commonServiceVersion; - final String partner; - final String endpointReadTimeout; - Integer index; - - public DME2(Properties properties) { - Iterator> it = properties.entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); - if (entry.getValue() == null || entry.getValue().toString().length() < 1) { - it.remove(); - } - } - this.aafUserName = properties.getProperty(AAF_USERNAME_KEY, null); - this.aafPassword = properties.getProperty(AAF_PASSWORD_KEY, null); - this.envContext = properties.getProperty(ENV_CONTEXT_KEY, null); - this.routeOffer = properties.getProperty(ROUTE_OFFER_KEY, null); - this.commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY, null); - this.partner = properties.getProperty(PARTNER_KEY, null); - this.endpointReadTimeout = properties.getProperty(ENDPOINT_READ_TIMEOUT_KEY, null); - String proxyUrlString = properties.getProperty(PROXY_URL_KEY, null); - if (proxyUrlString != null && proxyUrlString.length() > 0) { - this.proxyUrls = proxyUrlString.split(PROXY_URLS_VALUE_SEPARATOR); - } else { - String[] local = {"http://localhost:5000"}; - this.proxyUrls = local; - } - this.index = 0; - } - - // constructs a URL to contact the proxy which contacts a DME2 service - public String constructUrl(Map parameters) { - StringBuilder sb = new StringBuilder(); - - // The hostname is assigned in a round robin fashion - sb.append(acquireHostName()); - sb.append("/service=" + parameters.get(SERVICE_KEY)); - - // If the directedGraph passes an explicit version use that, if not use the commonServiceVersion - // found in the properties file - String version = parameters.get(VERSION_KEY); - if (version != null && version.length() > 0) { - sb.append("/version=" + version); - }else { - sb.append("/version=" + this.commonServiceVersion); - } - String envContext = parameters.getOrDefault(ENV_CONTEXT_KEY, this.envContext); - sb.append("/envContext=" + envContext); - - String routeOffer = parameters.getOrDefault(ROUTE_OFFER_KEY, this.routeOffer); - if (routeOffer != null && routeOffer.length() > 0) { - sb.append("/routeOffer=" + routeOffer); - } - - String subContext = parameters.get(SUBCONTEXT_KEY); - if (subContext != null && subContext.length() > 0) { - sb.append("/subContext=" + subContext); - } - sb.append("?dme2.password=" + this.aafPassword); - sb.append("&dme2.username=" + this.aafUserName); - if (this.partner != null) { - sb.append("&partner=" + this.partner); - } - sb.append("&dme2.allowhttpcode=true"); - String endpointReadTimeout = parameters.getOrDefault(ENDPOINT_READ_TIMEOUT_KEY, this.endpointReadTimeout); - if (endpointReadTimeout != null) { - sb.append("&dme2.endpointReadTimeout=" + endpointReadTimeout); - } - String incompleteUrl = sb.toString(); - - // Support optional parameters in a flexible way - for (Entry param : parameters.entrySet()) { - if (!incompleteUrl.contains(param.getKey() + "=") && param.getValue() != null - && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey()) && !PARTNER_KEY.equals(param.getKey())) { - sb.append("&" + param.getKey() + "=" + param.getValue()); - } - } - return sb.toString(); - } - - public synchronized String acquireHostName() { - String retVal = proxyUrls[index]; - index++; - if (index == this.proxyUrls.length) { - index = 0; - } - return retVal; - } - - // Node entry point - public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[] {SERVICE_KEY, OUTPUT_PATH_KEY}, LOG); - String completeProxyUrl = constructUrl(parameters); - ctx.setAttribute(parameters.get(OUTPUT_PATH_KEY), completeProxyUrl); - } - - // Support legacy direct java call - public String constructUrl(String service, String version, String subContext) { - Map parameters = new HashMap<>(); - parameters.put(SERVICE_KEY, service); - if (version != null) { - parameters.put(VERSION_KEY, version); - } - parameters.put(SUBCONTEXT_KEY, subContext); - return constructUrl(parameters); - } - -} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java deleted file mode 100644 index 7013a9c5d..000000000 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java +++ /dev/null @@ -1,109 +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.slipluginutils; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Optional; -import java.util.Properties; -import java.util.Vector; -import org.onap.ccsdk.sli.core.utils.JREFileResolver; -import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; -import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; -import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Immutable properties container for dme2 properties. Since the initial design decision was made to - * utilize Properties instead of an OSGi ManagedService, it was decided to - * make these properties immutable. - */ -public final class Dme2Factory { - - private static final Logger LOG = LoggerFactory.getLogger(Dme2Factory.class); - private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; - - static Properties properties; - private Vector dme2PropertiesFileResolvers = new Vector<>(); - - public Dme2Factory() { - dme2PropertiesFileResolvers - .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); - dme2PropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); - dme2PropertiesFileResolvers - .add(new JREFileResolver("Using property file (3) from JRE argument", Dme2Factory.class)); - dme2PropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); - File dme2File = getDme2File(DME2_PROPERTIES_FILE_NAME); - init(dme2File); - } - - private void init(final File dme2propertiesFile) { - try { - properties = getProperties(dme2propertiesFile); - } catch (final FileNotFoundException e) { - LOG.error("dme2.properties file could not be found at path: {}", dme2propertiesFile, e); - } catch (final IOException e) { - LOG.error("fatal error reading dme2.properties at path: {}", dme2propertiesFile, e); - } - } - - /** - * Reports the method chosen for properties resolution to the Logger. - * - * @param message Some user friendly message - * @param fileOptional The file location of the chosen properties file - * @return the file location of the chosen properties file - */ - private static File reportSuccess(final String message, final Optional fileOptional) { - if (fileOptional.isPresent()) { - final File file = fileOptional.get(); - LOG.info("{} {}", message, file.getPath()); - return file; - } - return null; - } - - private File getDme2File(final String dme2Filename) { - for (final PropertiesFileResolver dblibPropertiesFileResolver : dme2PropertiesFileResolvers) { - final Optional fileOptional = dblibPropertiesFileResolver.resolveFile(dme2Filename); - if (fileOptional.isPresent()) { - return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); - } - } - return (new File(dme2Filename)); - } - - private static Properties getProperties(final File dme2File) throws IOException { - final Properties properties = new Properties(); - properties.load(new FileReader(dme2File)); - return properties; - } - - public DME2 createDme2() { - return new DME2(properties); - } - -} diff --git a/sliPluginUtils/provider/src/main/resources/dme2.properties b/sliPluginUtils/provider/src/main/resources/dme2.properties deleted file mode 100644 index 373448447..000000000 --- a/sliPluginUtils/provider/src/main/resources/dme2.properties +++ /dev/null @@ -1,7 +0,0 @@ -aafUserName=user@sample.com -aafPassword=fake -envContext=UAT -routeOffer=UAT -proxyUrl=http://sample.com:25055,http://sample.com:25055 -commonServiceVersion=1702.0 -partner= \ No newline at end of file diff --git a/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml b/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml index 283dbbaa9..534b92c93 100644 --- a/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml +++ b/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml @@ -10,11 +10,4 @@ - - - - - - - \ No newline at end of file + diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java deleted file mode 100644 index a06def652..000000000 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Test.java +++ /dev/null @@ -1,302 +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.slipluginutils; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public class Dme2Test { - public Properties makesProperties(String aafUserName, String aafPassword, String envContext, String routeOffer, - String proxyUrls, String commonServiceVersion) { - Properties props = new Properties(); - props.put(DME2.AAF_USERNAME_KEY, aafUserName); - props.put(DME2.AAF_PASSWORD_KEY, aafPassword); - props.put(DME2.ENV_CONTEXT_KEY, envContext); - props.put(DME2.ROUTE_OFFER_KEY, routeOffer); - props.put(DME2.PROXY_URL_KEY, proxyUrls); - props.put(DME2.COMMON_SERVICE_VERSION_KEY, commonServiceVersion); - return props; - } - - @Test - public void createUrl() { - String localUrl = - "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = - makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.VERSION_KEY, "1702.0"); - parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - parameters.put(DME2.OUTPUT_PATH_KEY, "tmp.test"); - - String constructedUrl = dme.constructUrl(parameters); - assertEquals(localUrl, constructedUrl); - } - - @Test - public void createUrlNoSubContext() { - String localUrl = - "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = - makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.VERSION_KEY, "1702.0"); - parameters.put(DME2.SUBCONTEXT_KEY, null); - String constructedUrl = dme.constructUrl(parameters); - assertEquals(localUrl, constructedUrl); - } - - @Test - public void testRoundRobin() { - String[] proxyHostNames = new String[] {"http://one:25055", "http://two:25055", "http://three:25055"}; - String proxyHostNameString = proxyHostNames[0] + "," + proxyHostNames[1] + "," + proxyHostNames[2]; - - String urlSuffix = - "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", proxyHostNameString, "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.VERSION_KEY, "1702.0"); - parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - String constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl(parameters); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - } - - @Test - public void createDme2EndtoEnd() throws FileNotFoundException, IOException { - Properties props = new Properties(); - props.load(new FileInputStream("src/test/resources/dme2.e2e.properties")); - DME2 dme2 = new DME2(props); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("UAT", dme2.envContext); - assertEquals("UAT", dme2.routeOffer); - Assert.assertArrayEquals( - "http://sample.com:25055,http://sample.com:25055".split(DME2.PROXY_URLS_VALUE_SEPARATOR), - dme2.proxyUrls); - assertEquals("1702.0", dme2.commonServiceVersion); - assertEquals(null, dme2.partner); - Map parameters = new HashMap(); - parameters.put(DME2.PARTNER_KEY, "I SHOULD BE FILTERED NOW!"); - parameters.put(DME2.SERVICE_KEY, "sample.com/restservices/sys/v1/assetSearch"); - parameters.put(DME2.VERSION_KEY, null); - parameters.put(DME2.SUBCONTEXT_KEY, "/mySubContext"); - String constructedUrl = dme2.constructUrl(parameters); - assertNotNull(constructedUrl); - String expected = - "http://sample.com:25055/service=sample.com/restservices/sys/v1/assetSearch/version=1702.0/envContext=UAT/routeOffer=UAT/subContext=/mySubContext?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - assertEquals(expected, constructedUrl); - } - - @Test - public void createDme2Prod() throws FileNotFoundException, IOException { - Properties props = new Properties(); - props.load(new FileInputStream("src/test/resources/dme2.prod.properties")); - DME2 dme2 = new DME2(props); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("PROD", dme2.envContext); - assertEquals(null, dme2.routeOffer); - Assert.assertArrayEquals( - "http://sample.com:25055,http://sample.com:25055".split(DME2.PROXY_URLS_VALUE_SEPARATOR), - dme2.proxyUrls); - assertEquals("1.0", dme2.commonServiceVersion); - assertEquals("LPP_PROD", dme2.partner); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.VERSION_KEY, "1702.0"); - parameters.put(DME2.SUBCONTEXT_KEY, "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - String constructedUrl = dme2.constructUrl(parameters); - assertNotNull(constructedUrl); - String expected = - "http://sample.com:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=PROD/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&partner=LPP_PROD&dme2.allowhttpcode=true"; - assertEquals(expected, constructedUrl); - } - - @Test - public void blankProperties() throws Exception { - Properties props = new Properties(); - DME2 dme2 = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "easyService"); - parameters.put(DME2.VERSION_KEY, "3"); - parameters.put(DME2.SUBCONTEXT_KEY, "/sub"); - assertEquals( - "http://localhost:5000/service=easyService/version=3/envContext=null/subContext=/sub?dme2.password=null&dme2.username=null&dme2.allowhttpcode=true", - dme2.constructUrl(parameters)); - } - - @Test - public void optionalParameters() { - String localUrl = - "http://localhost:25055/service=serv/version=4/envContext=TEST/routeOffer=DEFAULT/subContext=/sub?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true&test=123"; - Properties props = - makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - parameters.put(DME2.SERVICE_KEY, "serv"); - parameters.put(DME2.VERSION_KEY, "4"); - parameters.put(DME2.SUBCONTEXT_KEY, "/sub"); - parameters.put("test", "123"); - - String constructedUrl = dme.constructUrl(parameters); - assertEquals(localUrl, constructedUrl); - } - - @Test - public void createLocalUrlLegacy() { - String localUrl = - "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = - makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); - DME2 dme = new DME2(props); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", - "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(localUrl, constructedUrl); - } - - @Test - public void createLocalUrlNoSubContextLegacy() { - String localUrl = - "http://localhost:25055/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = - makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", "http://localhost:25055", "common"); - DME2 dme = new DME2(props); - Map parameters = new HashMap(); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", parameters.get(null)); - assertEquals(localUrl, constructedUrl); - } - - @Test - public void testRoundRobinLegacy() { - String[] proxyHostNames = new String[] {"http://one:25055", "http://two:25055", "http://three:25055"}; - String urlSuffix = - "/service=sample.com/services/eim/v1/rest/version=1702.0/envContext=TEST/routeOffer=DEFAULT/subContext=/enterpriseConnection/getEnterpriseConnectionDetails/v1?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - Properties props = makesProperties("user@sample.com", "fake", "TEST", "DEFAULT", - "http://one:25055,http://two:25055,http://three:25055", "common"); - DME2 dme = new DME2(props); - String constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", - "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", - "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", - "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", - "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", - "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[1] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", - "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[2] + urlSuffix, constructedUrl); - constructedUrl = dme.constructUrl("sample.com/services/eim/v1/rest", "1702.0", - "/enterpriseConnection/getEnterpriseConnectionDetails/v1"); - assertEquals(proxyHostNames[0] + urlSuffix, constructedUrl); - } - - @Test - public void createDme2EndtoEndLegacy() throws Exception { - Properties props = new Properties(); - props.load(new FileInputStream("src/test/resources/dme2.e2e.properties")); - DME2 dme2 = new DME2(props); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("UAT", dme2.envContext); - assertEquals("UAT", dme2.routeOffer); - Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); - assertEquals("1702.0", dme2.commonServiceVersion); - assertEquals(null, dme2.partner); - String constructedUrl = dme2.constructUrl("sample.com/restservices/sys/v1/assetSearch", null, "/mySubContext"); - assertNotNull(constructedUrl); - String expected = - "http://sample.com:25055/service=sample.com/restservices/sys/v1/assetSearch/version=1702.0/envContext=UAT/routeOffer=UAT/subContext=/mySubContext?dme2.password=fake&dme2.username=user@sample.com&dme2.allowhttpcode=true"; - assertEquals(expected, constructedUrl); - } - - @Test - public void createDme2ProdLegacy() throws Exception { - Properties props = new Properties(); - props.load(new FileInputStream("src/test/resources/dme2.prod.properties")); - DME2 dme2 = new DME2(props); - assertEquals("user@sample.com", dme2.aafUserName); - assertEquals("fake", dme2.aafPassword); - assertEquals("PROD", dme2.envContext); - assertEquals(null, dme2.routeOffer); - Assert.assertArrayEquals("http://sample.com:25055,http://sample.com:25055".split(","), dme2.proxyUrls); - assertEquals("1.0", dme2.commonServiceVersion); - assertEquals("LPP_PROD", dme2.partner); - String constructedUrl = dme2.constructUrl("sample.com/restservices/sys/v1/assetSearch", null, "/mySubContext"); - assertNotNull(constructedUrl); - String expected = - "http://sample.com:25055/service=sample.com/restservices/sys/v1/assetSearch/version=1.0/envContext=PROD/subContext=/mySubContext?dme2.password=fake&dme2.username=user@sample.com&partner=LPP_PROD&dme2.allowhttpcode=true"; - assertEquals(expected, constructedUrl); - } - - @Test - public void testConstructUrl() throws FileNotFoundException, IOException, SvcLogicException - { - Properties props = new Properties(); - props.load(new FileInputStream("src/test/resources/dme2.prod.properties")); - DME2 dme2 = new DME2(props); - Map parameters= new HashMap<>(); - SvcLogicContext ctx= new SvcLogicContext(); - parameters.put(DME2.SERVICE_KEY, "sample.com/services/eim/v1/rest"); - parameters.put(DME2.OUTPUT_PATH_KEY, "tmp.test"); - dme2.constructUrl(parameters,ctx); - String expected= "http://sample.com:25055/service=sample.com/services/eim/v1/rest/version=1.0/envContext=PROD?dme2.password=fake&dme2.username=user@sample.com&partner=LPP_PROD&dme2.allowhttpcode=true"; - assertEquals(expected,ctx.getAttribute(parameters.get(DME2.OUTPUT_PATH_KEY))); - } - -} diff --git a/sliPluginUtils/provider/src/test/resources/dme2.e2e.properties b/sliPluginUtils/provider/src/test/resources/dme2.e2e.properties deleted file mode 100644 index 373448447..000000000 --- a/sliPluginUtils/provider/src/test/resources/dme2.e2e.properties +++ /dev/null @@ -1,7 +0,0 @@ -aafUserName=user@sample.com -aafPassword=fake -envContext=UAT -routeOffer=UAT -proxyUrl=http://sample.com:25055,http://sample.com:25055 -commonServiceVersion=1702.0 -partner= \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/resources/dme2.prod.properties b/sliPluginUtils/provider/src/test/resources/dme2.prod.properties deleted file mode 100644 index 4326b0048..000000000 --- a/sliPluginUtils/provider/src/test/resources/dme2.prod.properties +++ /dev/null @@ -1,7 +0,0 @@ -aafUserName=user@sample.com -aafPassword=fake -envContext=PROD -routeOffer= -proxyUrl=http://sample.com:25055,http://sample.com:25055 -commonServiceVersion=1.0 -partner=LPP_PROD \ No newline at end of file -- cgit 1.2.3-korg From 3afef48beebb503e466c611e2b731f3d761e81fb Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 17 May 2019 20:41:13 +0000 Subject: Make MdsalHelper.getFullPropertiesPath generic Make MdsalHelper.getFullPropertiesPath generic and have a default for backwards compatibility Change-Id: I0d5006b895691d2f0fb2b71803324d58c8819956 Issue-ID: CCSDK-1342 Signed-off-by: Smokowski, Kevin (ks6305) --- .../org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 3 ++- .../onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 818077fb7..4d17f8730 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -1325,7 +1325,8 @@ public class MdsalHelper { @Deprecated public static String getFullPropertiesPath(String propertiesFileName) { - return "/opt/bvc/controller/configuration/" + propertiesFileName; + String karafHome = System.getProperty("karaf.home","/opt/lsc/controller"); + return karafHome + "/configuration/" + propertiesFileName; } // This is called when mapping a valid java enumeration back to the yang model value diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index 56d0369e2..744d48d70 100755 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -349,4 +349,15 @@ public class MdsalHelperTest extends TestCase { MdsalHelper.toProperties(props, address); assertEquals("/cafe:0:0:0:0:0:0:8888", props.getProperty("")); } -} \ No newline at end of file + + public void testGetFullPropertiesPath() { + String propertiesName = "l3ucpe.properties"; + String path = MdsalHelper.getFullPropertiesPath(propertiesName); + //verify the default works + assertEquals("/opt/lsc/controller/configuration/l3ucpe.properties",path); + System.setProperty("karaf.home", "/opt/opendaylight/current"); + path = MdsalHelper.getFullPropertiesPath(propertiesName); + //verify the system property is read + assertEquals("/opt/opendaylight/current/configuration/l3ucpe.properties",path); + } +} -- cgit 1.2.3-korg From a3d782bc5e0bc07fcc5efd9a118e109011ee2889 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 22 May 2019 15:31:08 +0000 Subject: add escape and unescape json to SliStringUtils Add escape and unescape json to SliStringUtils. Can be useful when creating payloads from escaped json or sending payloads that involved escaped json. Change-Id: I736024ef91b5e6fff75374802b0fee2370f12b2f Issue-ID: CCSDK-1353 Signed-off-by: Smokowski, Kevin (ks6305) --- .../sli/core/slipluginutils/SliStringUtils.java | 38 ++++++++++++++++++++++ .../core/slipluginutils/SliStringUtilsTest.java | 20 ++++++++++++ 2 files changed, 58 insertions(+) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index 574178e39..888ef8834 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -437,4 +437,42 @@ public class SliStringUtils implements SvcLogicJavaPlugin { source = StringEscapeUtils.escapeXml(source); ctx.setAttribute(target, source); } + + /** + * unescapeJsonString takes an escaped json string stored as a single property in context memory and unescapes it storing it as a single property + * @param parameters - requires source and outputPath to not be null. + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public static void unescapeJsonString(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] { INPUT_PARAM_SOURCE, INPUT_PARAM_TARGET }, LOG); + try { + String source = parameters.get(INPUT_PARAM_SOURCE); + String target = parameters.get(INPUT_PARAM_TARGET); + String unescapedJson = StringEscapeUtils.unescapeJson(source); + ctx.setAttribute(target, unescapedJson); + } catch (Exception ex) { + ex.printStackTrace(); + throw new SvcLogicException("problem with unescapeJsonString", ex); + } + } + + /** + * escapeJsonString takes json stored as a single string in context memory and escapes it storing it as a single property + * @param parameters - requires source and outputPath to not be null. + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public static void escapeJsonString(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] { INPUT_PARAM_SOURCE, INPUT_PARAM_TARGET }, LOG); + try { + String source = parameters.get(INPUT_PARAM_SOURCE); + String target = parameters.get(INPUT_PARAM_TARGET); + String unescapedJson = StringEscapeUtils.escapeJson(source); + ctx.setAttribute(target, unescapedJson); + } catch (Exception ex) { + ex.printStackTrace(); + throw new SvcLogicException("problem with escapeJsonString", ex); + } + } } diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index 085d46ef7..b88e8d2c9 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -297,4 +297,24 @@ public class SliStringUtilsTest { utils.substring(param, ctx); } + @Test + public void testUnescapeJsonString() throws Exception { + String source = "{\\\"image_name\\\":\\\"Ubuntu 14.04\\\",\\\"service-instance-id\\\":\\\"1\\\",\\\"vnf-model-customization-uuid\\\":\\\"2f\\\",\\\"vnf-id\\\":\\\"3b\\\"}"; + param.put(SliStringUtils.INPUT_PARAM_SOURCE, source); + String outputPath = "unescaped"; + param.put(SliStringUtils.INPUT_PARAM_TARGET, outputPath); + SliStringUtils.unescapeJsonString(param, ctx); + assertEquals("{\"image_name\":\"Ubuntu 14.04\",\"service-instance-id\":\"1\",\"vnf-model-customization-uuid\":\"2f\",\"vnf-id\":\"3b\"}", ctx.getAttribute(outputPath)); + } + + @Test + public void testEscapeJsonString() throws Exception { + String source = "{\"image_name\":\"Ubuntu 14.04\",\"service-instance-id\":\"1\",\"vnf-model-customization-uuid\":\"2f\",\"vnf-id\":\"3b\"}"; + param.put(SliStringUtils.INPUT_PARAM_SOURCE, source); + String outputPath = "unescaped"; + param.put(SliStringUtils.INPUT_PARAM_TARGET, outputPath); + SliStringUtils.escapeJsonString(param, ctx); + assertEquals("{\\\"image_name\\\":\\\"Ubuntu 14.04\\\",\\\"service-instance-id\\\":\\\"1\\\",\\\"vnf-model-customization-uuid\\\":\\\"2f\\\",\\\"vnf-id\\\":\\\"3b\\\"}", ctx.getAttribute(outputPath)); + } + } -- cgit 1.2.3-korg From 82e7550ed8f20025dba7f2a7afb1cd8ae2c7b017 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 23 May 2019 15:50:35 +0000 Subject: Add additional SvcLogicParser junit Add additional SvcLogicParser junit Change-Id: I3186d2ce0981ac20c5655e5f88d8cb2e4ed55b9f Issue-ID: CCSDK-1361 Signed-off-by: Smokowski, Kevin (ks6305) --- .../base/SvcLogicExpressionResolverTest.java | 157 +++++++++++++++++++++ .../src/test/resources/expressions.xml | 55 ++++++++ 2 files changed, 212 insertions(+) create mode 100755 sli/provider-base/src/test/resources/expressions.xml diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java index bf4a2622e..054b38d0f 100644 --- a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolverTest.java @@ -24,6 +24,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.LinkedList; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicExprListener; @@ -32,6 +33,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicExpressionFactory; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -120,4 +122,159 @@ public class SvcLogicExpressionResolverTest extends TestCase { } } + public void testSvcLogicExpressions() throws Exception { + SwitchNodeExecutor switchNodeExecutor = new SwitchNodeExecutor(); + SetNodeExecutor setNodeExecutor = new SetNodeExecutor(); + SvcLogicContext ctx = new SvcLogicContext(); + SvcLogicParser slp = new SvcLogicParser(); + LinkedList graph = slp.parse("src/test/resources/expressions.xml"); + SvcLogicNode root = graph.getFirst().getRootNode(); +//Test a set node that makes use of arithmetic operations +/* + + + + + + + + + + +*/ +//the node matching outcome value 1 comes from parsing the block of xml above + ctx.setAttribute("a", "5"); + ctx.setAttribute("b", "3"); + setNodeExecutor.execute(root.getOutcomeValue("1"), ctx); + assertEquals("2", ctx.getAttribute("add")); + assertEquals("1", ctx.getAttribute("sub")); + assertEquals("3", ctx.getAttribute("div")); + assertEquals("4", ctx.getAttribute("multi")); + assertEquals("2", ctx.getAttribute("addDoubleQuotes")); + assertEquals("1", ctx.getAttribute("subDoubleQuotes")); + assertEquals("3", ctx.getAttribute("divDoubleQuotes")); + assertEquals("4", ctx.getAttribute("multiDoubleQuotes")); + +//Test a set node that makes use of string concatenation +/* + + + + + + + + + + +*/ +//the node matching outcome value 2 comes from parsing the block of xml above + ctx.setAttribute("a", "cat"); + ctx.setAttribute("b", "dog"); + setNodeExecutor.execute(root.getOutcomeValue("2"), ctx); + assertEquals("catdog", ctx.getAttribute("varA")); + assertEquals("catliteral", ctx.getAttribute("varB")); + assertEquals("literaldog", ctx.getAttribute("varC")); + assertEquals("tooliteral", ctx.getAttribute("varD")); + assertEquals("catdog", ctx.getAttribute("varADoubleQuotes")); + assertEquals("catliteral", ctx.getAttribute("varBDoubleQuotes")); + assertEquals("literaldog", ctx.getAttribute("varCDoubleQuotes")); + assertEquals("tooliteral", ctx.getAttribute("varDDoubleQuotes")); + +//Shows how backticks interact with + operator +/* + + + + + + + + +*/ +//the node matching outcome value 3 comes from parsing the block of xml above + ctx.setAttribute("portNumber", "2"); + ctx.setAttribute("slot", "3"); + ctx.setAttribute("shelf", "1"); + + setNodeExecutor.execute(root.getOutcomeValue("3"), ctx); + assertEquals("2", ctx.getAttribute("testOne")); + assertEquals("\"1\" +\"1\"", ctx.getAttribute("testThree")); + assertEquals("6", ctx.getAttribute("testFour")); + assertEquals("2", ctx.getAttribute("testOneDoubleQuotes")); + assertEquals("'1' +'1'", ctx.getAttribute("testThreeDoubleQuotes")); + assertEquals("6", ctx.getAttribute("testFourDoubleQuotes")); + + ctx.setAttribute("a", "5"); + ctx.setAttribute("b", "3"); + + // series of switch statements showing and or != > < >= == <= + // the XML for the node is commented above the line that evaluates that node, the switch statements are single line + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("4"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("5"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("6"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("7"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("8"), ctx)); + + // + assertEquals("false",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("9"), ctx)); + + // + assertEquals("false",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("10"), ctx)); + + // + assertEquals("false",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("11"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("12"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("13"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("14"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("15"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("16"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("17"), ctx)); + + // Series of switch statements that show the effect of using backticks + + ctx.setAttribute("literalStartingWithDollarSign", "DONT READ ME!"); + // + assertEquals("$literalStartingWithDollarSign",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("18"), ctx)); + + ctx.setAttribute("dollarSignFollowedByVariableSurroundedinBackticks", "README"); + // + assertEquals("README",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("19"), ctx)); + + ctx.setAttribute("a", "2"); + ctx.setAttribute("b", "2"); + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("20"), ctx)); + + // + assertEquals("true",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("21"), ctx)); + + // + assertEquals("$a == $b",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("22"), ctx)); + + // + assertEquals("$a == $b",switchNodeExecutor.evaluateNodeTest(root.getOutcomeValue("23"), ctx)); + } } diff --git a/sli/provider-base/src/test/resources/expressions.xml b/sli/provider-base/src/test/resources/expressions.xml new file mode 100755 index 000000000..79118570c --- /dev/null +++ b/sli/provider-base/src/test/resources/expressions.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg From 2f7123a54f1528b20a19d57bae146e01c0499a58 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 31 May 2019 18:58:41 +0000 Subject: Mdsalhelper toBuilder performance issue Mdsalhelper toBuilder performance issue, no impact Change-Id: I2788352b0f25f970380f15653008026f8a12a233 Issue-ID: CCSDK-1374 Signed-off-by: Smokowski, Kevin (ks6305) --- .../java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 4d17f8730..0300236f7 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -401,7 +401,7 @@ public class MdsalHelper { LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); - if (props.contains(pfx + "_length")) { + if (props.containsKey(pfx + "_length")) { try { int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); @@ -413,18 +413,19 @@ public class MdsalHelper { } } + String arrayKey = pfx + "["; + int arrayKeyLength = arrayKey.length(); if (maxIdx == -1) { // Figure out array size for (Object pNameObj : props.keySet()) { String key = (String) pNameObj; - if (key.startsWith(pfx + "[")) { - String idxStr = key.substring(pfx.length() + 1); + if (key.startsWith(arrayKey)) { + String idxStr = key.substring(arrayKeyLength); int endloc = idxStr.indexOf("]"); if (endloc != -1) { idxStr = idxStr.substring(0, endloc); } - try { int curIdx = Integer.parseInt(idxStr); if (curIdx > maxIdx) { -- cgit 1.2.3-korg From df52e371cf9f5e01a721aef0505ebf238e9eed55 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 18 Jun 2019 15:43:26 -0400 Subject: Remove versions from project poms Remove versions from dependencies in project poms and rely instead on dependencyManagement in parent pom. Change-Id: I15a8b25281854dfc84e5dafab79ca522b5dc5c0a Issue-ID: CCSDK-1416 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 2 -- dblib/installer/pom.xml | 2 -- dblib/provider/pom.xml | 3 --- sli/common/pom.xml | 2 -- sli/features/odl-sli/pom.xml | 1 - sli/installer/pom.xml | 3 --- sliPluginUtils/installer/pom.xml | 1 - sliPluginUtils/provider/pom.xml | 1 - 8 files changed, 15 deletions(-) diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index dd26fe87e..7f3f38b4c 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -28,12 +28,10 @@ org.mariadb.jdbc mariadb-java-client - ${mariadb.connector.version} org.apache.tomcat tomcat-jdbc - ${tomcat-jdbc.version} org.onap.ccsdk.sli.core diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index f6122e038..34d171cb0 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -48,12 +48,10 @@ org.slf4j jcl-over-slf4j - ${slf4j.version} org.apache.tomcat tomcat-jdbc - ${tomcat-jdbc.version} diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 245b19691..f1d46bdf3 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -30,7 +30,6 @@ ch.vorburger.mariaDB4j mariaDB4j - 2.2.3 test @@ -54,12 +53,10 @@ org.mariadb.jdbc mariadb-java-client - ${mariadb.connector.version} org.apache.tomcat tomcat-jdbc - ${tomcat-jdbc.version} com.google.guava diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 50e26d49a..908009367 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -50,13 +50,11 @@ org.osgi org.osgi.core - ${osgi.core.version} provided org.mariadb.jdbc mariadb-java-client - ${mariadb.connector.version} jar compile diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 59f14feab..9a9e5255d 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -46,7 +46,6 @@ org.mariadb.jdbc mariadb-java-client - ${mariadb.connector.version} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index a45a030ea..726615f47 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -69,17 +69,14 @@ com.att.eelf eelf-core - 1.0.0 ch.qos.logback logback-core - ${logback.version} ch.qos.logback logback-classic - ${logback.version} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 907a76056..e6f4d3b2c 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -69,7 +69,6 @@ org.apache.commons commons-text - 1.1 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 2b05d93d2..d955a9438 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -66,7 +66,6 @@ org.apache.commons commons-text - 1.1 -- cgit 1.2.3-korg From bcddb35fdcd176e210c95ef8b22d5b0321f1e658 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 25 Jun 2019 16:40:05 +0000 Subject: support yang enumerations with underscores underscores should be stripeed before Enum.valueOf is called Change-Id: Ie69e16dbf515b9fc8375bb9be2597198ccbd3c65 Issue-ID: CCSDK-1434 Signed-off-by: Smokowski, Kevin (ks6305) --- .../main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 3 +++ .../java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java | 1 + 2 files changed, 4 insertions(+) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 0300236f7..730f272ba 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -1255,6 +1255,9 @@ public class MdsalHelper { return (inStr); } + // This is needed for enums containing under scores + inStr = inStr.replaceAll("_", ""); + // This will strip out all periods, which cannot be in a java enum inStr = inStr.replaceAll("\\.", ""); diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index 744d48d70..cebb99663 100755 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -151,6 +151,7 @@ public class MdsalHelperTest extends TestCase { } public void testToJavaEnum() throws Exception { + assertEquals("VENDOR6500MODEL", MdsalHelper.toJavaEnum("VENDOR_6500_MODEL")); assertEquals("_2018HelloWorld", MdsalHelper.toJavaEnum("2018Hello World")); assertEquals("SomethingElse", MdsalHelper.toJavaEnum("Something.Else")); assertEquals("MyTestString", MdsalHelper.toJavaEnum("my-test-string")); -- cgit 1.2.3-korg From 89c0511e3839e2d707c7baf7dbab594eec627d09 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 10 Jul 2019 11:03:36 -0400 Subject: Change log level for parameter print Change execute node so that values of parameters are only printed at TRACE level. Change-Id: I458e77819eef2f14a9e56db44544c3fd945a5a44 Issue-ID: CCSDK-1465 Signed-off-by: Timoney, Dan (dt5972) --- .../org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java index e9fe78e88..cef582b7c 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java @@ -91,7 +91,7 @@ public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { SvcLogicExpression curExpr = curEnt.getValue(); String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); + LOG.trace("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); parmMap.put(curName,curExprValue); } -- cgit 1.2.3-korg From d9d9f8df0b8aa289937f3fad5fff683bbfd9a58a Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 12 Jul 2019 08:29:53 -0400 Subject: Add Brinda as committer Added Brinda as committer to INFO.yaml Change-Id: If012bf5ab89fdf7bf680b1cb0e208191e35b5f6c Issue-ID: CCSDK-1480 Signed-off-by: Timoney, Dan (dt5972) --- INFO.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index f3793623b..7a3f089d5 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -22,7 +22,7 @@ realtime_discussion: '' meetings: - type: 'zoom' agenda: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' - url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project#CommonControllerSDKProject-MeetingMinutes' + url: 'https://wiki.onap.org/display/DW/Common+Controller+SDK+Project' server: 'n/a' channel: 'n/a' repeats: 'weekly' @@ -44,6 +44,11 @@ committers: company: 'Huawei' id: 'agrawalgaurav' timezone: 'Asia/Kolkata' + - name: 'Brinda Santh Muthuramalingam' + email: 'brindasanth@in.ibm.com' + company: 'IBM' + id: 'brindasanthm' + timezone: 'America/New York' repositories: - ccsdk-apps - ccsdk-cds @@ -64,8 +69,9 @@ tsc: - type: 'Deletion' name: 'Ryan Goulding' link: 'https://lists.onap.org/g/onap-tsc/message/4261' - changes: - type: 'Addition' name: 'Gaurav Agrawal' link: 'https://lists.onap.org/g/onap-tsc/message/4324' - + - type: 'Addition' + name: 'Brinda Santh Muthuramalingam' + link: 'https://lists.onap.org/g/onap-tsc/message/5208' -- cgit 1.2.3-korg From 69a3d84baf4c5b312b6fd402616881d4dd6333a3 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 17 Jul 2019 10:54:34 -0400 Subject: Update parent version to 1.3.1 Update parent poms to version 1.3.1-SNAPSHOT Change-Id: I822e73287adcf0edca3283264600a2cbcd4f53b6 Issue-ID: CCSDK-1496 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/ccsdk-slicore-utils/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 47 files changed, 47 insertions(+), 47 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index ac6bf073a..32f6ccca1 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 7f3f38b4c..b4dad637b 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 5adff72f9..35b5b1188 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index b2d55cea3..ee86137b6 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 34d171cb0..876f5ad3f 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/dblib/pom.xml b/dblib/pom.xml index 547294144..db7d4dbcd 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index f1d46bdf3..4cb68f726 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index d2e50a00a..25f7bd0e2 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index fe458ce39..3f35f882a 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 4ca4cc989..0a1d28360 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/features/pom.xml b/features/pom.xml index 606dbda3d..9c1e6e081 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index a390f967d..0f9237bbb 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 3436e06ea..5ffb70d7f 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 69304b3b0..cd59ceaf0 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 64069bf8e..1e61e154f 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/filters/pom.xml b/filters/pom.xml index 8a8b8b249..70103a99a 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 05dac2db9..cb624b71f 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/pom.xml b/pom.xml index b05886e08..2b45ae1bb 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 908009367..75af872f6 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index b3293233a..128d49758 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 9a9e5255d..e7bbb262b 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/features/pom.xml b/sli/features/pom.xml index a960763e5..ae317f6a3 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 726615f47..3a701a174 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/model/pom.xml b/sli/model/pom.xml index d6deac83a..52b8f361a 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/pom.xml b/sli/pom.xml index 933bd3cc7..9fea5cc2f 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index ff01e75d2..0d31e9150 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 00f69c8e7..b97f514a9 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 405bfabe3..6da0a8e77 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 64dd98ff7..2abb298b1 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index cfa0e4dbe..e71995bea 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 77f9ed9fa..6f3a367ee 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index e6f4d3b2c..aa7844631 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 684537bdb..c6bdcedff 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index d955a9438..6291d26ce 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index e65fd23b1..faf4ffc87 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 9b6ced5de..c21ad0c29 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 22cfdf7a7..29f3e84e9 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 99b4a78b1..1d8bd06dc 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 47e3b5abe..90b56d76b 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 817413113..458a6cd4b 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index c91e792c0..be6689ec3 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 3bc78983b..3db798e22 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 497f1c246..74ff3fd97 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 92ce899c6..d371dee63 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 34859ffce..aaeff0736 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/utils/pom.xml b/utils/pom.xml index 7a6aabb82..b9d045dd6 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index ab54f1304..198319cae 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.3.0-SNAPSHOT + 1.3.1-SNAPSHOT -- cgit 1.2.3-korg From 83e356b94c5943e76e47a15abe70d7085ff0bfaf Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 23 Jul 2019 18:26:55 +0000 Subject: Adding a test model This test model will be helpful in unit tests Change-Id: I62f7aa2ed6d1e1ba71c20700a4d29bdca204b4f0 Issue-ID: CCSDK-1521 Signed-off-by: Smokowski, Kevin (ks6305) --- sli/model/src/main/yang/test-model@2019-07-23.yang | 210 +++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100755 sli/model/src/main/yang/test-model@2019-07-23.yang diff --git a/sli/model/src/main/yang/test-model@2019-07-23.yang b/sli/model/src/main/yang/test-model@2019-07-23.yang new file mode 100755 index 000000000..fc8e8b007 --- /dev/null +++ b/sli/model/src/main/yang/test-model@2019-07-23.yang @@ -0,0 +1,210 @@ +module test-model { + + yang-version 1; + + namespace "org:onap:ccsdk:sli:core:testmodel"; + + prefix sample; + + import ietf-inet-types { prefix "inet"; revision-date 2013-07-15; } + + organization "ONAP"; + + contact + "Test Author"; + + description + "A test model not used in business flows"; + + revision "2019-07-23" { + description + "First release of the test model"; + } + + identity sample-identity { + description + "Base identity"; + } + + typedef percentage { + type uint8 { + range "0 .. 100"; + } + description "represents a percentage"; + } + + grouping builtin { + leaf sample-binary { + type binary; + } + leaf sample-bits { + type bits{ + bit fan-running { + position 0; + } + bit hd-led { + position 1; + } + bit power-led { + position 2; + } + } + } + leaf sample-boolean { + type boolean; + } + leaf sample-decimal64 { + type decimal64{ + fraction-digits 1; + } + } + leaf sample-empty { + type empty; + } + leaf sample-enumeration { + type enumeration{ + enum "shelf.slot.port"; + enum "not available"; + enum "CURRENTLY_AVAILABLE"; + enum "200OK"; + enum "hyphen-separated-value"; + } + } + leaf sample-identityref { + type identityref { + base "sample-identity"; + } + } + leaf sample-int8 { + type int8; + } + leaf sample-int16 { + type int16; + } + leaf sample-int32 { + type int32; + } + leaf sample-int64 { + type int64; + } + leaf sample-leafref { + type leafref { + path "../sample-boolean"; + } + } + leaf sample-string { + type string; + } + leaf sample-uint8 { + type uint8; + } + leaf sample-uint16 { + type uint16; + } + leaf sample-uint32 { + type uint32; + } + leaf sample-uint64 { + type uint64; + } + leaf sample-union { + type union { + type int32; + type enumeration { + enum "unbounded"; + } + } + } + leaf percent-completed { + type percentage; + } + } + + grouping inet-types-grouping { + leaf ip-version { + type inet:ip-version; + } + leaf dscp { + type inet:dscp; + } + leaf port-number { + type inet:port-number; + } + leaf ipv6-flow-label { + type inet:ipv6-flow-label; + } + leaf as-number { + type inet:as-number; + } + leaf ip-address { + type inet:ip-address; + } + leaf ipv4-address { + type inet:ipv4-address; + } + leaf ipv6-address { + type inet:ipv6-address; + } + leaf ip-address-no-zone { + type inet:ip-address-no-zone; + } + leaf ipv4-address-no-zone { + type inet:ipv4-address-no-zone; + } + leaf ipv6-address-no-zone { + type inet:ipv6-address-no-zone; + } + leaf ip-prefix { + type inet:ip-prefix; + } + leaf ipv4-prefix { + type inet:ipv4-prefix; + } + leaf ipv6-prefix { + type inet:ipv6-prefix; + } + leaf domain-name { + type inet:domain-name; + } + leaf host { + type inet:host; + } + leaf uri { + type inet:uri; + } + anyxml data; + } + + container sample-container { + leaf customer-name { + type string; + } + + leaf-list customer-nicknames { + type string; + } + + container login { + leaf message { + type string; + description + "Message given at start of login session"; + } + + list customer-addresses { + key "address-name"; + leaf address-name { + type string; + } + leaf street-address { + type string; + } + leaf state { + type string; + } + } + } + uses builtin; + uses inet-types-grouping; + } +} -- cgit 1.2.3-korg From acb4a83484ca6fb1fa97fafaf14626317a2f48e1 Mon Sep 17 00:00:00 2001 From: anushadasari Date: Wed, 24 Jul 2019 13:03:00 +0530 Subject: JUNIT- DuplicateValueException.java JUNIT for file DuplicateValueException.java Issue-ID: CCSDK-1523 Change-Id: I08cb7cca1d02cfac5517ec603273b441b7311ff5 Signed-off-by: anushadasari --- .../sli/core/sli/DuplicatevalueExceptionTest.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/DuplicatevalueExceptionTest.java diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/DuplicatevalueExceptionTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/DuplicatevalueExceptionTest.java new file mode 100644 index 000000000..387873557 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/DuplicatevalueExceptionTest.java @@ -0,0 +1,28 @@ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class DuplicatevalueExceptionTest { + + + @Test + public void DuplicateValueExceptionTest() { + assertNotNull(new DuplicateValueException()); + + } + + @Test + public void DuplicateValueExceptionTestString() { + assertNotNull(new DuplicateValueException("JUnit Test")); + + } + + @Test + public void DuplicateValueExceptionTestStringThrowable() { + assertNotNull(new DuplicateValueException("JUnit Test", new Exception("JUnit Test"))); + + } + +} -- cgit 1.2.3-korg From 46c7c43043d8f48dc866e73c752248f4d466b3a0 Mon Sep 17 00:00:00 2001 From: anushadasari Date: Tue, 23 Jul 2019 23:06:04 +0530 Subject: JUNIT-ConfigurationException.java JUNIT for ConfigurationException.java Issue-ID: CCSDK-1520 Change-Id: I64e50083b9b0fe40fa0ba32723e30adb0dbce08e Signed-off-by: anushadasari --- .../ccsdk/sli/core/dblib/DBLibExceptionTest.java | 14 ---------- .../sli/core/sli/ConfigurationExceptionTestt.java | 30 ++++++++++++++++++++++ sli/features/features-sli/pom.xml | 2 +- 3 files changed, 31 insertions(+), 15 deletions(-) delete mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBLibExceptionTest.java create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ConfigurationExceptionTestt.java diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBLibExceptionTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBLibExceptionTest.java deleted file mode 100644 index cab24042c..000000000 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/DBLibExceptionTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class DBLibExceptionTest { - - @Test - public void testDBLibException() { - assertNotNull(new DBLibException("test")); - } - -} diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ConfigurationExceptionTestt.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ConfigurationExceptionTestt.java new file mode 100644 index 000000000..ef7492366 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ConfigurationExceptionTestt.java @@ -0,0 +1,30 @@ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ConfigurationExceptionTestt { + + + @Test + public void ConfigurationExceptionTest() { + assertNotNull(new ConfigurationException()); + + } + + @Test + public void ConfigurationExceptionTestString() { + assertNotNull(new ConfigurationException("JUnit Test")); + + } + + @Test + public void ConfigurationExceptionTestStringThrowable() { + assertNotNull(new ConfigurationException("JUnit Test", new Exception("JUnit Test"))); + + } + + + +} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 128d49758..c16347968 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -24,6 +24,6 @@ xml features - + -- cgit 1.2.3-korg From 4a1919139ffa44fd413e30d7288cafe659e1cc41 Mon Sep 17 00:00:00 2001 From: anushadasari Date: Wed, 24 Jul 2019 13:07:23 +0530 Subject: JUNIT-ExitNodeException.java Junit for file ExitNodeException.java Issue-ID: CCSDK-1524 Change-Id: If94b520053f47db083779dd38c7117a978bd6ae5 Signed-off-by: anushadasari --- .../ccsdk/sli/core/sli/ExitNodeExceptionTest.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ExitNodeExceptionTest.java diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ExitNodeExceptionTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ExitNodeExceptionTest.java new file mode 100644 index 000000000..039b9f5ca --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ExitNodeExceptionTest.java @@ -0,0 +1,27 @@ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ExitNodeExceptionTest { + + @Test + public void ExitNodeExceptionTest() { + assertNotNull(new ExitNodeException()); + + } + + @Test + public void ExitNodeExceptionTestString() { + assertNotNull(new ExitNodeException("JUnit Test")); + + } + + @Test + public void ExitNodeExceptionTestStringThrowable() { + assertNotNull(new ExitNodeException("JUnit Test", new Exception("JUnit Test"))); + + } + +} -- cgit 1.2.3-korg From 65928b7ad6d4ac0a28f13338baecc9530b15ed0b Mon Sep 17 00:00:00 2001 From: anushadasari Date: Wed, 24 Jul 2019 13:10:51 +0530 Subject: Junit-SvcLogicParserException.java JUNIT for file SvcLogicParserException.java Issue-ID: CCSDK-1525 Change-Id: I64cebc8a692b2c1700a7a28206c30d1ba4e66fc1 Signed-off-by: anushadasari --- .../sli/core/sli/SvcLogicParserExceptionTest.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserExceptionTest.java diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserExceptionTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserExceptionTest.java new file mode 100644 index 000000000..f9d33cb16 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicParserExceptionTest.java @@ -0,0 +1,34 @@ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class SvcLogicParserExceptionTest { + + @Test + public void SvcLogicParserExceptionTest() { + assertNotNull(new SvcLogicParserException()); + + } + + @Test + public void SvcLogicParserExceptionTestString() { + assertNotNull(new SvcLogicParserException("JUnit Test")); + + } + + @Test + public void SvcLogicParserExceptionTestThrowable() { + assertNotNull(new SvcLogicParserException(new Exception("JUnit Test"))); + + } + + @Test + public void SvcLogicParserExceptionTestStringThrowable() { + assertNotNull(new SvcLogicParserException("JUnit Test", new Exception("JUnit Test"))); + + } + + +} -- cgit 1.2.3-korg From e7cf07032824f878ec4aaa746dba24fd87c06afd Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 31 Jul 2019 15:10:19 -0400 Subject: Release sli/core version 0.5.0 Release sli/core version 0.5.0 via new self release process Change-Id: Ieefb18eaecc1d2c11f4466175e165638735e83d6 Issue-ID: CCSDK-1563 Signed-off-by: Timoney, Dan (dt5972) --- releases/0.5.0.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.5.0.yaml diff --git a/releases/0.5.0.yaml b/releases/0.5.0.yaml new file mode 100644 index 000000000..dc9dae2c0 --- /dev/null +++ b/releases/0.5.0.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.5.0' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/157/' -- cgit 1.2.3-korg From 71e3c018f63401ede689d665b5e6d4c9301301f2 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 6 Aug 2019 09:54:45 -0400 Subject: Roll version to recreate release artifacts Roll versions to 0.5.1 - need to re-release El Alto early release Change-Id: Id56175e77fe52596059aa072b8a64c35c1ccba06 Issue-ID: CCSDK-1563 Signed-off-by: Timoney, Dan (dt5972) --- .gitignore | 1 + artifacts/pom.xml | 4 ++-- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/ccsdk-slicore-utils/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 4 ++-- 49 files changed, 95 insertions(+), 94 deletions(-) diff --git a/.gitignore b/.gitignore index 6a9d9826d..9244b48b3 100755 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ target target-ide MANIFEST.MF **/yang-gen-sal +sli/model/src/main/java ## Misc Ignores (OS specific etc) ## bin/ diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 32f6ccca1..ceb1b966d 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.1-SNAPSHOT + 1.3.2 diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index b4dad637b..14a6c3c35 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core ccsdk-dblib - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 35b5b1188..7a8659edc 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core features-dblib - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index ee86137b6..2139d82c9 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 876f5ad3f..1f5913220 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core dblib-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index db7d4dbcd..ff8d83d28 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core dblib - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 4cb68f726..342fbc80a 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core dblib-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 25f7bd0e2..738e55032 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 3f35f882a..d864c7cc0 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core features-sli-core - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 0a1d28360..9c2ebe721 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core slicore-features-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 9c1e6e081..00893b851 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 0f9237bbb..af7c99f5f 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core ccsdk-filters - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 5ffb70d7f..eaf203183 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core features-filters - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index cd59ceaf0..59a24029e 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 1e61e154f..3a4797f64 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core filters-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 70103a99a..35fb5ce24 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core filters - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index cb624b71f..260896e17 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core filters-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 2b45ae1bb..2a0b243e0 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core ccsdk-sli-core - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 75af872f6..b7093c554 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sli-common - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index c16347968..5903ed227 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core features-sli - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index e7bbb262b..9ac645358 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core ccsdk-sli - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index ae317f6a3..7fdc30587 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sli-feature-aggregator - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 3a701a174..90e462523 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sli-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 52b8f361a..fa2c6474e 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sli-model - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 9fea5cc2f..2edc30498 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sli - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 0d31e9150..24c2bede7 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sli-provider-base - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index b97f514a9..9b0c7ddbc 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sli-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 6da0a8e77..f5950cbed 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sli-recording - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 2abb298b1..1f17dad03 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index e71995bea..bdb381630 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core features-sliPluginUtils - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 6f3a367ee..8c0c32f97 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliPluginUtils-features - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index aa7844631..42a13259b 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index c6bdcedff..100e8d513 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliPluginUtils - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 6291d26ce..60f84789f 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index faf4ffc87..960221851 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core ccsdk-sliapi - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index c21ad0c29..660e1b44b 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core features-sliapi - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 29f3e84e9..91305232e 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 1d8bd06dc..2a5333acc 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliapi-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 90b56d76b..910c90f09 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliapi-model - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 458a6cd4b..48ff0374f 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliapi - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index be6689ec3..e8bd62f45 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core sliapi-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 3db798e22..7361a07f8 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 74ff3fd97..5c66fe6e5 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core features-util - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index d371dee63..c6aad2082 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index aaeff0736..c83a446be 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core utils-installer - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index b9d045dd6..6ad6d30f2 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core utils - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 198319cae..bea852a88 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.1-SNAPSHOT + 1.3.2 org.onap.ccsdk.sli.core utils-provider - 0.5.0-SNAPSHOT + 0.5.1-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 1c98ae9b3..813522d54 100644 --- a/version.properties +++ b/version.properties @@ -5,8 +5,8 @@ release_name=0 -sprint_number=4 -feature_revision=2 +sprint_number=5 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From fb964aac0ef1dd30c0fe542b3a690180a1317030 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 6 Aug 2019 11:56:06 -0400 Subject: Add missing version tag Add missing version tag to project pom.xml Change-Id: Ic26f795190b1d543963d3c98256e81531816debc Issue-ID: CCSDK-1563 Signed-off-by: Timoney, Dan (dt5972) --- utils/features/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/features/pom.xml b/utils/features/pom.xml index c6aad2082..77ab9f01c 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -11,6 +11,7 @@ org.onap.ccsdk.sli.core utils-features-aggregator + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} -- cgit 1.2.3-korg From 6ccae7fc25d4ae51b58405b06c4091a6adac2706 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 6 Aug 2019 13:51:40 -0400 Subject: Add missing version tag Add missing version tag to project pom.xml Change-Id: I5dad3bbb9e1d91959304b7e86e1d5bc618b7fbaa Issue-ID: CCSDK-1563 Signed-off-by: Timoney, Dan (dt5972) --- filters/features/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 59a24029e..b0337dadd 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -11,6 +11,7 @@ org.onap.ccsdk.sli.core filters-features-aggregator + 0.5.1-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} -- cgit 1.2.3-korg From 5aa8229c6cda25948c59ac3174071ddf8b83c1dc Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 6 Aug 2019 11:41:25 -0400 Subject: Release 0.5.1 CCSDK artifact Release version 0.5.1 of CCSDK artifacts Issue-ID: CCSDK-1563 Change-Id: Idda8465c70f2c11182b9149ae00b1781a63d65f0 Signed-off-by: Timoney, Dan (dt5972) --- releases/0.5.1.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.5.1.yaml diff --git a/releases/0.5.1.yaml b/releases/0.5.1.yaml new file mode 100644 index 000000000..00785283f --- /dev/null +++ b/releases/0.5.1.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.5.1' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/165/' -- cgit 1.2.3-korg From b1b655ed85713d2143b6ee1c00a3c68238b9227d Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 7 Aug 2019 19:01:10 +0000 Subject: update metric logger name to be consistent update metric logger name to be consistent with convention of the other loggers Issue-ID: CCSDK-1601 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I011745376a940822659eb1de5dcd04aea38b692f --- artifacts/pom.xml | 4 ++-- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 4 ++-- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- .../src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java | 2 +- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/ccsdk-slicore-utils/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 4 ++-- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 2 +- 49 files changed, 96 insertions(+), 96 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index ceb1b966d..405a572b7 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.2 + 1.3.3-SNAPSHOT diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 14a6c3c35..ef0c3ee07 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 7a8659edc..87c7ed78b 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 2139d82c9..89c0c8b19 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 1f5913220..a283157eb 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index ff8d83d28..0d5d565a8 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 342fbc80a..d0b97afe0 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 738e55032..3f9a272a2 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index d864c7cc0..8109a7a29 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 9c2ebe721..b15835444 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 00893b851..52f8a427e 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index af7c99f5f..952e8da11 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index eaf203183..c130afe9c 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index b0337dadd..4daca915f 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core filters-features-aggregator - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 3a4797f64..b980d5a58 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 35fb5ce24..2fee26b06 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 260896e17..bf28ad975 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 2a0b243e0..c52876b93 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index b7093c554..c35397f37 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index b4bd2017e..ccafad0ff 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -41,7 +41,7 @@ import org.slf4j.MDC; public class MetricLogger { private static final Logger KARAF = LoggerFactory.getLogger(MetricLogger.class); - private static final Logger METRIC = LoggerFactory.getLogger("org.onap.ccsdk.sli.filters.metric"); + private static final Logger METRIC = LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.metric"); public static final String BEGIN_TIMESTAMP = "X-ECOMP-BeginTimestamp"; public static final String END_TIMESTAMP = "X-ECOMP-EndTimestamp"; diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 5903ed227..ee93bab69 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 9ac645358..d53cb4498 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 7fdc30587..5beb26338 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 90e462523..54e24d004 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index fa2c6474e..75befd35f 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 2edc30498..bfb63846d 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 24c2bede7..e31119377 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 9b0c7ddbc..aff9ca270 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index f5950cbed..a4ec1b255 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 1f17dad03..a0450630b 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index bdb381630..e639b1c64 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 8c0c32f97..5c56b0174 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 42a13259b..fde893095 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 100e8d513..1ce7757c2 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 60f84789f..49a1210fd 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 960221851..329d6ff7a 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 660e1b44b..c95311cc3 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 91305232e..6e366e6e4 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 2a5333acc..eb69925b5 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 910c90f09..a4faeae36 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 48ff0374f..c5ed07a00 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index e8bd62f45..8dd79432c 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 7361a07f8..fdeeb4412 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 5c66fe6e5..c1e60c647 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 77ab9f01c..19279b3ff 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core utils-features-aggregator - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index c83a446be..db0c505d1 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 6ad6d30f2..2b42734e0 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index bea852a88..2b7799741 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.2 + 1.3.3-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.5.1-SNAPSHOT + 0.5.2-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 813522d54..6a35b9035 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=5 -feature_revision=1 +feature_revision=2 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From b663ad6126af491136470415c8761ce321c2f90e Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 14 Aug 2019 08:55:22 -0400 Subject: Release version 0.5.2 Release version 0.5.2 (last Fluorine SR2 version of CCSDK) Change-Id: I50196bf7df12ca48858889becd0688ae6b045892 Issue-ID: CCSDK-1401 Signed-off-by: Timoney, Dan (dt5972) --- releases/0.5.2.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.5.2.yaml diff --git a/releases/0.5.2.yaml b/releases/0.5.2.yaml new file mode 100644 index 000000000..25c0b4ada --- /dev/null +++ b/releases/0.5.2.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.5.2' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/173/' -- cgit 1.2.3-korg From 06877cb9a30c4ea3e7e95c230f214a78fb4db9e1 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 3 Jul 2019 13:53:18 -0400 Subject: Code changes for OpenDaylight Neon Updated code for OpenDaylight Neon (using ccsdk/parent/tools/fluorine2neon.sh) Change-Id: Ic54b636f691cb2c9dd627dfc3b22b523c0f4f8da Issue-ID: CCSDK-1389 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 +- dblib/features/ccsdk-dblib/pom.xml | 4 +- dblib/features/features-dblib/pom.xml | 4 +- dblib/features/pom.xml | 4 +- dblib/installer/pom.xml | 4 +- dblib/pom.xml | 4 +- dblib/provider/pom.xml | 4 +- .../OSGI-INF/blueprint/dblib-blueprint.xml | 24 + features/ccsdk-sli-core-all/pom.xml | 4 +- features/features-sli-core/pom.xml | 4 +- features/installer/pom.xml | 4 +- features/pom.xml | 4 +- filters/features/ccsdk-filters/pom.xml | 4 +- filters/features/features-filters/pom.xml | 4 +- filters/features/pom.xml | 3 +- filters/installer/pom.xml | 4 +- filters/pom.xml | 4 +- filters/provider/pom.xml | 4 +- .../OSGI-INF/blueprint/filters-blueprint.xml | 9 + pom.xml | 4 +- sli/common/pom.xml | 14 +- sli/features/features-sli/pom.xml | 4 +- sli/features/odl-sli/pom.xml | 4 +- sli/features/pom.xml | 4 +- sli/installer/pom.xml | 4 +- sli/model/pom.xml | 16 +- sli/pom.xml | 4 +- sli/provider-base/pom.xml | 4 +- sli/provider/pom.xml | 4 +- .../resources/OSGI-INF/blueprint/sli-blueprint.xml | 21 + sli/recording/pom.xml | 4 +- .../OSGI-INF/blueprint/recording-blueprint.xml | 20 + .../features/ccsdk-sliPluginUtils/pom.xml | 4 +- .../features/features-sliPluginUtils/pom.xml | 4 +- sliPluginUtils/features/pom.xml | 4 +- sliPluginUtils/installer/pom.xml | 4 +- sliPluginUtils/pom.xml | 4 +- sliPluginUtils/provider/pom.xml | 4 +- .../blueprint/slipluginutils-blueprint.xml | 13 + sliapi/features/ccsdk-sliapi/pom.xml | 4 +- sliapi/features/features-sliapi/pom.xml | 4 +- sliapi/features/pom.xml | 4 +- sliapi/installer/pom.xml | 4 +- sliapi/model/pom.xml | 16 +- sliapi/pom.xml | 4 +- sliapi/provider/pom.xml | 4 +- .../onap/ccsdk/sli/core/sliapi/SliapiProvider.java | 676 ++++++++++++++++++++ .../onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 677 --------------------- .../OSGI-INF/blueprint/sliapi-blueprint.xml | 28 + .../opendaylight/blueprint/sliapi-blueprint.xml | 2 +- .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 10 +- .../src/test/resources/simplelogger.properties | 2 +- utils/features/ccsdk-slicore-utils/pom.xml | 4 +- utils/features/features-util/pom.xml | 4 +- utils/features/pom.xml | 3 +- utils/installer/pom.xml | 4 +- utils/pom.xml | 4 +- utils/provider/pom.xml | 4 +- version.properties | 4 +- 59 files changed, 906 insertions(+), 800 deletions(-) create mode 100755 dblib/provider/src/main/resources/OSGI-INF/blueprint/dblib-blueprint.xml create mode 100644 filters/provider/src/main/resources/OSGI-INF/blueprint/filters-blueprint.xml create mode 100644 sli/provider/src/main/resources/OSGI-INF/blueprint/sli-blueprint.xml create mode 100644 sli/recording/src/main/resources/OSGI-INF/blueprint/recording-blueprint.xml create mode 100644 sliPluginUtils/provider/src/main/resources/OSGI-INF/blueprint/slipluginutils-blueprint.xml create mode 100644 sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/SliapiProvider.java delete mode 100644 sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java create mode 100644 sliapi/provider/src/main/resources/OSGI-INF/blueprint/sliapi-blueprint.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 405a572b7..245077465 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index ef0c3ee07..d541bab9c 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 87c7ed78b..462ca365b 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 89c0c8b19..bac999f62 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index a283157eb..c02f6ee62 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 0d5d565a8..258a4307a 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index d0b97afe0..52a39b8f9 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/provider/src/main/resources/OSGI-INF/blueprint/dblib-blueprint.xml b/dblib/provider/src/main/resources/OSGI-INF/blueprint/dblib-blueprint.xml new file mode 100755 index 000000000..d9bb99c07 --- /dev/null +++ b/dblib/provider/src/main/resources/OSGI-INF/blueprint/dblib-blueprint.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + javax.sql.DataSource + org.onap.ccsdk.sli.core.dblib.DbLibService + + + + + + + + + + \ No newline at end of file diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 3f9a272a2..a040c3687 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 8109a7a29..b90f020e8 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index b15835444..76bd191b2 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 52f8a427e..f374be96b 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 952e8da11..390f1b34e 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index c130afe9c..d72f95a5f 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 4daca915f..494f7f169 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,13 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core filters-features-aggregator - 0.5.2-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index b980d5a58..42c39e9c3 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 2fee26b06..12f44bfeb 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index bf28ad975..e7555aaf6 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/provider/src/main/resources/OSGI-INF/blueprint/filters-blueprint.xml b/filters/provider/src/main/resources/OSGI-INF/blueprint/filters-blueprint.xml new file mode 100644 index 000000000..3bf8423e9 --- /dev/null +++ b/filters/provider/src/main/resources/OSGI-INF/blueprint/filters-blueprint.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/pom.xml b/pom.xml index c52876b93..711f3faea 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index c35397f37..24e29b2ec 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} @@ -70,13 +70,11 @@ test - org.opendaylight.mdsal.model - ietf-inet-types-2013-07-15 - - - org.opendaylight.mdsal.model - ietf-yang-types-20130715 + org.opendaylight.mdsal.binding.model.ietf + rfc6991 + + org.opendaylight.controller sal-core-api diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index ee93bab69..8597432e1 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index d53cb4498..8c46e8193 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 5beb26338..871d41c37 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 54e24d004..ad8a9200e 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 75befd35f..243223e17 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,25 +5,23 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} - org.opendaylight.mdsal.model - ietf-inet-types-2013-07-15 - - - org.opendaylight.mdsal.model - ietf-yang-types-20130715 - + org.opendaylight.mdsal.binding.model.ietf + rfc6991 + + + diff --git a/sli/pom.xml b/sli/pom.xml index bfb63846d..b9b60e9e3 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index e31119377..d1dd62930 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index aff9ca270..1326ef7aa 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} 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 new file mode 100644 index 000000000..bb14477e4 --- /dev/null +++ b/sli/provider/src/main/resources/OSGI-INF/blueprint/sli-blueprint.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + org.onap.ccsdk.sli.core.sli.provider.SvcLogicService + + + + \ No newline at end of file diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index a4ec1b255..de8a56440 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} 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 new file mode 100644 index 000000000..6786b955b --- /dev/null +++ b/sli/recording/src/main/resources/OSGI-INF/blueprint/recording-blueprint.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index a0450630b..f55d3d47e 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index e639b1c64..3950c94ec 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 5c56b0174..d95b5fdf1 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index fde893095..fdb245d62 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 1ce7757c2..f9cdcec2e 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 49a1210fd..1814a0085 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/provider/src/main/resources/OSGI-INF/blueprint/slipluginutils-blueprint.xml b/sliPluginUtils/provider/src/main/resources/OSGI-INF/blueprint/slipluginutils-blueprint.xml new file mode 100644 index 000000000..534b92c93 --- /dev/null +++ b/sliPluginUtils/provider/src/main/resources/OSGI-INF/blueprint/slipluginutils-blueprint.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 329d6ff7a..004ec95f4 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index c95311cc3..8765fb97f 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 6e366e6e4..719aa1962 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index eb69925b5..95fea32cd 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index a4faeae36..2b0f58717 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,25 +5,23 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} - org.opendaylight.mdsal.model - ietf-inet-types-2013-07-15 - - - org.opendaylight.mdsal.model - ietf-yang-types-20130715 - + org.opendaylight.mdsal.binding.model.ietf + rfc6991 + + + diff --git a/sliapi/pom.xml b/sliapi/pom.xml index c5ed07a00..c9541ac22 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 8dd79432c..533b18e0c 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/SliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/SliapiProvider.java new file mode 100644 index 000000000..449fc3822 --- /dev/null +++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/SliapiProvider.java @@ -0,0 +1,676 @@ +/*- + * ============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.sliapi; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.binding.impl.AbstractForwardedDataBroker; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Defines a base implementation for your provider. This class extends from a + * helper class which provides storage for the most commonly used components of + * the MD-SAL. Additionally the base class provides some basic logging and + * initialization / clean up methods. + * + * To use this, copy and paste (overwrite) the following method into the + * TestApplicationProviderModule class which is auto generated under + * src/main/java in this project (created only once during first compilation): + * + *
    + * 
    + * @Override
    + * public java.lang.AutoCloseable createInstance() {
    + * 
    + * 	final SliapiProvider provider = new SliapiProvider();
    + * 	provider.setDataBroker(getDataBrokerDependency());
    + * 	provider.setNotificationService(getNotificationServiceDependency());
    + * 	provider.setRpcRegistry(getRpcRegistryDependency());
    + * 	provider.initialize();
    + * 	return new AutoCloseable() {
    + * 
    + * 		@Override
    + * 		public void close() throws Exception {
    + * 			// TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE
    + * 			// BROKER/NOTIFICATION
    + * 			// SERVIE/RPC REGISTRY
    + * 			provider.close();
    + * 		}
    + * 	};
    + * }
    + * 
    + * 
    + */ +public class SliapiProvider implements AutoCloseable, SLIAPIService { + + private static final Logger LOG = LoggerFactory.getLogger(SliapiProvider.class); + private static final String appName = "slitester"; + + protected DataBroker dataBroker; + protected DOMDataBroker domDataBroker; + protected NotificationPublishService notificationService; + protected RpcProviderRegistry rpcRegistry; + + private SvcLogicService svcLogic; + + protected BindingAwareBroker.RpcRegistration rpcRegistration; + + private static String SLIAPI_NAMESPACE = "org:onap:ccsdk:sli:core:sliapi"; + private static String SLIAPI_REVISION = "2016-11-10"; + private static String SDNC_STATUS_FILE = "SDNC_STATUS_FILE"; + private static String sdncStatusFile = null; + + private static QName TEST_RESULTS_QNAME = null; + private static QName TEST_RESULT_QNAME = null; + private static QName TEST_ID_QNAME = null; + private static QName RESULTS_QNAME = null; + private static final String NON_NULL = "non-null"; + + static { + + TEST_RESULTS_QNAME = QName.create(SLIAPI_NAMESPACE, SLIAPI_REVISION, "test-results"); + TEST_RESULT_QNAME = QName.create(TEST_RESULTS_QNAME, "test-result"); + TEST_ID_QNAME = QName.create(TEST_RESULT_QNAME, "test-identifier"); + RESULTS_QNAME = QName.create(TEST_RESULT_QNAME, "results"); + } + + public SliapiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry) { + this(dataBroker, notificationPublishService, rpcProviderRegistry, findSvcLogicService()); + } + + public SliapiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry, SvcLogicService svcLogic) { + this.LOG.info("Creating provider for " + appName); + this.dataBroker = dataBroker; + this.notificationService = notificationPublishService; + this.rpcRegistry = rpcProviderRegistry; + this.svcLogic = svcLogic; + initialize(); + } + + public void initialize() { + LOG.info("Initializing provider for " + appName); + // initialization code goes here. + rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); + + sdncStatusFile = System.getenv(SDNC_STATUS_FILE); + LOG.info("SDNC STATUS FILE = " + sdncStatusFile); + LOG.info("Initialization complete for " + appName); + } + + protected void initializeChild() { + // Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + LOG.info("Closing provider for " + appName); + // closing code goes here + + rpcRegistration.close(); + LOG.info("Successfully closed provider for " + appName); + } + + public void setDataBroker(DataBroker dataBroker) { + this.dataBroker = dataBroker; + if (dataBroker instanceof AbstractForwardedDataBroker) { + domDataBroker = ((AbstractForwardedDataBroker) dataBroker).getDelegate(); + } + if (LOG.isDebugEnabled()) { + LOG.debug("DataBroker set to " + (dataBroker == null ? "null" : NON_NULL) + "."); + } + } + + public void setNotificationService(NotificationPublishService notificationService) { + this.notificationService = notificationService; + if (LOG.isDebugEnabled()) { + LOG.debug("Notification Service set to " + (notificationService == null ? "null" : NON_NULL) + "."); + } + } + + public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { + this.rpcRegistry = rpcRegistry; + if (LOG.isDebugEnabled()) { + LOG.debug("RpcRegistry set to " + (rpcRegistry == null ? "null" : NON_NULL) + "."); + } + } + + @Override + public ListenableFuture> executeGraph(ExecuteGraphInput input) { + RpcResult rpcResult = null; + + SvcLogicService svcLogic = getSvcLogicService(); + ExecuteGraphOutputBuilder respBuilder = new ExecuteGraphOutputBuilder(); + + String calledModule = input.getModuleName(); + String calledRpc = input.getRpcName(); + Mode calledMode = input.getMode(); + String modeStr = "sync"; + + if (calledMode == Mode.Async) { + modeStr = "async"; + } + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + respBuilder.setResponseCode("404"); + respBuilder.setResponseMessage( + "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + } catch (Exception e) { + LOG.error( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + // Load properties + Properties parms = new Properties(); + + // Pass properties using names from sli-parameters + for (SliParameter sliParm : input.getSliParameter()) { + + String propValue = ""; + + Boolean boolval = sliParm.isBooleanValue(); + + if (boolval != null) { + propValue = boolval.toString(); + } else { + Integer intval = sliParm.getIntValue(); + if (intval != null) { + propValue = intval.toString(); + } else { + propValue = sliParm.getStringValue(); + if (propValue == null) { + propValue = ""; + } + } + } + parms.setProperty(sliParm.getParameterName(), propValue); + } + + // Also, pass "meta" properties (i.e. pass SliParameter objects themselves) + ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder(input); + + SliapiHelper.toProperties(parms, "input", inputBuilder); + + try { + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); + + if (LOG.isTraceEnabled()) { + StringBuffer argList = new StringBuffer(); + argList.append("Parameters : {"); + Enumeration e = parms.propertyNames(); + while (e.hasMoreElements()) { + String propName = (String) e.nextElement(); + argList.append(" (" + propName + "," + parms.getProperty(propName) + ") "); + } + argList.append("}"); + LOG.trace(argList.toString()); + argList = null; + } + + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms, domDataBroker); + + StringBuilder sb = new StringBuilder("{"); + + for (Object key : respProps.keySet()) { + String keyValue = (String) key; + if (keyValue != null && !"".equals(keyValue) && !keyValue.contains("input.sli-parameter")) { + sb.append("\"").append(keyValue).append("\": \"").append(respProps.getProperty(keyValue)) + .append("\","); + } + } + + sb.setLength(sb.length() - 1); + sb.append("}"); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", ""));// TODO change response-text to + // response-message to match + // other BVC APIs + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + respBuilder.setContextMemoryJson(sb.toString()); + + TestResultBuilder testResultBuilder = new TestResultBuilder(); + + SliapiHelper.toBuilder(respProps, testResultBuilder); + + String testIdentifier = testResultBuilder.getTestIdentifier(); + + if ((testIdentifier != null) && (testIdentifier.length() > 0)) { + + // Add test results to config tree + LOG.debug("Saving test results for test id " + testIdentifier); + + DomSaveTestResult(testResultBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + + } + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr + + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule + + "/" + calledRpc + "/" + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + private SvcLogicService getSvcLogicService() { + if (svcLogic == null) { + svcLogic = findSvcLogicService(); + } + + return (svcLogic); + } + + private static SvcLogicService findSvcLogicService() { + BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext(); + + SvcLogicService svcLogic = null; + + // Get SvcLogicService reference + ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME); + if (sref != null) { + svcLogic = (SvcLogicService) bctx.getService(sref); + + } else { + LOG.warn("Cannot find service reference for " + SvcLogicService.NAME); + + } + + return (svcLogic); + } + + @Override + public ListenableFuture> healthcheck(HealthcheckInput healthcheckInput) { + + RpcResult rpcResult = null; + SvcLogicService svcLogic = getSvcLogicService(); + + HealthcheckOutputBuilder respBuilder = new HealthcheckOutputBuilder(); + + String calledModule = "sli"; + String calledRpc = "healthcheck"; + String modeStr = "sync"; + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + respBuilder.setResponseCode("404"); + respBuilder.setResponseMessage( + "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); + + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + } catch (Exception e) { + LOG.error( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + try { + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); + + Properties parms = new Properties(); + + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr + + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule + + "/" + calledRpc + "/" + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + public ListenableFuture> vlbcheck(VlbcheckInput vlbInput) { + + RpcResult rpcResult = null; + SvcLogicService svcLogic = getSvcLogicService(); + + VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder(); + + String calledModule = "sli"; + String calledRpc = "vlbcheck"; + String modeStr = "sync"; + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + boolean dgExists = true; + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + dgExists = false; + } + } catch (Exception e) { + LOG.warn( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); + + dgExists = false; + } + + if (dgExists) { + try { + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); + + Properties parms = new Properties(); + + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + + modeStr + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + + calledModule + "/" + calledRpc + "/" + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } else { + // check the state based on the config file + + boolean suspended = false; + BufferedReader br = null; + String line = ""; + + if (sdncStatusFile != null) { + try { + br = new BufferedReader(new FileReader(sdncStatusFile)); + while ((line = br.readLine()) != null) { + if ("ODL_STATE=SUSPENDED".equals(line)) { + suspended = true; + LOG.debug("vlbcheck: server is suspended"); + } + } + br.close(); + } catch (FileNotFoundException e) { + LOG.trace("Caught File not found exception " + sdncStatusFile + "\n", e); + } catch (Exception e) { + LOG.trace("Failed to read status file " + sdncStatusFile + "\n", e); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + LOG.warn("Failed to close status file " + sdncStatusFile + "\n", e); + } + } + } + } + + if (suspended) { + rpcResult = RpcResultBuilder.failed() + .withError(ErrorType.APPLICATION, "resource-denied", "Server Suspended").build(); + } else { + respBuilder.setResponseMessage("server is normal"); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + } + return (Futures.immediateFuture(rpcResult)); + } + } + + private void DomSaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) { + + if (domDataBroker == null) { + LOG.error("domDataBroker unset - cannot save test result using DOMDataBroker"); + return; + } + + MapEntryNode resultNode = null; + + try { + resultNode = toMapEntryNode(entry); + } catch (Exception e) { + LOG.error("Caught exception trying to create map entry node", e); + } + + if (resultNode == null) { + LOG.error("Could not convert entry to MapEntryNode"); + return; + } + + YangInstanceIdentifier testResultsPid = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) + .node(QName.create(TEST_RESULTS_QNAME, "test-result")).build(); + YangInstanceIdentifier testResultPid = testResultsPid + .node(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, resultNode.getIdentifier().getKeyValues())); + + int tries = 2; + while (true) { + try { + DOMDataWriteTransaction wtx = domDataBroker.newWriteOnlyTransaction(); + if (merge) { + LOG.info("Merging test identifier " + entry.getTestIdentifier()); + wtx.merge(storeType, testResultPid, resultNode); + } else { + LOG.info("Putting test identifier " + entry.getTestIdentifier()); + wtx.put(storeType, testResultPid, resultNode); + } + wtx.submit().checkedGet(); + LOG.trace("Update DataStore succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + LOG.trace("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + LOG.trace("Got OptimisticLockFailedException - trying again "); + } else { + LOG.trace("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + + } + + private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) + throws IllegalStateException { + // Each entry will be identifiable by a unique key, we have to create that + // identifier + + InstanceIdentifier.InstanceIdentifierBuilder testResultIdBuilder = InstanceIdentifier + .builder(TestResults.class).child(TestResult.class, entry.key()); + InstanceIdentifier path = testResultIdBuilder.build(); + int tries = 2; + while (true) { + try { + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); + if (merge) { + tx.merge(storeType, path, entry); + } else { + tx.put(storeType, path, entry); + } + tx.submit().checkedGet(); + LOG.trace("Update DataStore succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + LOG.trace("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + LOG.trace("Got OptimisticLockFailedException - trying again "); + } else { + LOG.trace("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + } + + private MapEntryNode toMapEntryNode(TestResult testResult) { + + YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) + .node(TEST_RESULT_QNAME).build(); + + // Construct results list + LinkedList> entryList = new LinkedList<>(); + for (String result : testResult.getResults()) { + LeafSetEntryNode leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create() + .withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result)).withValue(result).build(); + entryList.add(leafSetEntryNode); + } + // Construct results LeafSetNode + LeafSetNode resultsNode = ImmutableLeafSetNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(RESULTS_QNAME)).withValue(entryList).build(); + + // Construct test result ContainerNode with 2 children - test-identifier leaf + // and results leaf-set + MapEntryNode testResultNode = ImmutableNodes.mapEntryBuilder() + .withNodeIdentifier(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, TEST_ID_QNAME, + testResult.getTestIdentifier())) + .withChild(ImmutableNodes.leafNode(TEST_ID_QNAME, testResult.getTestIdentifier())) + .withChild(resultsNode).build(); + + return (testResultNode); + + } + +} diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java deleted file mode 100644 index 20cbc2e0f..000000000 --- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java +++ /dev/null @@ -1,677 +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.sliapi; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Enumeration; -import java.util.LinkedList; -import java.util.Properties; -import java.util.concurrent.Future; - -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.impl.AbstractForwardedDataBroker; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Defines a base implementation for your provider. This class extends from a - * helper class which provides storage for the most commonly used components of - * the MD-SAL. Additionally the base class provides some basic logging and - * initialization / clean up methods. - * - * To use this, copy and paste (overwrite) the following method into the - * TestApplicationProviderModule class which is auto generated under - * src/main/java in this project (created only once during first compilation): - * - *
    - * 
    - * @Override
    - * public java.lang.AutoCloseable createInstance() {
    - * 
    - * 	final sliapiProvider provider = new sliapiProvider();
    - * 	provider.setDataBroker(getDataBrokerDependency());
    - * 	provider.setNotificationService(getNotificationServiceDependency());
    - * 	provider.setRpcRegistry(getRpcRegistryDependency());
    - * 	provider.initialize();
    - * 	return new AutoCloseable() {
    - * 
    - * 		@Override
    - * 		public void close() throws Exception {
    - * 			// TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE
    - * 			// BROKER/NOTIFICATION
    - * 			// SERVIE/RPC REGISTRY
    - * 			provider.close();
    - * 		}
    - * 	};
    - * }
    - * 
    - * 
    - */ -public class sliapiProvider implements AutoCloseable, SLIAPIService { - - private static final Logger LOG = LoggerFactory.getLogger(sliapiProvider.class); - private static final String appName = "slitester"; - - protected DataBroker dataBroker; - protected DOMDataBroker domDataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - - private SvcLogicService svcLogic; - - protected BindingAwareBroker.RpcRegistration rpcRegistration; - - private static String SLIAPI_NAMESPACE = "org:onap:ccsdk:sli:core:sliapi"; - private static String SLIAPI_REVISION = "2016-11-10"; - private static String SDNC_STATUS_FILE = "SDNC_STATUS_FILE"; - private static String sdncStatusFile = null; - - private static QName TEST_RESULTS_QNAME = null; - private static QName TEST_RESULT_QNAME = null; - private static QName TEST_ID_QNAME = null; - private static QName RESULTS_QNAME = null; - private static final String NON_NULL = "non-null"; - - static { - - TEST_RESULTS_QNAME = QName.create(SLIAPI_NAMESPACE, SLIAPI_REVISION, "test-results"); - TEST_RESULT_QNAME = QName.create(TEST_RESULTS_QNAME, "test-result"); - TEST_ID_QNAME = QName.create(TEST_RESULT_QNAME, "test-identifier"); - RESULTS_QNAME = QName.create(TEST_RESULT_QNAME, "results"); - } - - public sliapiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry) { - this(dataBroker, notificationPublishService, rpcProviderRegistry, findSvcLogicService()); - } - - public sliapiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry, SvcLogicService svcLogic) { - this.LOG.info("Creating provider for " + appName); - this.dataBroker = dataBroker; - this.notificationService = notificationPublishService; - this.rpcRegistry = rpcProviderRegistry; - this.svcLogic = svcLogic; - initialize(); - } - - public void initialize() { - LOG.info("Initializing provider for " + appName); - // initialization code goes here. - rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); - - sdncStatusFile = System.getenv(SDNC_STATUS_FILE); - LOG.info("SDNC STATUS FILE = " + sdncStatusFile); - LOG.info("Initialization complete for " + appName); - } - - protected void initializeChild() { - // Override if you have custom initialization intelligence - } - - @Override - public void close() throws Exception { - LOG.info("Closing provider for " + appName); - // closing code goes here - - rpcRegistration.close(); - LOG.info("Successfully closed provider for " + appName); - } - - public void setDataBroker(DataBroker dataBroker) { - this.dataBroker = dataBroker; - if (dataBroker instanceof AbstractForwardedDataBroker) { - domDataBroker = ((AbstractForwardedDataBroker) dataBroker).getDelegate(); - } - if (LOG.isDebugEnabled()) { - LOG.debug("DataBroker set to " + (dataBroker == null ? "null" : NON_NULL) + "."); - } - } - - public void setNotificationService(NotificationPublishService notificationService) { - this.notificationService = notificationService; - if (LOG.isDebugEnabled()) { - LOG.debug("Notification Service set to " + (notificationService == null ? "null" : NON_NULL) + "."); - } - } - - public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { - this.rpcRegistry = rpcRegistry; - if (LOG.isDebugEnabled()) { - LOG.debug("RpcRegistry set to " + (rpcRegistry == null ? "null" : NON_NULL) + "."); - } - } - - @Override - public ListenableFuture> executeGraph(ExecuteGraphInput input) { - RpcResult rpcResult = null; - - SvcLogicService svcLogic = getSvcLogicService(); - ExecuteGraphOutputBuilder respBuilder = new ExecuteGraphOutputBuilder(); - - String calledModule = input.getModuleName(); - String calledRpc = input.getRpcName(); - Mode calledMode = input.getMode(); - String modeStr = "sync"; - - if (calledMode == Mode.Async) { - modeStr = "async"; - } - - if (svcLogic == null) { - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - try { - if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { - respBuilder.setResponseCode("404"); - respBuilder.setResponseMessage( - "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - } catch (Exception e) { - LOG.error( - "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, - e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - // Load properties - Properties parms = new Properties(); - - // Pass properties using names from sli-parameters - for (SliParameter sliParm : input.getSliParameter()) { - - String propValue = ""; - - Boolean boolval = sliParm.isBooleanValue(); - - if (boolval != null) { - propValue = boolval.toString(); - } else { - Integer intval = sliParm.getIntValue(); - if (intval != null) { - propValue = intval.toString(); - } else { - propValue = sliParm.getStringValue(); - if (propValue == null) { - propValue = ""; - } - } - } - parms.setProperty(sliParm.getParameterName(), propValue); - } - - // Also, pass "meta" properties (i.e. pass SliParameter objects themselves) - ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder(input); - - SliapiHelper.toProperties(parms, "input", inputBuilder); - - try { - LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); - - if (LOG.isTraceEnabled()) { - StringBuffer argList = new StringBuffer(); - argList.append("Parameters : {"); - Enumeration e = parms.propertyNames(); - while (e.hasMoreElements()) { - String propName = (String) e.nextElement(); - argList.append(" (" + propName + "," + parms.getProperty(propName) + ") "); - } - argList.append("}"); - LOG.trace(argList.toString()); - argList = null; - } - - Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms, domDataBroker); - - StringBuilder sb = new StringBuilder("{"); - - for (Object key : respProps.keySet()) { - String keyValue = (String) key; - if (keyValue != null && !"".equals(keyValue) && !keyValue.contains("input.sli-parameter")) { - sb.append("\"").append(keyValue).append("\": \"").append(respProps.getProperty(keyValue)) - .append("\","); - } - } - - sb.setLength(sb.length() - 1); - sb.append("}"); - - respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); - respBuilder.setResponseMessage(respProps.getProperty("error-message", ""));// TODO change response-text to - // response-message to match - // other BVC APIs - respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); - respBuilder.setContextMemoryJson(sb.toString()); - - TestResultBuilder testResultBuilder = new TestResultBuilder(); - - SliapiHelper.toBuilder(respProps, testResultBuilder); - - String testIdentifier = testResultBuilder.getTestIdentifier(); - - if ((testIdentifier != null) && (testIdentifier.length() > 0)) { - - // Add test results to config tree - LOG.debug("Saving test results for test id " + testIdentifier); - - DomSaveTestResult(testResultBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); - - } - - } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr - + ">", e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule - + "/" + calledRpc + "/" + modeStr); - respBuilder.setAckFinalIndicator("Y"); - - } - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - private SvcLogicService getSvcLogicService() { - if (svcLogic == null) { - svcLogic = findSvcLogicService(); - } - - return (svcLogic); - } - - private static SvcLogicService findSvcLogicService() { - BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext(); - - SvcLogicService svcLogic = null; - - // Get SvcLogicService reference - ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME); - if (sref != null) { - svcLogic = (SvcLogicService) bctx.getService(sref); - - } else { - LOG.warn("Cannot find service reference for " + SvcLogicService.NAME); - - } - - return (svcLogic); - } - - @Override - public ListenableFuture> healthcheck(HealthcheckInput healthcheckInput) { - - RpcResult rpcResult = null; - SvcLogicService svcLogic = getSvcLogicService(); - - HealthcheckOutputBuilder respBuilder = new HealthcheckOutputBuilder(); - - String calledModule = "sli"; - String calledRpc = "healthcheck"; - String modeStr = "sync"; - - if (svcLogic == null) { - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - try { - if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { - respBuilder.setResponseCode("404"); - respBuilder.setResponseMessage( - "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); - - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - } catch (Exception e) { - LOG.error( - "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, - e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - try { - LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); - - Properties parms = new Properties(); - - Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); - - respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); - respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); - respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); - - } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr - + ">", e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule - + "/" + calledRpc + "/" + modeStr); - respBuilder.setAckFinalIndicator("Y"); - - } - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - public ListenableFuture> vlbcheck(VlbcheckInput vlbInput) { - - RpcResult rpcResult = null; - SvcLogicService svcLogic = getSvcLogicService(); - - VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder(); - - String calledModule = "sli"; - String calledRpc = "vlbcheck"; - String modeStr = "sync"; - - if (svcLogic == null) { - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - boolean dgExists = true; - try { - if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { - dgExists = false; - } - } catch (Exception e) { - LOG.warn( - "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, - e); - - dgExists = false; - } - - if (dgExists) { - try { - LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); - - Properties parms = new Properties(); - - Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); - - respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); - respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); - respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); - - } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," - + modeStr + ">", e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " - + calledModule + "/" + calledRpc + "/" + modeStr); - respBuilder.setAckFinalIndicator("Y"); - - } - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } else { - // check the state based on the config file - - boolean suspended = false; - BufferedReader br = null; - String line = ""; - - if (sdncStatusFile != null) { - try { - br = new BufferedReader(new FileReader(sdncStatusFile)); - while ((line = br.readLine()) != null) { - if ("ODL_STATE=SUSPENDED".equals(line)) { - suspended = true; - LOG.debug("vlbcheck: server is suspended"); - } - } - br.close(); - } catch (FileNotFoundException e) { - LOG.trace("Caught File not found exception " + sdncStatusFile + "\n", e); - } catch (Exception e) { - LOG.trace("Failed to read status file " + sdncStatusFile + "\n", e); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - LOG.warn("Failed to close status file " + sdncStatusFile + "\n", e); - } - } - } - } - - if (suspended) { - rpcResult = RpcResultBuilder.failed() - .withError(ErrorType.APPLICATION, "resource-denied", "Server Suspended").build(); - } else { - respBuilder.setResponseMessage("server is normal"); - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - } - return (Futures.immediateFuture(rpcResult)); - } - } - - private void DomSaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) { - - if (domDataBroker == null) { - LOG.error("domDataBroker unset - cannot save test result using DOMDataBroker"); - return; - } - - MapEntryNode resultNode = null; - - try { - resultNode = toMapEntryNode(entry); - } catch (Exception e) { - LOG.error("Caught exception trying to create map entry node", e); - } - - if (resultNode == null) { - LOG.error("Could not convert entry to MapEntryNode"); - return; - } - - YangInstanceIdentifier testResultsPid = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) - .node(QName.create(TEST_RESULTS_QNAME, "test-result")).build(); - YangInstanceIdentifier testResultPid = testResultsPid - .node(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, resultNode.getIdentifier().getKeyValues())); - - int tries = 2; - while (true) { - try { - DOMDataWriteTransaction wtx = domDataBroker.newWriteOnlyTransaction(); - if (merge) { - LOG.info("Merging test identifier " + entry.getTestIdentifier()); - wtx.merge(storeType, testResultPid, resultNode); - } else { - LOG.info("Putting test identifier " + entry.getTestIdentifier()); - wtx.put(storeType, testResultPid, resultNode); - } - wtx.submit().checkedGet(); - LOG.trace("Update DataStore succeeded"); - break; - } catch (final TransactionCommitFailedException e) { - if (e instanceof OptimisticLockFailedException) { - if (--tries <= 0) { - LOG.trace("Got OptimisticLockFailedException on last try - failing "); - throw new IllegalStateException(e); - } - LOG.trace("Got OptimisticLockFailedException - trying again "); - } else { - LOG.trace("Update DataStore failed"); - throw new IllegalStateException(e); - } - } - } - - } - - private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) - throws IllegalStateException { - // Each entry will be identifiable by a unique key, we have to create that - // identifier - - InstanceIdentifier.InstanceIdentifierBuilder testResultIdBuilder = InstanceIdentifier - .builder(TestResults.class).child(TestResult.class, entry.key()); - InstanceIdentifier path = testResultIdBuilder.build(); - int tries = 2; - while (true) { - try { - WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); - if (merge) { - tx.merge(storeType, path, entry); - } else { - tx.put(storeType, path, entry); - } - tx.submit().checkedGet(); - LOG.trace("Update DataStore succeeded"); - break; - } catch (final TransactionCommitFailedException e) { - if (e instanceof OptimisticLockFailedException) { - if (--tries <= 0) { - LOG.trace("Got OptimisticLockFailedException on last try - failing "); - throw new IllegalStateException(e); - } - LOG.trace("Got OptimisticLockFailedException - trying again "); - } else { - LOG.trace("Update DataStore failed"); - throw new IllegalStateException(e); - } - } - } - } - - private MapEntryNode toMapEntryNode(TestResult testResult) { - - YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) - .node(TEST_RESULT_QNAME).build(); - - // Construct results list - LinkedList> entryList = new LinkedList<>(); - for (String result : testResult.getResults()) { - LeafSetEntryNode leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create() - .withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result)).withValue(result).build(); - entryList.add(leafSetEntryNode); - } - // Construct results LeafSetNode - LeafSetNode resultsNode = ImmutableLeafSetNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(RESULTS_QNAME)).withValue(entryList).build(); - - // Construct test result ContainerNode with 2 children - test-identifier leaf - // and results leaf-set - MapEntryNode testResultNode = ImmutableNodes.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, TEST_ID_QNAME, - testResult.getTestIdentifier())) - .withChild(ImmutableNodes.leafNode(TEST_ID_QNAME, testResult.getTestIdentifier())) - .withChild(resultsNode).build(); - - return (testResultNode); - - } - -} diff --git a/sliapi/provider/src/main/resources/OSGI-INF/blueprint/sliapi-blueprint.xml b/sliapi/provider/src/main/resources/OSGI-INF/blueprint/sliapi-blueprint.xml new file mode 100644 index 000000000..875027e63 --- /dev/null +++ b/sliapi/provider/src/main/resources/OSGI-INF/blueprint/sliapi-blueprint.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sliapi/provider/src/main/resources/org/opendaylight/blueprint/sliapi-blueprint.xml b/sliapi/provider/src/main/resources/org/opendaylight/blueprint/sliapi-blueprint.xml index 761b014a0..875027e63 100644 --- a/sliapi/provider/src/main/resources/org/opendaylight/blueprint/sliapi-blueprint.xml +++ b/sliapi/provider/src/main/resources/org/opendaylight/blueprint/sliapi-blueprint.xml @@ -19,7 +19,7 @@ interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry" odl:type="default" /> - + diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index 0326429c9..c898ffffe 100644 --- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -65,7 +65,7 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.exe */ public class TestSliapiProvider { - private sliapiProvider provider; + private SliapiProvider provider; private static final String HEALTHCHECK_DG = "sli_healthcheck.xml"; @@ -129,8 +129,8 @@ public class TestSliapiProvider { svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } - // Finally ready to create sliapiProvider - provider = new sliapiProvider(dataBroker, notifyService, rpcRegistry, svc); + // Finally ready to create SliapiProvider + provider = new SliapiProvider(dataBroker, notifyService, rpcRegistry, svc); provider.setDataBroker(dataBroker); provider.setNotificationService(notifyService); provider.setRpcRegistry(rpcRegistry); @@ -146,7 +146,7 @@ public class TestSliapiProvider { /** * Test method for - * {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#executeGraph(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)}. + * {@link SliapiProvider#executeGraph(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)}. */ @Test public void testExecuteGraph() { @@ -198,7 +198,7 @@ public class TestSliapiProvider { /** * Test method for - * {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#healthcheck()}. + * {@link SliapiProvider#healthcheck()}. */ @Test public void testHealthcheck() { diff --git a/sliapi/provider/src/test/resources/simplelogger.properties b/sliapi/provider/src/test/resources/simplelogger.properties index 417c4d143..2f7d8ea0b 100644 --- a/sliapi/provider/src/test/resources/simplelogger.properties +++ b/sliapi/provider/src/test/resources/simplelogger.properties @@ -20,4 +20,4 @@ ### org.slf4j.simpleLogger.defaultLogLevel=info -org.slf4j.simplelogger.log.org.onap.ccsdk.sli.core.sliapi.sliapiProvider=debug +org.slf4j.simplelogger.log.org.onap.ccsdk.sli.core.sliapi.SliapiProvider=debug diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index fdeeb4412..71110f6b6 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index c1e60c647..cc52237da 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 19279b3ff..e1528efb3 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,13 +5,12 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core utils-features-aggregator - 0.5.2-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index db0c505d1..02b824013 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 2b42734e0..f2bb15ca0 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 2b7799741..d65fa253f 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.3.3-SNAPSHOT + 1.4.0-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.5.2-SNAPSHOT + 0.6.0-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 6a35b9035..50be578e4 100644 --- a/version.properties +++ b/version.properties @@ -5,8 +5,8 @@ release_name=0 -sprint_number=5 -feature_revision=2 +sprint_number=6 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 85041dd8795b84a48d0b48dd746bfbcb230c8794 Mon Sep 17 00:00:00 2001 From: Matej Perina Date: Wed, 3 Apr 2019 09:09:00 +0200 Subject: Proposal to remove OSGi dependencies from the CCSDK project Dependencies on the OSGi frameworks and libraries are removed by integrating the CCSDK project with the lighty.io. It's a toolkit that allows to use ODL services (in this case core services and the Restconf) without the dependency on the Karaf framework and the Blueprint DI. In this change are created the lighty.io modules which initialize and expose same services as the Blueprint DI in the blueprint.xml files. More info about the lighty.io - https://lighty.io Change-Id: I38171e83b018a18bfd8eaec95d4dc2fa2e3f5b36 Signed-off-by: Matej Perina Signed-off-by: Samuel Kontris --- dblib/lighty/pom.xml | 51 ++ .../core/dblib/DBLIBResourceProviderLighty.java | 174 ++++ .../sli/core/dblib/DBResourceManagerLighty.java | 977 +++++++++++++++++++++ .../ccsdk/sli/core/dblib/lighty/DblibModule.java | 56 ++ dblib/pom.xml | 1 + lighty/ccsdk-core-lighty/pom.xml | 38 + .../sli/core/lighty/CcsdkCoreLightyModule.java | 148 ++++ .../sli/core/lighty/common/CcsdkLightyUtils.java | 78 ++ lighty/ccsdk-lighty-dependency-versions/pom.xml | 50 ++ lighty/pom.xml | 14 + pom.xml | 1 + sli/lighty/pom.xml | 47 + .../onap/ccsdk/sli/core/sli/lighty/SliModule.java | 77 ++ .../sli/provider/SvcLogicAdaptorFactoryLighty.java | 53 ++ .../sli/provider/SvcLogicClassResolverLighty.java | 51 ++ .../SvcLogicPropertiesProviderImplLighty.java | 172 ++++ .../sli/provider/SvcLogicServiceImplLighty.java | 110 +++ sli/pom.xml | 1 + sliPluginUtils/lighty/pom.xml | 48 + .../lighty/SliPluginUtilsModule.java | 51 ++ sliPluginUtils/pom.xml | 1 + sliapi/lighty/pom.xml | 48 + .../ccsdk/sli/core/sliapi/lighty/SliApiModule.java | 64 ++ .../sli/core/sliapi/sliapiProviderLighty.java | 606 +++++++++++++ sliapi/pom.xml | 1 + 25 files changed, 2918 insertions(+) create mode 100755 dblib/lighty/pom.xml create mode 100644 dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProviderLighty.java create mode 100644 dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManagerLighty.java create mode 100644 dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/lighty/DblibModule.java create mode 100755 lighty/ccsdk-core-lighty/pom.xml create mode 100644 lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/CcsdkCoreLightyModule.java create mode 100644 lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/common/CcsdkLightyUtils.java create mode 100755 lighty/ccsdk-lighty-dependency-versions/pom.xml create mode 100644 lighty/pom.xml create mode 100755 sli/lighty/pom.xml create mode 100644 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/lighty/SliModule.java create mode 100644 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactoryLighty.java create mode 100644 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolverLighty.java create mode 100644 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImplLighty.java create mode 100755 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImplLighty.java create mode 100755 sliPluginUtils/lighty/pom.xml create mode 100644 sliPluginUtils/lighty/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/lighty/SliPluginUtilsModule.java create mode 100755 sliapi/lighty/pom.xml create mode 100644 sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/lighty/SliApiModule.java create mode 100644 sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProviderLighty.java diff --git a/dblib/lighty/pom.xml b/dblib/lighty/pom.xml new file mode 100755 index 000000000..e1ba85f90 --- /dev/null +++ b/dblib/lighty/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + dblib-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-core :: dblib :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + org.opendaylight.aaa + aaa-encrypt-service + + + diff --git a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProviderLighty.java b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProviderLighty.java new file mode 100644 index 000000000..82579d7ec --- /dev/null +++ b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProviderLighty.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Optional; +import java.util.Properties; +import java.util.Vector; +import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; +import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; +import org.opendaylight.aaa.encrypt.AAAEncryptionService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * THIS CLASS IS A COPY OF {@link DBLIBResourceProvider} WITH REMOVED OSGi DEPENDENCIES + */ +public class DBLIBResourceProviderLighty { + + private static final Logger LOG = LoggerFactory.getLogger(DBLIBResourceProviderLighty.class); + + /** + * The name of the properties file for database configuration + */ + private static final String DBLIB_PROP_FILE_NAME = "dblib.properties"; + + private static final String DBLIB_PROPERTY_NAME = "org.onap.ccsdk.sli.jdbc.password"; + private final AAAEncryptionService aaaEncryptionService; + + /** + * A prioritized list of strategies for resolving dblib properties files. + */ + private Vector dblibPropertiesFileResolvers = new Vector<>(); + + /** + * The configuration properties for the db connection. + */ + private Properties properties; + + /** + * Set up the prioritized list of strategies for resolving dblib properties files. + */ + public DBLIBResourceProviderLighty(AAAEncryptionService aaaEncryptionService) { + this.aaaEncryptionService = aaaEncryptionService; + + dblibPropertiesFileResolvers.add(new SdncConfigEnvVarFileResolver( + "Using property file (1) from environment variable" + )); + dblibPropertiesFileResolvers.add(new CoreDefaultFileResolver( + "Using property file (2) from default directory" + )); + dblibPropertiesFileResolvers.add(new KarafRootFileResolver( + "Using property file (4) from karaf root", this)); + + // determines properties file as according to the priority described in the class header comment + final File propertiesFile = determinePropertiesFile(this); + if (propertiesFile != null) { + try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { + properties = new Properties(); + properties.load(fileInputStream); + + if(properties.containsKey(DBLIB_PROPERTY_NAME)) { + String sensitive = properties.getProperty(DBLIB_PROPERTY_NAME); + if(sensitive != null && sensitive.startsWith("ENC:")) { + try { + sensitive = sensitive.substring(4); + String postsense = decrypt(sensitive); + properties.setProperty(DBLIB_PROPERTY_NAME, postsense); + } catch(Exception exc) { + LOG.error("Failed to translate property", exc); + } + } + } + + } catch (final IOException e) { + LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), + new DblibConfigurationException("Failed to load properties for file: " + + propertiesFile.toString(), e)); + } + } + } + + /** + * + * @param value + * @return decrypted string if successful or the original value if unsuccessful + */ + private String decrypt(String value) { + return aaaEncryptionService.decrypt(value); + } + + /** + * Extract db config properties. + * + * @return the db config properties + */ + public Properties getProperties() { + return properties; + } + + /** + * Reports the method chosen for properties resolution to the Logger. + * + * @param message Some user friendly message + * @param fileOptional The file location of the chosen properties file + * @return the file location of the chosen properties file + */ + private static File reportSuccess(final String message, final Optional fileOptional) { + if(fileOptional.isPresent()) { + final File file = fileOptional.get(); + LOG.info("{} {}", message, file.getPath()); + return file; + } + return null; + } + + /** + * Reports fatal errors. This is the case in which no properties file could be found. + * + * @param message An appropriate fatal error message + * @param dblibConfigurationException An exception describing what went wrong during resolution + */ + private static void reportFailure(final String message, + final DblibConfigurationException dblibConfigurationException) { + + LOG.error("{}", message, dblibConfigurationException); + } + + /** + * Determines the dblib properties file to use based on the following priority: + *
      + *
    1. A directory identified by the system environment variable SDNC_CONFIG_DIR
    2. + *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. + *
    5. A directory identified by the JRE argument dblib.properties
    6. + *
    7. A dblib.properties file located in the karaf root directory
    8. + *
    + */ + File determinePropertiesFile(final DBLIBResourceProviderLighty dblibResourceProvider) { + + for (final PropertiesFileResolver dblibPropertiesFileResolver : dblibPropertiesFileResolvers) { + final Optional fileOptional = dblibPropertiesFileResolver.resolveFile(DBLIB_PROP_FILE_NAME); + if (fileOptional.isPresent()) { + return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); + } + } + + reportFailure("Missing configuration properties resource(3)", + new DblibConfigurationException("Missing configuration properties resource(3): " + + DBLIB_PROP_FILE_NAME)); + return null; + } +} diff --git a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManagerLighty.java b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManagerLighty.java new file mode 100644 index 000000000..9b474a5eb --- /dev/null +++ b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManagerLighty.java @@ -0,0 +1,977 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * ================================================================================ + * 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.dblib; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.Driver; +import java.sql.SQLDataException; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.sql.SQLNonTransientConnectionException; +import java.sql.SQLSyntaxErrorException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Observable; +import java.util.Properties; +import java.util.Set; +import java.util.SortedSet; +import java.util.TimerTask; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentSkipListSet; +import java.util.stream.Collectors; +import javax.sql.DataSource; +import javax.sql.rowset.CachedRowSet; +import org.apache.tomcat.jdbc.pool.PoolExhaustedException; +import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; +import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; +import org.onap.ccsdk.sli.core.dblib.config.TerminatingConfiguration; +import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; +import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; +import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * THIS CLASS IS A COPY OF {@link DBResourceManager} WITH REMOVED OSGi DEPENDENCIES + */ +public class DBResourceManagerLighty implements DataSource, DataAccessor, DBResourceObserver, DbLibService { + private static final Logger LOGGER = LoggerFactory.getLogger(DBResourceManagerLighty.class); + private static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url"; + + transient boolean terminating = false; + transient protected long retryInterval = 10000L; + transient boolean recoveryMode = true; + + SortedSet dsQueue = new ConcurrentSkipListSet<>(new DataSourceComparator()); + protected final Set broken = Collections.synchronizedSet(new HashSet()); + protected final Object monitor = new Object(); + protected final Properties configProps; + protected final Thread worker; + + protected final long terminationTimeOut; + protected final boolean monitorDbResponse; + protected final long monitoringInterval; + protected final long monitoringInitialDelay; + protected final long expectedCompletionTime; + protected final long unprocessedFailoverThreshold; + private static final String LOGGER_ALARM_MSG="Generated alarm: DBResourceManager.getData - No active DB connection pools are available."; + private static final String EXCEPTION_MSG= "No active DB connection pools are available in RequestDataNoRecovery call."; + + public DBResourceManagerLighty(final DBLIBResourceProviderLighty configuration) { + this(configuration.getProperties()); + } + + public DBResourceManagerLighty(final Properties properties) { + this.configProps = processSystemVariables(properties); + + // TODO : hack to force classloader to cache mariadb driver. This shouldnt be necessary, + // but for some reason it is (without this, dblib throws ClassNotFound on mariadb driver + // and fails to load). + LOGGER.info("Creating dummy instance of org.mariadb.jdbc.Driver"); + Driver dvr = new org.mariadb.jdbc.Driver(); + dvr = null; + + // get retry interval value + retryInterval = getLongFromProperties(configProps, "org.onap.dblib.connection.retry", 10000L); + + // get recovery mode flag + recoveryMode = getBooleanFromProperties(configProps, "org.onap.dblib.connection.recovery", true); + if(!recoveryMode) + { + recoveryMode = false; + LOGGER.info("Recovery Mode disabled"); + } + // get time out value for thread cleanup + terminationTimeOut = getLongFromProperties(configProps, "org.onap.dblib.termination.timeout", 300000L); + // get properties for monitoring + monitorDbResponse = getBooleanFromProperties(configProps, "org.onap.dblib.connection.monitor", false); + monitoringInterval = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.interval", 1000L); + monitoringInitialDelay = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.startdelay", 5000L); + expectedCompletionTime = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); + unprocessedFailoverThreshold = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); + + // initialize performance monitor + PollingWorker.createInistance(configProps); + + // initialize recovery thread + worker = new RecoveryMgr(); + worker.setName("DBResourcemanagerWatchThread"); + worker.setDaemon(true); + worker.start(); + + try { + this.config(configProps); + } catch (final Exception e) { + // TODO: config throws Exception which is poor practice. Eliminate this in a separate patch. + LOGGER.error("Fatal Exception encountered while configuring DBResourceManager", e); + } + } + + public static Properties processSystemVariables(Properties properties) { + Map hmap = new Properties(); + hmap.putAll(properties); + + Map result = hmap.entrySet().stream() + .filter(map -> map.getValue().toString().startsWith("${")) + .filter(map -> map.getValue().toString().endsWith("}")) + .collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue())); + + result.forEach((name, propEntries) -> { + hmap.put(name, replace(propEntries.toString())); + }); + + if(hmap.containsKey(DATABASE_URL) && hmap.get(DATABASE_URL).toString().contains("${")) { + String url = hmap.get(DATABASE_URL).toString(); + String[] innerChunks = url.split("\\$\\{"); + for(String chunk : innerChunks) { + if(chunk.contains("}")) { + String subChunk = chunk.substring(0, chunk.indexOf("}")); + String varValue = System.getenv(subChunk); + url = url.replace("${"+subChunk+"}", varValue); + } + } + hmap.put(DATABASE_URL, url); + } + return Properties.class.cast(hmap); + } + + + private static String replace(String value) { + String globalVariable = value.substring(2, value.length() -1); + String varValue = System.getenv(globalVariable); + return (varValue != null) ? varValue : value; + } + + + private void config(Properties configProps) throws Exception { + final ConcurrentLinkedQueue semaphore = new ConcurrentLinkedQueue<>(); + final DbConfigPool dbConfig = DBConfigFactory.createConfig(configProps); + + long startTime = System.currentTimeMillis(); + + try { + JDBCConfiguration[] config = dbConfig.getJDBCbSourceArray(); + CachedDataSource[] cachedDS = new CachedDataSource[config.length]; + if (cachedDS == null || cachedDS.length == 0) { + LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); + throw new Exception("Failed to initialize DB Library. No data source was created."); + } + + for(int i = 0; i < config.length; i++) { + cachedDS[i] = CachedDataSourceFactory.createDataSource(config[i]); + if(cachedDS[i] == null) + continue; + semaphore.add(cachedDS[i]); + cachedDS[i].setInterval(monitoringInterval); + cachedDS[i].setInitialDelay(monitoringInitialDelay); + cachedDS[i].setExpectedCompletionTime(expectedCompletionTime); + cachedDS[i].setUnprocessedFailoverThreshold(unprocessedFailoverThreshold); + cachedDS[i].addObserver(DBResourceManagerLighty.this); + } + + DataSourceTester[] tester = new DataSourceTester[config.length]; + + for(int i=0; i { + @Override + public int compare(CachedDataSource left, CachedDataSource right) { + if(LOGGER.isTraceEnabled()) + LOGGER.trace("----------SORTING-------- () : ()", left.getDbConnectionName(), right.getDbConnectionName()); + try { + if(left == right) { + return 0; + } + if(left == null){ + return 1; + } + if(right == null){ + return -1; + } + + boolean leftMaster = !left.isSlave(); + if(leftMaster) { + if(left.getIndex() <= right.getIndex()) + return -1; + else { + boolean rightMaster = !right.isSlave(); + if(rightMaster) { + if(left.getIndex() <= right.getIndex()) + return -1; +// if(left.getIndex() > right.getIndex()) + else { + return 1; + } + } else { + return -1; + } + } + } + if(!right.isSlave()) + return 1; + + if(left.getIndex() <= right.getIndex()) + return -1; + if(left.getIndex() > right.getIndex()) + return 1; + + + } catch (Throwable e) { + LOGGER.warn("", e); + } + return -1; + } + } + + class DataSourceTester extends Thread { + + private final CachedDataSource ds; + private final DBResourceManagerLighty manager; + private final ConcurrentLinkedQueue semaphoreQ; + + public DataSourceTester(CachedDataSource ds, DBResourceManagerLighty manager, ConcurrentLinkedQueue semaphore) { + this.ds = ds; + this.manager = manager; + this.semaphoreQ = semaphore; + } + + @Override + public void run() { + manager.setDataSource(ds); + boolean slave = true; + if(ds != null) { + try { + slave = ds.isSlave(); + } catch (Exception exc) { + LOGGER.warn("", exc); + } + } + if(!slave) { + LOGGER.info("Adding MASTER {} to active queue", ds.getDbConnectionName()); + try { + synchronized (semaphoreQ) { + semaphoreQ.notifyAll(); + } + } catch(Exception exc) { + LOGGER.warn("", exc); + } + } + try { + synchronized (semaphoreQ) { + semaphoreQ.remove(ds); + } + if(semaphoreQ.isEmpty()) { + synchronized (semaphoreQ) { + semaphoreQ.notifyAll(); + } + } + } catch(Exception exc) { + LOGGER.warn("", exc); + } + if(ds != null) + LOGGER.info("Thread DataSourceTester terminated {} for {}", this.getName(), ds.getDbConnectionName()); + } + + } + + + private long getLongFromProperties(Properties props, String property, long defaultValue) + { + String value = null; + long tmpLongValue = defaultValue; + try { + value = props.getProperty(property); + if(value != null) + tmpLongValue = Long.parseLong(value); + + } catch(NumberFormatException exc) { + if(LOGGER.isWarnEnabled()){ + LOGGER.warn("'"+property+"'=" + value+" is invalid. It should be a numeric value"); + } + } catch(Exception exc) { + } + return tmpLongValue; + + } + + private boolean getBooleanFromProperties(Properties props, String property, boolean defaultValue) + { + boolean tmpValue = defaultValue; + String value = null; + + try { + value = props.getProperty(property); + if(value != null) + tmpValue = Boolean.parseBoolean(value); + + } catch(NumberFormatException exc) { + if(LOGGER.isWarnEnabled()){ + LOGGER.warn("'"+property+"'=" + value+" is invalid. It should be a boolean value"); + } + } catch(Exception exc) { + } + return tmpValue; + + } + + + @Override + public void update(Observable observable, Object data) { + // if observable is active and there is a standby available, switch + if(observable instanceof SQLExecutionMonitor) + { + SQLExecutionMonitor monitor = (SQLExecutionMonitor)observable; + if(monitor.getParent() instanceof CachedDataSource) + { + CachedDataSource dataSource = (CachedDataSource)monitor.getParent(); + if(dataSource == dsQueue.first()) + { + if(recoveryMode && dsQueue.size() > 1){ + handleGetConnectionException(dataSource, new Exception(data.toString())); + } + } + } + } + } + + public void testForceRecovery() + { + CachedDataSource active = this.dsQueue.first(); + handleGetConnectionException(active, new Exception("test")); + } + + class RecoveryMgr extends Thread { + + @Override + public void run() { + while(!terminating) + { + try { + Thread.sleep(retryInterval); + } catch (InterruptedException e1) { } + CachedDataSource brokenSource = null; + try { + if (!broken.isEmpty()) { + CachedDataSource[] sourceArray = broken.toArray(new CachedDataSource[0]); + for (int i = 0; i < sourceArray.length; i++) + { + brokenSource = sourceArray[i]; + if (brokenSource instanceof TerminatingCachedDataSource) + break; + if (resetConnectionPool(brokenSource)) { + broken.remove(brokenSource); + brokenSource.blockImmediateOffLine(); + dsQueue.add(brokenSource); + LOGGER.info("DataSource <" + + brokenSource.getDbConnectionName() + + "> recovered."); + } + brokenSource = null; + } + } + } catch (Exception exc) { + LOGGER.warn(exc.getMessage()); + if(brokenSource != null){ + try { + if(!broken.contains(brokenSource)) + broken.add(brokenSource); + brokenSource = null; + } catch (Exception e1) { } + } + } + } + LOGGER.info("DBResourceManager.RecoveryMgr <"+this.toString() +"> terminated." ); + } + + private boolean resetConnectionPool(CachedDataSource dataSource){ + try { + return dataSource.testConnection(); + } catch (Exception exc) { + LOGGER.info("DataSource <" + dataSource.getDbConnectionName() + "> resetCache failed with error: "+ exc.getMessage()); + return false; + } + } + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#getData(java.lang.String, java.util.ArrayList, java.lang.String) + */ + @Override + public CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) throws SQLException { + ArrayList newList= new ArrayList<>(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + if(recoveryMode) + return requestDataWithRecovery(statement, newList, preferredDS); + else + return requestDataNoRecovery(statement, newList, preferredDS); + } + + private CachedRowSet requestDataWithRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + Throwable lastException = null; + + // test if there are any connection pools available + if(this.dsQueue.isEmpty()){ + LOGGER.error(LOGGER_ALARM_MSG); + throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); + } + + // loop through available data sources to retrieve data. + for(int i=0; i< 2; i++) + { + CachedDataSource active = this.dsQueue.first(); + + long time = System.currentTimeMillis(); + try { + if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } + } + + return active.getData(statement, arguments); + } catch(SQLDataException | SQLSyntaxErrorException | SQLIntegrityConstraintViolationException exc){ + throw exc; + } catch(Throwable exc){ + if(exc instanceof SQLException) { + SQLException sqlExc = (SQLException)exc; + int code = sqlExc.getErrorCode(); + String state = sqlExc.getSQLState(); + LOGGER.debug("SQLException code: {} state: {}", code, state); + if("07001".equals(sqlExc.getSQLState())) { + throw sqlExc; + } + } + lastException = exc; + LOGGER.error("Generated alarm: {}", active.getDbConnectionName(), exc); + handleGetConnectionException(active, exc); + } finally { + if(LOGGER.isDebugEnabled()){ + time = System.currentTimeMillis() - time; + LOGGER.debug("getData processing time : {} {} miliseconds.", active.getDbConnectionName(), time); + } + } + } + if(lastException instanceof SQLException){ + throw (SQLException)lastException; + } + // repackage the exception + // you are here because either you run out of available data sources + // or the last exception was not of SQLException type. + // repackage the exception + if(lastException == null) { + throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); + } else { + SQLException exception = new DBLibException(lastException.getMessage()); + exception.setStackTrace(lastException.getStackTrace()); + if(lastException.getCause() instanceof SQLException) { + throw (SQLException)lastException.getCause(); + } + throw exception; + } + } + + private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + if(dsQueue.isEmpty()){ + LOGGER.error(LOGGER_ALARM_MSG); + throw new DBLibException(EXCEPTION_MSG); + } + CachedDataSource active = this.dsQueue.first(); + long time = System.currentTimeMillis(); + try { + if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } + } + return active.getData(statement, arguments); + + } catch(Throwable exc){ + String message = exc.getMessage(); + if(message == null) + message = exc.getClass().getName(); + LOGGER.error("Generated alarm: {} - {}",active.getDbConnectionName(), message); + if(exc instanceof SQLException) + throw (SQLException)exc; + else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } finally { + if(LOGGER.isDebugEnabled()){ + time = System.currentTimeMillis() - time; + LOGGER.debug(">> getData : {} {} miliseconds.", active.getDbConnectionName(), time); + } + } + } + + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#writeData(java.lang.String, java.util.ArrayList, java.lang.String) + */ + @Override + public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException + { + ArrayList newList= new ArrayList<>(); + if(arguments != null && !arguments.isEmpty()) { + newList.addAll(arguments); + } + + return writeDataNoRecovery(statement, newList, preferredDS); + } + + synchronized CachedDataSource findMaster() throws SQLException { + final CachedDataSource[] clone = this.dsQueue.toArray(new CachedDataSource[0]); + + for(final CachedDataSource dss : clone) { + if(!dss.isSlave()) { + final CachedDataSource first = this.dsQueue.first(); + if(first != dss) { + if(LOGGER.isDebugEnabled()) + LOGGER.debug("----------REODRERING--------"); + dsQueue.clear(); + if(!dsQueue.addAll(Arrays.asList(clone))) { + LOGGER.error("Failed adding datasources"); + } + } + return dss; + } + } + LOGGER.warn("MASTER not found."); + return null; + } + + + private boolean writeDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { + if(dsQueue.isEmpty()){ + LOGGER.error(LOGGER_ALARM_MSG); + throw new DBLibException(EXCEPTION_MSG); + } + + boolean initialRequest = true; + boolean retryAllowed = true; + CachedDataSource active = this.dsQueue.first(); + long time = System.currentTimeMillis(); + while(initialRequest) { + initialRequest = false; + try { + if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } + } + + return active.writeData(statement, arguments); + } catch(Throwable exc){ + String message = exc.getMessage(); + if(message == null) + message = exc.getClass().getName(); + LOGGER.error("Generated alarm: {} - {}", active.getDbConnectionName(), message); + if(exc instanceof SQLException) { + SQLException sqlExc = SQLException.class.cast(exc); + // handle read-only exception + if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { + LOGGER.warn("retrying due to: {}", sqlExc.getMessage()); + this.findMaster(); + if(retryAllowed){ + retryAllowed = false; + initialRequest = true; + continue; + } + } + throw (SQLException)exc; + } else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } finally { + if(LOGGER.isDebugEnabled()){ + time = System.currentTimeMillis() - time; + LOGGER.debug("writeData processing time : {} {} miliseconds.", active.getDbConnectionName(), time); + } + } + } + return true; + } + + public void setDataSource(CachedDataSource dataSource) { + if(this.dsQueue.contains(dataSource)) + return; + if(this.broken.contains(dataSource)) + return; + + if(dataSource.testConnection(true)){ + this.dsQueue.add(dataSource); + } else { + this.broken.add(dataSource); + } + } + + @Override + public Connection getConnection() throws SQLException { + Throwable lastException = null; + CachedDataSource active = null; + + if(dsQueue.isEmpty()){ + throw new DBLibException("No active DB connection pools are available in GetConnection call."); + } + + try { + active = dsQueue.first(); + + if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { + LOGGER.debug("Forcing reorder on: {}", dsQueue.toString()); + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } + } + return new DBLibConnection(active.getConnection(), active); + } catch(javax.sql.rowset.spi.SyncFactoryException exc){ + LOGGER.debug("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); + LOGGER.warn("CLASSPATH issue. Allowing retry", exc); + lastException = exc; + } catch(PoolExhaustedException exc) { + throw new NoAvailableConnectionsException(exc); + } catch(SQLNonTransientConnectionException exc){ + throw new NoAvailableConnectionsException(exc); + } catch(Exception exc){ + lastException = exc; + if(recoveryMode){ + handleGetConnectionException(active, exc); + } else { + if(exc instanceof SQLException) { + throw (SQLException)exc; + } else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } + } catch (Throwable trwb) { + DBLibException excptn = new DBLibException(trwb.getMessage()); + excptn.setStackTrace(trwb.getStackTrace()); + throw excptn; + } finally { + if(LOGGER.isDebugEnabled()){ + displayState(); + } + } + + if(lastException instanceof SQLException){ + throw (SQLException)lastException; + } + // repackage the exception + if(lastException == null) { + throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); + } else { + SQLException exception = new DBLibException(lastException.getMessage()); + exception.setStackTrace(lastException.getStackTrace()); + if(lastException.getCause() instanceof SQLException) { + + throw (SQLException)lastException.getCause(); + } + throw exception; + } + } + + @Override + public Connection getConnection(String username, String password) + throws SQLException { + CachedDataSource active = null; + + if(dsQueue.isEmpty()){ + throw new DBLibException("No active DB connection pools are available in GetConnection call."); + } + + + try { + active = dsQueue.first(); + if(!active.isFabric()) { + if(this.dsQueue.size() > 1 && active.isSlave()) { + CachedDataSource master = findMaster(); + if(master != null) { + active = master; + } + } + } + return active.getConnection(username, password); + } catch(Throwable exc){ + if(recoveryMode){ + handleGetConnectionException(active, exc); + } else { + if(exc instanceof SQLException) + throw (SQLException)exc; + else { + DBLibException excptn = new DBLibException(exc.getMessage()); + excptn.setStackTrace(exc.getStackTrace()); + throw excptn; + } + } + + } + + throw new DBLibException("No connections available in DBResourceManager in GetConnection call."); + } + + private void handleGetConnectionException(final CachedDataSource source, Throwable exc) { + try { + if(!source.canTakeOffLine()) + { + LOGGER.error("Could not switch due to blocking"); + return; + } + + boolean removed = dsQueue.remove(source); + if(!broken.contains(source)) + { + if(broken.add(source)) + { + LOGGER.warn("DB Recovery: DataSource <" + source.getDbConnectionName() + "> put in the recovery mode. Reason : " + exc.getMessage()); + } else { + LOGGER.warn("Error putting DataSource <" +source.getDbConnectionName()+ "> in recovery mode."); + } + } else { + LOGGER.info("DB Recovery: DataSource <" + source.getDbConnectionName() + "> already in recovery queue"); + } + if(removed) + { + if(!dsQueue.isEmpty()) + { + LOGGER.warn("DB DataSource <" + dsQueue.first().getDbConnectionName() + "> became active"); + } + } + } catch (Exception e) { + LOGGER.error("", e); + } + } + + public void cleanUp() { + for(Iterator it=dsQueue.iterator();it.hasNext();){ + CachedDataSource cds = it.next(); + it.remove(); + cds.cleanUp(); + } + + try { + this.terminating = true; + if(broken != null) + { + try { + broken.add( new TerminatingCachedDataSource(new TerminatingConfiguration())); + } catch(Exception exc){ + LOGGER.error("Waiting for Worker to stop", exc); + } + } + worker.join(terminationTimeOut); + LOGGER.info("DBResourceManager.RecoveryMgr <"+worker.toString() +"> termination was successful: " + worker.getState()); + } catch(Exception exc){ + LOGGER.error("Waiting for Worker thread to terminate ", exc); + } + } + + @Override + public PrintWriter getLogWriter() throws SQLException { + return this.dsQueue.first().getLogWriter(); + } + + @Override + public int getLoginTimeout() throws SQLException { + return this.dsQueue.first().getLoginTimeout(); + } + + @Override + public void setLogWriter(PrintWriter out) throws SQLException { + this.dsQueue.first().setLogWriter(out); + } + + @Override + public void setLoginTimeout(int seconds) throws SQLException { + this.dsQueue.first().setLoginTimeout(seconds); + } + + public void displayState(){ + if(LOGGER.isDebugEnabled()){ + LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); + CachedDataSource current = dsQueue.first(); + if(current != null) { + LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); + } + } + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#isActive() + */ + @Override + public boolean isActive() { + return this.dsQueue.size()>0; + } + + public String getActiveStatus(){ + return "Connected: " + dsQueue.size()+"\tIn-recovery: "+broken.size(); + } + + public String getDBStatus(boolean htmlFormat) { + StringBuilder buffer = new StringBuilder(); + + ArrayList list = new ArrayList<>(); + list.addAll(dsQueue); + list.addAll(broken); + if (htmlFormat) + { + buffer.append("") + .append("Name:").append(""); + for (int i = 0; i < list.size(); i++) { + buffer.append(""); + buffer.append(list.get(i).getDbConnectionName()).append(""); + } + buffer.append(""); + + buffer.append("State:"); + for (int i = 0; i < list.size(); i++) { + if (broken.contains(list.get(i))) { + buffer.append("in recovery"); + } + if (dsQueue.contains(list.get(i))) { + if (dsQueue.first() == list.get(i)) + buffer.append("active"); + else + buffer.append("standby"); + } + } + buffer.append(""); + + } else { + for (int i = 0; i < list.size(); i++) { + buffer.append("Name: ").append(list.get(i).getDbConnectionName()); + buffer.append("\tState: "); + if (broken.contains(list.get(i))) { + buffer.append("in recovery"); + } else + if (dsQueue.contains(list.get(i))) { + if (dsQueue.first() == list.get(i)) + buffer.append("active"); + else + buffer.append("standby"); + } + + buffer.append("\n"); + + } + } + return buffer.toString(); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return false; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return null; + } + + /** + * @return the monitorDbResponse + */ + @Override + public final boolean isMonitorDbResponse() { + return recoveryMode && monitorDbResponse; + } + + public void test(){ + CachedDataSource obj = dsQueue.first(); + Exception ption = new Exception(); + try { + for(int i=0; i<5; i++) + { + handleGetConnectionException(obj, ption); + } + } catch(Throwable exc){ + LOGGER.warn("", exc); + } + } + + @Override + public java.util.logging.Logger getParentLogger() + throws SQLFeatureNotSupportedException { + return null; + } + + class RemindTask extends TimerTask { + @Override + public void run() { + CachedDataSource ds = dsQueue.first(); + if(ds != null) + ds.getPoolInfo(false); + } + } + + public int poolSize() { + return dsQueue.size(); + } +} diff --git a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/lighty/DblibModule.java b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/lighty/DblibModule.java new file mode 100644 index 000000000..bce166dff --- /dev/null +++ b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/lighty/DblibModule.java @@ -0,0 +1,56 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.dblib.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProviderLighty; +import org.onap.ccsdk.sli.core.dblib.DBResourceManagerLighty; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.opendaylight.aaa.encrypt.AAAEncryptionService; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the dblib artifact. + */ +public class DblibModule extends AbstractLightyModule { + + private final AAAEncryptionService aaaEncryptionService; + + private DBLIBResourceProviderLighty dbLibResourceProvider; + private DBResourceManagerLighty dbResourceManager; + + public DblibModule(AAAEncryptionService aaaEncryptionService) { + this.aaaEncryptionService = aaaEncryptionService; + } + + @Override + protected boolean initProcedure() { + this.dbLibResourceProvider = new DBLIBResourceProviderLighty(aaaEncryptionService); + this.dbResourceManager = new DBResourceManagerLighty(this.dbLibResourceProvider); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + + public DbLibService getDbLibService() { + return dbResourceManager; + } +} diff --git a/dblib/pom.xml b/dblib/pom.xml index 258a4307a..d5a986e6c 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -24,5 +24,6 @@ provider features installer + lighty diff --git a/lighty/ccsdk-core-lighty/pom.xml b/lighty/ccsdk-core-lighty/pom.xml new file mode 100755 index 000000000..24c03cc2b --- /dev/null +++ b/lighty/ccsdk-core-lighty/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.core + ccsdk-core-lighty + 0.6.0-SNAPSHOT + jar + + + 1.8 + 1.8 + UTF-8 + + + + + org.onap.ccsdk.sli.core + dblib-lighty + ${project.version} + + + org.onap.ccsdk.sli.core + sli-lighty + ${project.version} + + + org.onap.ccsdk.sli.core + sliapi-lighty + ${project.version} + + + org.onap.ccsdk.sli.core + sliPluginUtil-lighty + ${project.version} + + + diff --git a/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/CcsdkCoreLightyModule.java b/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/CcsdkCoreLightyModule.java new file mode 100644 index 000000000..578d18240 --- /dev/null +++ b/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/CcsdkCoreLightyModule.java @@ -0,0 +1,148 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import org.onap.ccsdk.sli.core.dblib.lighty.DblibModule; +import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.core.sli.lighty.SliModule; +import org.onap.ccsdk.sli.core.sliapi.lighty.SliApiModule; +import org.onap.ccsdk.sli.core.slipluginutils.lighty.SliPluginUtilsModule; +import org.opendaylight.aaa.encrypt.AAAEncryptionService; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all other LightyModules + * from the ccsdk-sli-core repository so they can be all treated as one component (for example started/stopped at once). + * For more information about the lighty.io visit the website https://lighty.io. + */ +public class CcsdkCoreLightyModule extends AbstractLightyModule { + + private static final Logger LOG = LoggerFactory.getLogger(CcsdkCoreLightyModule.class); + + private final DataBroker dataBroker; + private final NotificationPublishService notificationPublishService; + private final RpcProviderRegistry rpcProviderRegistry; + private final AAAEncryptionService aaaEncryptionService; + private final SvcLogicResource svcLogicResource; + private final SvcLogicRecorder svcLogicRecorder; + private final SvcLogicJavaPlugin svcLogicJavaPlugin; + private final SvcLogicAdaptor svcLogicAdaptor; + + private DblibModule dblibModule; + private SliModule sliModule; + private SliApiModule sliApiModule; + private SliPluginUtilsModule sliPluginUtilsModule; + + // FIXME cyclic dependency - implementation of SvcLogicResource is located in adaptors and CcsdkAdaptorsLightyModule + // is depencent on DbLibService from core + public CcsdkCoreLightyModule(DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry, AAAEncryptionService aaaEncryptionService, + SvcLogicResource svcLogicResource, SvcLogicRecorder svcLogicRecorder, SvcLogicJavaPlugin svcLogicJavaPlugin, + SvcLogicAdaptor svcLogicAdaptor) { + this.dataBroker = dataBroker; + this.notificationPublishService = notificationPublishService; + this.rpcProviderRegistry = rpcProviderRegistry; + this.aaaEncryptionService = aaaEncryptionService; + this.svcLogicResource = svcLogicResource; + this.svcLogicRecorder = svcLogicRecorder; + this.svcLogicJavaPlugin = svcLogicJavaPlugin; + this.svcLogicAdaptor = svcLogicAdaptor; + } + + protected boolean initProcedure() { + LOG.debug("Initializing CCSDK Core Lighty module..."); + + this.dblibModule = new DblibModule(aaaEncryptionService); + if (!CcsdkLightyUtils.startLightyModule(dblibModule)) { + return false; + } + + this.sliModule = new SliModule(dblibModule.getDbLibService(), svcLogicResource, svcLogicRecorder, + svcLogicJavaPlugin, svcLogicAdaptor); + if (!CcsdkLightyUtils.startLightyModule(sliModule)) { + return false; + } + + this.sliApiModule = new SliApiModule(dataBroker, notificationPublishService, rpcProviderRegistry, sliModule.getSvcLogicServiceImpl()); + if (!CcsdkLightyUtils.startLightyModule(sliApiModule)) { + return false; + } + + this.sliPluginUtilsModule = new SliPluginUtilsModule(); + if (!CcsdkLightyUtils.startLightyModule(sliPluginUtilsModule)) { + return false; + } + + LOG.debug("CCSDK Core Lighty module was initialized successfully"); + return true; + } + + protected boolean stopProcedure() { + LOG.debug("Stopping CCSDK Core Lighty module..."); + + boolean stopSuccessful = true; + + if (!CcsdkLightyUtils.stopLightyModule(sliPluginUtilsModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(sliApiModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(sliModule)) { + stopSuccessful = false; + } + + if (!CcsdkLightyUtils.stopLightyModule(dblibModule)) { + stopSuccessful = false; + } + + if (stopSuccessful) { + LOG.debug("CCSDK Core Lighty module was stopped successfully"); + } else { + LOG.error("CCSDK Core Lighty module was not stopped successfully!"); + } + return stopSuccessful; + } + + public DblibModule getDblibModule() { + return dblibModule; + } + + public SliModule getSliModule() { + return sliModule; + } + + public SliApiModule getSliApiModule() { + return sliApiModule; + } + + public SliPluginUtilsModule getSliPluginUtilsModule() { + return sliPluginUtilsModule; + } +} diff --git a/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/common/CcsdkLightyUtils.java b/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/common/CcsdkLightyUtils.java new file mode 100644 index 000000000..bfbcb135b --- /dev/null +++ b/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/common/CcsdkLightyUtils.java @@ -0,0 +1,78 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.lighty.common; + +import io.lighty.core.controller.api.LightyModule; +import java.util.concurrent.ExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Utils class containing methods to start/stop LightyModules easier. + */ +public class CcsdkLightyUtils { + + private static final Logger LOG = LoggerFactory.getLogger(CcsdkLightyUtils.class); + + private CcsdkLightyUtils() { + throw new IllegalStateException("This class should not be instantiated!"); + } + + /** + * Starts provided LightyModule + * @param lightyModule LightyModule to start + * @return true if start was successful; false otherwise + */ + public static boolean startLightyModule(LightyModule lightyModule) { + LOG.debug("Starting Lighty module: {} ...", lightyModule.getClass()); + try { + if (lightyModule.start().get()) { + LOG.debug("Lighty module: {} was started successfully", lightyModule.getClass()); + return true; + } else { + LOG.error("Unable to start Lighty Module: {}!", lightyModule.getClass()); + return false; + } + } catch (InterruptedException | ExecutionException e) { + LOG.error("Exception thrown while initializing Lighty Module: {}!", lightyModule.getClass(), e); + return false; + } + } + + /** + * Stops provided LightyModule + * @param lightyModule LightyModule to stop + * @return true if stop was successful; false otherwise + */ + public static boolean stopLightyModule(LightyModule lightyModule) { + LOG.debug("Stopping Lighty Module: {}...", lightyModule.getClass()); + try { + if (lightyModule.shutdown().get()) { + LOG.debug("Lighty Module: {} was stopped successfully", lightyModule.getClass()); + return true; + } else { + LOG.error("Unable to stop Lighty Module: {}!", lightyModule.getClass()); + return false; + } + } catch (Exception e) { + LOG.error("Exception thrown while shutting down {} in CCSDK Core Lighty module!", lightyModule.getClass(), + e); + return false; + } + } +} diff --git a/lighty/ccsdk-lighty-dependency-versions/pom.xml b/lighty/ccsdk-lighty-dependency-versions/pom.xml new file mode 100755 index 000000000..e30a7e610 --- /dev/null +++ b/lighty/ccsdk-lighty-dependency-versions/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + 0.6.0-SNAPSHOT + pom + + + 10.1.0 + 0.9.0 + + + + + + io.lighty.core + lighty-controller + ${lighty.version} + + + io.lighty.modules + lighty-restconf-nb-community + ${lighty.version} + + + io.lighty.modules + lighty-netconf-sb + ${lighty.version} + + + io.lighty.resources + singlenode-configuration + ${lighty.version} + + + org.opendaylight.aaa + aaa-artifacts + ${odl.aaa.version} + + + org.opendaylight.aaa + aaa-encrypt-service + ${odl.aaa.version} + + + + + diff --git a/lighty/pom.xml b/lighty/pom.xml new file mode 100644 index 000000000..cd94259cb --- /dev/null +++ b/lighty/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.core + ccsdk-core-lighty-aggregator + 0.6.0-SNAPSHOT + pom + + + ccsdk-core-lighty + ccsdk-lighty-dependency-versions + + diff --git a/pom.xml b/pom.xml index 711f3faea..bb3bc635e 100755 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ sliapi features artifacts + lighty diff --git a/sli/lighty/pom.xml b/sli/lighty/pom.xml new file mode 100755 index 000000000..c38ad286a --- /dev/null +++ b/sli/lighty/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + sli-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-core :: sli :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/lighty/SliModule.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/lighty/SliModule.java new file mode 100644 index 000000000..d48469320 --- /dev/null +++ b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/lighty/SliModule.java @@ -0,0 +1,77 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicClassResolverLighty; +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.SvcLogicServiceImplLighty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the sli-provider artifact. + */ +public class SliModule extends AbstractLightyModule { + + private static final Logger LOG = LoggerFactory.getLogger(SliModule.class); + + private final DbLibService dbLibService; + private final SvcLogicResource svcLogicResource; + private final SvcLogicRecorder svcLogicRecorder; + private final SvcLogicJavaPlugin svcLogicJavaPlugin; + private final SvcLogicAdaptor svcLogicAdaptor; + + private SvcLogicPropertiesProviderImpl svcLogicPropertiesImpl; + private SvcLogicServiceImplLighty svcLogicImpl; + private SvcLogicClassResolverLighty svcLogicClassResolver; + + public SliModule(DbLibService dbLibService, SvcLogicResource svcLogicResource, SvcLogicRecorder svcLogicRecorder, + SvcLogicJavaPlugin svcLogicJavaPlugin, SvcLogicAdaptor svcLogicAdaptor) { + this.dbLibService = dbLibService; + this.svcLogicResource = svcLogicResource; + this.svcLogicRecorder = svcLogicRecorder; + this.svcLogicJavaPlugin = svcLogicJavaPlugin; + this.svcLogicAdaptor = svcLogicAdaptor; + } + + @Override + protected boolean initProcedure() { + this.svcLogicPropertiesImpl = new SvcLogicPropertiesProviderImpl(); + this.svcLogicClassResolver = new SvcLogicClassResolverLighty(svcLogicResource, svcLogicRecorder, + svcLogicJavaPlugin, svcLogicAdaptor); + this.svcLogicImpl = new SvcLogicServiceImplLighty(this.svcLogicPropertiesImpl, dbLibService, + svcLogicClassResolver); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + + public SvcLogicService getSvcLogicServiceImpl() { + return this.svcLogicImpl; + } +} diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactoryLighty.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactoryLighty.java new file mode 100644 index 000000000..d60e43117 --- /dev/null +++ b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactoryLighty.java @@ -0,0 +1,53 @@ +/*- + * ============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.provider; + +import java.util.HashMap; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * THIS CLASS IS A COPY OF {@link SvcLogicAdaptorFactory} WITH REMOVED OSGi DEPENDENCIES + */ +public class SvcLogicAdaptorFactoryLighty { + + private static final Logger LOG = LoggerFactory + .getLogger(SvcLogicAdaptorFactoryLighty.class); + + private static HashMap adaptorMap = new HashMap<>(); + + public static void registerAdaptor(SvcLogicAdaptor adaptor) { + String name = adaptor.getClass().getName(); + LOG.info("Registering adaptor " + name); + adaptorMap.put(name, adaptor); + + } + + public static void unregisterAdaptor(String name) { + if (adaptorMap.containsKey(name)) { + LOG.info("Unregistering " + name); + adaptorMap.remove(name); + } + } + +} diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolverLighty.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolverLighty.java new file mode 100644 index 000000000..7b730a8e0 --- /dev/null +++ b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolverLighty.java @@ -0,0 +1,51 @@ +package org.onap.ccsdk.sli.core.sli.provider; + +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * THIS CLASS IS A COPY OF {@link SvcLogicClassResolver} WITH REMOVED OSGi DEPENDENCIES + */ +public class SvcLogicClassResolverLighty implements SvcLogicResolver { + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolverLighty.class); + + private final SvcLogicResource svcLogicResource; + private final SvcLogicRecorder svcLogicRecorder; + private final SvcLogicJavaPlugin svcLogicJavaPlugin; + private final SvcLogicAdaptor svcLogicAdaptor; + + public SvcLogicClassResolverLighty(SvcLogicResource svcLogicResource, SvcLogicRecorder svcLogicRecorder, + SvcLogicJavaPlugin svcLogicJavaPlugin, SvcLogicAdaptor svcLogicAdaptor) { + this.svcLogicResource = svcLogicResource; + this.svcLogicRecorder = svcLogicRecorder; + this.svcLogicJavaPlugin = svcLogicJavaPlugin; + this.svcLogicAdaptor = svcLogicAdaptor; + } + + @Override + public SvcLogicResource getSvcLogicResource(String resourceName) { + return svcLogicResource; + } + + @Override + public SvcLogicRecorder getSvcLogicRecorder(String recorderName) { + return svcLogicRecorder; + } + + @Override + public SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { + return svcLogicJavaPlugin; + } + + @Override + public SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName) { + return svcLogicAdaptor; + } + +} diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImplLighty.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImplLighty.java new file mode 100644 index 000000000..dfc5855fd --- /dev/null +++ b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImplLighty.java @@ -0,0 +1,172 @@ +/*- + * ============LICENSE_START======================================================= + * onap + * ================================================================================ + * Copyright (C) 2016 - 2017 ONAP + * 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.provider; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Optional; +import java.util.Properties; +import java.util.Vector; +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; +import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; +import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; +import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * THIS CLASS IS A COPY OF {@link SvcLogicPropertiesProviderImpl} WITH REMOVED OSGi DEPENDENCIES + */ +public class SvcLogicPropertiesProviderImplLighty implements SvcLogicPropertiesProvider { + + private static final Logger log = LoggerFactory.getLogger(SvcLogicPropertiesProviderImplLighty.class); + + /** + * The name of the properties file for database configuration + */ + private static final String SVCLOGIC_PROP_FILE_NAME = "svclogic.properties"; + + /** + * A prioritized list of strategies for resolving dblib properties files. + */ + private Vector sliPropertiesFileResolvers = new Vector<>(); + + /** + * The configuration properties for the db connection. + */ + private Properties properties; + + /** + * Set up the prioritized list of strategies for resolving dblib properties + * files. + */ + public SvcLogicPropertiesProviderImplLighty() { + sliPropertiesFileResolvers + .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); + sliPropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); + sliPropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); + + // determines properties file as according to the priority described in the + // class header comment + final File propertiesFile = determinePropertiesFile(this); + if (propertiesFile != null) { + try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { + properties = new Properties(); + properties.load(fileInputStream); + } catch (final IOException e) { + log.error("Failed to load properties for file: {}", propertiesFile.toString(), + new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(), + e)); + } + } else { + // Try to read properties as resource + + InputStream propStr = getClass().getResourceAsStream("/" + SVCLOGIC_PROP_FILE_NAME); + if (propStr != null) { + properties = new Properties(); + try { + properties.load(propStr); + propStr.close(); + } catch (IOException e) { + log.error("IO Exception",e); + properties = null; + } + } + + } + + if (properties == null) { + reportFailure("Missing configuration properties resource(3)", new ConfigurationException( + "Missing configuration properties resource(3): " + SVCLOGIC_PROP_FILE_NAME)); + } + } + + /** + * Extract svclogic config properties. + * + * @return the svclogic config properties + */ + public Properties getProperties() { + return properties; + } + + /** + * Reports the method chosen for properties resolution to the + * Logger. + * + * @param message + * Some user friendly message + * @param fileOptional + * The file location of the chosen properties file + * @return the file location of the chosen properties file + */ + private static File reportSuccess(final String message, final Optional fileOptional) { + if (fileOptional.isPresent()) { + final File file = fileOptional.get(); + log.info("{} {}", message, file.getPath()); + return file; + } + return null; + } + + /** + * Reports fatal errors. This is the case in which no properties file could be + * found. + * + * @param message + * An appropriate fatal error message + * @param configurationException + * An exception describing what went wrong during resolution + */ + private static void reportFailure(final String message, final ConfigurationException configurationException) { + + log.error("{}", message, configurationException); + } + + /** + * Determines the dblib properties file to use based on the following priority: + *
      + *
    1. A directory identified by the system environment variable + * SDNC_CONFIG_DIR
    2. + *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. + *
    5. A directory identified by the JRE argument + * dblib.properties
    6. + *
    7. A dblib.properties file located in the karaf root + * directory
    8. + *
    + */ + File determinePropertiesFile(final SvcLogicPropertiesProviderImplLighty resourceProvider) { + + for (final PropertiesFileResolver sliPropertiesFileResolver : sliPropertiesFileResolvers) { + final Optional fileOptional = sliPropertiesFileResolver.resolveFile(SVCLOGIC_PROP_FILE_NAME); + if (fileOptional.isPresent()) { + return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); + } + } + + return null; + } +} diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImplLighty.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImplLighty.java new file mode 100755 index 000000000..b9740c583 --- /dev/null +++ b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImplLighty.java @@ -0,0 +1,110 @@ +/*- + * ============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.provider; + +import java.util.Properties; +import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +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.sli.provider.base.SvcLogicServiceImplBase; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +/** + * THIS CLASS IS A COPY OF {@link SvcLogicServiceImpl} WITH REMOVED OSGi DEPENDENCIES + */ +public class SvcLogicServiceImplLighty extends SvcLogicServiceImplBase implements SvcLogicService { + + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImplLighty.class); + + public SvcLogicServiceImplLighty(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc, + SvcLogicResolver resolver) { + super(null); + this.resolver = resolver; + properties = resourceProvider.getProperties(); + this.store = new SvcLogicDblibStore(dbSvc); + } + + @Override + public Properties execute(String module, String rpc, String version, String mode, Properties props) + throws SvcLogicException { + return (execute(module, rpc, version, mode, props, null)); + } + + @Override + public Properties execute(String module, String rpc, String version, String mode, Properties props, + DOMDataBroker domDataBroker) throws SvcLogicException { + LOG.info("Fetching service logic from data store"); + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + + if (graph == null) { + Properties retProps = new Properties(); + retProps.setProperty("error-code", "401"); + retProps.setProperty("error-message", + "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]"); + return (retProps); + } + + SvcLogicContext ctx = new SvcLogicContext(props); + ctx.setAttribute(CURRENT_GRAPH, graph.toString()); + ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); + ctx.setDomDataBroker(domDataBroker); + execute(graph, ctx); + return (ctx.toProperties()); + } + + @Override + public SvcLogicStore getStore() throws SvcLogicException { + // Create and initialize SvcLogicStore object - used to access + // saved service logic. + if (store != null) { + return store; + } + + try { + store = SvcLogicStoreFactory.getSvcLogicStore(properties); + } catch (Exception e) { + throw new ConfigurationException("Could not get service logic store", e); + + } + + try { + store.init(properties); + } catch (SvcLogicException e) { + throw new ConfigurationException("Could not get service logic store", e); + } + + return store; + } + +} diff --git a/sli/pom.xml b/sli/pom.xml index b9b60e9e3..bf21cb630 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -28,5 +28,6 @@ recording features installer + lighty diff --git a/sliPluginUtils/lighty/pom.xml b/sliPluginUtils/lighty/pom.xml new file mode 100755 index 000000000..53445dafa --- /dev/null +++ b/sliPluginUtils/lighty/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + sliPluginUtil-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-core :: sliPluginUtil :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.core + sliPluginUtils-provider + ${project.version} + compile + + + diff --git a/sliPluginUtils/lighty/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/lighty/SliPluginUtilsModule.java b/sliPluginUtils/lighty/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/lighty/SliPluginUtilsModule.java new file mode 100644 index 000000000..41b63f535 --- /dev/null +++ b/sliPluginUtils/lighty/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/lighty/SliPluginUtilsModule.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.slipluginutils.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; +import org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the sliPluginUtils-provider artifact. + */ +public class SliPluginUtilsModule extends AbstractLightyModule { + + private SliPluginUtils sliPluginUtils; + private SliStringUtils sliStringUtils; + + @Override + protected boolean initProcedure() { + this.sliPluginUtils = new SliPluginUtils(); + this.sliStringUtils = new SliStringUtils(); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + + public SliPluginUtils getSliPluginUtils() { + return this.sliPluginUtils; + } + + public SliStringUtils getSliStringUtils() { + return sliStringUtils; + } +} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index f9cdcec2e..48994d8ef 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -21,5 +21,6 @@ provider features installer + lighty diff --git a/sliapi/lighty/pom.xml b/sliapi/lighty/pom.xml new file mode 100755 index 000000000..2812d6baf --- /dev/null +++ b/sliapi/lighty/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 1.4.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + sliapi-lighty + 0.6.0-SNAPSHOT + jar + + ccsdk-sli-core :: sliapi :: ${project.artifactId} + http://maven.apache.org + + + UTF-8 + + + + + + org.onap.ccsdk.sli.core + ccsdk-lighty-dependency-versions + ${project.version} + pom + import + + + + + + + io.lighty.core + lighty-controller + + + org.onap.ccsdk.sli.core + sliapi-provider + ${project.version} + compile + + + diff --git a/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/lighty/SliApiModule.java b/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/lighty/SliApiModule.java new file mode 100644 index 000000000..24d8958e1 --- /dev/null +++ b/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/lighty/SliApiModule.java @@ -0,0 +1,64 @@ +/* + * ============LICENSE_START========================================== + * Copyright (c) 2019 PANTHEON.tech s.r.o. + * =================================================================== + * 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.sliapi.lighty; + +import io.lighty.core.controller.api.AbstractLightyModule; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.onap.ccsdk.sli.core.sliapi.sliapiProviderLighty; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from + * the sliapi-provider artifact. + */ +public class SliApiModule extends AbstractLightyModule { + + private static final Logger LOG = LoggerFactory.getLogger(SliApiModule.class); + + private final DataBroker dataBroker; + private final NotificationPublishService notificationPublishService; + private final RpcProviderRegistry rpcRegistry; + private final SvcLogicService svcLogic; + + private sliapiProviderLighty sliapiProvider; + + public SliApiModule (DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcRegistry, SvcLogicService svcLogic) { + this.dataBroker = dataBroker; + this.notificationPublishService = notificationPublishService; + this.rpcRegistry = rpcRegistry; + this.svcLogic = svcLogic; + } + + @Override + protected boolean initProcedure() { + LOG.debug("Initializing Lighty module {}...", this.getClass()); + this.sliapiProvider = new sliapiProviderLighty(dataBroker, notificationPublishService, rpcRegistry, svcLogic); + LOG.debug("Lighty module {} initialized", this.getClass()); + return true; + } + + @Override + protected boolean stopProcedure() { + return true; + } + +} diff --git a/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProviderLighty.java b/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProviderLighty.java new file mode 100644 index 000000000..946984128 --- /dev/null +++ b/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProviderLighty.java @@ -0,0 +1,606 @@ +/*- + * ============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.sliapi; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.Properties; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.binding.impl.AbstractForwardedDataBroker; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckInput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutput; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * THIS CLASS IS A COPY OF {@link sliapiProvider} WITH REMOVED OSGi DEPENDENCIES + */ +public class sliapiProviderLighty implements AutoCloseable, SLIAPIService { + + private static final Logger LOG = LoggerFactory.getLogger(sliapiProviderLighty.class); + private static final String appName = "slitester"; + + protected DataBroker dataBroker; + protected DOMDataBroker domDataBroker; + protected NotificationPublishService notificationService; + protected RpcProviderRegistry rpcRegistry; + + private SvcLogicService svcLogic; + + protected BindingAwareBroker.RpcRegistration rpcRegistration; + + private static String SLIAPI_NAMESPACE = "org:onap:ccsdk:sli:core:sliapi"; + private static String SLIAPI_REVISION = "2016-11-10"; + private static String SDNC_STATUS_FILE = "SDNC_STATUS_FILE"; + private static String sdncStatusFile = null; + + private static QName TEST_RESULTS_QNAME = null; + private static QName TEST_RESULT_QNAME = null; + private static QName TEST_ID_QNAME = null; + private static QName RESULTS_QNAME = null; + private static final String NON_NULL = "non-null"; + + static { + + TEST_RESULTS_QNAME = QName.create(SLIAPI_NAMESPACE, SLIAPI_REVISION, "test-results"); + TEST_RESULT_QNAME = QName.create(TEST_RESULTS_QNAME, "test-result"); + TEST_ID_QNAME = QName.create(TEST_RESULT_QNAME, "test-identifier"); + RESULTS_QNAME = QName.create(TEST_RESULT_QNAME, "results"); + } + + public sliapiProviderLighty(DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry, SvcLogicService svcLogic) { + this.LOG.info("Creating provider for " + appName); + this.dataBroker = dataBroker; + this.notificationService = notificationPublishService; + this.rpcRegistry = rpcProviderRegistry; + this.svcLogic = svcLogic; + initialize(); + } + + public void initialize() { + LOG.info("Initializing provider for " + appName); + // initialization code goes here. + rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); + + sdncStatusFile = System.getenv(SDNC_STATUS_FILE); + LOG.info("SDNC STATUS FILE = " + sdncStatusFile); + LOG.info("Initialization complete for " + appName); + } + + protected void initializeChild() { + // Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + LOG.info("Closing provider for " + appName); + // closing code goes here + + rpcRegistration.close(); + LOG.info("Successfully closed provider for " + appName); + } + + public void setDataBroker(DataBroker dataBroker) { + this.dataBroker = dataBroker; + if (dataBroker instanceof AbstractForwardedDataBroker) { + domDataBroker = ((AbstractForwardedDataBroker) dataBroker).getDelegate(); + } + if (LOG.isDebugEnabled()) { + LOG.debug("DataBroker set to " + (dataBroker == null ? "null" : NON_NULL) + "."); + } + } + + public void setNotificationService(NotificationPublishService notificationService) { + this.notificationService = notificationService; + if (LOG.isDebugEnabled()) { + LOG.debug("Notification Service set to " + (notificationService == null ? "null" : NON_NULL) + "."); + } + } + + public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { + this.rpcRegistry = rpcRegistry; + if (LOG.isDebugEnabled()) { + LOG.debug("RpcRegistry set to " + (rpcRegistry == null ? "null" : NON_NULL) + "."); + } + } + + @Override + public ListenableFuture> executeGraph(ExecuteGraphInput input) { + RpcResult rpcResult = null; + + ExecuteGraphOutputBuilder respBuilder = new ExecuteGraphOutputBuilder(); + + String calledModule = input.getModuleName(); + String calledRpc = input.getRpcName(); + Mode calledMode = input.getMode(); + String modeStr = "sync"; + + if (calledMode == Mode.Async) { + modeStr = "async"; + } + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + respBuilder.setResponseCode("404"); + respBuilder.setResponseMessage( + "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + } catch (Exception e) { + LOG.error( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + // Load properties + Properties parms = new Properties(); + + // Pass properties using names from sli-parameters + for (SliParameter sliParm : input.getSliParameter()) { + + String propValue = ""; + + Boolean boolval = sliParm.isBooleanValue(); + + if (boolval != null) { + propValue = boolval.toString(); + } else { + Integer intval = sliParm.getIntValue(); + if (intval != null) { + propValue = intval.toString(); + } else { + propValue = sliParm.getStringValue(); + if (propValue == null) { + propValue = ""; + } + } + } + parms.setProperty(sliParm.getParameterName(), propValue); + } + + // Also, pass "meta" properties (i.e. pass SliParameter objects themselves) + ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder(input); + + SliapiHelper.toProperties(parms, "input", inputBuilder); + + try { + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); + + if (LOG.isTraceEnabled()) { + StringBuffer argList = new StringBuffer(); + argList.append("Parameters : {"); + Enumeration e = parms.propertyNames(); + while (e.hasMoreElements()) { + String propName = (String) e.nextElement(); + argList.append(" (" + propName + "," + parms.getProperty(propName) + ") "); + } + argList.append("}"); + LOG.trace(argList.toString()); + argList = null; + } + + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms, domDataBroker); + + StringBuilder sb = new StringBuilder("{"); + + for (Object key : respProps.keySet()) { + String keyValue = (String) key; + if (keyValue != null && !"".equals(keyValue) && !keyValue.contains("input.sli-parameter")) { + sb.append("\"").append(keyValue).append("\": \"").append(respProps.getProperty(keyValue)) + .append("\","); + } + } + + sb.setLength(sb.length() - 1); + sb.append("}"); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", ""));// TODO change response-text to + // response-message to match + // other BVC APIs + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + respBuilder.setContextMemoryJson(sb.toString()); + + TestResultBuilder testResultBuilder = new TestResultBuilder(); + + SliapiHelper.toBuilder(respProps, testResultBuilder); + + String testIdentifier = testResultBuilder.getTestIdentifier(); + + if ((testIdentifier != null) && (testIdentifier.length() > 0)) { + + // Add test results to config tree + LOG.debug("Saving test results for test id " + testIdentifier); + + DomSaveTestResult(testResultBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + + } + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr + + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule + + "/" + calledRpc + "/" + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + @Override + public ListenableFuture> healthcheck(HealthcheckInput healthcheckInput) { + + RpcResult rpcResult = null; + + HealthcheckOutputBuilder respBuilder = new HealthcheckOutputBuilder(); + + String calledModule = "sli"; + String calledRpc = "healthcheck"; + String modeStr = "sync"; + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + respBuilder.setResponseCode("404"); + respBuilder.setResponseMessage( + "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); + + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + } catch (Exception e) { + LOG.error( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + try { + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); + + Properties parms = new Properties(); + + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr + + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule + + "/" + calledRpc + "/" + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + public ListenableFuture> vlbcheck(VlbcheckInput vlbInput) { + + RpcResult rpcResult = null; + + VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder(); + + String calledModule = "sli"; + String calledRpc = "vlbcheck"; + String modeStr = "sync"; + + if (svcLogic == null) { + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); + respBuilder.setAckFinalIndicator("Y"); + + rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } + + boolean dgExists = true; + try { + if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { + dgExists = false; + } + } catch (Exception e) { + LOG.warn( + "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, + e); + + dgExists = false; + } + + if (dgExists) { + try { + LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); + + Properties parms = new Properties(); + + Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); + + respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); + respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); + respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); + + } catch (Exception e) { + LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + + modeStr + ">", e); + + respBuilder.setResponseCode("500"); + respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + + calledModule + "/" + calledRpc + "/" + modeStr); + respBuilder.setAckFinalIndicator("Y"); + + } + + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + return (Futures.immediateFuture(rpcResult)); + } else { + // check the state based on the config file + + boolean suspended = false; + BufferedReader br = null; + String line = ""; + + if (sdncStatusFile != null) { + try { + br = new BufferedReader(new FileReader(sdncStatusFile)); + while ((line = br.readLine()) != null) { + if ("ODL_STATE=SUSPENDED".equals(line)) { + suspended = true; + LOG.debug("vlbcheck: server is suspended"); + } + } + br.close(); + } catch (FileNotFoundException e) { + LOG.trace("Caught File not found exception " + sdncStatusFile + "\n", e); + } catch (Exception e) { + LOG.trace("Failed to read status file " + sdncStatusFile + "\n", e); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + LOG.warn("Failed to close status file " + sdncStatusFile + "\n", e); + } + } + } + } + + if (suspended) { + rpcResult = RpcResultBuilder.failed() + .withError(ErrorType.APPLICATION, "resource-denied", "Server Suspended").build(); + } else { + respBuilder.setResponseMessage("server is normal"); + rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); + } + return (Futures.immediateFuture(rpcResult)); + } + } + + private void DomSaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) { + + if (domDataBroker == null) { + LOG.error("domDataBroker unset - cannot save test result using DOMDataBroker"); + return; + } + + MapEntryNode resultNode = null; + + try { + resultNode = toMapEntryNode(entry); + } catch (Exception e) { + LOG.error("Caught exception trying to create map entry node", e); + } + + if (resultNode == null) { + LOG.error("Could not convert entry to MapEntryNode"); + return; + } + + YangInstanceIdentifier testResultsPid = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) + .node(QName.create(TEST_RESULTS_QNAME, "test-result")).build(); + YangInstanceIdentifier testResultPid = testResultsPid + .node(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, resultNode.getIdentifier().getKeyValues())); + + int tries = 2; + while (true) { + try { + DOMDataWriteTransaction wtx = domDataBroker.newWriteOnlyTransaction(); + if (merge) { + LOG.info("Merging test identifier " + entry.getTestIdentifier()); + wtx.merge(storeType, testResultPid, resultNode); + } else { + LOG.info("Putting test identifier " + entry.getTestIdentifier()); + wtx.put(storeType, testResultPid, resultNode); + } + wtx.submit().checkedGet(); + LOG.trace("Update DataStore succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + LOG.trace("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + LOG.trace("Got OptimisticLockFailedException - trying again "); + } else { + LOG.trace("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + + } + + private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) + throws IllegalStateException { + // Each entry will be identifiable by a unique key, we have to create that + // identifier + + InstanceIdentifier.InstanceIdentifierBuilder testResultIdBuilder = InstanceIdentifier + .builder(TestResults.class).child(TestResult.class, entry.key()); + InstanceIdentifier path = testResultIdBuilder.build(); + int tries = 2; + while (true) { + try { + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); + if (merge) { + tx.merge(storeType, path, entry); + } else { + tx.put(storeType, path, entry); + } + tx.submit().checkedGet(); + LOG.trace("Update DataStore succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + LOG.trace("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + LOG.trace("Got OptimisticLockFailedException - trying again "); + } else { + LOG.trace("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + } + + private MapEntryNode toMapEntryNode(TestResult testResult) { + + YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) + .node(TEST_RESULT_QNAME).build(); + + // Construct results list + LinkedList> entryList = new LinkedList<>(); + for (String result : testResult.getResults()) { + LeafSetEntryNode leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create() + .withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result)).withValue(result).build(); + entryList.add(leafSetEntryNode); + } + // Construct results LeafSetNode + LeafSetNode resultsNode = ImmutableLeafSetNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(RESULTS_QNAME)).withValue(entryList).build(); + + // Construct test result ContainerNode with 2 children - test-identifier leaf + // and results leaf-set + MapEntryNode testResultNode = ImmutableNodes.mapEntryBuilder() + .withNodeIdentifier(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, TEST_ID_QNAME, + testResult.getTestIdentifier())) + .withChild(ImmutableNodes.leafNode(TEST_ID_QNAME, testResult.getTestIdentifier())) + .withChild(resultsNode).build(); + + return (testResultNode); + + } + +} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index c9541ac22..62651d065 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -21,6 +21,7 @@ features provider installer + lighty -- cgit 1.2.3-korg From 4a62d9f6f3dfb24c2181f797339b004e16eb0649 Mon Sep 17 00:00:00 2001 From: Samuel Kontris Date: Fri, 23 Aug 2019 13:51:37 +0200 Subject: Add the odlparent-lite to the lighty.io artifacts without any parent This addition should fix failing merge job. Error log from merge job: "Deployment failed: repository element was not specified in the POM inside distributionManagement element" Signed-off-by: Samuel Kontris Change-Id: I0a0cc6fc59dbb5645ca9f3a5b3b250a0581763da --- lighty/ccsdk-core-lighty/pom.xml | 13 +++++++------ lighty/ccsdk-lighty-dependency-versions/pom.xml | 7 +++++++ lighty/pom.xml | 7 +++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lighty/ccsdk-core-lighty/pom.xml b/lighty/ccsdk-core-lighty/pom.xml index 24c03cc2b..60541ccbf 100755 --- a/lighty/ccsdk-core-lighty/pom.xml +++ b/lighty/ccsdk-core-lighty/pom.xml @@ -2,17 +2,18 @@ 4.0.0 + + org.onap.ccsdk.parent + odlparent-lite + 1.4.0-SNAPSHOT + + + org.onap.ccsdk.sli.core ccsdk-core-lighty 0.6.0-SNAPSHOT jar - - 1.8 - 1.8 - UTF-8 - - org.onap.ccsdk.sli.core diff --git a/lighty/ccsdk-lighty-dependency-versions/pom.xml b/lighty/ccsdk-lighty-dependency-versions/pom.xml index e30a7e610..48e4e9b0b 100755 --- a/lighty/ccsdk-lighty-dependency-versions/pom.xml +++ b/lighty/ccsdk-lighty-dependency-versions/pom.xml @@ -2,6 +2,13 @@ 4.0.0 + + org.onap.ccsdk.parent + odlparent-lite + 1.4.0-SNAPSHOT + + + org.onap.ccsdk.sli.core ccsdk-lighty-dependency-versions 0.6.0-SNAPSHOT diff --git a/lighty/pom.xml b/lighty/pom.xml index cd94259cb..06aedec69 100644 --- a/lighty/pom.xml +++ b/lighty/pom.xml @@ -2,6 +2,13 @@ 4.0.0 + + org.onap.ccsdk.parent + odlparent-lite + 1.4.0-SNAPSHOT + + + org.onap.ccsdk.sli.core ccsdk-core-lighty-aggregator 0.6.0-SNAPSHOT -- cgit 1.2.3-korg From 47742e9ac1626eccc7f383cd22b7af1d44438f1a Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 27 Aug 2019 15:47:29 -0400 Subject: Release version 0.6.0 Release version 0.6.0 of ccsdk artifacts Change-Id: I8ad418bd911ed0d70efc4329635d570f976f45de Signed-off-by: Timoney, Dan (dt5972) --- releases/0.6.0.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.6.0.yaml diff --git a/releases/0.6.0.yaml b/releases/0.6.0.yaml new file mode 100644 index 000000000..0106367c1 --- /dev/null +++ b/releases/0.6.0.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.6.0' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/187/' -- cgit 1.2.3-korg From c4ed9e1fce217d171afd569676e625b0be51cbfb Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 28 Aug 2019 13:12:38 -0400 Subject: Roll versions Roll versions in master branch Change-Id: I15535fec1da460f7227b855a4700e7b93aae93ea Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/lighty/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- lighty/ccsdk-core-lighty/pom.xml | 4 ++-- lighty/ccsdk-lighty-dependency-versions/pom.xml | 4 ++-- lighty/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/lighty/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/lighty/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/lighty/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/ccsdk-slicore-utils/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 2 +- 55 files changed, 107 insertions(+), 107 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 245077465..bf728ed66 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index d541bab9c..cebb0b9e6 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index 462ca365b..b9445e037 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index bac999f62..c3941cc31 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index c02f6ee62..200ae612a 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/lighty/pom.xml b/dblib/lighty/pom.xml index e1ba85f90..24db66712 100755 --- a/dblib/lighty/pom.xml +++ b/dblib/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core dblib-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index d5a986e6c..932ace788 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 52a39b8f9..0f2a7083c 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index a040c3687..5e2bc3df5 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index b90f020e8..6b21cad21 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 76bd191b2..d8b1c8d87 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index f374be96b..62c59cc47 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 390f1b34e..b1677a7a2 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index d72f95a5f..8b37eeaf0 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 494f7f169..14519c71b 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 42c39e9c3..4be194c8c 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 12f44bfeb..b6fe401c7 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index e7555aaf6..3a7090dd3 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/lighty/ccsdk-core-lighty/pom.xml b/lighty/ccsdk-core-lighty/pom.xml index 60541ccbf..98c6a7f80 100755 --- a/lighty/ccsdk-core-lighty/pom.xml +++ b/lighty/ccsdk-core-lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-core-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar diff --git a/lighty/ccsdk-lighty-dependency-versions/pom.xml b/lighty/ccsdk-lighty-dependency-versions/pom.xml index 48e4e9b0b..9c4e63b26 100755 --- a/lighty/ccsdk-lighty-dependency-versions/pom.xml +++ b/lighty/ccsdk-lighty-dependency-versions/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-lighty-dependency-versions - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom diff --git a/lighty/pom.xml b/lighty/pom.xml index 06aedec69..f6df30ac6 100644 --- a/lighty/pom.xml +++ b/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-core-lighty-aggregator - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom diff --git a/pom.xml b/pom.xml index bb3bc635e..fd5f4160a 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 24e29b2ec..63967b1f0 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 8597432e1..23224e101 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 8c46e8193..069895df4 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 871d41c37..780035b76 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index ad8a9200e..723cd1740 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/lighty/pom.xml b/sli/lighty/pom.xml index c38ad286a..74581a10e 100755 --- a/sli/lighty/pom.xml +++ b/sli/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 243223e17..7882669f7 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index bf21cb630..add94ce9b 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index d1dd62930..729439188 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 1326ef7aa..783fbb913 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index de8a56440..c0c0e256a 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index f55d3d47e..f7343f1ca 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 3950c94ec..18f9da5cc 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index d95b5fdf1..03f999e42 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index fdb245d62..34896d5fa 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/lighty/pom.xml b/sliPluginUtils/lighty/pom.xml index 53445dafa..57c8b3cdb 100755 --- a/sliPluginUtils/lighty/pom.xml +++ b/sliPluginUtils/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtil-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-core :: sliPluginUtil :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 48994d8ef..4ad33be12 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 1814a0085..0d4a18344 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 004ec95f4..53436b54b 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 8765fb97f..0bf59c16c 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 719aa1962..1b66dd354 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 95fea32cd..f72f010c1 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/lighty/pom.xml b/sliapi/lighty/pom.xml index 2812d6baf..4fb9afc64 100755 --- a/sliapi/lighty/pom.xml +++ b/sliapi/lighty/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-lighty - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT jar ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 2b0f58717..92d1b96b5 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 62651d065..1b083797c 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 533b18e0c..ab1dc4c5c 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 71110f6b6..3086dd0d8 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index cc52237da..169fa621b 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index e1528efb3..84e9a7547 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 02b824013..bc406463b 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index f2bb15ca0..ac1a736f0 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index d65fa253f..cf5dc8a89 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.6.0-SNAPSHOT + 0.6.1-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 50be578e4..5d94f48dd 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=6 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From dc991917059feb8243f249319ca022751253a4dd Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 27 Aug 2019 20:59:58 +0000 Subject: logging changes Synchronize metric logger with casablanca logging spec Issue-ID: CCSDK-1658 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I2d4e6af9eebdd0521792f03bbbaf25736b1b698e --- .../org/onap/ccsdk/sli/core/sli/MetricLogger.java | 275 ++++----------------- .../onap/ccsdk/sli/core/sli/TestMetricLogger.java | 97 +------- .../base/AbstractSvcLogicNodeExecutor.java | 2 - .../sli/provider/base/SvcLogicServiceImplBase.java | 3 - 4 files changed, 53 insertions(+), 324 deletions(-) mode change 100644 => 100755 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java mode change 100644 => 100755 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java old mode 100644 new mode 100755 index ccafad0ff..30340d476 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -24,7 +24,6 @@ */ package org.onap.ccsdk.sli.core.sli; -import java.net.InetAddress; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -33,6 +32,8 @@ import java.util.TimeZone; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; /** * @author dt5972 @@ -40,208 +41,33 @@ import org.slf4j.MDC; */ public class MetricLogger { - private static final Logger KARAF = LoggerFactory.getLogger(MetricLogger.class); private static final Logger METRIC = LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.metric"); + + //TODO use ONAPLogConstants + public static final String BEGIN_TIMESTAMP = "InvokeTimestamp"; + public static final String LOG_TIMESTAMP = "LogTimestamp"; + public static final String REQUEST_ID = "RequestID"; + public static final String SERVICE_INSTANCE_ID = "ServiceInstanceID"; + public static final String TARGET_ENTITY = "TargetEntity"; + public static final String TARGET_SERVICE_NAME = "TargetServiceName"; + public static final String STATUS_CODE = "StatusCode"; + public static final String RESPONSE_CODE = "ResponseCode"; + public static final String RESPONSE_DESCRIPTION = "ResponseDesc"; + public static final String INSTANCE_UUID = "InstanceID"; + public static final String ELAPSED_TIME = "ElapsedTime"; + public static final String CLIENT_IP = "ClientIPaddress"; + public static final String TARGET_VIRTUAL_ENTITY = "TargetElement"; + private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN"); + private static final Marker INVOKE = MarkerFactory.getMarker("INVOKE"); - public static final String BEGIN_TIMESTAMP = "X-ECOMP-BeginTimestamp"; - public static final String END_TIMESTAMP = "X-ECOMP-EndTimestamp"; - public static final String REQUEST_ID = "X-ECOMP-RequestID"; - public static final String SERVICE_INSTANCE_ID = "X-ECOMP-ServiceInstanceID"; - public static final String SERVICE_NAME = "X-ECOMP-ServiceName"; - public static final String PARTNER_NAME = "X-ECOMP-PartnerName"; - public static final String TARGET_ENTITY = "X-ECOMP-TargetEntity"; - public static final String TARGET_SERVICE_NAME = "X-ECOMP-TargetServiceName"; - public static final String STATUS_CODE = "X-ECOMP-StatusCode"; - public static final String RESPONSE_CODE = "X-ECOMP-ResponseCode"; - public static final String RESPONSE_DESCRIPTION = "X-ECOMP-ResponseDescription"; - public static final String INSTANCE_UUID = "X-ECOMP-InstanceUUID"; - public static final String CATEGORY_LOG_LEVEL = "X-ECOMP-CategoryLogLevel"; - public static final String SEVERITY = "X-ECOMP-Severity"; - public static final String SERVER_IP_ADDRESS = "X-ECOMP-ServerIpAddress"; - public static final String ELAPSED_TIME = "X-ECOMP-ElapsedTime"; - public static final String SERVER = "X-ECOMP-Server"; - public static final String CLIENT_IP = "X-ECOMP-ClientIp"; - public static final String CLASS_NAME = "X-ECOMP-ClassName"; - public static final String TARGET_VIRTUAL_ENTITY = "X-ECOMP-TargetVirtualEntity"; - - private long beginTimestamp; private String lastMsg = null; - public MetricLogger() { - beginTimestamp = System.currentTimeMillis(); - - try { - InetAddress localhost = InetAddress.getLocalHost(); - setServerIpAddress(localhost.getHostAddress()); - setServer(localhost.getCanonicalHostName()); - } catch (Exception e) { - KARAF.error("Could not get localhost", e); - } - - } - - - public String getBeginTimestamp() { - return MDC.get(BEGIN_TIMESTAMP); - } - - private void setBeginTimestamp(long beginTimestamp) { - this.beginTimestamp = beginTimestamp; - MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(beginTimestamp)); - } - - public String getEndTimestamp() { - return MDC.get(END_TIMESTAMP); - } - - private void setEndTimestamp(long endTimestamp) { - // Set MDC with formatted time stamp - MDC.put(END_TIMESTAMP, MetricLogger.asIso8601(endTimestamp)); - - // Set elapsed time - setElapsedTime(endTimestamp - beginTimestamp); - - } - public String getRequestID() { return MDC.get(REQUEST_ID); } + + public MetricLogger() { - - public String getServiceInstanceID() { - return MDC.get(SERVICE_INSTANCE_ID); - } - - private void setServiceInstanceID(String svcInstanceId) { - MDC.put(SERVICE_INSTANCE_ID, svcInstanceId); - } - - public String getServiceName() { - return MDC.get(SERVICE_NAME); - } - - private void setServiceName(String svcName) { - MDC.put(SERVICE_NAME, svcName); - } - - public String getPartnerName() { - return MDC.get(PARTNER_NAME); - } - - private void setPartnerName(String partnerName) { - MDC.put(PARTNER_NAME, partnerName); - } - - public String getTargetEntity() { - return MDC.get(TARGET_ENTITY); - } - - private void setTargetEntity(String targetEntity) { - MDC.put(TARGET_ENTITY, targetEntity); - } - - public String getTargetServiceName() { - return MDC.get(TARGET_SERVICE_NAME); - } - - private void setTargetServiceName(String targetServiceName) { - MDC.put(TARGET_SERVICE_NAME, targetServiceName); - } - - public String getStatusCode() { - return MDC.get(STATUS_CODE); - } - - private void setStatusCode(String statusCode) { - MDC.put(STATUS_CODE, statusCode); - } - - public String getResponseCode() { - return MDC.get(RESPONSE_CODE); - } - - private void setResponseCode(String responseCode) { - MDC.put(RESPONSE_CODE, responseCode); - } - - public String getResponseDescription() { - return MDC.get(RESPONSE_DESCRIPTION); - } - - private void setResponseDescription(String responseDesc) { - MDC.put(RESPONSE_DESCRIPTION, formatString(responseDesc)); - } - - public String getInstanceUUID() { - return MDC.get(INSTANCE_UUID); - } - - private void setInstanceUUID(String instanceUUID) { - MDC.put(INSTANCE_UUID, instanceUUID); - } - - public String getCategoryLogLevel() { - return MDC.get(CATEGORY_LOG_LEVEL); - } - - private void setCategoryLogLevel(String categoryLogLevel) { - MDC.put(CATEGORY_LOG_LEVEL, categoryLogLevel); - } - - public String getSeverity() { - return MDC.get(SEVERITY); - } - - private void setSeverity(String severity) { - MDC.put(SEVERITY, severity); - } - - public String getServerIpAddress() { - return MDC.get(SERVER_IP_ADDRESS); - } - - private void setServerIpAddress(String serverIpAddress) { - MDC.put(SERVER_IP_ADDRESS, serverIpAddress); - } - - public String getElapsedTime() { - return MDC.get(ELAPSED_TIME); - } - - private void setElapsedTime(long elapsedTime) { - MDC.put(ELAPSED_TIME, Long.toString(elapsedTime)); - } - - public String getServer() { - return MDC.get(SERVER); - } - - private void setServer(String server) { - MDC.put(SERVER, server); - } - - public String getClientIp() { - return MDC.get(CLIENT_IP); - } - - private void setClientIp(String clientIp) { - MDC.put(CLIENT_IP, clientIp); - } - - public String getClassName() { - return MDC.get(CLASS_NAME); - } - - private void setClassName(String className) { - MDC.put(CLASS_NAME, className); - } - - public String getTargetVirtualEntity() { - return MDC.get(TARGET_VIRTUAL_ENTITY); - } - - private void setTargetVirtualEntity(String targetVirtualEntity) { - MDC.put(TARGET_VIRTUAL_ENTITY, targetVirtualEntity); } public static String asIso8601(Date date) { @@ -255,50 +81,53 @@ public class MetricLogger { return MetricLogger.asIso8601(new Date(tsInMillis)); } - public void logRequest(String svcInstanceId, String svcName, String partnerName, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) { + @Deprecated + public void logRequest(String svcInstanceId, String svcName, String partnerName, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) { + logRequest(svcInstanceId,targetEntity,targetServiceName,targetVirtualEntity,msg); + } - setBeginTimestamp(System.currentTimeMillis()); + public void logRequest(String svcInstanceId, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) { + long start = System.currentTimeMillis(); + MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(start)); if (svcInstanceId != null) { - setServiceInstanceID(svcInstanceId); - } - - if (svcName != null) { - setServiceName(svcName); + MDC.put(SERVICE_INSTANCE_ID, svcInstanceId); } - - if (partnerName != null) { - setPartnerName(partnerName); - } - if (targetEntity != null) { - setTargetEntity(targetEntity); + MDC.put(TARGET_ENTITY, targetEntity); } if (targetServiceName != null) { - setTargetServiceName(targetServiceName); + MDC.put(TARGET_SERVICE_NAME, targetServiceName); } if (targetVirtualEntity != null) { - setTargetVirtualEntity(targetVirtualEntity); + MDC.put(TARGET_VIRTUAL_ENTITY, targetVirtualEntity); } - this.lastMsg = msg; - - + METRIC.info(INVOKE, "Invoke"); } - + public void logResponse(String statusCode, String responseCode, String responseDescription) { - setEndTimestamp(System.currentTimeMillis()); - - setStatusCode(statusCode); - setResponseCode(responseCode); - setResponseDescription(responseDescription); - - METRIC.info(formatString(lastMsg)); + long start = System.currentTimeMillis(); + MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(start)); + if (statusCode != null) { + MDC.put(STATUS_CODE, statusCode); + } + if (responseCode != null) { + MDC.put(RESPONSE_CODE, responseCode); + } + if (responseDescription != null) { + MDC.put(RESPONSE_DESCRIPTION, formatString(responseDescription)); + } + long end = System.currentTimeMillis(); + MDC.put(LOG_TIMESTAMP, MetricLogger.asIso8601(end)); + MDC.put(ELAPSED_TIME, Long.toString(end-start)); + METRIC.info(INVOKE_RETURN, formatString(lastMsg)); + resetContext(); } - + protected String formatString(String str) { if (str != null) { str = str.replaceAll("\\R", ""); // this will strip all new line characters @@ -306,7 +135,7 @@ public class MetricLogger { } return str; } - + public static void resetContext() { MDC.remove(TARGET_ENTITY); MDC.remove(TARGET_SERVICE_NAME); diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java old mode 100644 new mode 100755 index 971a700f5..ec3a31ea5 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java @@ -19,106 +19,11 @@ public class TestMetricLogger { } - @Test - public final void testGetBeginTimestamp() { - logger.getBeginTimestamp(); - } - - @Test - public final void testGetEndTimestamp() { - logger.getEndTimestamp(); - } - @Test public final void testGetRequestID() { logger.getRequestID(); } - - @Test - public final void testGetServiceInstanceID() { - logger.getServiceInstanceID(); - } - - @Test - public final void testGetServiceName() { - logger.getServiceName(); - } - - @Test - public final void testGetPartnerName() { - logger.getPartnerName(); - } - - @Test - public final void testGetTargetEntity() { - logger.getTargetEntity(); - } - - @Test - public final void testGetTargetServiceName() { - logger.getTargetServiceName(); - } - - @Test - public final void testGetStatusCode() { - logger.getStatusCode(); - } - - @Test - public final void testGetResponseCode() { - logger.getResponseCode(); - } - - @Test - public final void testGetResponseDescription() { - logger.getResponseDescription(); - } - - @Test - public final void testGetInstanceUUID() { - logger.getInstanceUUID(); - } - - @Test - public final void testGetCategoryLogLevel() { - logger.getCategoryLogLevel(); - } - - @Test - public final void testGetSeverity() { - logger.getSeverity(); - } - - @Test - public final void testGetServerIpAddress() { - logger.getServerIpAddress(); - } - - @Test - public final void testGetElapsedTime() { - logger.getElapsedTime(); - } - - @Test - public final void testGetServer() { - logger.getServer(); - } - - @Test - public final void testGetClientIp() { - logger.getClientIp(); - } - - @Test - public final void testGetClassName() { - logger.getClassName(); - } - - @Test - public final void testGetTargetVirtualEntity() { - logger.getTargetVirtualEntity(); - } - + @Test public final void testAsIso8601Date() { logger.asIso8601(new Date()); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java index 3574b88f6..a51accbb9 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java @@ -21,7 +21,6 @@ package org.onap.ccsdk.sli.core.sli.provider.base; -import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -70,7 +69,6 @@ public abstract class AbstractSvcLogicNodeExecutor { } protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) { - MetricLogger.resetContext(); SvcLogicNode nextNode = node.getOutcomeValue(outValue); if (nextNode != null) { if (LOG.isDebugEnabled()) { diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java index f850bc4c8..8351e95b8 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java @@ -105,9 +105,6 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { registerExecutors(); } - // Set service name in MDC to reference current working directed graph - MDC.put(MetricLogger.SERVICE_NAME, graph.getModule() + ":" + graph.getRpc() + "/v" + graph.getVersion()); - MDC.put(CURRENT_GRAPH, graph.toString()); SvcLogicNode curNode = graph.getRootNode(); -- cgit 1.2.3-korg From e1b15a3b62259a0a7e8da3561b044dabf3c5e9d4 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 29 Aug 2019 11:11:24 -0400 Subject: Revert "Proposal to remove OSGi dependencies from the CCSDK project" This reverts commit 85041dd8795b84a48d0b48dd746bfbcb230c8794. This needs to be reverted due to insufficient testing (no jUnit tests provided) Change-Id: I011f3eb7ab27ba9946f04d4d528dd4d91b593685 Signed-off-by: Timoney, Dan (dt5972) --- dblib/lighty/pom.xml | 51 -- .../core/dblib/DBLIBResourceProviderLighty.java | 174 ---- .../sli/core/dblib/DBResourceManagerLighty.java | 977 --------------------- .../ccsdk/sli/core/dblib/lighty/DblibModule.java | 56 -- dblib/pom.xml | 1 - lighty/ccsdk-core-lighty/pom.xml | 39 - .../sli/core/lighty/CcsdkCoreLightyModule.java | 148 ---- .../sli/core/lighty/common/CcsdkLightyUtils.java | 78 -- lighty/ccsdk-lighty-dependency-versions/pom.xml | 57 -- lighty/pom.xml | 21 - pom.xml | 1 - sli/lighty/pom.xml | 47 - .../onap/ccsdk/sli/core/sli/lighty/SliModule.java | 77 -- .../sli/provider/SvcLogicAdaptorFactoryLighty.java | 53 -- .../sli/provider/SvcLogicClassResolverLighty.java | 51 -- .../SvcLogicPropertiesProviderImplLighty.java | 172 ---- .../sli/provider/SvcLogicServiceImplLighty.java | 110 --- sli/pom.xml | 1 - sliPluginUtils/lighty/pom.xml | 48 - .../lighty/SliPluginUtilsModule.java | 51 -- sliPluginUtils/pom.xml | 1 - sliapi/lighty/pom.xml | 48 - .../ccsdk/sli/core/sliapi/lighty/SliApiModule.java | 64 -- .../sli/core/sliapi/sliapiProviderLighty.java | 606 ------------- sliapi/pom.xml | 1 - 25 files changed, 2933 deletions(-) delete mode 100755 dblib/lighty/pom.xml delete mode 100644 dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProviderLighty.java delete mode 100644 dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManagerLighty.java delete mode 100644 dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/lighty/DblibModule.java delete mode 100755 lighty/ccsdk-core-lighty/pom.xml delete mode 100644 lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/CcsdkCoreLightyModule.java delete mode 100644 lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/common/CcsdkLightyUtils.java delete mode 100755 lighty/ccsdk-lighty-dependency-versions/pom.xml delete mode 100644 lighty/pom.xml delete mode 100755 sli/lighty/pom.xml delete mode 100644 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/lighty/SliModule.java delete mode 100644 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactoryLighty.java delete mode 100644 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolverLighty.java delete mode 100644 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImplLighty.java delete mode 100755 sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImplLighty.java delete mode 100755 sliPluginUtils/lighty/pom.xml delete mode 100644 sliPluginUtils/lighty/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/lighty/SliPluginUtilsModule.java delete mode 100755 sliapi/lighty/pom.xml delete mode 100644 sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/lighty/SliApiModule.java delete mode 100644 sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProviderLighty.java diff --git a/dblib/lighty/pom.xml b/dblib/lighty/pom.xml deleted file mode 100755 index 24db66712..000000000 --- a/dblib/lighty/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - dblib-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-core :: dblib :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - org.opendaylight.aaa - aaa-encrypt-service - - - diff --git a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProviderLighty.java b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProviderLighty.java deleted file mode 100644 index 82579d7ec..000000000 --- a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProviderLighty.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Optional; -import java.util.Properties; -import java.util.Vector; -import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; -import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; -import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; -import org.opendaylight.aaa.encrypt.AAAEncryptionService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * THIS CLASS IS A COPY OF {@link DBLIBResourceProvider} WITH REMOVED OSGi DEPENDENCIES - */ -public class DBLIBResourceProviderLighty { - - private static final Logger LOG = LoggerFactory.getLogger(DBLIBResourceProviderLighty.class); - - /** - * The name of the properties file for database configuration - */ - private static final String DBLIB_PROP_FILE_NAME = "dblib.properties"; - - private static final String DBLIB_PROPERTY_NAME = "org.onap.ccsdk.sli.jdbc.password"; - private final AAAEncryptionService aaaEncryptionService; - - /** - * A prioritized list of strategies for resolving dblib properties files. - */ - private Vector dblibPropertiesFileResolvers = new Vector<>(); - - /** - * The configuration properties for the db connection. - */ - private Properties properties; - - /** - * Set up the prioritized list of strategies for resolving dblib properties files. - */ - public DBLIBResourceProviderLighty(AAAEncryptionService aaaEncryptionService) { - this.aaaEncryptionService = aaaEncryptionService; - - dblibPropertiesFileResolvers.add(new SdncConfigEnvVarFileResolver( - "Using property file (1) from environment variable" - )); - dblibPropertiesFileResolvers.add(new CoreDefaultFileResolver( - "Using property file (2) from default directory" - )); - dblibPropertiesFileResolvers.add(new KarafRootFileResolver( - "Using property file (4) from karaf root", this)); - - // determines properties file as according to the priority described in the class header comment - final File propertiesFile = determinePropertiesFile(this); - if (propertiesFile != null) { - try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); - properties.load(fileInputStream); - - if(properties.containsKey(DBLIB_PROPERTY_NAME)) { - String sensitive = properties.getProperty(DBLIB_PROPERTY_NAME); - if(sensitive != null && sensitive.startsWith("ENC:")) { - try { - sensitive = sensitive.substring(4); - String postsense = decrypt(sensitive); - properties.setProperty(DBLIB_PROPERTY_NAME, postsense); - } catch(Exception exc) { - LOG.error("Failed to translate property", exc); - } - } - } - - } catch (final IOException e) { - LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), - new DblibConfigurationException("Failed to load properties for file: " - + propertiesFile.toString(), e)); - } - } - } - - /** - * - * @param value - * @return decrypted string if successful or the original value if unsuccessful - */ - private String decrypt(String value) { - return aaaEncryptionService.decrypt(value); - } - - /** - * Extract db config properties. - * - * @return the db config properties - */ - public Properties getProperties() { - return properties; - } - - /** - * Reports the method chosen for properties resolution to the Logger. - * - * @param message Some user friendly message - * @param fileOptional The file location of the chosen properties file - * @return the file location of the chosen properties file - */ - private static File reportSuccess(final String message, final Optional fileOptional) { - if(fileOptional.isPresent()) { - final File file = fileOptional.get(); - LOG.info("{} {}", message, file.getPath()); - return file; - } - return null; - } - - /** - * Reports fatal errors. This is the case in which no properties file could be found. - * - * @param message An appropriate fatal error message - * @param dblibConfigurationException An exception describing what went wrong during resolution - */ - private static void reportFailure(final String message, - final DblibConfigurationException dblibConfigurationException) { - - LOG.error("{}", message, dblibConfigurationException); - } - - /** - * Determines the dblib properties file to use based on the following priority: - *
      - *
    1. A directory identified by the system environment variable SDNC_CONFIG_DIR
    2. - *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. - *
    5. A directory identified by the JRE argument dblib.properties
    6. - *
    7. A dblib.properties file located in the karaf root directory
    8. - *
    - */ - File determinePropertiesFile(final DBLIBResourceProviderLighty dblibResourceProvider) { - - for (final PropertiesFileResolver dblibPropertiesFileResolver : dblibPropertiesFileResolvers) { - final Optional fileOptional = dblibPropertiesFileResolver.resolveFile(DBLIB_PROP_FILE_NAME); - if (fileOptional.isPresent()) { - return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); - } - } - - reportFailure("Missing configuration properties resource(3)", - new DblibConfigurationException("Missing configuration properties resource(3): " - + DBLIB_PROP_FILE_NAME)); - return null; - } -} diff --git a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManagerLighty.java b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManagerLighty.java deleted file mode 100644 index 9b474a5eb..000000000 --- a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManagerLighty.java +++ /dev/null @@ -1,977 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * 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.dblib; - -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.Driver; -import java.sql.SQLDataException; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.sql.SQLIntegrityConstraintViolationException; -import java.sql.SQLNonTransientConnectionException; -import java.sql.SQLSyntaxErrorException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Observable; -import java.util.Properties; -import java.util.Set; -import java.util.SortedSet; -import java.util.TimerTask; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ConcurrentSkipListSet; -import java.util.stream.Collectors; -import javax.sql.DataSource; -import javax.sql.rowset.CachedRowSet; -import org.apache.tomcat.jdbc.pool.PoolExhaustedException; -import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool; -import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration; -import org.onap.ccsdk.sli.core.dblib.config.TerminatingConfiguration; -import org.onap.ccsdk.sli.core.dblib.factory.DBConfigFactory; -import org.onap.ccsdk.sli.core.dblib.pm.PollingWorker; -import org.onap.ccsdk.sli.core.dblib.pm.SQLExecutionMonitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * THIS CLASS IS A COPY OF {@link DBResourceManager} WITH REMOVED OSGi DEPENDENCIES - */ -public class DBResourceManagerLighty implements DataSource, DataAccessor, DBResourceObserver, DbLibService { - private static final Logger LOGGER = LoggerFactory.getLogger(DBResourceManagerLighty.class); - private static final String DATABASE_URL = "org.onap.ccsdk.sli.jdbc.url"; - - transient boolean terminating = false; - transient protected long retryInterval = 10000L; - transient boolean recoveryMode = true; - - SortedSet dsQueue = new ConcurrentSkipListSet<>(new DataSourceComparator()); - protected final Set broken = Collections.synchronizedSet(new HashSet()); - protected final Object monitor = new Object(); - protected final Properties configProps; - protected final Thread worker; - - protected final long terminationTimeOut; - protected final boolean monitorDbResponse; - protected final long monitoringInterval; - protected final long monitoringInitialDelay; - protected final long expectedCompletionTime; - protected final long unprocessedFailoverThreshold; - private static final String LOGGER_ALARM_MSG="Generated alarm: DBResourceManager.getData - No active DB connection pools are available."; - private static final String EXCEPTION_MSG= "No active DB connection pools are available in RequestDataNoRecovery call."; - - public DBResourceManagerLighty(final DBLIBResourceProviderLighty configuration) { - this(configuration.getProperties()); - } - - public DBResourceManagerLighty(final Properties properties) { - this.configProps = processSystemVariables(properties); - - // TODO : hack to force classloader to cache mariadb driver. This shouldnt be necessary, - // but for some reason it is (without this, dblib throws ClassNotFound on mariadb driver - // and fails to load). - LOGGER.info("Creating dummy instance of org.mariadb.jdbc.Driver"); - Driver dvr = new org.mariadb.jdbc.Driver(); - dvr = null; - - // get retry interval value - retryInterval = getLongFromProperties(configProps, "org.onap.dblib.connection.retry", 10000L); - - // get recovery mode flag - recoveryMode = getBooleanFromProperties(configProps, "org.onap.dblib.connection.recovery", true); - if(!recoveryMode) - { - recoveryMode = false; - LOGGER.info("Recovery Mode disabled"); - } - // get time out value for thread cleanup - terminationTimeOut = getLongFromProperties(configProps, "org.onap.dblib.termination.timeout", 300000L); - // get properties for monitoring - monitorDbResponse = getBooleanFromProperties(configProps, "org.onap.dblib.connection.monitor", false); - monitoringInterval = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.interval", 1000L); - monitoringInitialDelay = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.startdelay", 5000L); - expectedCompletionTime = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.expectedcompletiontime", 5000L); - unprocessedFailoverThreshold = getLongFromProperties(configProps, "org.onap.dblib.connection.monitor.unprocessedfailoverthreshold", 3L); - - // initialize performance monitor - PollingWorker.createInistance(configProps); - - // initialize recovery thread - worker = new RecoveryMgr(); - worker.setName("DBResourcemanagerWatchThread"); - worker.setDaemon(true); - worker.start(); - - try { - this.config(configProps); - } catch (final Exception e) { - // TODO: config throws Exception which is poor practice. Eliminate this in a separate patch. - LOGGER.error("Fatal Exception encountered while configuring DBResourceManager", e); - } - } - - public static Properties processSystemVariables(Properties properties) { - Map hmap = new Properties(); - hmap.putAll(properties); - - Map result = hmap.entrySet().stream() - .filter(map -> map.getValue().toString().startsWith("${")) - .filter(map -> map.getValue().toString().endsWith("}")) - .collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue())); - - result.forEach((name, propEntries) -> { - hmap.put(name, replace(propEntries.toString())); - }); - - if(hmap.containsKey(DATABASE_URL) && hmap.get(DATABASE_URL).toString().contains("${")) { - String url = hmap.get(DATABASE_URL).toString(); - String[] innerChunks = url.split("\\$\\{"); - for(String chunk : innerChunks) { - if(chunk.contains("}")) { - String subChunk = chunk.substring(0, chunk.indexOf("}")); - String varValue = System.getenv(subChunk); - url = url.replace("${"+subChunk+"}", varValue); - } - } - hmap.put(DATABASE_URL, url); - } - return Properties.class.cast(hmap); - } - - - private static String replace(String value) { - String globalVariable = value.substring(2, value.length() -1); - String varValue = System.getenv(globalVariable); - return (varValue != null) ? varValue : value; - } - - - private void config(Properties configProps) throws Exception { - final ConcurrentLinkedQueue semaphore = new ConcurrentLinkedQueue<>(); - final DbConfigPool dbConfig = DBConfigFactory.createConfig(configProps); - - long startTime = System.currentTimeMillis(); - - try { - JDBCConfiguration[] config = dbConfig.getJDBCbSourceArray(); - CachedDataSource[] cachedDS = new CachedDataSource[config.length]; - if (cachedDS == null || cachedDS.length == 0) { - LOGGER.error("Initialization of CachedDataSources failed. No instance was created."); - throw new Exception("Failed to initialize DB Library. No data source was created."); - } - - for(int i = 0; i < config.length; i++) { - cachedDS[i] = CachedDataSourceFactory.createDataSource(config[i]); - if(cachedDS[i] == null) - continue; - semaphore.add(cachedDS[i]); - cachedDS[i].setInterval(monitoringInterval); - cachedDS[i].setInitialDelay(monitoringInitialDelay); - cachedDS[i].setExpectedCompletionTime(expectedCompletionTime); - cachedDS[i].setUnprocessedFailoverThreshold(unprocessedFailoverThreshold); - cachedDS[i].addObserver(DBResourceManagerLighty.this); - } - - DataSourceTester[] tester = new DataSourceTester[config.length]; - - for(int i=0; i { - @Override - public int compare(CachedDataSource left, CachedDataSource right) { - if(LOGGER.isTraceEnabled()) - LOGGER.trace("----------SORTING-------- () : ()", left.getDbConnectionName(), right.getDbConnectionName()); - try { - if(left == right) { - return 0; - } - if(left == null){ - return 1; - } - if(right == null){ - return -1; - } - - boolean leftMaster = !left.isSlave(); - if(leftMaster) { - if(left.getIndex() <= right.getIndex()) - return -1; - else { - boolean rightMaster = !right.isSlave(); - if(rightMaster) { - if(left.getIndex() <= right.getIndex()) - return -1; -// if(left.getIndex() > right.getIndex()) - else { - return 1; - } - } else { - return -1; - } - } - } - if(!right.isSlave()) - return 1; - - if(left.getIndex() <= right.getIndex()) - return -1; - if(left.getIndex() > right.getIndex()) - return 1; - - - } catch (Throwable e) { - LOGGER.warn("", e); - } - return -1; - } - } - - class DataSourceTester extends Thread { - - private final CachedDataSource ds; - private final DBResourceManagerLighty manager; - private final ConcurrentLinkedQueue semaphoreQ; - - public DataSourceTester(CachedDataSource ds, DBResourceManagerLighty manager, ConcurrentLinkedQueue semaphore) { - this.ds = ds; - this.manager = manager; - this.semaphoreQ = semaphore; - } - - @Override - public void run() { - manager.setDataSource(ds); - boolean slave = true; - if(ds != null) { - try { - slave = ds.isSlave(); - } catch (Exception exc) { - LOGGER.warn("", exc); - } - } - if(!slave) { - LOGGER.info("Adding MASTER {} to active queue", ds.getDbConnectionName()); - try { - synchronized (semaphoreQ) { - semaphoreQ.notifyAll(); - } - } catch(Exception exc) { - LOGGER.warn("", exc); - } - } - try { - synchronized (semaphoreQ) { - semaphoreQ.remove(ds); - } - if(semaphoreQ.isEmpty()) { - synchronized (semaphoreQ) { - semaphoreQ.notifyAll(); - } - } - } catch(Exception exc) { - LOGGER.warn("", exc); - } - if(ds != null) - LOGGER.info("Thread DataSourceTester terminated {} for {}", this.getName(), ds.getDbConnectionName()); - } - - } - - - private long getLongFromProperties(Properties props, String property, long defaultValue) - { - String value = null; - long tmpLongValue = defaultValue; - try { - value = props.getProperty(property); - if(value != null) - tmpLongValue = Long.parseLong(value); - - } catch(NumberFormatException exc) { - if(LOGGER.isWarnEnabled()){ - LOGGER.warn("'"+property+"'=" + value+" is invalid. It should be a numeric value"); - } - } catch(Exception exc) { - } - return tmpLongValue; - - } - - private boolean getBooleanFromProperties(Properties props, String property, boolean defaultValue) - { - boolean tmpValue = defaultValue; - String value = null; - - try { - value = props.getProperty(property); - if(value != null) - tmpValue = Boolean.parseBoolean(value); - - } catch(NumberFormatException exc) { - if(LOGGER.isWarnEnabled()){ - LOGGER.warn("'"+property+"'=" + value+" is invalid. It should be a boolean value"); - } - } catch(Exception exc) { - } - return tmpValue; - - } - - - @Override - public void update(Observable observable, Object data) { - // if observable is active and there is a standby available, switch - if(observable instanceof SQLExecutionMonitor) - { - SQLExecutionMonitor monitor = (SQLExecutionMonitor)observable; - if(monitor.getParent() instanceof CachedDataSource) - { - CachedDataSource dataSource = (CachedDataSource)monitor.getParent(); - if(dataSource == dsQueue.first()) - { - if(recoveryMode && dsQueue.size() > 1){ - handleGetConnectionException(dataSource, new Exception(data.toString())); - } - } - } - } - } - - public void testForceRecovery() - { - CachedDataSource active = this.dsQueue.first(); - handleGetConnectionException(active, new Exception("test")); - } - - class RecoveryMgr extends Thread { - - @Override - public void run() { - while(!terminating) - { - try { - Thread.sleep(retryInterval); - } catch (InterruptedException e1) { } - CachedDataSource brokenSource = null; - try { - if (!broken.isEmpty()) { - CachedDataSource[] sourceArray = broken.toArray(new CachedDataSource[0]); - for (int i = 0; i < sourceArray.length; i++) - { - brokenSource = sourceArray[i]; - if (brokenSource instanceof TerminatingCachedDataSource) - break; - if (resetConnectionPool(brokenSource)) { - broken.remove(brokenSource); - brokenSource.blockImmediateOffLine(); - dsQueue.add(brokenSource); - LOGGER.info("DataSource <" - + brokenSource.getDbConnectionName() - + "> recovered."); - } - brokenSource = null; - } - } - } catch (Exception exc) { - LOGGER.warn(exc.getMessage()); - if(brokenSource != null){ - try { - if(!broken.contains(brokenSource)) - broken.add(brokenSource); - brokenSource = null; - } catch (Exception e1) { } - } - } - } - LOGGER.info("DBResourceManager.RecoveryMgr <"+this.toString() +"> terminated." ); - } - - private boolean resetConnectionPool(CachedDataSource dataSource){ - try { - return dataSource.testConnection(); - } catch (Exception exc) { - LOGGER.info("DataSource <" + dataSource.getDbConnectionName() + "> resetCache failed with error: "+ exc.getMessage()); - return false; - } - } - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#getData(java.lang.String, java.util.ArrayList, java.lang.String) - */ - @Override - public CachedRowSet getData(String statement, ArrayList arguments, String preferredDS) throws SQLException { - ArrayList newList= new ArrayList<>(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - if(recoveryMode) - return requestDataWithRecovery(statement, newList, preferredDS); - else - return requestDataNoRecovery(statement, newList, preferredDS); - } - - private CachedRowSet requestDataWithRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { - Throwable lastException = null; - - // test if there are any connection pools available - if(this.dsQueue.isEmpty()){ - LOGGER.error(LOGGER_ALARM_MSG); - throw new DBLibException("No active DB connection pools are available in RequestDataWithRecovery call."); - } - - // loop through available data sources to retrieve data. - for(int i=0; i< 2; i++) - { - CachedDataSource active = this.dsQueue.first(); - - long time = System.currentTimeMillis(); - try { - if(!active.isFabric()) { - if(this.dsQueue.size() > 1 && active.isSlave()) { - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - } - } - } - - return active.getData(statement, arguments); - } catch(SQLDataException | SQLSyntaxErrorException | SQLIntegrityConstraintViolationException exc){ - throw exc; - } catch(Throwable exc){ - if(exc instanceof SQLException) { - SQLException sqlExc = (SQLException)exc; - int code = sqlExc.getErrorCode(); - String state = sqlExc.getSQLState(); - LOGGER.debug("SQLException code: {} state: {}", code, state); - if("07001".equals(sqlExc.getSQLState())) { - throw sqlExc; - } - } - lastException = exc; - LOGGER.error("Generated alarm: {}", active.getDbConnectionName(), exc); - handleGetConnectionException(active, exc); - } finally { - if(LOGGER.isDebugEnabled()){ - time = System.currentTimeMillis() - time; - LOGGER.debug("getData processing time : {} {} miliseconds.", active.getDbConnectionName(), time); - } - } - } - if(lastException instanceof SQLException){ - throw (SQLException)lastException; - } - // repackage the exception - // you are here because either you run out of available data sources - // or the last exception was not of SQLException type. - // repackage the exception - if(lastException == null) { - throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); - } else { - SQLException exception = new DBLibException(lastException.getMessage()); - exception.setStackTrace(lastException.getStackTrace()); - if(lastException.getCause() instanceof SQLException) { - throw (SQLException)lastException.getCause(); - } - throw exception; - } - } - - private CachedRowSet requestDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { - if(dsQueue.isEmpty()){ - LOGGER.error(LOGGER_ALARM_MSG); - throw new DBLibException(EXCEPTION_MSG); - } - CachedDataSource active = this.dsQueue.first(); - long time = System.currentTimeMillis(); - try { - if(!active.isFabric()) { - if(this.dsQueue.size() > 1 && active.isSlave()) { - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - } - } - } - return active.getData(statement, arguments); - - } catch(Throwable exc){ - String message = exc.getMessage(); - if(message == null) - message = exc.getClass().getName(); - LOGGER.error("Generated alarm: {} - {}",active.getDbConnectionName(), message); - if(exc instanceof SQLException) - throw (SQLException)exc; - else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } finally { - if(LOGGER.isDebugEnabled()){ - time = System.currentTimeMillis() - time; - LOGGER.debug(">> getData : {} {} miliseconds.", active.getDbConnectionName(), time); - } - } - } - - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#writeData(java.lang.String, java.util.ArrayList, java.lang.String) - */ - @Override - public boolean writeData(String statement, ArrayList arguments, String preferredDS) throws SQLException - { - ArrayList newList= new ArrayList<>(); - if(arguments != null && !arguments.isEmpty()) { - newList.addAll(arguments); - } - - return writeDataNoRecovery(statement, newList, preferredDS); - } - - synchronized CachedDataSource findMaster() throws SQLException { - final CachedDataSource[] clone = this.dsQueue.toArray(new CachedDataSource[0]); - - for(final CachedDataSource dss : clone) { - if(!dss.isSlave()) { - final CachedDataSource first = this.dsQueue.first(); - if(first != dss) { - if(LOGGER.isDebugEnabled()) - LOGGER.debug("----------REODRERING--------"); - dsQueue.clear(); - if(!dsQueue.addAll(Arrays.asList(clone))) { - LOGGER.error("Failed adding datasources"); - } - } - return dss; - } - } - LOGGER.warn("MASTER not found."); - return null; - } - - - private boolean writeDataNoRecovery(String statement, ArrayList arguments, String preferredDS) throws SQLException { - if(dsQueue.isEmpty()){ - LOGGER.error(LOGGER_ALARM_MSG); - throw new DBLibException(EXCEPTION_MSG); - } - - boolean initialRequest = true; - boolean retryAllowed = true; - CachedDataSource active = this.dsQueue.first(); - long time = System.currentTimeMillis(); - while(initialRequest) { - initialRequest = false; - try { - if(!active.isFabric()) { - if(this.dsQueue.size() > 1 && active.isSlave()) { - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - } - } - } - - return active.writeData(statement, arguments); - } catch(Throwable exc){ - String message = exc.getMessage(); - if(message == null) - message = exc.getClass().getName(); - LOGGER.error("Generated alarm: {} - {}", active.getDbConnectionName(), message); - if(exc instanceof SQLException) { - SQLException sqlExc = SQLException.class.cast(exc); - // handle read-only exception - if(sqlExc.getErrorCode() == 1290 && "HY000".equals(sqlExc.getSQLState())) { - LOGGER.warn("retrying due to: {}", sqlExc.getMessage()); - this.findMaster(); - if(retryAllowed){ - retryAllowed = false; - initialRequest = true; - continue; - } - } - throw (SQLException)exc; - } else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } finally { - if(LOGGER.isDebugEnabled()){ - time = System.currentTimeMillis() - time; - LOGGER.debug("writeData processing time : {} {} miliseconds.", active.getDbConnectionName(), time); - } - } - } - return true; - } - - public void setDataSource(CachedDataSource dataSource) { - if(this.dsQueue.contains(dataSource)) - return; - if(this.broken.contains(dataSource)) - return; - - if(dataSource.testConnection(true)){ - this.dsQueue.add(dataSource); - } else { - this.broken.add(dataSource); - } - } - - @Override - public Connection getConnection() throws SQLException { - Throwable lastException = null; - CachedDataSource active = null; - - if(dsQueue.isEmpty()){ - throw new DBLibException("No active DB connection pools are available in GetConnection call."); - } - - try { - active = dsQueue.first(); - - if(!active.isFabric()) { - if(this.dsQueue.size() > 1 && active.isSlave()) { - LOGGER.debug("Forcing reorder on: {}", dsQueue.toString()); - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - } - } - } - return new DBLibConnection(active.getConnection(), active); - } catch(javax.sql.rowset.spi.SyncFactoryException exc){ - LOGGER.debug("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); - LOGGER.warn("CLASSPATH issue. Allowing retry", exc); - lastException = exc; - } catch(PoolExhaustedException exc) { - throw new NoAvailableConnectionsException(exc); - } catch(SQLNonTransientConnectionException exc){ - throw new NoAvailableConnectionsException(exc); - } catch(Exception exc){ - lastException = exc; - if(recoveryMode){ - handleGetConnectionException(active, exc); - } else { - if(exc instanceof SQLException) { - throw (SQLException)exc; - } else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } - } catch (Throwable trwb) { - DBLibException excptn = new DBLibException(trwb.getMessage()); - excptn.setStackTrace(trwb.getStackTrace()); - throw excptn; - } finally { - if(LOGGER.isDebugEnabled()){ - displayState(); - } - } - - if(lastException instanceof SQLException){ - throw (SQLException)lastException; - } - // repackage the exception - if(lastException == null) { - throw new DBLibException("The operation timed out while waiting to acquire a new connection." ); - } else { - SQLException exception = new DBLibException(lastException.getMessage()); - exception.setStackTrace(lastException.getStackTrace()); - if(lastException.getCause() instanceof SQLException) { - - throw (SQLException)lastException.getCause(); - } - throw exception; - } - } - - @Override - public Connection getConnection(String username, String password) - throws SQLException { - CachedDataSource active = null; - - if(dsQueue.isEmpty()){ - throw new DBLibException("No active DB connection pools are available in GetConnection call."); - } - - - try { - active = dsQueue.first(); - if(!active.isFabric()) { - if(this.dsQueue.size() > 1 && active.isSlave()) { - CachedDataSource master = findMaster(); - if(master != null) { - active = master; - } - } - } - return active.getConnection(username, password); - } catch(Throwable exc){ - if(recoveryMode){ - handleGetConnectionException(active, exc); - } else { - if(exc instanceof SQLException) - throw (SQLException)exc; - else { - DBLibException excptn = new DBLibException(exc.getMessage()); - excptn.setStackTrace(exc.getStackTrace()); - throw excptn; - } - } - - } - - throw new DBLibException("No connections available in DBResourceManager in GetConnection call."); - } - - private void handleGetConnectionException(final CachedDataSource source, Throwable exc) { - try { - if(!source.canTakeOffLine()) - { - LOGGER.error("Could not switch due to blocking"); - return; - } - - boolean removed = dsQueue.remove(source); - if(!broken.contains(source)) - { - if(broken.add(source)) - { - LOGGER.warn("DB Recovery: DataSource <" + source.getDbConnectionName() + "> put in the recovery mode. Reason : " + exc.getMessage()); - } else { - LOGGER.warn("Error putting DataSource <" +source.getDbConnectionName()+ "> in recovery mode."); - } - } else { - LOGGER.info("DB Recovery: DataSource <" + source.getDbConnectionName() + "> already in recovery queue"); - } - if(removed) - { - if(!dsQueue.isEmpty()) - { - LOGGER.warn("DB DataSource <" + dsQueue.first().getDbConnectionName() + "> became active"); - } - } - } catch (Exception e) { - LOGGER.error("", e); - } - } - - public void cleanUp() { - for(Iterator it=dsQueue.iterator();it.hasNext();){ - CachedDataSource cds = it.next(); - it.remove(); - cds.cleanUp(); - } - - try { - this.terminating = true; - if(broken != null) - { - try { - broken.add( new TerminatingCachedDataSource(new TerminatingConfiguration())); - } catch(Exception exc){ - LOGGER.error("Waiting for Worker to stop", exc); - } - } - worker.join(terminationTimeOut); - LOGGER.info("DBResourceManager.RecoveryMgr <"+worker.toString() +"> termination was successful: " + worker.getState()); - } catch(Exception exc){ - LOGGER.error("Waiting for Worker thread to terminate ", exc); - } - } - - @Override - public PrintWriter getLogWriter() throws SQLException { - return this.dsQueue.first().getLogWriter(); - } - - @Override - public int getLoginTimeout() throws SQLException { - return this.dsQueue.first().getLoginTimeout(); - } - - @Override - public void setLogWriter(PrintWriter out) throws SQLException { - this.dsQueue.first().setLogWriter(out); - } - - @Override - public void setLoginTimeout(int seconds) throws SQLException { - this.dsQueue.first().setLoginTimeout(seconds); - } - - public void displayState(){ - if(LOGGER.isDebugEnabled()){ - LOGGER.debug("POOLS : Active = "+dsQueue.size() + ";\t Broken = "+broken.size()); - CachedDataSource current = dsQueue.first(); - if(current != null) { - LOGGER.debug("POOL : Active name = \'"+current.getDbConnectionName()+ "\'"); - } - } - } - - /* (non-Javadoc) - * @see org.onap.ccsdk.sli.resource.dblib.DbLibService#isActive() - */ - @Override - public boolean isActive() { - return this.dsQueue.size()>0; - } - - public String getActiveStatus(){ - return "Connected: " + dsQueue.size()+"\tIn-recovery: "+broken.size(); - } - - public String getDBStatus(boolean htmlFormat) { - StringBuilder buffer = new StringBuilder(); - - ArrayList list = new ArrayList<>(); - list.addAll(dsQueue); - list.addAll(broken); - if (htmlFormat) - { - buffer.append("") - .append("Name:").append(""); - for (int i = 0; i < list.size(); i++) { - buffer.append(""); - buffer.append(list.get(i).getDbConnectionName()).append(""); - } - buffer.append(""); - - buffer.append("State:"); - for (int i = 0; i < list.size(); i++) { - if (broken.contains(list.get(i))) { - buffer.append("in recovery"); - } - if (dsQueue.contains(list.get(i))) { - if (dsQueue.first() == list.get(i)) - buffer.append("active"); - else - buffer.append("standby"); - } - } - buffer.append(""); - - } else { - for (int i = 0; i < list.size(); i++) { - buffer.append("Name: ").append(list.get(i).getDbConnectionName()); - buffer.append("\tState: "); - if (broken.contains(list.get(i))) { - buffer.append("in recovery"); - } else - if (dsQueue.contains(list.get(i))) { - if (dsQueue.first() == list.get(i)) - buffer.append("active"); - else - buffer.append("standby"); - } - - buffer.append("\n"); - - } - } - return buffer.toString(); - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } - - @Override - public T unwrap(Class iface) throws SQLException { - return null; - } - - /** - * @return the monitorDbResponse - */ - @Override - public final boolean isMonitorDbResponse() { - return recoveryMode && monitorDbResponse; - } - - public void test(){ - CachedDataSource obj = dsQueue.first(); - Exception ption = new Exception(); - try { - for(int i=0; i<5; i++) - { - handleGetConnectionException(obj, ption); - } - } catch(Throwable exc){ - LOGGER.warn("", exc); - } - } - - @Override - public java.util.logging.Logger getParentLogger() - throws SQLFeatureNotSupportedException { - return null; - } - - class RemindTask extends TimerTask { - @Override - public void run() { - CachedDataSource ds = dsQueue.first(); - if(ds != null) - ds.getPoolInfo(false); - } - } - - public int poolSize() { - return dsQueue.size(); - } -} diff --git a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/lighty/DblibModule.java b/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/lighty/DblibModule.java deleted file mode 100644 index bce166dff..000000000 --- a/dblib/lighty/src/main/java/org/onap/ccsdk/sli/core/dblib/lighty/DblibModule.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.dblib.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProviderLighty; -import org.onap.ccsdk.sli.core.dblib.DBResourceManagerLighty; -import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.opendaylight.aaa.encrypt.AAAEncryptionService; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the dblib artifact. - */ -public class DblibModule extends AbstractLightyModule { - - private final AAAEncryptionService aaaEncryptionService; - - private DBLIBResourceProviderLighty dbLibResourceProvider; - private DBResourceManagerLighty dbResourceManager; - - public DblibModule(AAAEncryptionService aaaEncryptionService) { - this.aaaEncryptionService = aaaEncryptionService; - } - - @Override - protected boolean initProcedure() { - this.dbLibResourceProvider = new DBLIBResourceProviderLighty(aaaEncryptionService); - this.dbResourceManager = new DBResourceManagerLighty(this.dbLibResourceProvider); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public DbLibService getDbLibService() { - return dbResourceManager; - } -} diff --git a/dblib/pom.xml b/dblib/pom.xml index 932ace788..a8a2a1314 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -24,6 +24,5 @@ provider features installer - lighty diff --git a/lighty/ccsdk-core-lighty/pom.xml b/lighty/ccsdk-core-lighty/pom.xml deleted file mode 100755 index 98c6a7f80..000000000 --- a/lighty/ccsdk-core-lighty/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-core-lighty - 0.6.1-SNAPSHOT - jar - - - - org.onap.ccsdk.sli.core - dblib-lighty - ${project.version} - - - org.onap.ccsdk.sli.core - sli-lighty - ${project.version} - - - org.onap.ccsdk.sli.core - sliapi-lighty - ${project.version} - - - org.onap.ccsdk.sli.core - sliPluginUtil-lighty - ${project.version} - - - diff --git a/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/CcsdkCoreLightyModule.java b/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/CcsdkCoreLightyModule.java deleted file mode 100644 index 578d18240..000000000 --- a/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/CcsdkCoreLightyModule.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import org.onap.ccsdk.sli.core.dblib.lighty.DblibModule; -import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.core.sli.lighty.SliModule; -import org.onap.ccsdk.sli.core.sliapi.lighty.SliApiModule; -import org.onap.ccsdk.sli.core.slipluginutils.lighty.SliPluginUtilsModule; -import org.opendaylight.aaa.encrypt.AAAEncryptionService; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all other LightyModules - * from the ccsdk-sli-core repository so they can be all treated as one component (for example started/stopped at once). - * For more information about the lighty.io visit the website https://lighty.io. - */ -public class CcsdkCoreLightyModule extends AbstractLightyModule { - - private static final Logger LOG = LoggerFactory.getLogger(CcsdkCoreLightyModule.class); - - private final DataBroker dataBroker; - private final NotificationPublishService notificationPublishService; - private final RpcProviderRegistry rpcProviderRegistry; - private final AAAEncryptionService aaaEncryptionService; - private final SvcLogicResource svcLogicResource; - private final SvcLogicRecorder svcLogicRecorder; - private final SvcLogicJavaPlugin svcLogicJavaPlugin; - private final SvcLogicAdaptor svcLogicAdaptor; - - private DblibModule dblibModule; - private SliModule sliModule; - private SliApiModule sliApiModule; - private SliPluginUtilsModule sliPluginUtilsModule; - - // FIXME cyclic dependency - implementation of SvcLogicResource is located in adaptors and CcsdkAdaptorsLightyModule - // is depencent on DbLibService from core - public CcsdkCoreLightyModule(DataBroker dataBroker, NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry, AAAEncryptionService aaaEncryptionService, - SvcLogicResource svcLogicResource, SvcLogicRecorder svcLogicRecorder, SvcLogicJavaPlugin svcLogicJavaPlugin, - SvcLogicAdaptor svcLogicAdaptor) { - this.dataBroker = dataBroker; - this.notificationPublishService = notificationPublishService; - this.rpcProviderRegistry = rpcProviderRegistry; - this.aaaEncryptionService = aaaEncryptionService; - this.svcLogicResource = svcLogicResource; - this.svcLogicRecorder = svcLogicRecorder; - this.svcLogicJavaPlugin = svcLogicJavaPlugin; - this.svcLogicAdaptor = svcLogicAdaptor; - } - - protected boolean initProcedure() { - LOG.debug("Initializing CCSDK Core Lighty module..."); - - this.dblibModule = new DblibModule(aaaEncryptionService); - if (!CcsdkLightyUtils.startLightyModule(dblibModule)) { - return false; - } - - this.sliModule = new SliModule(dblibModule.getDbLibService(), svcLogicResource, svcLogicRecorder, - svcLogicJavaPlugin, svcLogicAdaptor); - if (!CcsdkLightyUtils.startLightyModule(sliModule)) { - return false; - } - - this.sliApiModule = new SliApiModule(dataBroker, notificationPublishService, rpcProviderRegistry, sliModule.getSvcLogicServiceImpl()); - if (!CcsdkLightyUtils.startLightyModule(sliApiModule)) { - return false; - } - - this.sliPluginUtilsModule = new SliPluginUtilsModule(); - if (!CcsdkLightyUtils.startLightyModule(sliPluginUtilsModule)) { - return false; - } - - LOG.debug("CCSDK Core Lighty module was initialized successfully"); - return true; - } - - protected boolean stopProcedure() { - LOG.debug("Stopping CCSDK Core Lighty module..."); - - boolean stopSuccessful = true; - - if (!CcsdkLightyUtils.stopLightyModule(sliPluginUtilsModule)) { - stopSuccessful = false; - } - - if (!CcsdkLightyUtils.stopLightyModule(sliApiModule)) { - stopSuccessful = false; - } - - if (!CcsdkLightyUtils.stopLightyModule(sliModule)) { - stopSuccessful = false; - } - - if (!CcsdkLightyUtils.stopLightyModule(dblibModule)) { - stopSuccessful = false; - } - - if (stopSuccessful) { - LOG.debug("CCSDK Core Lighty module was stopped successfully"); - } else { - LOG.error("CCSDK Core Lighty module was not stopped successfully!"); - } - return stopSuccessful; - } - - public DblibModule getDblibModule() { - return dblibModule; - } - - public SliModule getSliModule() { - return sliModule; - } - - public SliApiModule getSliApiModule() { - return sliApiModule; - } - - public SliPluginUtilsModule getSliPluginUtilsModule() { - return sliPluginUtilsModule; - } -} diff --git a/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/common/CcsdkLightyUtils.java b/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/common/CcsdkLightyUtils.java deleted file mode 100644 index bfbcb135b..000000000 --- a/lighty/ccsdk-core-lighty/src/main/java/org/onap/ccsdk/sli/core/lighty/common/CcsdkLightyUtils.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.lighty.common; - -import io.lighty.core.controller.api.LightyModule; -import java.util.concurrent.ExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Utils class containing methods to start/stop LightyModules easier. - */ -public class CcsdkLightyUtils { - - private static final Logger LOG = LoggerFactory.getLogger(CcsdkLightyUtils.class); - - private CcsdkLightyUtils() { - throw new IllegalStateException("This class should not be instantiated!"); - } - - /** - * Starts provided LightyModule - * @param lightyModule LightyModule to start - * @return true if start was successful; false otherwise - */ - public static boolean startLightyModule(LightyModule lightyModule) { - LOG.debug("Starting Lighty module: {} ...", lightyModule.getClass()); - try { - if (lightyModule.start().get()) { - LOG.debug("Lighty module: {} was started successfully", lightyModule.getClass()); - return true; - } else { - LOG.error("Unable to start Lighty Module: {}!", lightyModule.getClass()); - return false; - } - } catch (InterruptedException | ExecutionException e) { - LOG.error("Exception thrown while initializing Lighty Module: {}!", lightyModule.getClass(), e); - return false; - } - } - - /** - * Stops provided LightyModule - * @param lightyModule LightyModule to stop - * @return true if stop was successful; false otherwise - */ - public static boolean stopLightyModule(LightyModule lightyModule) { - LOG.debug("Stopping Lighty Module: {}...", lightyModule.getClass()); - try { - if (lightyModule.shutdown().get()) { - LOG.debug("Lighty Module: {} was stopped successfully", lightyModule.getClass()); - return true; - } else { - LOG.error("Unable to stop Lighty Module: {}!", lightyModule.getClass()); - return false; - } - } catch (Exception e) { - LOG.error("Exception thrown while shutting down {} in CCSDK Core Lighty module!", lightyModule.getClass(), - e); - return false; - } - } -} diff --git a/lighty/ccsdk-lighty-dependency-versions/pom.xml b/lighty/ccsdk-lighty-dependency-versions/pom.xml deleted file mode 100755 index 9c4e63b26..000000000 --- a/lighty/ccsdk-lighty-dependency-versions/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - 0.6.1-SNAPSHOT - pom - - - 10.1.0 - 0.9.0 - - - - - - io.lighty.core - lighty-controller - ${lighty.version} - - - io.lighty.modules - lighty-restconf-nb-community - ${lighty.version} - - - io.lighty.modules - lighty-netconf-sb - ${lighty.version} - - - io.lighty.resources - singlenode-configuration - ${lighty.version} - - - org.opendaylight.aaa - aaa-artifacts - ${odl.aaa.version} - - - org.opendaylight.aaa - aaa-encrypt-service - ${odl.aaa.version} - - - - - diff --git a/lighty/pom.xml b/lighty/pom.xml deleted file mode 100644 index f6df30ac6..000000000 --- a/lighty/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-core-lighty-aggregator - 0.6.1-SNAPSHOT - pom - - - ccsdk-core-lighty - ccsdk-lighty-dependency-versions - - diff --git a/pom.xml b/pom.xml index fd5f4160a..b72b3c83b 100755 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,6 @@ sliapi features artifacts - lighty diff --git a/sli/lighty/pom.xml b/sli/lighty/pom.xml deleted file mode 100755 index 74581a10e..000000000 --- a/sli/lighty/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sli-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-core :: sli :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/lighty/SliModule.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/lighty/SliModule.java deleted file mode 100644 index d48469320..000000000 --- a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/lighty/SliModule.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicClassResolverLighty; -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.SvcLogicServiceImplLighty; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the sli-provider artifact. - */ -public class SliModule extends AbstractLightyModule { - - private static final Logger LOG = LoggerFactory.getLogger(SliModule.class); - - private final DbLibService dbLibService; - private final SvcLogicResource svcLogicResource; - private final SvcLogicRecorder svcLogicRecorder; - private final SvcLogicJavaPlugin svcLogicJavaPlugin; - private final SvcLogicAdaptor svcLogicAdaptor; - - private SvcLogicPropertiesProviderImpl svcLogicPropertiesImpl; - private SvcLogicServiceImplLighty svcLogicImpl; - private SvcLogicClassResolverLighty svcLogicClassResolver; - - public SliModule(DbLibService dbLibService, SvcLogicResource svcLogicResource, SvcLogicRecorder svcLogicRecorder, - SvcLogicJavaPlugin svcLogicJavaPlugin, SvcLogicAdaptor svcLogicAdaptor) { - this.dbLibService = dbLibService; - this.svcLogicResource = svcLogicResource; - this.svcLogicRecorder = svcLogicRecorder; - this.svcLogicJavaPlugin = svcLogicJavaPlugin; - this.svcLogicAdaptor = svcLogicAdaptor; - } - - @Override - protected boolean initProcedure() { - this.svcLogicPropertiesImpl = new SvcLogicPropertiesProviderImpl(); - this.svcLogicClassResolver = new SvcLogicClassResolverLighty(svcLogicResource, svcLogicRecorder, - svcLogicJavaPlugin, svcLogicAdaptor); - this.svcLogicImpl = new SvcLogicServiceImplLighty(this.svcLogicPropertiesImpl, dbLibService, - svcLogicClassResolver); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public SvcLogicService getSvcLogicServiceImpl() { - return this.svcLogicImpl; - } -} diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactoryLighty.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactoryLighty.java deleted file mode 100644 index d60e43117..000000000 --- a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactoryLighty.java +++ /dev/null @@ -1,53 +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.provider; - -import java.util.HashMap; -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * THIS CLASS IS A COPY OF {@link SvcLogicAdaptorFactory} WITH REMOVED OSGi DEPENDENCIES - */ -public class SvcLogicAdaptorFactoryLighty { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicAdaptorFactoryLighty.class); - - private static HashMap adaptorMap = new HashMap<>(); - - public static void registerAdaptor(SvcLogicAdaptor adaptor) { - String name = adaptor.getClass().getName(); - LOG.info("Registering adaptor " + name); - adaptorMap.put(name, adaptor); - - } - - public static void unregisterAdaptor(String name) { - if (adaptorMap.containsKey(name)) { - LOG.info("Unregistering " + name); - adaptorMap.remove(name); - } - } - -} diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolverLighty.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolverLighty.java deleted file mode 100644 index 7b730a8e0..000000000 --- a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolverLighty.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.onap.ccsdk.sli.core.sli.provider; - -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * THIS CLASS IS A COPY OF {@link SvcLogicClassResolver} WITH REMOVED OSGi DEPENDENCIES - */ -public class SvcLogicClassResolverLighty implements SvcLogicResolver { - - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolverLighty.class); - - private final SvcLogicResource svcLogicResource; - private final SvcLogicRecorder svcLogicRecorder; - private final SvcLogicJavaPlugin svcLogicJavaPlugin; - private final SvcLogicAdaptor svcLogicAdaptor; - - public SvcLogicClassResolverLighty(SvcLogicResource svcLogicResource, SvcLogicRecorder svcLogicRecorder, - SvcLogicJavaPlugin svcLogicJavaPlugin, SvcLogicAdaptor svcLogicAdaptor) { - this.svcLogicResource = svcLogicResource; - this.svcLogicRecorder = svcLogicRecorder; - this.svcLogicJavaPlugin = svcLogicJavaPlugin; - this.svcLogicAdaptor = svcLogicAdaptor; - } - - @Override - public SvcLogicResource getSvcLogicResource(String resourceName) { - return svcLogicResource; - } - - @Override - public SvcLogicRecorder getSvcLogicRecorder(String recorderName) { - return svcLogicRecorder; - } - - @Override - public SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { - return svcLogicJavaPlugin; - } - - @Override - public SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName) { - return svcLogicAdaptor; - } - -} diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImplLighty.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImplLighty.java deleted file mode 100644 index dfc5855fd..000000000 --- a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImplLighty.java +++ /dev/null @@ -1,172 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * 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.provider; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; -import java.util.Properties; -import java.util.Vector; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; -import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; -import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; -import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * THIS CLASS IS A COPY OF {@link SvcLogicPropertiesProviderImpl} WITH REMOVED OSGi DEPENDENCIES - */ -public class SvcLogicPropertiesProviderImplLighty implements SvcLogicPropertiesProvider { - - private static final Logger log = LoggerFactory.getLogger(SvcLogicPropertiesProviderImplLighty.class); - - /** - * The name of the properties file for database configuration - */ - private static final String SVCLOGIC_PROP_FILE_NAME = "svclogic.properties"; - - /** - * A prioritized list of strategies for resolving dblib properties files. - */ - private Vector sliPropertiesFileResolvers = new Vector<>(); - - /** - * The configuration properties for the db connection. - */ - private Properties properties; - - /** - * Set up the prioritized list of strategies for resolving dblib properties - * files. - */ - public SvcLogicPropertiesProviderImplLighty() { - sliPropertiesFileResolvers - .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); - sliPropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); - sliPropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); - - // determines properties file as according to the priority described in the - // class header comment - final File propertiesFile = determinePropertiesFile(this); - if (propertiesFile != null) { - try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); - properties.load(fileInputStream); - } catch (final IOException e) { - log.error("Failed to load properties for file: {}", propertiesFile.toString(), - new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(), - e)); - } - } else { - // Try to read properties as resource - - InputStream propStr = getClass().getResourceAsStream("/" + SVCLOGIC_PROP_FILE_NAME); - if (propStr != null) { - properties = new Properties(); - try { - properties.load(propStr); - propStr.close(); - } catch (IOException e) { - log.error("IO Exception",e); - properties = null; - } - } - - } - - if (properties == null) { - reportFailure("Missing configuration properties resource(3)", new ConfigurationException( - "Missing configuration properties resource(3): " + SVCLOGIC_PROP_FILE_NAME)); - } - } - - /** - * Extract svclogic config properties. - * - * @return the svclogic config properties - */ - public Properties getProperties() { - return properties; - } - - /** - * Reports the method chosen for properties resolution to the - * Logger. - * - * @param message - * Some user friendly message - * @param fileOptional - * The file location of the chosen properties file - * @return the file location of the chosen properties file - */ - private static File reportSuccess(final String message, final Optional fileOptional) { - if (fileOptional.isPresent()) { - final File file = fileOptional.get(); - log.info("{} {}", message, file.getPath()); - return file; - } - return null; - } - - /** - * Reports fatal errors. This is the case in which no properties file could be - * found. - * - * @param message - * An appropriate fatal error message - * @param configurationException - * An exception describing what went wrong during resolution - */ - private static void reportFailure(final String message, final ConfigurationException configurationException) { - - log.error("{}", message, configurationException); - } - - /** - * Determines the dblib properties file to use based on the following priority: - *
      - *
    1. A directory identified by the system environment variable - * SDNC_CONFIG_DIR
    2. - *
    3. The default directory DEFAULT_DBLIB_PROP_DIR
    4. - *
    5. A directory identified by the JRE argument - * dblib.properties
    6. - *
    7. A dblib.properties file located in the karaf root - * directory
    8. - *
    - */ - File determinePropertiesFile(final SvcLogicPropertiesProviderImplLighty resourceProvider) { - - for (final PropertiesFileResolver sliPropertiesFileResolver : sliPropertiesFileResolvers) { - final Optional fileOptional = sliPropertiesFileResolver.resolveFile(SVCLOGIC_PROP_FILE_NAME); - if (fileOptional.isPresent()) { - return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); - } - } - - return null; - } -} diff --git a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImplLighty.java b/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImplLighty.java deleted file mode 100755 index b9740c583..000000000 --- a/sli/lighty/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImplLighty.java +++ /dev/null @@ -1,110 +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.provider; - -import java.util.Properties; -import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -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.sli.provider.base.SvcLogicServiceImplBase; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -/** - * THIS CLASS IS A COPY OF {@link SvcLogicServiceImpl} WITH REMOVED OSGi DEPENDENCIES - */ -public class SvcLogicServiceImplLighty extends SvcLogicServiceImplBase implements SvcLogicService { - - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImplLighty.class); - - public SvcLogicServiceImplLighty(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc, - SvcLogicResolver resolver) { - super(null); - this.resolver = resolver; - properties = resourceProvider.getProperties(); - this.store = new SvcLogicDblibStore(dbSvc); - } - - @Override - public Properties execute(String module, String rpc, String version, String mode, Properties props) - throws SvcLogicException { - return (execute(module, rpc, version, mode, props, null)); - } - - @Override - public Properties execute(String module, String rpc, String version, String mode, Properties props, - DOMDataBroker domDataBroker) throws SvcLogicException { - LOG.info("Fetching service logic from data store"); - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - - if (graph == null) { - Properties retProps = new Properties(); - retProps.setProperty("error-code", "401"); - retProps.setProperty("error-message", - "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]"); - return (retProps); - } - - SvcLogicContext ctx = new SvcLogicContext(props); - ctx.setAttribute(CURRENT_GRAPH, graph.toString()); - ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); - ctx.setDomDataBroker(domDataBroker); - execute(graph, ctx); - return (ctx.toProperties()); - } - - @Override - public SvcLogicStore getStore() throws SvcLogicException { - // Create and initialize SvcLogicStore object - used to access - // saved service logic. - if (store != null) { - return store; - } - - try { - store = SvcLogicStoreFactory.getSvcLogicStore(properties); - } catch (Exception e) { - throw new ConfigurationException("Could not get service logic store", e); - - } - - try { - store.init(properties); - } catch (SvcLogicException e) { - throw new ConfigurationException("Could not get service logic store", e); - } - - return store; - } - -} diff --git a/sli/pom.xml b/sli/pom.xml index add94ce9b..91c520201 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -28,6 +28,5 @@ recording features installer - lighty diff --git a/sliPluginUtils/lighty/pom.xml b/sliPluginUtils/lighty/pom.xml deleted file mode 100755 index 57c8b3cdb..000000000 --- a/sliPluginUtils/lighty/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sliPluginUtil-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-core :: sliPluginUtil :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.core - sliPluginUtils-provider - ${project.version} - compile - - - diff --git a/sliPluginUtils/lighty/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/lighty/SliPluginUtilsModule.java b/sliPluginUtils/lighty/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/lighty/SliPluginUtilsModule.java deleted file mode 100644 index 41b63f535..000000000 --- a/sliPluginUtils/lighty/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/lighty/SliPluginUtilsModule.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.slipluginutils.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; -import org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the sliPluginUtils-provider artifact. - */ -public class SliPluginUtilsModule extends AbstractLightyModule { - - private SliPluginUtils sliPluginUtils; - private SliStringUtils sliStringUtils; - - @Override - protected boolean initProcedure() { - this.sliPluginUtils = new SliPluginUtils(); - this.sliStringUtils = new SliStringUtils(); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public SliPluginUtils getSliPluginUtils() { - return this.sliPluginUtils; - } - - public SliStringUtils getSliStringUtils() { - return sliStringUtils; - } -} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 4ad33be12..a6b8b83a7 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -21,6 +21,5 @@ provider features installer - lighty diff --git a/sliapi/lighty/pom.xml b/sliapi/lighty/pom.xml deleted file mode 100755 index 4fb9afc64..000000000 --- a/sliapi/lighty/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sliapi-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-core :: sliapi :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.core - sliapi-provider - ${project.version} - compile - - - diff --git a/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/lighty/SliApiModule.java b/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/lighty/SliApiModule.java deleted file mode 100644 index 24d8958e1..000000000 --- a/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/lighty/SliApiModule.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.sliapi.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; -import org.onap.ccsdk.sli.core.sliapi.sliapiProviderLighty; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the sliapi-provider artifact. - */ -public class SliApiModule extends AbstractLightyModule { - - private static final Logger LOG = LoggerFactory.getLogger(SliApiModule.class); - - private final DataBroker dataBroker; - private final NotificationPublishService notificationPublishService; - private final RpcProviderRegistry rpcRegistry; - private final SvcLogicService svcLogic; - - private sliapiProviderLighty sliapiProvider; - - public SliApiModule (DataBroker dataBroker, NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcRegistry, SvcLogicService svcLogic) { - this.dataBroker = dataBroker; - this.notificationPublishService = notificationPublishService; - this.rpcRegistry = rpcRegistry; - this.svcLogic = svcLogic; - } - - @Override - protected boolean initProcedure() { - LOG.debug("Initializing Lighty module {}...", this.getClass()); - this.sliapiProvider = new sliapiProviderLighty(dataBroker, notificationPublishService, rpcRegistry, svcLogic); - LOG.debug("Lighty module {} initialized", this.getClass()); - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - -} diff --git a/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProviderLighty.java b/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProviderLighty.java deleted file mode 100644 index 946984128..000000000 --- a/sliapi/lighty/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProviderLighty.java +++ /dev/null @@ -1,606 +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.sliapi; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Enumeration; -import java.util.LinkedList; -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.impl.AbstractForwardedDataBroker; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckInput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * THIS CLASS IS A COPY OF {@link sliapiProvider} WITH REMOVED OSGi DEPENDENCIES - */ -public class sliapiProviderLighty implements AutoCloseable, SLIAPIService { - - private static final Logger LOG = LoggerFactory.getLogger(sliapiProviderLighty.class); - private static final String appName = "slitester"; - - protected DataBroker dataBroker; - protected DOMDataBroker domDataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - - private SvcLogicService svcLogic; - - protected BindingAwareBroker.RpcRegistration rpcRegistration; - - private static String SLIAPI_NAMESPACE = "org:onap:ccsdk:sli:core:sliapi"; - private static String SLIAPI_REVISION = "2016-11-10"; - private static String SDNC_STATUS_FILE = "SDNC_STATUS_FILE"; - private static String sdncStatusFile = null; - - private static QName TEST_RESULTS_QNAME = null; - private static QName TEST_RESULT_QNAME = null; - private static QName TEST_ID_QNAME = null; - private static QName RESULTS_QNAME = null; - private static final String NON_NULL = "non-null"; - - static { - - TEST_RESULTS_QNAME = QName.create(SLIAPI_NAMESPACE, SLIAPI_REVISION, "test-results"); - TEST_RESULT_QNAME = QName.create(TEST_RESULTS_QNAME, "test-result"); - TEST_ID_QNAME = QName.create(TEST_RESULT_QNAME, "test-identifier"); - RESULTS_QNAME = QName.create(TEST_RESULT_QNAME, "results"); - } - - public sliapiProviderLighty(DataBroker dataBroker, NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry, SvcLogicService svcLogic) { - this.LOG.info("Creating provider for " + appName); - this.dataBroker = dataBroker; - this.notificationService = notificationPublishService; - this.rpcRegistry = rpcProviderRegistry; - this.svcLogic = svcLogic; - initialize(); - } - - public void initialize() { - LOG.info("Initializing provider for " + appName); - // initialization code goes here. - rpcRegistration = rpcRegistry.addRpcImplementation(SLIAPIService.class, this); - - sdncStatusFile = System.getenv(SDNC_STATUS_FILE); - LOG.info("SDNC STATUS FILE = " + sdncStatusFile); - LOG.info("Initialization complete for " + appName); - } - - protected void initializeChild() { - // Override if you have custom initialization intelligence - } - - @Override - public void close() throws Exception { - LOG.info("Closing provider for " + appName); - // closing code goes here - - rpcRegistration.close(); - LOG.info("Successfully closed provider for " + appName); - } - - public void setDataBroker(DataBroker dataBroker) { - this.dataBroker = dataBroker; - if (dataBroker instanceof AbstractForwardedDataBroker) { - domDataBroker = ((AbstractForwardedDataBroker) dataBroker).getDelegate(); - } - if (LOG.isDebugEnabled()) { - LOG.debug("DataBroker set to " + (dataBroker == null ? "null" : NON_NULL) + "."); - } - } - - public void setNotificationService(NotificationPublishService notificationService) { - this.notificationService = notificationService; - if (LOG.isDebugEnabled()) { - LOG.debug("Notification Service set to " + (notificationService == null ? "null" : NON_NULL) + "."); - } - } - - public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { - this.rpcRegistry = rpcRegistry; - if (LOG.isDebugEnabled()) { - LOG.debug("RpcRegistry set to " + (rpcRegistry == null ? "null" : NON_NULL) + "."); - } - } - - @Override - public ListenableFuture> executeGraph(ExecuteGraphInput input) { - RpcResult rpcResult = null; - - ExecuteGraphOutputBuilder respBuilder = new ExecuteGraphOutputBuilder(); - - String calledModule = input.getModuleName(); - String calledRpc = input.getRpcName(); - Mode calledMode = input.getMode(); - String modeStr = "sync"; - - if (calledMode == Mode.Async) { - modeStr = "async"; - } - - if (svcLogic == null) { - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - try { - if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { - respBuilder.setResponseCode("404"); - respBuilder.setResponseMessage( - "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - } catch (Exception e) { - LOG.error( - "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, - e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - // Load properties - Properties parms = new Properties(); - - // Pass properties using names from sli-parameters - for (SliParameter sliParm : input.getSliParameter()) { - - String propValue = ""; - - Boolean boolval = sliParm.isBooleanValue(); - - if (boolval != null) { - propValue = boolval.toString(); - } else { - Integer intval = sliParm.getIntValue(); - if (intval != null) { - propValue = intval.toString(); - } else { - propValue = sliParm.getStringValue(); - if (propValue == null) { - propValue = ""; - } - } - } - parms.setProperty(sliParm.getParameterName(), propValue); - } - - // Also, pass "meta" properties (i.e. pass SliParameter objects themselves) - ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder(input); - - SliapiHelper.toProperties(parms, "input", inputBuilder); - - try { - LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); - - if (LOG.isTraceEnabled()) { - StringBuffer argList = new StringBuffer(); - argList.append("Parameters : {"); - Enumeration e = parms.propertyNames(); - while (e.hasMoreElements()) { - String propName = (String) e.nextElement(); - argList.append(" (" + propName + "," + parms.getProperty(propName) + ") "); - } - argList.append("}"); - LOG.trace(argList.toString()); - argList = null; - } - - Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms, domDataBroker); - - StringBuilder sb = new StringBuilder("{"); - - for (Object key : respProps.keySet()) { - String keyValue = (String) key; - if (keyValue != null && !"".equals(keyValue) && !keyValue.contains("input.sli-parameter")) { - sb.append("\"").append(keyValue).append("\": \"").append(respProps.getProperty(keyValue)) - .append("\","); - } - } - - sb.setLength(sb.length() - 1); - sb.append("}"); - - respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); - respBuilder.setResponseMessage(respProps.getProperty("error-message", ""));// TODO change response-text to - // response-message to match - // other BVC APIs - respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); - respBuilder.setContextMemoryJson(sb.toString()); - - TestResultBuilder testResultBuilder = new TestResultBuilder(); - - SliapiHelper.toBuilder(respProps, testResultBuilder); - - String testIdentifier = testResultBuilder.getTestIdentifier(); - - if ((testIdentifier != null) && (testIdentifier.length() > 0)) { - - // Add test results to config tree - LOG.debug("Saving test results for test id " + testIdentifier); - - DomSaveTestResult(testResultBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); - - } - - } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr - + ">", e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule - + "/" + calledRpc + "/" + modeStr); - respBuilder.setAckFinalIndicator("Y"); - - } - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - @Override - public ListenableFuture> healthcheck(HealthcheckInput healthcheckInput) { - - RpcResult rpcResult = null; - - HealthcheckOutputBuilder respBuilder = new HealthcheckOutputBuilder(); - - String calledModule = "sli"; - String calledRpc = "healthcheck"; - String modeStr = "sync"; - - if (svcLogic == null) { - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - try { - if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { - respBuilder.setResponseCode("404"); - respBuilder.setResponseMessage( - "Directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr + " not found"); - - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - } catch (Exception e) { - LOG.error( - "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, - e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : could not determine if target graph exists"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - try { - LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); - - Properties parms = new Properties(); - - Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); - - respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); - respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); - respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); - - } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," + modeStr - + ">", e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " + calledModule - + "/" + calledRpc + "/" + modeStr); - respBuilder.setAckFinalIndicator("Y"); - - } - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - public ListenableFuture> vlbcheck(VlbcheckInput vlbInput) { - - RpcResult rpcResult = null; - - VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder(); - - String calledModule = "sli"; - String calledRpc = "vlbcheck"; - String modeStr = "sync"; - - if (svcLogic == null) { - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service"); - respBuilder.setAckFinalIndicator("Y"); - - rpcResult = RpcResultBuilder.failed().withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } - - boolean dgExists = true; - try { - if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) { - dgExists = false; - } - } catch (Exception e) { - LOG.warn( - "Caught exception looking for directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr, - e); - - dgExists = false; - } - - if (dgExists) { - try { - LOG.info("Calling directed graph for " + calledModule + "/" + calledRpc + "/" + modeStr); - - Properties parms = new Properties(); - - Properties respProps = svcLogic.execute(calledModule, calledRpc, null, modeStr, parms); - - respBuilder.setResponseCode(respProps.getProperty("error-code", "0")); - respBuilder.setResponseMessage(respProps.getProperty("error-message", "")); - respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y")); - - } catch (Exception e) { - LOG.error("Caught exception executing directed graph for" + calledModule + ":" + calledRpc + "," - + modeStr + ">", e); - - respBuilder.setResponseCode("500"); - respBuilder.setResponseMessage("Internal error : caught exception executing directed graph " - + calledModule + "/" + calledRpc + "/" + modeStr); - respBuilder.setAckFinalIndicator("Y"); - - } - - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - return (Futures.immediateFuture(rpcResult)); - } else { - // check the state based on the config file - - boolean suspended = false; - BufferedReader br = null; - String line = ""; - - if (sdncStatusFile != null) { - try { - br = new BufferedReader(new FileReader(sdncStatusFile)); - while ((line = br.readLine()) != null) { - if ("ODL_STATE=SUSPENDED".equals(line)) { - suspended = true; - LOG.debug("vlbcheck: server is suspended"); - } - } - br.close(); - } catch (FileNotFoundException e) { - LOG.trace("Caught File not found exception " + sdncStatusFile + "\n", e); - } catch (Exception e) { - LOG.trace("Failed to read status file " + sdncStatusFile + "\n", e); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - LOG.warn("Failed to close status file " + sdncStatusFile + "\n", e); - } - } - } - } - - if (suspended) { - rpcResult = RpcResultBuilder.failed() - .withError(ErrorType.APPLICATION, "resource-denied", "Server Suspended").build(); - } else { - respBuilder.setResponseMessage("server is normal"); - rpcResult = RpcResultBuilder.status(true).withResult(respBuilder.build()).build(); - } - return (Futures.immediateFuture(rpcResult)); - } - } - - private void DomSaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) { - - if (domDataBroker == null) { - LOG.error("domDataBroker unset - cannot save test result using DOMDataBroker"); - return; - } - - MapEntryNode resultNode = null; - - try { - resultNode = toMapEntryNode(entry); - } catch (Exception e) { - LOG.error("Caught exception trying to create map entry node", e); - } - - if (resultNode == null) { - LOG.error("Could not convert entry to MapEntryNode"); - return; - } - - YangInstanceIdentifier testResultsPid = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) - .node(QName.create(TEST_RESULTS_QNAME, "test-result")).build(); - YangInstanceIdentifier testResultPid = testResultsPid - .node(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, resultNode.getIdentifier().getKeyValues())); - - int tries = 2; - while (true) { - try { - DOMDataWriteTransaction wtx = domDataBroker.newWriteOnlyTransaction(); - if (merge) { - LOG.info("Merging test identifier " + entry.getTestIdentifier()); - wtx.merge(storeType, testResultPid, resultNode); - } else { - LOG.info("Putting test identifier " + entry.getTestIdentifier()); - wtx.put(storeType, testResultPid, resultNode); - } - wtx.submit().checkedGet(); - LOG.trace("Update DataStore succeeded"); - break; - } catch (final TransactionCommitFailedException e) { - if (e instanceof OptimisticLockFailedException) { - if (--tries <= 0) { - LOG.trace("Got OptimisticLockFailedException on last try - failing "); - throw new IllegalStateException(e); - } - LOG.trace("Got OptimisticLockFailedException - trying again "); - } else { - LOG.trace("Update DataStore failed"); - throw new IllegalStateException(e); - } - } - } - - } - - private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) - throws IllegalStateException { - // Each entry will be identifiable by a unique key, we have to create that - // identifier - - InstanceIdentifier.InstanceIdentifierBuilder testResultIdBuilder = InstanceIdentifier - .builder(TestResults.class).child(TestResult.class, entry.key()); - InstanceIdentifier path = testResultIdBuilder.build(); - int tries = 2; - while (true) { - try { - WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); - if (merge) { - tx.merge(storeType, path, entry); - } else { - tx.put(storeType, path, entry); - } - tx.submit().checkedGet(); - LOG.trace("Update DataStore succeeded"); - break; - } catch (final TransactionCommitFailedException e) { - if (e instanceof OptimisticLockFailedException) { - if (--tries <= 0) { - LOG.trace("Got OptimisticLockFailedException on last try - failing "); - throw new IllegalStateException(e); - } - LOG.trace("Got OptimisticLockFailedException - trying again "); - } else { - LOG.trace("Update DataStore failed"); - throw new IllegalStateException(e); - } - } - } - } - - private MapEntryNode toMapEntryNode(TestResult testResult) { - - YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME) - .node(TEST_RESULT_QNAME).build(); - - // Construct results list - LinkedList> entryList = new LinkedList<>(); - for (String result : testResult.getResults()) { - LeafSetEntryNode leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create() - .withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result)).withValue(result).build(); - entryList.add(leafSetEntryNode); - } - // Construct results LeafSetNode - LeafSetNode resultsNode = ImmutableLeafSetNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(RESULTS_QNAME)).withValue(entryList).build(); - - // Construct test result ContainerNode with 2 children - test-identifier leaf - // and results leaf-set - MapEntryNode testResultNode = ImmutableNodes.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(TEST_RESULT_QNAME, TEST_ID_QNAME, - testResult.getTestIdentifier())) - .withChild(ImmutableNodes.leafNode(TEST_ID_QNAME, testResult.getTestIdentifier())) - .withChild(resultsNode).build(); - - return (testResultNode); - - } - -} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 1b083797c..a3e978ccb 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -21,7 +21,6 @@ features provider installer - lighty -- cgit 1.2.3-korg From 0b1062c36db793fb8c16f42b85b006395b2e4b5f Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 30 Aug 2019 21:29:32 +0000 Subject: remove useless log lines delete excess log statements from sli core Issue-ID: CCSDK-1665 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: Iccf1e5eec024b5d5ba0a63d4a6a9cc45c931ea8a --- .../ccsdk/sli/core/sli/SvcLogicExprListener.java | 66 +++------------ .../features-sli/src/main/feature/feature.xml | 7 ++ .../core/sli/provider/base/BlockNodeExecutor.java | 8 +- .../core/sli/provider/base/CallNodeExecutor.java | 8 -- .../provider/base/SvcLogicExpressionResolver.java | 6 +- .../sli/provider/base/SvcLogicServiceImplBase.java | 9 --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 93 ++-------------------- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 2 - 8 files changed, 24 insertions(+), 175 deletions(-) create mode 100644 sli/features/features-sli/src/main/feature/feature.xml diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java index e96b702ef..185986d8e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java @@ -52,7 +52,7 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener .getLogger(SvcLogicExprListener.class); private SvcLogicExpression curExpr; - private SvcLogicExpression topExpr; + //private SvcLogicExpression topExpr; private LinkedList exprStack; public SvcLogicExprListener() @@ -91,37 +91,27 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener { if (exprStack.isEmpty()) { - LOG.trace("Popping last expression"); - topExpr = curExpr; + //topExpr = curExpr; } else { SvcLogicExpression lastExpr = curExpr; curExpr = exprStack.pop(); curExpr.addOperand(lastExpr); - LOG.trace("New curExpr is ["+curExpr.getClass().getName()+"]"); } } @Override public void enterAtom(AtomContext ctx) { - - String atomText = ctx.getText(); - - LOG.trace("enterAtom: text = "+atomText); - - + String atomText = ctx.getText(); SvcLogicAtom newAtom = new SvcLogicAtom(atomText); - pushExpr(newAtom); } @Override public void enterMultExpr(MultExprContext ctx) { - LOG.trace("enterMultExpr: text = "+ctx.getText()); - SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); pushExpr(curBinExpr); @@ -129,7 +119,6 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener for (TerminalNode nd : opList) { - LOG.trace("enterMultExpr: operator - "+nd.getText()); curBinExpr.addOperator(nd.getText()); } @@ -137,22 +126,16 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener @Override public void exitMultExpr(MultExprContext ctx) { - - LOG.trace("exitMultExpr: text = "+ctx.getText()); - popExpr(); - } @Override public void exitAtom(AtomContext ctx) { - LOG.trace("exitAtom: text = "+ctx.getText()); popExpr(); } @Override public void enterAddExpr(AddExprContext ctx) { - LOG.trace("enterAddExpr: text = "+ctx.getText()); List opList = ctx.ADDOP(); @@ -162,16 +145,13 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener for (TerminalNode nd : opList) { - LOG.trace("enterAddExpr: operator - "+nd.getText()); curBinExpr.addOperator(nd.getText()); } } @Override - public void exitAddExpr(AddExprContext ctx) { - LOG.trace("exitAddExpr: text = "+ctx.getText()); - + public void exitAddExpr(AddExprContext ctx) { popExpr(); } @@ -190,9 +170,7 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener } @Override - public void exitFuncExpr(FuncExprContext ctx) { - LOG.trace("exitFuncExpr: text = "+ctx.getText()); - + public void exitFuncExpr(FuncExprContext ctx) { popExpr(); } @@ -208,9 +186,7 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener } @Override - public void enterRelExpr(RelExprContext ctx) { - LOG.trace("enterRelExpr: text = "+ctx.getText()); - + public void enterRelExpr(RelExprContext ctx) { List opList = ctx.RELOP(); @@ -220,36 +196,30 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener for (TerminalNode nd : opList) { - LOG.trace("enterRelExpr: operator - "+nd.getText()); curBinExpr.addOperator(nd.getText()); } } @Override - public void exitRelExpr(RelExprContext ctx) { - LOG.trace("exitRelExpr: text = "+ctx.getText()); - + public void exitRelExpr(RelExprContext ctx) { popExpr(); } @Override public void enterCompareExpr(CompareExprContext ctx) { - LOG.trace("enterCompareExpr: text = "+ctx.getText()); TerminalNode nd = ctx.COMPAREOP(); SvcLogicBinaryExpression curBinExpr = new SvcLogicBinaryExpression(); pushExpr(curBinExpr); - LOG.trace("enterCompareExpr: operator - "+nd.getText()); curBinExpr.addOperator(nd.getText()); } @Override public void exitCompareExpr(CompareExprContext ctx) { - LOG.trace("exitCompareExpr : text = "+ctx.getText()); popExpr(); } @@ -258,47 +228,32 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener @Override public void enterConstant(ConstantContext ctx) { - LOG.trace("enterConstant: text = "+ctx.getText()); } @Override public void exitConstant(ConstantContext ctx) { - LOG.trace("exitConstant: text = "+ctx.getText()); } @Override public void enterVariable(VariableContext ctx) { - LOG.trace("enterVariable: text = "+ctx.getText()); - - } @Override - public void exitVariable(VariableContext ctx) { - LOG.debug("exitVariable: text ="+ctx.getText()); - + public void exitVariable(VariableContext ctx) { } @Override public void enterVariableLead(VariableLeadContext ctx) { - - LOG.debug("enterVariableLead: text ="+ctx.getText()); - - } @Override public void exitVariableLead(VariableLeadContext ctx) { - - LOG.trace("exitVariableLead: text ="+ctx.getText()); } @Override - public void enterVariableTerm(VariableTermContext ctx) { - LOG.trace("enterVariableTerm: text ="+ctx.getText()); - + public void enterVariableTerm(VariableTermContext ctx) { String name = ctx.getText(); int subscrStart = name.indexOf("["); @@ -312,7 +267,6 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener @Override public void exitVariableTerm(VariableTermContext ctx) { - LOG.trace("exitVariableTerm: text="+ctx.getText()); - popExpr(); + popExpr(); } } diff --git a/sli/features/features-sli/src/main/feature/feature.xml b/sli/features/features-sli/src/main/feature/feature.xml new file mode 100644 index 000000000..f8ecf8d60 --- /dev/null +++ b/sli/features/features-sli/src/main/feature/feature.xml @@ -0,0 +1,7 @@ + + + + + wrap:mvn:org.onap.ccsdk.sli.core/sli-provider-base/${project.version}$Bundle-SymbolicName=org.onap.ccsdk.sli.core.sli-provider.base + + diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java index 7aaf795b3..fb1527901 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java @@ -54,17 +54,11 @@ public class BlockNodeExecutor extends AbstractSvcLogicNodeExecutor { SvcLogicNode nextNode = node.getOutcomeValue("" + (i + 1)); if (nextNode != null) { - if (LOG.isDebugEnabled()) { - LOG.debug("Block - executing outcome " + (i + 1)); - } + while (nextNode != null) { nextNode = svc.executeNode(nextNode, ctx); } - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("Block - done: no outcome " + (i + 1)); - } } } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java index fd052ada2..766826f7d 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/CallNodeExecutor.java @@ -50,10 +50,6 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { { LOG.debug("execute: getGraph returned null"); } - else - { - LOG.debug("execute: got SvcLogicGraph"); - } SvcLogicExpression moduleExpr = null; @@ -70,7 +66,6 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { if (myGraph != null) { module = myGraph.getModule(); - LOG.debug("myGraph.getModule() returned "+module); } } @@ -87,7 +82,6 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { if (myGraph != null) { rpc = myGraph.getRpc(); - LOG.debug("myGraph.getRpc() returned "+rpc); } } @@ -104,8 +98,6 @@ public class CallNodeExecutor extends AbstractSvcLogicNodeExecutor { if (myGraph != null) { mode = myGraph.getMode(); - - LOG.debug("myGraph.getMode() returned "+mode); } } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java index 0e502035b..59ba6cd77 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java @@ -68,7 +68,6 @@ public class SvcLogicExpressionResolver { if (atomType == AtomType.CONTEXT_VAR) { - LOG.trace("Evaluating context variable $"+varName); String varValue = ctx.getAttribute(varName); @@ -80,9 +79,7 @@ public class SvcLogicExpressionResolver { return (varValue); } SvcLogicExpression parm = node.getParameter(varName); - if (parm != null) { - LOG.trace("Evaluating value of parameter "+varName+": "+parm.asParsedExpr()); - + if (parm != null) { return (evaluate(parm, node, ctx)); } else @@ -491,7 +488,6 @@ public class SvcLogicExpressionResolver { } String varName = varNameBuff.toString(); - LOG.debug("Evaluating context variable $"+varName); String ctxValue = ctx.getAttribute(varName); if (ctxValue == null) { diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java index f850bc4c8..29f3da811 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java @@ -77,26 +77,20 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { } protected void registerExecutors() { - - LOG.info("Entered register executors"); for (String nodeType : BUILTIN_NODES.keySet()) { - LOG.info("SLI - registering node executor for node type " + nodeType); registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } - LOG.info("Done registerExecutors"); } public void registerExecutor(String nodeName, AbstractSvcLogicNodeExecutor executor) { if (nodeExecutors == null) { nodeExecutors = new HashMap<>(); } - LOG.info("SLI - registering executor for node type {}", nodeName); executor.setResolver(resolver); nodeExecutors.put(nodeName, executor); } public void unregisterExecutor(String nodeName) { - LOG.info("SLI - unregistering executor for node type {}", nodeName); nodeExecutors.remove(nodeName); } @@ -140,9 +134,6 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { AbstractSvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); if (executor != null) { - LOG.debug("Executing node executor for node type {} - {}", node.getNodeType(), - executor.getClass().getName()); - MDC.put("nodeId", node.getNodeId() + " (" + node.getNodeType() + ")"); return (executor.execute(this, node, ctx)); } else { diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 730f272ba..3b6151c91 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -128,7 +128,6 @@ public class MdsalHelper { } String simpleTypeName = fromObj.getClass().getTypeName(); simpleTypeName = simpleTypeName.substring(simpleTypeName.lastIndexOf(".") + 1); - LOG.trace("Extracting properties from " + fromClass.getName() + " class"); if (classHasSpecialHandling(simpleTypeName)) { try { @@ -157,10 +156,6 @@ public class MdsalHelper { + ".getValue() to Properties entry", e); } } else if (fromObj instanceof List) { - - // Class is a List. List should contain yang-generated classes. - LOG.trace(fromClass.getName() + " is a List"); - List fromList = (List) fromObj; for (int i = 0; i < fromList.size(); i++) { @@ -170,7 +165,6 @@ public class MdsalHelper { } else if (isYangGenerated(fromClass)) { // Class is yang generated. - LOG.trace(fromClass.getName() + " is a Yang-generated class"); String propNamePfx = null; @@ -261,10 +255,7 @@ public class MdsalHelper { Object retValue = m.invoke(fromObj); if (retValue instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); retValue = new String((byte[]) retValue, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " - + retValue); } if (!isAccessible) { m.setAccessible(isAccessible); @@ -285,8 +276,6 @@ public class MdsalHelper { } } else if (returnType.equals(Class.class)) { - LOG.trace(m.getName() + " returns a Class object - not interested"); - } else if (List.class.isAssignableFrom(returnType)) { // This getter method returns a list. @@ -327,11 +316,7 @@ public class MdsalHelper { if (propValObj != null) { if (propValObj instanceof byte[]) { - LOG.trace(m.getName() + " returns a byte[]"); propVal = new String((byte[]) propValObj, "UTF-8"); - LOG.trace("Converted byte array " + propNamePfx + "." + fieldName + "to string " - + propVal); - } else { propVal = propValObj.toString(); } @@ -373,7 +358,6 @@ public class MdsalHelper { if (fromObj instanceof byte[]) { try { fromVal = new String((byte[]) fromObj, "UTF-8"); - LOG.trace("Converted byte array " + pfx + "to string " + fromVal); } catch (Exception e) { LOG.warn("Caught exception trying to convert " + pfx + " from byte[] to String", e); fromVal = fromObj.toString(); @@ -399,8 +383,6 @@ public class MdsalHelper { int maxIdx = -1; boolean foundValue = false; - LOG.trace("Saving properties to List<" + elemType.getName() + "> from " + pfx); - if (props.containsKey(pfx + "_length")) { try { int listLength = Integer.parseInt(props.getProperty(pfx + "_length")); @@ -439,7 +421,6 @@ public class MdsalHelper { } } - LOG.trace(pfx + " has max index of " + maxIdx); for (int i = 0; i <= maxIdx; i++) { String curBase = pfx + "[" + i + "]"; @@ -501,8 +482,6 @@ public class MdsalHelper { Method buildMethod = builderClass.getMethod("build"); builderObj = toBuilder(props, curBase, builderObj, true); if (builderObj != null) { - LOG.trace( - "Calling " + builderObj.getClass().getName() + "." + buildMethod.getName() + "()"); Object builtObj = buildMethod.invoke(builderObj); toObj.add(builtObj); foundValue = true; @@ -544,14 +523,10 @@ public class MdsalHelper { Class toClass = toObj.getClass(); boolean foundValue = false; - LOG.trace("Saving properties to " + toClass.getName() + " class from " + pfx); - Ipv4Address addr; if (isYangGenerated(toClass)) { // Class is yang generated. - LOG.trace(toClass.getName() + " is a Yang-generated class"); - String propNamePfx = null; if (preservePfx) { propNamePfx = pfx; @@ -573,7 +548,6 @@ public class MdsalHelper { } if (toObj instanceof Identifier) { - LOG.trace(toClass.getName() + " is a Key - skipping"); return (toObj); } @@ -592,12 +566,12 @@ public class MdsalHelper { String paramValue = props.getProperty(propName); if (paramValue == null) { - LOG.trace(propName + " is unset"); + } else if ("".equals(paramValue)) { LOG.trace(propName + " was set to the empty string, setting it to null"); paramValue = null; } else { - LOG.trace(propName + " = " + paramValue); + } // Is the return type a yang generated class? @@ -605,7 +579,6 @@ public class MdsalHelper { // Is it an enum? if (paramClass.isEnum()) { - LOG.trace(m.getName() + " expects an Enum"); // Param type is a typedef. if ((paramValue != null) && (paramValue.length() > 0)) { Object paramObj = null; @@ -623,8 +596,6 @@ public class MdsalHelper { m.setAccessible(true); } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); m.invoke(toObj, paramObj); if (!isAccessible) { @@ -669,8 +640,7 @@ public class MdsalHelper { if (!isAccessible) { m.setAccessible(true); } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); + m.invoke(toObj, paramValue); if (!isAccessible) { m.setAccessible(isAccessible); @@ -727,8 +697,6 @@ public class MdsalHelper { Object constObj = null; - LOG.trace(m.getName() + " expects a yang-generated class - looking for builder " - + builderName); try { builderClass = Class.forName(builderName); builderObj = builderClass.newInstance(); @@ -741,8 +709,7 @@ public class MdsalHelper { if (!isAccessible) { m.setAccessible(true); } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() - + "(null)"); + m.invoke(toObj, new Object[] { null }); if (!isAccessible) { m.setAccessible(isAccessible); @@ -826,8 +793,7 @@ public class MdsalHelper { try { Method buildMethod = builderClass.getMethod("build"); - LOG.trace("Calling " + paramObj.getClass().getName() + "." - + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(paramObj); boolean isAccessible = m.isAccessible(); @@ -835,7 +801,6 @@ public class MdsalHelper { m.setAccessible(true); } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "()"); m.invoke(toObj, builtObj); if (!isAccessible) { m.setAccessible(isAccessible); @@ -855,15 +820,9 @@ public class MdsalHelper { } if (constObj != null) { - - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + constObj.toString() + ")"); m.invoke(toObj, constObj); } else { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); m.invoke(toObj, paramValue); - } if (!isAccessible) { m.setAccessible(isAccessible); @@ -883,9 +842,6 @@ public class MdsalHelper { // if it is a List. if (List.class.isAssignableFrom(paramClass)) { - - LOG.trace("Parameter class " + paramClass.getName() + " is a List"); - // Figure out what type of args are in List and pass // that to toList(). @@ -905,8 +861,6 @@ public class MdsalHelper { if (!isAccessible) { m.setAccessible(true); } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); m.invoke(toObj, paramObj); if (!isAccessible) { m.setAccessible(isAccessible); @@ -922,10 +876,6 @@ public class MdsalHelper { // Setter expects something that is not a List and // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + paramClass.getName() - + " is not a yang-generated class or a List"); - if ((paramValue != null) && (paramValue.length() > 0)) { Object constObj = null; @@ -958,8 +908,6 @@ public class MdsalHelper { if (constObj != null) { try { - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + constObj + ")"); m.invoke(toObj, constObj); foundValue = true; } catch (Exception e2) { @@ -971,8 +919,6 @@ public class MdsalHelper { if (!isAccessible) { m.setAccessible(true); } - LOG.trace("Calling " + toObj.getClass().getName() + "." + m.getName() + "(" - + paramValue + ")"); m.invoke(toObj, paramValue); if (!isAccessible) { m.setAccessible(isAccessible); @@ -1022,21 +968,8 @@ public class MdsalHelper { public static void printPropertyList(PrintStream pstr, String pfx, Class toClass) { boolean foundValue = false; - LOG.trace("Analyzing " + toClass.getName() + " class : pfx " + pfx); - if (isYangGenerated(toClass) && (!Identifier.class.isAssignableFrom(toClass))) { // Class is yang generated. - LOG.trace(toClass.getName() + " is a Yang-generated class"); - - if (toClass.getName().endsWith("Key")) { - if (Identifier.class.isAssignableFrom(toClass)) { - LOG.trace(Identifier.class.getName() + " is assignable from " + toClass.getName()); - } else { - - LOG.trace(Identifier.class.getName() + " is NOT assignable from " + toClass.getName()); - } - } - String propNamePfx = null; if (pfx.endsWith("]")) { propNamePfx = pfx; @@ -1061,9 +994,7 @@ public class MdsalHelper { // set for (Method m : toClass.getMethods()) { - LOG.trace("Is " + m.getName() + " method a getter?"); if (isGetter(m)) { - LOG.trace(m.getName() + " is a getter"); Class returnClass = m.getReturnType(); String fieldName = toLowerHyphen(m.getName().substring(3)); @@ -1078,10 +1009,7 @@ public class MdsalHelper { if (isYangGenerated(returnClass)) { // Is it an enum? if (returnClass.isEnum()) { - - LOG.trace(m.getName() + " is an Enum"); pstr.print("\n\n * " + propName); - } else { String simpleName = returnClass.getSimpleName(); @@ -1089,7 +1017,6 @@ public class MdsalHelper { if (IPV4_ADDRESS.equals(simpleName) || IPV6_ADDRESS.equals(simpleName) || IP_ADDRESS.equals(simpleName) || IP_PREFIX.equals(simpleName) || "PortNumber".equals(simpleName) || "Dscp".equals(simpleName)) { - LOG.trace(m.getName() + " is an " + simpleName); pstr.print("\n\n * " + propName); } else { printPropertyList(pstr, propNamePfx, returnClass); @@ -1102,17 +1029,12 @@ public class MdsalHelper { // if it is a List. if (List.class.isAssignableFrom(returnClass)) { - - LOG.trace("Parameter class " + returnClass.getName() + " is a List"); - // Figure out what type of args are in List and pass // that to toList(). Type returnType = m.getGenericReturnType(); Type elementType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; Class elementClass = (Class) elementType; - LOG.trace("Calling printPropertyList on list type (" + elementClass.getName() - + "), pfx is (" + pfx + "), toClass is (" + toClass.getName() + ")"); printPropertyList(pstr, propNamePfx + "." + toLowerHyphen(elementClass.getSimpleName()) + "[]", elementClass); @@ -1121,10 +1043,6 @@ public class MdsalHelper { // Setter expects something that is not a List and // not yang-generated. Just pass the parameter value - - LOG.trace("Parameter class " + returnClass.getName() - + " is not a yang-generated class or a List"); - pstr.print("\n\n * " + propName); } } @@ -1243,7 +1161,6 @@ public class MdsalHelper { String retval = str.replaceAll(regex, replacement).toLowerCase(); - LOG.trace("Converting " + inStr + " => " + str + " => " + retval); return (retval); } diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 6d466bc72..6092d1fb0 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -118,7 +118,6 @@ public class ITCaseSvcLogicGraphExecutor { SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); for (String nodeType : BUILTIN_NODES.keySet()) { - LOG.info("SLI - registering node executor for node type " + nodeType); svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } @@ -171,7 +170,6 @@ public class ITCaseSvcLogicGraphExecutor { assertNotNull(store); for (String nodeType : BUILTIN_NODES.keySet()) { - LOG.info("SLI - registering node executor for node type {}", nodeType); svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); -- cgit 1.2.3-korg From be5c33c26dae1ff3c9ae353f2dfa76e976a909be Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 5 Sep 2019 20:10:01 +0000 Subject: logging changes remove old logging statements, add a few helpful ones Issue-ID: CCSDK-1665 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I2272f54b447647c8beab6d2053413c57e816eeac --- .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 5 ++-- .../ccsdk/sli/core/sli/SvcLogicExprListener.java | 1 - .../sli/core/sli/SvcLogicExpressionFactory.java | 1 - .../features-sli/src/main/feature/feature.xml | 7 ------ sli/features/odl-sli/src/main/feature/feature.xml | 7 ++++++ .../base/AbstractSvcLogicNodeExecutor.java | 27 ++++++++++++++++++++++ .../sli/provider/base/ConfigureNodeExecutor.java | 22 ++++-------------- .../sli/provider/base/ExecuteNodeExecutor.java | 17 +------------- .../core/sli/provider/base/RecordNodeExecutor.java | 22 +----------------- .../core/sli/provider/base/ReturnNodeExecutor.java | 3 +-- .../core/sli/provider/base/SaveNodeExecutor.java | 19 +-------------- .../core/sli/provider/base/SetNodeExecutor.java | 3 +-- .../provider/base/SvcLogicExpressionResolver.java | 11 +++++---- .../sli/provider/base/SvcLogicServiceImplBase.java | 6 +---- .../core/sli/provider/base/UpdateNodeExecutor.java | 19 +-------------- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 7 ------ .../sli/core/sli/provider/SvcLogicServiceImpl.java | 1 - 17 files changed, 54 insertions(+), 124 deletions(-) delete mode 100644 sli/features/features-sli/src/main/feature/feature.xml create mode 100644 sli/features/odl-sli/src/main/feature/feature.xml diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 87e8f1a4d..94ffcd990 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -193,10 +193,9 @@ public class SvcLogicDblibStore implements SvcLogicStore { } else { return null; } - } catch (SQLException e) { - throw new ConfigurationException("SQL query failed", e); } catch (Exception e) { - throw new ConfigurationException("Graph processing failed", e); + LOG.error("Graph processing failed", e); + throw new ConfigurationException("Graph processing failed: " + e.getMessage()); } finally { try { if (fetchGraphStmt != null) { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java index 185986d8e..a1871951f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExprListener.java @@ -79,7 +79,6 @@ public class SvcLogicExprListener extends ExprGrammarBaseListener private void pushExpr(SvcLogicExpression expr) { - LOG.trace("Pushing expression ["+expr.getClass().getName()+"]"); if (curExpr != null) { exprStack.push(curExpr); diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java index d275e9703..9e9bfe0dc 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java @@ -42,7 +42,6 @@ public class SvcLogicExpressionFactory { public static SvcLogicExpression parse(String exprStr) throws IOException { - LOG.trace("parse("+exprStr+")"); InputStream exprStream = new ByteArrayInputStream(exprStr.getBytes()); CharStream input = new ANTLRInputStream(exprStream); ExprGrammarLexer lexer = new ExprGrammarLexer(input); diff --git a/sli/features/features-sli/src/main/feature/feature.xml b/sli/features/features-sli/src/main/feature/feature.xml deleted file mode 100644 index f8ecf8d60..000000000 --- a/sli/features/features-sli/src/main/feature/feature.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - wrap:mvn:org.onap.ccsdk.sli.core/sli-provider-base/${project.version}$Bundle-SymbolicName=org.onap.ccsdk.sli.core.sli-provider.base - - diff --git a/sli/features/odl-sli/src/main/feature/feature.xml b/sli/features/odl-sli/src/main/feature/feature.xml new file mode 100644 index 000000000..2304d9314 --- /dev/null +++ b/sli/features/odl-sli/src/main/feature/feature.xml @@ -0,0 +1,7 @@ + + + + + wrap:mvn:org.onap.ccsdk.sli.core/sli-provider-base/${project.version}/$Bundle-SymbolicName=org.onap.ccsdk.sli.core.sli-provider-base&Bundle-Name=sli-provider-base + + diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java index a51accbb9..9bab745b1 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java @@ -21,9 +21,15 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; @@ -36,6 +42,8 @@ public abstract class AbstractSvcLogicNodeExecutor { public abstract SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; private static final Logger LOG = LoggerFactory.getLogger(AbstractSvcLogicNodeExecutor.class); + protected static final String PARAMETER_DEBUG_PATTERN = "Parameter: {} resolves to: {} which came from the expression: {}"; + protected static final String SETTING_DEBUG_PATTERN = "Setting context attribute: {} to: {} which came from the expression: {}"; protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { @@ -90,4 +98,23 @@ public abstract class AbstractSvcLogicNodeExecutor { return (nextNode); } + protected Map getResolvedParameters(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException{ + Map parmMap = new HashMap<>(); + + Set> parmSet = node + .getParameterSet(); + + for (Iterator> iter = parmSet + .iterator(); iter.hasNext();) { + Map.Entry curEnt = iter.next(); + String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); + String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); + LOG.trace(PARAMETER_DEBUG_PATTERN, curName, curExprValue, curExpr.toString()); + parmMap.put(curName,curExprValue); + } + + return parmMap; + } + } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java index 5d6a08391..55afa8594 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java @@ -63,24 +63,12 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { String key = SvcLogicExpressionResolver.evaluate( node.getAttribute("key"), node, ctx); - Map parmMap = new HashMap<>(); - - Set> parmSet = node - .getParameterSet(); boolean hasParms = false; - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); - - parmMap.put(curName,curExprValue); - } + + Map parmMap = getResolvedParameters(node,ctx); + if(!parmMap.isEmpty()) { + hasParms = true; + } if (hasParms) { SvcLogicAdaptor.ConfigStatus confStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java index cef582b7c..0fe179b7a 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java @@ -79,23 +79,8 @@ public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { } else { try { - Map parmMap = new HashMap<>(); - - Set> parmSet = node - .getParameterSet(); - - for (Iterator> iter = parmSet - .iterator(); iter.hasNext();) { - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.trace("Parameter "+curName+" = "+curExpr.asParsedExpr()+" resolves to "+curExprValue); - - parmMap.put(curName,curExprValue); - } + Map parmMap = getResolvedParameters(node,ctx); Object o = pluginMethod.invoke(plugin, parmMap, ctx); String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java index be5462bdc..d233a36d7 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java @@ -46,27 +46,7 @@ public class RecordNodeExecutor extends AbstractSvcLogicNodeExecutor { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); String outValue = "failure"; - if (LOG.isTraceEnabled()) { - LOG.trace(node.getNodeType() + " node encountered - looking for recorder class " + plugin); - } - - Map parmMap = new HashMap<>(); - - Set> parmSet = node.getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - if (LOG.isTraceEnabled()) { - LOG.trace("executeRecordNode : parameter " + curName + " = " + curExpr + " => " + curExprValue); - } - parmMap.put(curName, curExprValue); - } + Map parmMap = getResolvedParameters(node,ctx); SvcLogicRecorder recorder = getSvcLogicRecorder(plugin); if (recorder != null) { diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java index d2fe35d75..ab284e5a7 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java @@ -66,8 +66,7 @@ public class ReturnNodeExecutor extends AbstractSvcLogicNodeExecutor { curEnt.getValue(), node, ctx); if (LOG.isDebugEnabled()) { - LOG.debug("Setting context attribute " + curName + " to " - + curValue); + LOG.debug(SETTING_DEBUG_PATTERN, curName, curValue); } ctx.setAttribute(curName, curValue); } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java index f8595fff2..64a44b3b9 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java @@ -54,24 +54,7 @@ public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor { boolean force = "true".equalsIgnoreCase(forceStr); boolean localOnly = "true".equalsIgnoreCase(localOnlyStr); - Map parmMap = new HashMap<>(); - - Set> parmSet = node.getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); - - parmMap.put(curName, curExprValue); - } - } + Map parmMap = getResolvedParameters(node,ctx); String outValue = FAILURE; diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java index caf0015ba..89074362f 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java @@ -169,8 +169,7 @@ public class SetNodeExecutor extends AbstractSvcLogicNodeExecutor { String curValue = SvcLogicExpressionResolver.evaluate(curEnt.getValue(), node, ctx); if (LOG.isDebugEnabled()) { - LOG.trace("Parameter value {} resolves to {}", curEnt.getValue().asParsedExpr(), curValue); - LOG.debug("Setting context attribute {} to {}", lhsVarName, curValue); + LOG.debug(SETTING_DEBUG_PATTERN, lhsVarName, curValue, curEnt.getValue().toString()); } ctx.setAttribute(lhsVarName, curValue); } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java index 59ba6cd77..e3c0ef205 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java @@ -44,6 +44,7 @@ public class SvcLogicExpressionResolver { private static final Logger LOG = LoggerFactory .getLogger(SvcLogicExpressionResolver.class); private static final String INVALID_EXPRESSION_MSG= "Invalid expression ("; + private static final String EXPRESSION_DEBUG_PATTERN = "Expression: {} resolves to {}: which has the value {}"; public static String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { @@ -51,8 +52,6 @@ public class SvcLogicExpressionResolver { return (null); } - - if (expr instanceof SvcLogicAtom) { SvcLogicAtom atom = (SvcLogicAtom) expr; @@ -75,15 +74,18 @@ public class SvcLogicExpressionResolver { LOG.trace("Context variable $"+varName+" unset - treating as empty string"); varValue = ""; } - + LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,varValue); return (varValue); } SvcLogicExpression parm = node.getParameter(varName); if (parm != null) { - return (evaluate(parm, node, ctx)); + String value = evaluate(parm, node, ctx); + LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,value); + return value; } else { + LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,varName); return(varName); } default: @@ -98,7 +100,6 @@ public class SvcLogicExpressionResolver { List operands = binExpr.getOperands(); if (operands.size() == 1) { - LOG.trace("SvcLogicBinaryExpression as no operator and one operand - evaluating its operand"); return(evaluate(operands.get(0), node, ctx)); } else diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java index 5d6843f91..361ca708a 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java @@ -122,11 +122,7 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { return (null); } - LOG.info("About to execute node # {} ({})", node.getNodeId(), node.getNodeType()); - - if (LOG.isDebugEnabled()) { - LOG.debug("Executing node " + node.getNodeId() + " of " + node.getGraph().getRpc()); - } + LOG.info("About to execute node #{} {} node in graph {}", node.getNodeId(), node.getNodeType(), node.getGraph().toString()); AbstractSvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType()); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java index 3d93a37ee..104f36f5f 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java @@ -49,24 +49,7 @@ public class UpdateNodeExecutor extends AbstractSvcLogicNodeExecutor { String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - Map parmMap = new HashMap<>(); - - Set> parmSet = node.getParameterSet(); - boolean hasParms = false; - - for (Iterator> iter = parmSet.iterator(); iter.hasNext();) { - hasParms = true; - Map.Entry curEnt = iter.next(); - String curName = curEnt.getKey(); - SvcLogicExpression curExpr = curEnt.getValue(); - if (curExpr != null) { - String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - - LOG.debug("Parameter " + curName + " = " + curExpr.asParsedExpr() + " resolves to " + curExprValue); - - parmMap.put(curName, curExprValue); - } - } + Map parmMap = getResolvedParameters(node,ctx); String outValue = "failure"; diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 3b6151c91..5bd4bd938 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -342,15 +342,8 @@ public class MdsalHelper { // "getValue", then // set value identified by "prefix" to that one value. if ((numGetters == 1) && ("getValue".equals(lastGetterName))) { - LOG.trace("getValueFIX : " + propNamePfx + " only has getValue() getter - setting " + propNamePfx - + " = " + propVal); props.setProperty(propNamePfx, propVal); - } else { - LOG.trace("getValueFIX : " + propNamePfx + " has " + numGetters + " getter(s), last one found was " - + lastGetterName); - } - } else { // Class is not yang generated and not a list // It must be an element of a leaf list - set "prefix" to value diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index d5c7f3bfe..f563d986e 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -94,7 +94,6 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL @Override public Properties execute(String module, String rpc, String version, String mode, Properties props, DOMDataBroker domDataBroker) throws SvcLogicException { - LOG.info("Fetching service logic from data store"); SvcLogicGraph graph = store.fetch(module, rpc, version, mode); if (graph == null) { -- cgit 1.2.3-korg From d93b2ab94d585f5166c8ff0b4bceb76ca6bcb3cc Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 6 Sep 2019 09:49:08 -0400 Subject: Fix errors in INFO.yaml Fix errors in INFO.yaml file Change-Id: I48a0645f97d23f5175d8af5b9a28d447031822f7 Issue-ID: CCSDK-1696 Signed-off-by: Timoney, Dan (dt5972) --- INFO.yaml | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index 7a3f089d5..3b7c1dfa4 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -8,7 +8,7 @@ project_lead: &onap_releng_ptl email: 'dtimoney@att.com' id: 'djtimoney' company: 'ATT' - timezone: 'America/New York' + timezone: 'America/New_York' primary_contact: *onap_releng_ptl issue_tracking: type: 'jira' @@ -33,12 +33,12 @@ committers: email: 'jflucas@research.att.com' company: 'ATT' id: 'jackl' - timezone: 'America/New York' + timezone: 'America/New_York' - name: 'Jun (Nicolas) Hu' email: 'jh245g@att.com' company: 'ATT' id: 'jh245g' - timezone: 'America/New York' + timezone: 'America/New_York' - name: 'Gaurav Agrawal' email: 'gaurav.agrawal@huawei.com' company: 'Huawei' @@ -48,21 +48,9 @@ committers: email: 'brindasanth@in.ibm.com' company: 'IBM' id: 'brindasanthm' - timezone: 'America/New York' + timezone: 'America/New_York' repositories: - - ccsdk-apps - - ccsdk-cds - - ccsdk-distribution - - ccsdk-features - - ccsdk-parent - - ccsdk-platform-blueprints - - ccsdk-platform-plugins - - ccsdk-sli-adaptors - - ccsdk-sli-core - - ccsdk-sli-northbound - - ccsdk-sli-plugins - - ccsdk-storage-esaas - - ccsdk-utils + - ccsdk/sli/core tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: -- cgit 1.2.3-korg From 0ece082d666bbd2d37bb3e8f888c339ca7a029eb Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Mon, 9 Sep 2019 21:44:30 +0000 Subject: prevent duplicate bundle startup prevent duplicate bundle startup Issue-ID: CCSDK-1699 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I678845701a0bd2c1756d367fdf1bf3dbe02792d2 --- sli/features/odl-sli/src/main/feature/feature.xml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 sli/features/odl-sli/src/main/feature/feature.xml diff --git a/sli/features/odl-sli/src/main/feature/feature.xml b/sli/features/odl-sli/src/main/feature/feature.xml deleted file mode 100644 index 2304d9314..000000000 --- a/sli/features/odl-sli/src/main/feature/feature.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - wrap:mvn:org.onap.ccsdk.sli.core/sli-provider-base/${project.version}/$Bundle-SymbolicName=org.onap.ccsdk.sli.core.sli-provider-base&Bundle-Name=sli-provider-base - - -- cgit 1.2.3-korg From 009d047e0abc2c8d9bfc56effd3e716bea9a5086 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 10 Sep 2019 11:57:17 -0400 Subject: Release version 1.6.1 Release CCSDK version 1.6.1 Change-Id: Iad4a69cf48ae0a198fbbe0900f0b535b82685cce Issue-ID: CCSDK-1701 Signed-off-by: Timoney, Dan (dt5972) --- releases/0.6.1.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.6.1.yaml diff --git a/releases/0.6.1.yaml b/releases/0.6.1.yaml new file mode 100644 index 000000000..8ccc981ed --- /dev/null +++ b/releases/0.6.1.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.6.1' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/203/' -- cgit 1.2.3-korg From 7d322a14fea0295f49b96ff6213a719c330072aa Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 10 Sep 2019 14:59:46 -0400 Subject: Roll version for Frankfurt release Roll version in master branch to Frankfurt version (1.5.0-SNAPSHOT) Change-Id: Ic2b3afb65d780360a056d50a1cfd0b32555ae32a Issue-ID: CCSDK-1701 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 4 ++-- dblib/features/ccsdk-dblib/pom.xml | 4 ++-- dblib/features/features-dblib/pom.xml | 4 ++-- dblib/features/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/features/ccsdk-filters/pom.xml | 4 ++-- filters/features/features-filters/pom.xml | 4 ++-- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/features/features-sli/pom.xml | 4 ++-- sli/features/odl-sli/pom.xml | 4 ++-- sli/features/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/features/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/features/ccsdk-sliapi/pom.xml | 4 ++-- sliapi/features/features-sliapi/pom.xml | 4 ++-- sliapi/features/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/features/ccsdk-slicore-utils/pom.xml | 4 ++-- utils/features/features-util/pom.xml | 4 ++-- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 4 ++-- 48 files changed, 94 insertions(+), 94 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index bf728ed66..1f0781b63 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index cebb0b9e6..7011202f2 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index b9445e037..e24b0f0e2 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core features-dblib - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index c3941cc31..25ab61bed 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-feature-aggregator - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 200ae612a..175d9fb9f 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index a8a2a1314..1a2dc28e9 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 0f2a7083c..a3bd00f3a 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 5e2bc3df5..3c49170a6 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 6b21cad21..e622944e5 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index d8b1c8d87..e8957b42e 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 62c59cc47..fc439b278 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index b1677a7a2..320dfab31 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 8b37eeaf0..3273ffea5 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core features-filters - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 14519c71b..ff153c9df 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 4be194c8c..8921eca8d 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index b6fe401c7..8c2d560fd 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 3a7090dd3..602b8384b 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index b72b3c83b..a199b7278 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 63967b1f0..050f96b45 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 23224e101..4ccebf892 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 069895df4..2b770e288 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 780035b76..2c74aa8bd 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sli-feature-aggregator - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 723cd1740..9685176b6 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 7882669f7..048ba51c1 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 91c520201..e1da778f3 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 729439188..93f207199 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 783fbb913..265831da4 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index c0c0e256a..76862c499 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index f7343f1ca..98ffac4e7 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 18f9da5cc..ec1650f39 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliPluginUtils - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 03f999e42..d6dad16a1 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-features - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 34896d5fa..74d26d3a8 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index a6b8b83a7..90cd5f35a 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 0d4a18344..be068e7fc 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 53436b54b..9425161d1 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 0bf59c16c..67f1c7009 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core features-sliapi - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 1b66dd354..1f7d8a3ee 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index f72f010c1..0f3f9de98 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 92d1b96b5..2bf3a3917 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index a3e978ccb..dc4734576 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index ab1dc4c5c..f845ae0f3 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 3086dd0d8..661a43443 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 169fa621b..4441b4fbb 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core features-util - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 84e9a7547..537f68a1a 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index bc406463b..e5bb6eb16 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index ac1a736f0..8448296e7 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index cf5dc8a89..1f1922bda 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.6.1-SNAPSHOT + 0.7.0-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 5d94f48dd..fc68f0298 100644 --- a/version.properties +++ b/version.properties @@ -5,8 +5,8 @@ release_name=0 -sprint_number=6 -feature_revision=1 +sprint_number=7 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From baf9900e9439e59de44c7a3b4548ea6f7cd935c4 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Wed, 18 Sep 2019 13:30:20 -0400 Subject: ReturnNodeExecutor Fixing Logger Statement Adding third variable to the logger so that Expression prints properly Change-Id: I2e4a74ace199506698abede88778e6314b226e59 Issue-ID: CCSDK-1745 Signed-off-by: Singal, Kapil (ks220y) --- .../org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java index ab284e5a7..8ee465774 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReturnNodeExecutor.java @@ -66,7 +66,7 @@ public class ReturnNodeExecutor extends AbstractSvcLogicNodeExecutor { curEnt.getValue(), node, ctx); if (LOG.isDebugEnabled()) { - LOG.debug(SETTING_DEBUG_PATTERN, curName, curValue); + LOG.debug(SETTING_DEBUG_PATTERN, curName, curValue, curEnt.getValue()); } ctx.setAttribute(curName, curValue); } -- cgit 1.2.3-korg From d815d848cd83cfb9180286af5bc8a7516f4eafe9 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Mon, 9 Sep 2019 20:55:15 +0000 Subject: update filters replace legacy filters with common filters Issue-ID: CCSDK-1698 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: Id6b1f003f19105956d221d5bfd31390ac096c9bc --- filters/features/ccsdk-filters/pom.xml | 51 ++- filters/installer/pom.xml | 22 -- filters/provider/pom.xml | 70 +--- .../sli/core/filters/ControllerAuditLogFilter.java | 40 +++ .../filters/ControllerPayloadLoggingFilter.java | 7 + .../ccsdk/sli/core/filters/FiltersService.java | 4 - .../ccsdk/sli/core/filters/FiltersServiceImpl.java | 33 -- .../org/onap/ccsdk/sli/core/filters/LogFilter.java | 223 ------------- .../core/filters/RequestResponseLoggingFilter.java | 363 --------------------- .../OSGI-INF/blueprint/filters-blueprint.xml | 9 - .../opendaylight/blueprint/filters-blueprint.xml | 9 - .../core/filters/ControllerAuditLogFilterTest.java | 23 ++ .../onap/ccsdk/sli/core/filters/TestLogFilter.java | 71 ---- .../filters/TestRequestResponseLoggingFilter.java | 165 ---------- sli/common/pom.xml | 6 +- .../org/onap/ccsdk/sli/core/sli/MetricLogger.java | 63 ++-- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 5 +- 17 files changed, 127 insertions(+), 1037 deletions(-) create mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/ControllerAuditLogFilter.java create mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/ControllerPayloadLoggingFilter.java delete mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersService.java delete mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersServiceImpl.java delete mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java delete mode 100644 filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java delete mode 100644 filters/provider/src/main/resources/OSGI-INF/blueprint/filters-blueprint.xml delete mode 100644 filters/provider/src/main/resources/org/opendaylight/blueprint/filters-blueprint.xml create mode 100644 filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/ControllerAuditLogFilterTest.java delete mode 100644 filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java delete mode 100644 filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index b1677a7a2..ae8f2dfd7 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -15,43 +15,32 @@ feature ccsdk-sli-core :: filters :: ${project.artifactId} - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - - - ${project.groupId} - ccsdk-sli - ${project.version} - xml - features - - ${project.groupId} filters-provider ${project.version} - + + + + + org.apache.karaf.tooling + karaf-maven-plugin + true + + + + slf4j-api + javax.annotation-api + javax.servlet-api + javax.ws.rs-api + + + + + + diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 4be194c8c..a8aa4e925 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -23,28 +23,6 @@ false - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 3a7090dd3..0da11a19f 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -1,4 +1,4 @@ - + 4.0.0 @@ -15,78 +15,16 @@ bundle ccsdk-sli-core :: filters :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - **/RequestResponseDbLoggingFilter.java - - - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - junit - junit - ${junit.version} - test - - - - org.mockito - mockito-core - test + org.onap.logging-analytics + logging-filter-base + 1.5.0 javax.servlet javax.servlet-api - - - - org.osgi - org.osgi.core - provided - - - - org.slf4j - slf4j-api - - - org.slf4j - jcl-over-slf4j - - - commons-codec - commons-codec - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/ControllerAuditLogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/ControllerAuditLogFilter.java new file mode 100644 index 000000000..7805e365d --- /dev/null +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/ControllerAuditLogFilter.java @@ -0,0 +1,40 @@ +package org.onap.ccsdk.sli.core.filters; + +import javax.servlet.http.HttpServletRequest; +import org.onap.logging.filter.base.AuditLogServletFilter; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.slf4j.MDC; + +public class ControllerAuditLogFilter extends AuditLogServletFilter { + private static final String MDC_HTTP_METHOD_KEY = "HttpMethod"; + + @Override + protected void additionalPreHandling(HttpServletRequest httpServletRequest) { + // Don't overwrite service instance id if it was set outside of this automated method + if (MDC.get(ONAPLogConstants.MDCs.SERVICE_INSTANCE_ID) == null) { + String serviceInstanceId = getServiceInstanceId(httpServletRequest.getPathInfo()); + if (serviceInstanceId != null) { + MDC.put(ONAPLogConstants.MDCs.SERVICE_INSTANCE_ID, serviceInstanceId); + } + } + MDC.put(MDC_HTTP_METHOD_KEY, httpServletRequest.getMethod()); + } + + // restconf URLs follow a pattern, this method attempts to extract the service instance id according to that pattern + protected String getServiceInstanceId(String path) { + int idx = path.indexOf("service-list"); + if (idx != -1) { + // chomp off service-list/ + String str = path.substring(idx + 13); + idx = str.indexOf("/"); + //if there is another forward slash with more information chomp it off + if (idx != -1) { + return str.substring(0, idx); + } else { + return str; + } + } + return null; + } + +} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/ControllerPayloadLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/ControllerPayloadLoggingFilter.java new file mode 100644 index 000000000..3f9f93fc5 --- /dev/null +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/ControllerPayloadLoggingFilter.java @@ -0,0 +1,7 @@ +package org.onap.ccsdk.sli.core.filters; + +import org.onap.logging.filter.base.PayloadLoggingServletFilter; + +public class ControllerPayloadLoggingFilter extends PayloadLoggingServletFilter { + +} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersService.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersService.java deleted file mode 100644 index 9587e8d96..000000000 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersService.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.onap.ccsdk.sli.core.filters; - -public interface FiltersService { -} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersServiceImpl.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersServiceImpl.java deleted file mode 100644 index 12370ca9a..000000000 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/FiltersServiceImpl.java +++ /dev/null @@ -1,33 +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.filters; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FiltersServiceImpl implements FiltersService { - private static final Logger LOG = LoggerFactory.getLogger(FiltersServiceImpl.class); - - public FiltersServiceImpl() { - LOG.debug("Registering {}", FiltersServiceImpl.class.getName()); - } -} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java deleted file mode 100644 index 4481ab904..000000000 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java +++ /dev/null @@ -1,223 +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.filters; - -import java.io.IOException; -import java.util.UUID; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.codec.binary.Base64; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - - - -/** - * Logs IN request according ECOMP Logging Guidelines at https://tspace.web.att.com/viewer/app/lcfiles/ae5f7751-39da-4c6b-8a83-5836c8c815e1/content - */ -public class LogFilter implements Filter { - - //X-ECOMP is shared between audit and metric - public static final String BEGIN_TIMESTAMP = "AUDIT-BeginTimestamp"; - public static final String END_TIMESTAMP = "AUDIT-EndTimestamp"; - public static final String REQUEST_ID = "X-ECOMP-RequestID"; - public static final String SERVICE_INSTANCE = "X-ECOMP-ServiceInstanceID"; - public static final String THREAD_ID ="X-ECOMP-ThreadId"; //optional - public static final String PHYSICAL_SERVER_NAME="X-ECOMP-PhysicalServerName"; //optional - public static final String SERVICE_NAME="X-ECOMP-ServiceName"; - public static final String PARTNER_NAME="X-ECOMP-PartnerName"; - public static final String STATUS_CODE="AUDIT-StatusCode"; - public static final String RESP_CODE="AUDIT-ResponseCode"; - public static final String RESP_DESC="AUDIT-ResponseDescription"; - public static final String INSTANCE_UUID="AUDIT-InstanceUUID"; - public static final String CATEGORY="AUDIT-INFO"; - public static final String SEVERITY ="AUDIT-Severity"; //optional - public static final String SERVER_IP="AUDIT-ServerIP"; //by chef node['ip'] - public static final String ELAPSED_TIME="AUDIT-ElapsedTime"; - public static final String SERVER_HOST="AUDIT-Server";//by chef node['fqdn'] - public static final String CLIENT_IP="AUDIT-ClientIPaddress"; - public static final String CLASS="AUDIT-Classname"; //optional - public static final String UNUSED="AUDIT-Unused"; //empty - public static final String PROCESS_KEY="AUDIT-ProcessKey"; //optional - public static final String CUST_1="AUDIT-CustomField1";//optional - public static final String CUST_2="AUDIT-CustomField2"; //optional - public static final String CUST_3="AUDIT-CustomField3"; //optional - public static final String CUST_4="AUDIT-CustomField4"; //optional - public static final String DETAIL_MESSAGE="AUDIT-DetailMessage";//optional - - - private static final Logger log = LoggerFactory.getLogger(LogFilter.class); - private static final Logger AUDIT = LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.audit"); - @Override - public void destroy() { - // this method does nothing - } - - @Override - public void doFilter(final ServletRequest request, final ServletResponse response, - final FilterChain filterChain) throws IOException, ServletException { - - long startTime = System.currentTimeMillis(); - try { - - if ( request != null && request instanceof HttpServletRequest ) { - pre((HttpServletRequest)request); - } - filterChain.doFilter(request, response); - - - } finally { - - if (request != null && request instanceof HttpServletRequest ) { - post((HttpServletRequest)request,(HttpServletResponse)response,startTime); - } - MDC.clear(); - } - - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - // this method does nothing - } - - - - private void pre(HttpServletRequest request) { - - UUID uuid = UUID.randomUUID(); - // check if uuid is in header X-ECOMP-RequestID - - String ecompUUID = request.getHeader(REQUEST_ID); - - if (ecompUUID != null && ecompUUID.length() > 0) { - try { - uuid = UUID.fromString(ecompUUID); - log.info("UUID is ECOMP UUID " + uuid.toString()); - } catch (Exception ex){ - log.warn("Failed to convert ECOMP UUID to java.util.UUID format:" + ecompUUID,ex); - } - } - MDC.put(REQUEST_ID, uuid.toString()); - - String userName="unknown"; - - - // going directly after Authorization header - if (request.getHeader("Authorization") != null) { - String authzHeader = request.getHeader("Authorization"); - String usernameAndPassword = new String(Base64.decodeBase64(authzHeader.substring(6).getBytes())); - - int userNameIndex = usernameAndPassword.indexOf(':'); - String username = usernameAndPassword.substring(0, userNameIndex); - userName = username; - - } - - - MDC.put(PARTNER_NAME, userName); - //just to initilaze for metric logger (outbound calls) - MDC.put("X-ECOMP-TargetEntity",""); - MDC.put("X-ECOMP-TargetServiceName",""); - - MDC.put(SERVICE_NAME,request.getRequestURL().toString()); - MDC.put(SERVICE_INSTANCE,""); - - } - - - private void post(HttpServletRequest request,HttpServletResponse response,long startTime) { - - MDC.put(BEGIN_TIMESTAMP,asIso8601(startTime)); - MDC.put(END_TIMESTAMP,asIso8601(System.currentTimeMillis())); - MDC.put(SERVICE_NAME,request.getRequestURL().toString()); - int idx = request.getPathInfo().lastIndexOf(':'); - String instance = ""; - if ( idx != -1 ) { - instance = request.getPathInfo().substring(idx+1); - } - MDC.put(SERVICE_INSTANCE,instance); - MDC.put(THREAD_ID,""); - MDC.put(PHYSICAL_SERVER_NAME,""); - if ( response.getStatus() >= 400 ) { - MDC.put(STATUS_CODE,"ERROR"); - } else { - MDC.put(STATUS_CODE,"COMPLETE"); - } - - MDC.put(RESP_CODE, Integer.toString(response.getStatus())); - MDC.put(RESP_DESC,""); - MDC.put(INSTANCE_UUID,""); - MDC.put(CATEGORY,""); - MDC.put(SEVERITY,""); - //MDC.put(SERVER_IP,""); //by chef - MDC.put(ELAPSED_TIME,Long.toString(System.currentTimeMillis() - startTime)); - //MDC.put(SERVER_HOST,""); //by chef - String forwardedHost = request.getHeader("X-Forwarded-For"); - if (forwardedHost != null) { - MDC.put(CLIENT_IP, forwardedHost); - } - else{ - MDC.put(CLIENT_IP,request.getRemoteHost()); - } - MDC.put(CLASS,""); - MDC.put(UNUSED,""); - MDC.put(PROCESS_KEY,""); - MDC.put(CUST_1,""); - MDC.put(CUST_2,""); - MDC.put(CUST_3,""); - MDC.put(CUST_4,""); - MDC.put(DETAIL_MESSAGE,request.getMethod()); - - AUDIT.info(""); - } - - private String asIso8601(Date date) { - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss.SS'+00:00'"); - df.setTimeZone(tz); - return df.format(date); - } - - private String asIso8601(long tsInMillis) { - return asIso8601(new Date(tsInMillis)); - } - - -} diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java deleted file mode 100644 index e24a75274..000000000 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java +++ /dev/null @@ -1,363 +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.filters; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.zip.GZIPInputStream; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ReadListener; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletOutputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.WriteListener; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; - -public class RequestResponseLoggingFilter implements Filter { - - private static org.slf4j.Logger log = - org.slf4j.LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.request.response"); - - private static class ByteArrayServletStream extends ServletOutputStream { - - ByteArrayOutputStream baos; - - ByteArrayServletStream(ByteArrayOutputStream baos) { - this.baos = baos; - } - - @Override - public void write(int param) throws IOException { - baos.write(param); - } - - @Override - public boolean isReady() { - return true; - } - - @Override - public void setWriteListener(WriteListener arg0) { - // this method does nothing - - } - } - - private static class ByteArrayPrintWriter extends PrintWriter { - private ByteArrayOutputStream baos; - private int errorCode = -1; - private String errorMsg = ""; - private boolean errored = false; - - public ByteArrayPrintWriter(ByteArrayOutputStream out) { - super(out); - this.baos = out; - } - - public ServletOutputStream getStream() { - return new ByteArrayServletStream(baos); - } - - public Boolean hasErrored() { - return errored; - } - public int getErrorCode() { - return errorCode; - } - public String getErrorMsg() { - return errorMsg; - } - - public void setError(int code) { - errorCode = code; - errored = true; - } - - public void setError(int code, String msg) { - errorMsg = msg; - errorCode = code; - errored = true; - } - - } - - private class BufferedServletInputStream extends ServletInputStream { - - ByteArrayInputStream bais; - - public BufferedServletInputStream(ByteArrayInputStream bais) { - this.bais = bais; - } - - @Override - public int available() { - return bais.available(); - } - - @Override - public int read() { - return bais.read(); - } - - @Override - public int read(byte[] buf, int off, int len) { - return bais.read(buf, off, len); - } - - @Override - public boolean isFinished() { - return available() < 1; - } - - @Override - public boolean isReady() { - return true; - } - - @Override - public void setReadListener(ReadListener arg0) { - // this method does nothing - } - - } - - private class BufferedRequestWrapper extends HttpServletRequestWrapper { - - ByteArrayInputStream bais; - - ByteArrayOutputStream baos; - - BufferedServletInputStream bsis; - - byte[] buffer; - - public BufferedRequestWrapper(HttpServletRequest req) throws IOException { - super(req); - - InputStream is = req.getInputStream(); - baos = new ByteArrayOutputStream(); - byte[] buf = new byte[1024]; - int letti; - while ((letti = is.read(buf)) > 0) { - baos.write(buf, 0, letti); - } - buffer = baos.toByteArray(); - - } - - @Override - public ServletInputStream getInputStream() { - try { - bais = new ByteArrayInputStream(buffer); - bsis = new BufferedServletInputStream(bais); - } catch (Exception ex) { - log.error("Exception in getInputStream", ex); - } - - return bsis; - } - - public byte[] getBuffer() { - return buffer; - } - - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - // this method does nothing - } - - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) - throws IOException, ServletException { - - final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; - BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest); - - StringBuilder requestHeaders = new StringBuilder("REQUEST|"); - requestHeaders.append(httpRequest.getMethod()); - requestHeaders.append(":"); - requestHeaders.append(httpRequest.getRequestURL().toString()); - requestHeaders.append("|"); - String header; - for (Enumeration e = httpRequest.getHeaderNames(); e.hasMoreElements();) { - header = e.nextElement(); - requestHeaders.append(header); - requestHeaders.append(":"); - requestHeaders.append(httpRequest.getHeader(header)); - requestHeaders.append(";"); - - } - log.info(requestHeaders.toString()); - - log.info("REQUEST BODY|" + new String(bufferedRequest.getBuffer())); - - final HttpServletResponse response = (HttpServletResponse) servletResponse; - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(baos); - - HttpServletResponse wrappedResp = new HttpServletResponseWrapper(response) { - @Override - public PrintWriter getWriter() { - return pw; - } - - @Override - public ServletOutputStream getOutputStream() { - return pw.getStream(); - } - - @Override - public void sendError(int sc) throws IOException { - super.sendError(sc); - pw.setError(sc); - - } - @Override - public void sendError(int sc, String msg) throws IOException { - super.sendError(sc, msg); - pw.setError(sc, msg); - } - }; - - try { - filterChain.doFilter(bufferedRequest, wrappedResp); - } catch (Exception e) { - log.error("Chain Exception", e); - throw e; - } finally { - try { - byte[] bytes = baos.toByteArray(); - StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|"); - - for (String headerName : response.getHeaderNames()) { - responseHeaders.append(headerName); - responseHeaders.append(":"); - responseHeaders.append(response.getHeader(headerName)); - responseHeaders.append(";"); - } - responseHeaders.append("Status:"); - responseHeaders.append(response.getStatus()); - responseHeaders.append(";IsCommited:" + wrappedResp.isCommitted()); - - log.info(responseHeaders.toString()); - - if ("gzip".equals(response.getHeader("Content-Encoding"))) { - - log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes)); - - } else { - - log.info("RESPONSE BODY|" + new String(bytes)); - } - - if (pw.hasErrored()) { - log.info("ERROR RESPONSE|" + pw.getErrorCode() + ":" + pw.getErrorMsg()); - } else { - if (!wrappedResp.isCommitted()){ - response.getOutputStream().write(bytes); - response.getOutputStream().flush(); - } - } - - } catch (Exception e) { - log.error("Exception in response filter", e); - } - - } - } - - @Override - public void destroy() { - // this method does nothing - } - - private String decompressGZIPByteArray(byte[] bytes) { - - BufferedReader in = null; - InputStreamReader inR = null; - ByteArrayInputStream byteS = null; - GZIPInputStream gzS = null; - StringBuilder str = new StringBuilder(); - try { - byteS = new ByteArrayInputStream(bytes); - gzS = new GZIPInputStream(byteS); - inR = new InputStreamReader(gzS); - in = new BufferedReader(inR); - - if (in != null) { - - String content; - - while ((content = in.readLine()) != null) { - str.append(content); - } - } - - } catch (Exception e) { - log.error("Failed get read GZIPInputStream", e); - } finally { - - if (byteS != null) - try { - byteS.close(); - } catch (IOException e1) { - log.error("Failed to close ByteStream", e1); - } - if (gzS != null) - try { - gzS.close(); - } catch (IOException e2) { - log.error("Failed to close GZStream", e2); - } - if (inR != null) - try { - inR.close(); - } catch (IOException e3) { - log.error("Failed to close InputReader", e3); - } - if (in != null) - try { - in.close(); - } catch (IOException e) { - log.error("Failed to close BufferedReader", e); - } - } - return str.toString(); - } -} diff --git a/filters/provider/src/main/resources/OSGI-INF/blueprint/filters-blueprint.xml b/filters/provider/src/main/resources/OSGI-INF/blueprint/filters-blueprint.xml deleted file mode 100644 index 3bf8423e9..000000000 --- a/filters/provider/src/main/resources/OSGI-INF/blueprint/filters-blueprint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/filters/provider/src/main/resources/org/opendaylight/blueprint/filters-blueprint.xml b/filters/provider/src/main/resources/org/opendaylight/blueprint/filters-blueprint.xml deleted file mode 100644 index 3bf8423e9..000000000 --- a/filters/provider/src/main/resources/org/opendaylight/blueprint/filters-blueprint.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/ControllerAuditLogFilterTest.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/ControllerAuditLogFilterTest.java new file mode 100644 index 000000000..9d0357a96 --- /dev/null +++ b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/ControllerAuditLogFilterTest.java @@ -0,0 +1,23 @@ +package org.onap.ccsdk.sli.core.filters; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class ControllerAuditLogFilterTest { + + @Test + public void getSimpleSiid() throws Exception { + ControllerAuditLogFilter filter = new ControllerAuditLogFilter(); + String siid = filter.getServiceInstanceId("/restconf/config/Layer3API:services/service-list/100"); + assertEquals("100", siid); + } + + @Test + public void getSimpleComplexSiid() throws Exception { + ControllerAuditLogFilter filter = new ControllerAuditLogFilter(); + String siid = filter.getServiceInstanceId( + "/restconf/config/Layer3API:services/service-list/1337/service-data/oper-status"); + assertEquals("1337", siid); + } + +} diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java deleted file mode 100644 index a900b246c..000000000 --- a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * - */ -package org.onap.ccsdk.sli.core.filters; - -import static org.junit.Assert.*; -import org.apache.commons.codec.binary.Base64; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.mockito.Mockito.*; -import java.io.IOException; -import java.util.UUID; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author dt5972 - * - */ -public class TestLogFilter { - - LogFilter logFilter; - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - logFilter = new LogFilter(); - logFilter.init(null); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - logFilter.destroy(); - } - - /** - * Test method for {@link org.onap.ccsdk.sli.core.filters.LogFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}. - * @throws ServletException - * @throws IOException - */ - @Test - public void testDoFilter() throws IOException, ServletException { - - // Test failed request with minimal headers - HttpServletRequest servletReq = mock(HttpServletRequest.class); - when(servletReq.getRequestURL()).thenReturn(new StringBuffer("SLI-API:healthcheck")); - when(servletReq.getPathInfo()).thenReturn("/hello:world"); - HttpServletResponse servletResp = mock(HttpServletResponse.class); - when(servletResp.getStatus()).thenReturn(400); - FilterChain filterChain = mock(FilterChain.class); - logFilter.doFilter(servletReq, servletResp, filterChain); - - // Test successful request with valid header - when(servletReq.getHeader(LogFilter.REQUEST_ID)).thenReturn(UUID.randomUUID().toString()); - when(servletReq.getHeader("Authorization")).thenReturn("Basic "+Base64.encodeBase64String("username:password".getBytes())); - when(servletResp.getStatus()).thenReturn(200); - logFilter.doFilter(servletReq, servletResp, filterChain); - - - } - -} diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java deleted file mode 100644 index 7ce856e68..000000000 --- a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * - */ -package org.onap.ccsdk.sli.core.filters; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.StringBufferInputStream; -import java.io.StringReader; -import java.util.LinkedList; -import java.util.UUID; -import java.util.Vector; -import javax.servlet.FilterChain; -import javax.servlet.ReadListener; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletOutputStream; -import javax.servlet.WriteListener; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.apache.commons.codec.binary.Base64; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * @author dt5972 - * - */ -public class TestRequestResponseLoggingFilter { - - RequestResponseLoggingFilter filter; - - private class DummyServletInputStream extends ServletInputStream { - - InputStream stream; - - public DummyServletInputStream(InputStream stream) { - this.stream = stream; - } - - - @Override - public void close() throws IOException { - super.close(); - stream.close(); - } - - - @Override - public int read() throws IOException { - return stream.read(); - } - - - @Override - public boolean isFinished() { - try { - return stream.available() < 1; - } catch (IOException e) { - return true; - } - } - - - @Override - public boolean isReady() { - // TODO Auto-generated method stub - return true; - } - - - @Override - public void setReadListener(ReadListener arg0) { - // TODO Auto-generated method stub - - } - - - - } - - private class DummyServletOutputStream extends ServletOutputStream { - - OutputStream ostr; - - public DummyServletOutputStream(OutputStream ostr) { - this.ostr = ostr; - } - - @Override - public void write(int b) throws IOException { - ostr.write(b); - } - - @Override - public boolean isReady() { - return true; - } - - @Override - public void setWriteListener(WriteListener arg0) { - - } - - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - filter = new RequestResponseLoggingFilter(); - filter.init(null); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception {} - - /** - * Test method for {@link org.onap.ccsdk.sli.core.filters.RequestResponseLoggingFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}. - * @throws IOException - * @throws ServletException - */ - @Test - public void testDoFilter() throws IOException, ServletException { - - HttpServletRequest request = mock(HttpServletRequest.class); - String msgBody = "hello world"; - InputStream reqInputStream = new ByteArrayInputStream(msgBody.getBytes()); - when(request.getInputStream()).thenReturn(new DummyServletInputStream(reqInputStream)); - when(request.getMethod()).thenReturn("POST"); - when(request.getRequestURL()).thenReturn(new StringBuffer("/HELLO:world")); - when(request.getPathInfo()).thenReturn("/hello:world"); - Vector headerList = new Vector<>(); - headerList.add(LogFilter.REQUEST_ID); - headerList.add("Authorization"); - when(request.getHeaderNames()).thenReturn(headerList.elements()); - - when(request.getHeader(LogFilter.REQUEST_ID)).thenReturn(UUID.randomUUID().toString()); - when(request.getHeader("Authorization")).thenReturn("Basic "+Base64.encodeBase64String("username:password".getBytes())); - - HttpServletResponse response = mock(HttpServletResponse.class); - OutputStream outStr = new ByteArrayOutputStream(); - when(response.getOutputStream()).thenReturn(new DummyServletOutputStream(outStr)); - - FilterChain filterChain = mock(FilterChain.class); - - filter.doFilter(request, response, filterChain); - - - - } - -} diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 63967b1f0..0aad76e0b 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -73,7 +73,11 @@ org.opendaylight.mdsal.binding.model.ietf rfc6991 - + + org.onap.logging-analytics + logging-slf4j + 1.5.0 + org.opendaylight.controller diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 30340d476..c2670ec38 100755 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -28,7 +28,7 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; - +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -42,28 +42,13 @@ import org.slf4j.MarkerFactory; public class MetricLogger { private static final Logger METRIC = LoggerFactory.getLogger("org.onap.ccsdk.sli.core.filters.metric"); - - //TODO use ONAPLogConstants - public static final String BEGIN_TIMESTAMP = "InvokeTimestamp"; - public static final String LOG_TIMESTAMP = "LogTimestamp"; - public static final String REQUEST_ID = "RequestID"; - public static final String SERVICE_INSTANCE_ID = "ServiceInstanceID"; - public static final String TARGET_ENTITY = "TargetEntity"; - public static final String TARGET_SERVICE_NAME = "TargetServiceName"; - public static final String STATUS_CODE = "StatusCode"; - public static final String RESPONSE_CODE = "ResponseCode"; - public static final String RESPONSE_DESCRIPTION = "ResponseDesc"; - public static final String INSTANCE_UUID = "InstanceID"; - public static final String ELAPSED_TIME = "ElapsedTime"; - public static final String CLIENT_IP = "ClientIPaddress"; - public static final String TARGET_VIRTUAL_ENTITY = "TargetElement"; private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN"); private static final Marker INVOKE = MarkerFactory.getMarker("INVOKE"); private String lastMsg = null; public String getRequestID() { - return MDC.get(REQUEST_ID); + return MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); } public MetricLogger() { @@ -82,27 +67,29 @@ public class MetricLogger { } @Deprecated - public void logRequest(String svcInstanceId, String svcName, String partnerName, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) { - logRequest(svcInstanceId,targetEntity,targetServiceName,targetVirtualEntity,msg); + public void logRequest(String svcInstanceId, String svcName, String partnerName, String targetEntity, + String targetServiceName, String targetElement, String msg) { + logRequest(svcInstanceId, targetEntity, targetServiceName, targetElement, msg); } - public void logRequest(String svcInstanceId, String targetEntity, String targetServiceName, String targetVirtualEntity, String msg) { + public void logRequest(String svcInstanceId, String targetEntity, String targetServiceName, String targetElement, + String msg) { long start = System.currentTimeMillis(); - MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(start)); + MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, MetricLogger.asIso8601(start)); if (svcInstanceId != null) { - MDC.put(SERVICE_INSTANCE_ID, svcInstanceId); + MDC.put(ONAPLogConstants.MDCs.SERVICE_INSTANCE_ID, svcInstanceId); } if (targetEntity != null) { - MDC.put(TARGET_ENTITY, targetEntity); + MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity); } if (targetServiceName != null) { - MDC.put(TARGET_SERVICE_NAME, targetServiceName); + MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, targetServiceName); } - if (targetVirtualEntity != null) { - MDC.put(TARGET_VIRTUAL_ENTITY, targetVirtualEntity); + if (targetElement != null) { + MDC.put(ONAPLogConstants.MDCs.TARGET_ELEMENT, targetElement); } this.lastMsg = msg; METRIC.info(INVOKE, "Invoke"); @@ -110,20 +97,20 @@ public class MetricLogger { public void logResponse(String statusCode, String responseCode, String responseDescription) { long start = System.currentTimeMillis(); - MDC.put(BEGIN_TIMESTAMP, MetricLogger.asIso8601(start)); + MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, MetricLogger.asIso8601(start)); if (statusCode != null) { - MDC.put(STATUS_CODE, statusCode); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); } if (responseCode != null) { - MDC.put(RESPONSE_CODE, responseCode); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, responseCode); } if (responseDescription != null) { - MDC.put(RESPONSE_DESCRIPTION, formatString(responseDescription)); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, formatString(responseDescription)); } long end = System.currentTimeMillis(); - MDC.put(LOG_TIMESTAMP, MetricLogger.asIso8601(end)); - MDC.put(ELAPSED_TIME, Long.toString(end-start)); + MDC.put(ONAPLogConstants.MDCs.LOG_TIMESTAMP, MetricLogger.asIso8601(end)); + MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME, Long.toString(end - start)); METRIC.info(INVOKE_RETURN, formatString(lastMsg)); resetContext(); } @@ -137,11 +124,11 @@ public class MetricLogger { } public static void resetContext() { - MDC.remove(TARGET_ENTITY); - MDC.remove(TARGET_SERVICE_NAME); - MDC.remove(TARGET_VIRTUAL_ENTITY); - MDC.remove(STATUS_CODE); - MDC.remove(RESPONSE_CODE); - MDC.remove(RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY); + MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME); + MDC.remove(ONAPLogConstants.MDCs.TARGET_ELEMENT); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index f563d986e..0d49366f7 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.util.Properties; - import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.core.sli.ConfigurationException; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -36,6 +35,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -106,7 +106,8 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL SvcLogicContext ctx = new SvcLogicContext(props); ctx.setAttribute(CURRENT_GRAPH, graph.toString()); - ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); + // To support legacy code we should not stop populating X-ECOMP-RequestID + ctx.setAttribute("X-ECOMP-RequestID", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); ctx.setDomDataBroker(domDataBroker); execute(graph, ctx); return (ctx.toProperties()); -- cgit 1.2.3-korg From 4999c933f01789a4f71eb34cc32c7377c62ee2dd Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Fri, 27 Sep 2019 10:23:36 -0400 Subject: Removing Extra space from POM SLI Filters Provider POM having space before XML Tag, which will cause issue in maven set:version goal Change-Id: Icbe00187ac9f6730f43d5359c16ce364b5627348 Issue-ID: CCSDK-1761 Signed-off-by: Singal, Kapil (ks220y) --- filters/provider/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index ef5b49c1f..a5a6379e9 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -1,4 +1,4 @@ - + 4.0.0 -- cgit 1.2.3-korg From 574363f5a29ac9237a377c4c0923b414a38fddec Mon Sep 17 00:00:00 2001 From: Samuel Kontris Date: Wed, 4 Sep 2019 15:31:48 +0200 Subject: Refactor class/instance loading and resolving in the SLI module Code from the static class SvcLogicAdaptorFactory is moved to the SvcLogicClassResolver class. Class SvcLogicClassResolver is created as a bean in the blueprint xml file, not as singleton directly in the code. Then is injected via blueprint into the SvcLogicServiceImpl. Methods registerExecutor and unregisterExecutor from the SvcLogicServiceImpl class are removed - are not used anywhere. This change causes compilation error in the northbound repository. Fix for this error is here: https://gerrit.onap.org/r/#/c/ccsdk/sli/northbound/+/95053/ Issue-ID: CCSDK-1688 Change-Id: I26ce01b761ab5d17f1cc19e39af581b1963658a5 Signed-off-by: Samuel Kontris --- .../core/sli/provider/SvcLogicAdaptorFactory.java | 65 ---------------------- .../core/sli/provider/SvcLogicClassResolver.java | 36 ++++++++++-- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 38 +++---------- .../resources/OSGI-INF/blueprint/sli-blueprint.xml | 7 ++- .../org/opendaylight/blueprint/sli-blueprint.xml | 7 ++- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 10 ++-- .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 5 +- 7 files changed, 54 insertions(+), 114 deletions(-) delete mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java deleted file mode 100644 index 540c04ef0..000000000 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java +++ /dev/null @@ -1,65 +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.provider; - -import java.util.HashMap; - -import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SvcLogicAdaptorFactory { - - private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicAdaptorFactory.class); - - private static HashMap adaptorMap = new HashMap<>(); - - public static void registerAdaptor(SvcLogicAdaptor adaptor) { - String name = adaptor.getClass().getName(); - LOG.info("Registering adaptor " + name); - adaptorMap.put(name, adaptor); - - } - - public static void unregisterAdaptor(String name) { - if (adaptorMap.containsKey(name)) { - LOG.info("Unregistering " + name); - adaptorMap.remove(name); - } - } - - public static SvcLogicAdaptor getInstance(String name) { - if (adaptorMap.containsKey(name)) { - return adaptorMap.get(name); - } else { - - SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.getInstance().resolve(name); - - if (adaptor != null) { - registerAdaptor(adaptor); - } - - return adaptor; - } - } -} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java index f10976a5d..08e957f1d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java @@ -1,5 +1,6 @@ package org.onap.ccsdk.sli.core.sli.provider; +import java.util.HashMap; import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; @@ -13,17 +14,40 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SvcLogicClassResolver implements SvcLogicResolver { + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class); - private static SvcLogicClassResolver instance = new SvcLogicClassResolver(); + private static HashMap adaptorMap = new HashMap<>(); + + public void registerAdaptor(SvcLogicAdaptor adaptor) { + String name = adaptor.getClass().getName(); + LOG.info("Registering adaptor " + name); + adaptorMap.put(name, adaptor); + + } - private SvcLogicClassResolver() { + public void unregisterAdaptor(String name) { + if (adaptorMap.containsKey(name)) { + LOG.info("Unregistering " + name); + adaptorMap.remove(name); + } } - public static SvcLogicClassResolver getInstance() { - return instance; + private SvcLogicAdaptor getAdaptorInstance(String name) { + if (adaptorMap.containsKey(name)) { + return adaptorMap.get(name); + } else { + + SvcLogicAdaptor adaptor = (SvcLogicAdaptor) resolve(name); + + if (adaptor != null) { + registerAdaptor(adaptor); + } + + return adaptor; + } } - public Object resolve(String className) { + private Object resolve(String className) { Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class); @@ -68,7 +92,7 @@ public class SvcLogicClassResolver implements SvcLogicResolver { @Override public SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName) { - return SvcLogicAdaptorFactory.getInstance(adaptorName); + return getAdaptorInstance(adaptorName); } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 0d49366f7..9e91b7518 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -32,13 +32,11 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor; 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.sli.provider.base.SvcLogicServiceImplBase; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -46,45 +44,23 @@ import org.slf4j.MDC; public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService { private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImpl.class); - protected BundleContext bctx = null; - public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider) throws SvcLogicException { + public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, SvcLogicResolver resolver) + throws SvcLogicException { super(null); - this.resolver = SvcLogicClassResolver.getInstance(); + this.resolver = resolver; properties = resourceProvider.getProperties(); this.store = getStore(); } - public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc) - throws SvcLogicException { + public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc, + SvcLogicResolver resolver) throws SvcLogicException { super(null); - this.resolver = SvcLogicClassResolver.getInstance(); + this.resolver = resolver; properties = resourceProvider.getProperties(); this.store = new SvcLogicDblibStore(dbSvc); } - public void registerExecutor(ServiceReference sr) { - String nodeName = (String) sr.getProperty("nodeType"); - if (nodeName != null) { - AbstractSvcLogicNodeExecutor executor; - try { - executor = (AbstractSvcLogicNodeExecutor) bctx.getService(sr); - } catch (Exception e) { - LOG.error("Cannot get service executor for {}", nodeName, e); - return; - } - registerExecutor(nodeName, executor); - } - } - - public void unregisterExecutor(ServiceReference sr) { - String nodeName = (String) sr.getProperty("nodeType"); - - if (nodeName != null) { - unregisterExecutor(nodeName); - } - } - @Override public Properties execute(String module, String rpc, String version, String mode, Properties props) throws SvcLogicException { 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 bb14477e4..d88cf3312 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 @@ -5,17 +5,18 @@ + - + + - org.onap.ccsdk.sli.core.sli.provider.SvcLogicService - \ No newline at end of file + 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 bb14477e4..d88cf3312 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 @@ -5,17 +5,18 @@ + - + + - org.onap.ccsdk.sli.core.sli.provider.SvcLogicService - \ No newline at end of file + diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index 6092d1fb0..ad439cdb4 100644 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -33,7 +33,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Properties; - import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -44,6 +43,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicParser; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.BlockNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.BreakNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.CallNodeExecutor; @@ -61,7 +61,6 @@ import org.onap.ccsdk.sli.core.sli.provider.base.ReserveNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.ReturnNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.SaveNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor; @@ -98,6 +97,8 @@ public class ITCaseSvcLogicGraphExecutor { } }; + private static SvcLogicClassResolver svcLogicClassResolver; + @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -115,7 +116,8 @@ public class ITCaseSvcLogicGraphExecutor { SvcLogicParser parser = new SvcLogicParser(); SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl(); - SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); + svcLogicClassResolver = new SvcLogicClassResolver(); + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider, svcLogicClassResolver); for (String nodeType : BUILTIN_NODES.keySet()) { svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); @@ -165,7 +167,7 @@ public class ITCaseSvcLogicGraphExecutor { return svcprops; } }; - SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider, svcLogicClassResolver); SvcLogicStore store = svc.getStore(); assertNotNull(store); for (String nodeType : BUILTIN_NODES.keySet()) { diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index c898ffffe..f48cf783b 100644 --- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -18,13 +18,13 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.Future; - import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicParser; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +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.SvcLogicServiceImpl; import org.onap.ccsdk.sli.core.sli.provider.base.AbstractSvcLogicNodeExecutor; @@ -124,7 +124,8 @@ public class TestSliapiProvider { SvcLogicParser.activate("sli", "healthcheck", "1.0.0", "sync", store); // Create a ServiceLogicService and initialize it - SvcLogicServiceImpl svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl()); + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl(), + new SvcLogicClassResolver()); for (String nodeType : BUILTIN_NODES.keySet()) { svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } -- cgit 1.2.3-korg From b4974d740eb9960f4054ab3bc89037e16dfe7bf5 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 17 Oct 2019 18:16:10 +0000 Subject: Update metric logger set status during invoke and escape certain characters Issue-ID: CCSDK-1845 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I3928364f480545ccdcce0af67e198d93152cfbd8 --- .../src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java | 4 ++++ .../src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index c2670ec38..518316d56 100755 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -92,6 +92,8 @@ public class MetricLogger { MDC.put(ONAPLogConstants.MDCs.TARGET_ELEMENT, targetElement); } this.lastMsg = msg; + //During invoke status will always be INPROGRESS + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); METRIC.info(INVOKE, "Invoke"); } @@ -119,6 +121,8 @@ public class MetricLogger { if (str != null) { str = str.replaceAll("\\R", ""); // this will strip all new line characters str = str.replaceAll("\\|", "%7C"); // log records should not contain a pipe, encode the pipe character + str = str.replaceAll("\t", " "); // tabs are not allowed, replace with spaces + str = str.replace(",", "\\,"); // comma must be escaped } return str; } diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java index ec3a31ea5..4b371cf8f 100755 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java @@ -42,6 +42,9 @@ public class TestMetricLogger { assertEquals("%7C",output); output = logger.formatString(null); assertEquals(null,output); + output = logger.formatString("\t"); + assertEquals(" ", output); + output = logger.formatString("one,two,three,"); + assertEquals("one\\,two\\,three\\,", output); } - } -- cgit 1.2.3-korg From 17bbf8be295cb8e2cfc4faf466ada9c899089c63 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 30 Oct 2019 14:07:38 +0000 Subject: remove ODL/karaf from common Don't let sli common use odl or karaf classes Issue-ID: CCSDK-1723 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I740fa32b9c40a7efdf7ef9ce25b26cf43353c559 --- sli/common/pom.xml | 40 +- .../org/onap/ccsdk/sli/core/sli/MessageWriter.java | 21 - .../onap/ccsdk/sli/core/sli/PrintYangToProp.java | 1355 -------------------- .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 14 - .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 125 -- .../sli/core/sli/SvcLogicExpressionFactory.java | 23 - .../ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 4 +- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 5 +- .../ccsdk/sli/core/sli/PrintYangToPropTest.java | 141 -- sli/provider/pom.xml | 9 +- .../sli/core/sli/provider/PrintYangToProp.java | 1355 ++++++++++++++++++++ .../sli/core/sli/provider/SvcLogicServiceImpl.java | 15 +- .../sli/core/sli/provider/PrintYangToPropTest.java | 142 ++ sli/recording/pom.xml | 32 - 14 files changed, 1521 insertions(+), 1760 deletions(-) delete mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java delete mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java create mode 100644 sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java create mode 100644 sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToPropTest.java diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 7b4adb8b7..2166760de 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -38,25 +38,9 @@ org.slf4j slf4j-api - - org.slf4j - slf4j-simple - compile - org.apache.commons commons-lang3 - - - org.osgi - org.osgi.core - provided - - - org.mariadb.jdbc - mariadb-java-client - jar - compile org.onap.ccsdk.sli.core @@ -70,32 +54,16 @@ test - org.opendaylight.mdsal.binding.model.ietf - rfc6991 - - - org.onap.logging-analytics - logging-slf4j - 1.5.0 - - - - org.opendaylight.controller - sal-core-api - - - - org.opendaylight.controller - sal-binding-api - - + org.onap.logging-analytics + logging-slf4j + 1.5.0 + junit junit test - org.mockito mockito-core diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java index 0e39896e0..5ededb9eb 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java @@ -28,13 +28,8 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Properties; - import javax.sql.rowset.CachedRowSet; - import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,22 +91,6 @@ public class MessageWriter { LOG.info(INCOMING_PROPERTY_NAME + ": " + incomingEnabled); LOG.info(OUTGOING_PROPERTY_NAME + ": " + outgoingEnabled); - - if (dbLibService != null) - return; - - BundleContext bctx = FrameworkUtil.getBundle(MessageWriter.class).getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(DBLIB_SERVICE); - - if (sref == null) { - LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")"); - } else { - dbLibService = (DbLibService) bctx.getService(sref); - if (dbLibService == null) { - LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")"); - } - } } public static void saveOutgoingRequest( diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java deleted file mode 100644 index 5df136fd9..000000000 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ /dev/null @@ -1,1355 +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; - -import java.io.PrintStream; -import java.io.FileDescriptor; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import java.util.Arrays; -import java.util.ArrayList; -import java.io.*; -import org.opendaylight.yangtools.yang.binding.Identifier; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.google.common.base.Strings; - - -public class PrintYangToProp { - - private static final Logger LOG = LoggerFactory.getLogger(PrintYangToProp.class); - public static final String PROPERTIES_FILE=""; - private static Properties properties; - private static final String BUILDER="-builder"; - private static final String IMPL="-impl"; - private static final String TO_PROPERTIES_STRING="() to Properties entry"; - private static final String CAUGHT_EXCEPTION_MSG="Caught exception trying to convert value returned by "; - public static Properties prop = new Properties(); - public static ArrayList propList = new ArrayList<>(); - - - public static Properties toProperties(Properties props, Object fromObj) { - Class fromClass = null; - - if (fromObj != null) - { - fromClass = fromObj.getClass(); - } - return (toProperties(props, "", fromObj, fromClass)); - } - - public static Properties toProperties(Properties props, String pfx, Object fromObj) - { - Class fromClass = null; - - if (fromObj != null) - { - fromClass = fromObj.getClass(); - } - - return(toProperties(props, pfx, fromObj, fromClass)); - } - - public static Properties toProperties(Properties props, String pfx, - Object fromObj, Class fromClass) { - - if (fromObj == null) { - return (props); - } - - - String simpleName = fromClass.getSimpleName(); - - if (fromObj instanceof List) { - - - List fromList = (List) fromObj; - - for (int i = 0; i < fromList.size(); i++) { - toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); - } - props.setProperty(pfx + "_length", "" + fromList.size()); - - } else if (isYangGenerated(fromClass)) { - - String propNamePfx = null; - - // If called from a list (so prefix ends in ']'), don't - // add class name again - if (pfx.endsWith("]")) { - propNamePfx = pfx; - } else { - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx ; - } else { - propNamePfx = toLowerHyphen(fromClass.getSimpleName()); - } - - if (propNamePfx.endsWith(BUILDER)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - BUILDER.length()); - } - - if (propNamePfx.endsWith(IMPL)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - IMPL.length()); - } - } - - // Iterate through getter methods to figure out values we need to - // save from - - for (Method m : fromClass.getMethods()) { - - if (isGetter(m)) { - - Class returnType = m.getReturnType(); - String fieldName = toLowerHyphen(m.getName().substring(3)); - if(m != null && m.getName().matches("^is[A-Z].*")){ - fieldName = toLowerHyphen(m.getName().substring(2)); - } - - if(Strings.isNullOrEmpty(fieldName)) fieldName = fieldName.substring(0, 1).toLowerCase()+ fieldName.substring(1); - - - // Is the return type a yang generated class? - if (isYangGenerated(returnType)) { - - // Is it an enum? - if (returnType.isEnum()) { - // Return type is a typedef. Save its value. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - Object retValue = m.invoke(fromObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - String propName = propNamePfx + "." - + fieldName; - String propVal = retValue.toString(); - String yangProp = "yang." + fieldName + "." + propVal; - if ( properties.containsKey(yangProp)) { - propVal = properties.getProperty(yangProp); - } - props.setProperty(propName, propVal); - } - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert Yang-generated enum returned by " - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else if (isIpv4Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - String propVal = retValue.getValue(); - - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else if (isIpv6Address(returnType)) { - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - String propVal = retValue.getValue(); - - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else if (isIpv4Prefix(returnType)) { - - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv4Prefix retValue = (Ipv4Prefix) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - String propVal = retValue.getValue(); - - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else if (isIpv6Prefix(returnType)) { - //System.out.println("isIpv6Prefix"); - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Ipv6Prefix retValue = (Ipv6Prefix) m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (retValue != null) { - String propVal = retValue.getValue().toString(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retValue = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - if (retValue != null) { - toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); - } - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert Yang-generated class returned by" - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } - } else if (returnType.equals(Class.class)) { - - //LOG.debug(m.getName() - // + " returns a Class object - not interested"); - - } else if (List.class.isAssignableFrom(returnType)) { - - // This getter method returns a list. - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object retList = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - // Figure out what type of elements are stored in this array. - Type paramType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) paramType) - .getActualTypeArguments()[0]; - toProperties(props, propNamePfx + "." + fieldName, - retList, (Class)elementType); - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert List returned by " - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - - } else { - - // Method returns something that is not a List and not - // yang-generated. - // Save its value - try { - String propName = propNamePfx + "." + fieldName; - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - Object propValObj = m.invoke(fromObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - - if (propValObj != null) { - String propVal = propValObj.toString(); - //LOG.debug("Setting property " + propName - // + " to " + propVal); - props.setProperty(propName, propVal); - - } - } catch (Exception e) { - LOG.error( - CAUGHT_EXCEPTION_MSG - + fromClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, e); - } - } - - } - } - - } else { - // Class is not yang generated and not a list - // Do nothing. - - } - - return (props); - } - - public static Object toBuilder(Properties props, Object toObj) { - - return (toBuilder(props, "", toObj)); - } - - public static List toList(Properties props, String pfx, List toObj, - Class elemType) { - - int maxIdx = -1; - boolean foundValue = false; - - //LOG.debug("Saving properties to List<" + elemType.getName() - // + "> from " + pfx); - - // Figure out array size - for (Object pNameObj : props.keySet()) { - String key = (String) pNameObj; - - if (key.startsWith(pfx + "[")) { - String idxStr = key.substring(pfx.length() + 1); - int endloc = idxStr.indexOf("]"); - if (endloc != -1) { - idxStr = idxStr.substring(0, endloc); - } - - try { - int curIdx = Integer.parseInt(idxStr); - if (curIdx > maxIdx) { - maxIdx = curIdx; - } - } catch (Exception e) { - LOG.error("Illegal subscript in property " + key); - } - - } - } - - //LOG.debug(pfx + " has max index of " + maxIdx); - for (int i = 0; i <= maxIdx; i++) { - - String curBase = pfx + "[" + i + "]"; - - if (isYangGenerated(elemType)) { - String builderName = elemType.getName() + "Builder"; - try { - Class builderClass = Class.forName(builderName); - Object builderObj = builderClass.newInstance(); - Method buildMethod = builderClass.getMethod("build"); - builderObj = toBuilder(props, curBase, builderObj, true); - if (builderObj != null) { - //LOG.debug("Calling " + builderObj.getClass().getName() - // + "." + buildMethod.getName() + "()"); - Object builtObj = buildMethod.invoke(builderObj); - toObj.add(builtObj); - foundValue = true; - } - - } catch (ClassNotFoundException e) { - LOG.warn("Could not find builder class " + builderName, e); - } catch (Exception e) { - LOG.error("Caught exception trying to populate list from " - + pfx); - } - } - - } - - if (foundValue) { - return (toObj); - } else { - return (null); - } - - } - - public static Object toBuilder(Properties props, String pfx, Object toObj) { - return(toBuilder(props, pfx, toObj, false)); - } - - public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { - Class toClass = toObj.getClass(); - boolean foundValue = false; - - //LOG.debug("Saving properties to " + toClass.getName() + " class from " - // + pfx); - - Ipv4Address addr; - - if (isYangGenerated(toClass)) { - // Class is yang generated. - //LOG.debug(toClass.getName() + " is a Yang-generated class"); - - String propNamePfx = null; - if (preservePfx) { - propNamePfx = pfx; - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." - + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith(BUILDER)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - BUILDER.length()); - } - - if (propNamePfx.endsWith(IMPL)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - IMPL.length()); - } - } - - if (toObj instanceof Identifier) { - //LOG.debug(toClass.getName() + " is a Key - skipping"); - return (toObj); - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - // LOG.debug("Is " + m.getName() + " method a setter?"); - if (isSetter(m)) { - // LOG.debug(m.getName() + " is a setter"); - Class paramTypes[] = m.getParameterTypes(); - Class paramClass = paramTypes[0]; - - String fieldName = toLowerHyphen(m.getName().substring(3)); - fieldName = fieldName.substring(0, 1).toLowerCase() - + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - - String paramValue = props.getProperty(propName); - if (paramValue == null) { - //LOG.debug(propName + " is unset"); - } else { - //LOG.debug(propName + " = " + paramValue); - } - - // Is the return type a yang generated class? - if (isYangGenerated(paramClass)) { - // Is it an enum? - if (paramClass.isEnum()) { - - //LOG.debug(m.getName() + " expects an Enum"); - // Param type is a typedef. - if (paramValue != null) { - Object paramObj = null; - - try { - paramObj = Enum.valueOf(paramClass, - toUpperCamelCase(paramValue)); - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert field " - + propName + " to enum " - + paramClass.getName(), e); - } - - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - //LOG.debug("Calling " - // + toObj.getClass().getName() + "." - // + m.getName() + "(" + paramValue - // + ")"); - m.invoke(toObj, paramObj); - - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to create Yang-generated enum expected by" - + toClass.getName() - + "." - + m.getName() - + "() from Properties entry", - e); - } - } - } else { - - String simpleName = paramClass.getSimpleName(); - LOG.info("simpleName:" + simpleName); - - if ("Ipv4Address".equals(simpleName) - || "Ipv6Address".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName)) { - - if (paramValue != null) { - if("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName)){ - try { - IpAddress ipAddr = IpAddressBuilder - .getDefaultInstance(paramValue); - - - if ("Ipv4Address".equals(simpleName)) - { - m.invoke(toObj, ipAddr.getIpv4Address()); - } - else - { - m.invoke(toObj, ipAddr.getIpv6Address()); - - } - foundValue = true; - } catch (Exception e) { - LOG.error( - "Caught exception calling " - + toClass.getName() + "." - + m.getName() + "(" - + paramValue + ")", e); - - } - }else if("Ipv4Prefix".equals(simpleName)|| "Ipv6Prefix".equals(simpleName)){ - try { - IpPrefix ipPrefix = IpPrefixBuilder - .getDefaultInstance(paramValue); - - - if ("Ipv4Prefix".equals(simpleName)) - { - m.invoke(toObj, ipPrefix.getIpv4Prefix()); - } - else - { - m.invoke(toObj, ipPrefix.getIpv6Prefix()); - - } - foundValue = true; - } catch (Exception e) { - LOG.error( - "Caught exception calling " - + toClass.getName() + "." - + m.getName() + "(" - + paramValue + ")", e); - - } - } - } - - } else { - // setter expects a yang-generated class. Need - // to - // create a builder to set it. - - String builderName = paramClass.getName() - + "Builder"; - Class builderClass = null; - Object builderObj = null; - Object paramObj = null; - - //LOG.debug(m.getName() - // + " expects a yang-generated class - looking for builder " - // + builderName); - try { - builderClass = Class.forName(builderName); - builderObj = builderClass.newInstance(); - paramObj = toBuilder(props, propNamePfx, - builderObj); - } catch (ClassNotFoundException e) { - Object constObj = null; - try { - // See if I can find a constructor I can - // use - Constructor[] constructors = paramClass - .getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c - .getParameterTypes(); - if ((cParms != null) - && (cParms.length == 1)) { - if (String.class - .isAssignableFrom(cParms[0])) { - constObj = c - .newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c - .getParameterTypes(); - if ((cParms != null) - && (cParms.length == 1)) { - if (Long.class - .isAssignableFrom(cParms[0])) { - constObj = c - .newInstance(Long - .parseLong(paramValue)); - } - } - } - - } - - if (constObj != null) { - try { - m.invoke(toObj, constObj); - foundValue = true; - } catch (Exception e2) { - LOG.error( - "Caught exception trying to call " - + m.getName(), - e2); - } - } - } catch (Exception e1) { - LOG.warn( - "Could not find a suitable constructor for " - + paramClass.getName(), - e1); - } - - if (paramObj == null) { - LOG.warn("Could not find builder class " - + builderName - + " and could not find a String or Long constructor - trying just to set passing paramValue"); - - } - - } catch (Exception e) { - LOG.error( - "Caught exception trying to create builder " - + builderName, e); - } - - if (paramObj != null) { - - try { - - Method buildMethod = builderClass - .getMethod("build"); - //LOG.debug("Calling " - // + paramObj.getClass().getName() - // + "." + buildMethod.getName() - // + "()"); - Object builtObj = buildMethod - .invoke(paramObj); - - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - - //LOG.debug("Calling " - // + toObj.getClass().getName() - // + "." + m.getName() + "()"); - m.invoke(toObj, builtObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to set Yang-generated class expected by" - + toClass.getName() - + "." - + m.getName() - + "() from Properties entry", - e); - } - } else { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - //LOG.debug("Calling " - // + toObj.getClass().getName() - // + "." + m.getName() + "(" - // + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by" - + toClass.getName() - + "." - + m.getName() - + TO_PROPERTIES_STRING, - e); - } - } - } - } - }else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(paramClass)) { - - //LOG.debug("Parameter class " + paramClass.getName() - // + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type paramType = m.getGenericParameterTypes()[0]; - Type elementType = ((ParameterizedType) paramType) - .getActualTypeArguments()[0]; - Object paramObj = new LinkedList(); - try { - paramObj = toList(props, propName, - (List) paramObj, (Class) elementType); - } catch (Exception e) { - LOG.error("Caught exception trying to create list expected as argument to " - + toClass.getName() + "." + m.getName()); - } - - if (paramObj != null) { - try { - boolean isAccessible = m.isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - //LOG.debug("Calling " - // + toObj.getClass().getName() + "." - // + m.getName() + "(" + paramValue - // + ")"); - m.invoke(toObj, paramObj); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert List returned by" - + toClass.getName() + "." - + m.getName() - + TO_PROPERTIES_STRING, - e); - } - } - } else { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - //LOG.debug("Parameter class " - // + paramClass.getName() - // + " is not a yang-generated class or a List"); - - if (paramValue != null) { - - Object constObj = null; - - try { - // See if I can find a constructor I can use - Constructor[] constructors = paramClass - .getConstructors(); - // Is there a String constructor? - for (Constructor c : constructors) { - Class[] cParms = c.getParameterTypes(); - if ((cParms != null) - && (cParms.length == 1)) { - if (String.class - .isAssignableFrom(cParms[0])) { - constObj = c - .newInstance(paramValue); - } - } - } - - if (constObj == null) { - // Is there a Long constructor? - for (Constructor c : constructors) { - Class[] cParms = c - .getParameterTypes(); - if ((cParms != null) - && (cParms.length == 1)) { - if (Long.class - .isAssignableFrom(cParms[0])) { - constObj = c - .newInstance(Long - .parseLong(paramValue)); - } - } - } - - } - - if (constObj != null) { - try { - //LOG.debug("Calling " - // + toObj.getClass() - // .getName() + "." - // + m.getName() + "(" - // + constObj + ")"); - m.invoke(toObj, constObj); - foundValue = true; - } catch (Exception e2) { - LOG.error( - "Caught exception trying to call " - + m.getName(), e2); - } - } else { - try { - boolean isAccessible = m - .isAccessible(); - if (!isAccessible) { - m.setAccessible(true); - } - //LOG.debug("Calling " - // + toObj.getClass() - // .getName() + "." - // + m.getName() + "(" - // + paramValue + ")"); - m.invoke(toObj, paramValue); - if (!isAccessible) { - m.setAccessible(isAccessible); - } - foundValue = true; - - } catch (Exception e) { - LOG.error( - "Caught exception trying to convert value returned by" - + toClass.getName() - + "." - + m.getName() - + TO_PROPERTIES_STRING, - e); - } - } - } catch (Exception e1) { - LOG.warn( - "Could not find a suitable constructor for " - + paramClass.getName(), e1); - } - - /* - * try { boolean isAccessible = - * m.isAccessible(); if (!isAccessible) { - * m.setAccessible(true); } LOG.debug("Calling " - * + toObj.getClass().getName() + "." + - * m.getName() + "(" + paramValue + ")"); - * m.invoke(toObj, paramValue); if - * (!isAccessible) { - * m.setAccessible(isAccessible); } foundValue = - * true; - * - * } catch (Exception e) { LOG.error( - * "Caught exception trying to convert value returned by" - * + toClass.getName() + "." + m.getName() + - * "() to Properties entry", e); } - */ - } - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - if (foundValue) { - return (toObj); - } else { - return (null); - } - } - - public static Properties getProperties(PrintStream pstr, String pfx, - Class toClass) { - boolean foundValue = false; - - //LOG.debug("Analyzing " + toClass.getName() + " class : pfx " + pfx); - - if (isYangGenerated(toClass) - && (!Identifier.class.isAssignableFrom(toClass))) { - // Class is yang generated. - //LOG.debug(toClass.getName() + " is a Yang-generated class"); - - if (toClass.getName().endsWith("Key")) { - if (Identifier.class.isAssignableFrom(toClass)) { - //LOG.debug(Identifier.class.getName() - // + " is assignable from " + toClass.getName()); - } else { - - //LOG.debug(Identifier.class.getName() - // + " is NOT assignable from " + toClass.getName()); - } - } - - String propNamePfx = null; - if (pfx.endsWith("]")) { - propNamePfx = pfx; - }else if(pfx.indexOf(".CLASS_FOUND") != -1){ - pfx = pfx.replace(".CLASS_FOUND",""); - propNamePfx = pfx + "." - + toLowerHyphen(toClass.getSimpleName()); - } else { - - if ((pfx != null) && (pfx.length() > 0)) { - propNamePfx = pfx + "." - + toLowerHyphen(toClass.getSimpleName()); - } else { - propNamePfx = toLowerHyphen(toClass.getSimpleName()); - } - - if (propNamePfx.endsWith(BUILDER)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - BUILDER.length()); - } - - if (propNamePfx.endsWith(IMPL)) { - propNamePfx = propNamePfx.substring(0, propNamePfx.length() - - IMPL.length()); - } - } - - // Iterate through getter methods to figure out values we need to - // set - - for (Method m : toClass.getMethods()) { - //LOG.debug("Is " + m.getName() + " method a getter?"); - if (isGetter(m)) { - // LOG.debug(m.getName() + " is a getter"); - Class returnClass = m.getReturnType(); - - String fieldName = toLowerHyphen(m.getName().substring(3)); - if(m != null && m.getName().matches("^is[A-Z].*")){ - fieldName = toLowerHyphen(m.getName().substring(2)); - } - fieldName = fieldName.substring(0, 1).toLowerCase() - + fieldName.substring(1); - - String propName = propNamePfx + "." + fieldName; - //System.out.println("****" + propName); - - // Is the return type a yang generated class? - if (isYangGenerated(returnClass)) { - // Is it an enum? - if (returnClass.isEnum()) { - - //LOG.debug(m.getName() + " is an Enum"); - //pstr.print("\n" + propName); - //pstr.print("\n" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\n"); - pstr.print("\"" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\","); - prop.setProperty(propName,""); - propList.add(propName); - - } else { - - String simpleName = returnClass.getSimpleName(); - //System.out.println("simpleName:" + simpleName); - - if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName) || "IpPrefix".equals(simpleName)) { - //LOG.debug(m.getName()+" is an "+simpleName); - //pstr.print("\n" + propName); - //pstr.print("\n" + propName + ":" + simpleName + "\n"); - pstr.print("\"" + propName + ":" + simpleName + "\","); - prop.setProperty(propName,""); - propList.add(propName); - } else { - boolean isString = false; - boolean isNumber = false; - boolean isBoolean = false; - boolean isIdentifier = false; - //System.out.println("simpleName:" + simpleName); - //System.out.println("propName:" + propName); - for(Method mthd : returnClass.getMethods()){ - String methodName = mthd.getName(); - //System.out.println("methodName:" + methodName); - if(methodName.equals("getValue")){ - Class retType = mthd.getReturnType(); - //System.out.println("retType:" + retType); - isString = String.class.isAssignableFrom(retType); - isNumber = Number.class.isAssignableFrom(retType); - isBoolean = Boolean.class.isAssignableFrom(retType); - isIdentifier = Identifier.class.isAssignableFrom(retType); - //System.out.println("isString:" + isString); - //System.out.println("isNumber:" + isNumber); - //System.out.println("isNumber:" + isNumber); - break; - } - } - - if(isString){ - pstr.print("\"" + propName + ":String\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(isNumber){ - pstr.print("\"" + propName + ":Number\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(isBoolean){ - pstr.print("\"" + propName + ":Boolean\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(isIdentifier){ - //System.out.println("isIdentifier"); - //isIdentifer so skipping - continue; - }else{ - /* - System.out.println("fieldName:" + fieldName); - System.out.println("simpleName:" + simpleName); - System.out.println("returnClass:" + returnClass); - System.out.println("pstr:" + pstr); - System.out.println("propNamePfx:" + propNamePfx); - */ - getProperties(pstr, propNamePfx + ".CLASS_FOUND", returnClass); - } - } - - } - } else { - - // Setter's argument is not a yang-generated class. See - // if it is a List. - - if (List.class.isAssignableFrom(returnClass)) { - - //LOG.debug("Parameter class " - // + returnClass.getName() + " is a List"); - - // Figure out what type of args are in List and pass - // that to toList(). - - Type returnType = m.getGenericReturnType(); - Type elementType = ((ParameterizedType) returnType) - .getActualTypeArguments()[0]; - Class elementClass = (Class) elementType; - //LOG.debug("Calling printPropertyList on list type (" - //+ elementClass.getName() - // + "), pfx is (" - // + pfx - // + "), toClass is (" - // + toClass.getName() + ")"); - //System.out.println("List propNamePfx:" + propNamePfx+ "." + toLowerHyphen(elementClass.getSimpleName()) + "[]"); - if(String.class.isAssignableFrom(elementClass)){ - pstr.print("\"" + propName + ":[String,String,...]\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(Number.class.isAssignableFrom(elementClass)){ - pstr.print("\"" + propName + ":[Number,Number,...]\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(Boolean.class.isAssignableFrom(elementClass)){ - pstr.print("\"" + propName + ":[Boolean,Boolean,...]\","); - prop.setProperty(propName,""); - propList.add(propName); - }else if(Identifier.class.isAssignableFrom(elementClass)){ - continue; - }else{ - getProperties( - pstr, - propNamePfx - + "." - + toLowerHyphen(elementClass - .getSimpleName()) + "[]", - elementClass); - } - - } else if (!returnClass.equals(Class.class)) { - - // Setter expects something that is not a List and - // not yang-generated. Just pass the parameter value - - //LOG.debug("Parameter class " - // + returnClass.getName() - // + " is not a yang-generated class or a List"); - - //pstr.print("\n" + propName); - String className=returnClass.getName(); - int nClassNameIndex = className.lastIndexOf('.'); - String nClassName = className; - if(nClassNameIndex != -1){ - nClassName=className.substring(nClassNameIndex+1); - } - boolean isString = String.class.isAssignableFrom(returnClass); - boolean isNumber = Number.class.isAssignableFrom(returnClass); - boolean isBoolean = Boolean.class.isAssignableFrom(returnClass); - //pstr.print("\n" + propName +":" + nClassName +"\n"); - boolean isIdentifier = Identifier.class.isAssignableFrom(returnClass); - if(!isIdentifier && !nClassName.equals("[C")){ - if(isNumber){ - pstr.print("\"" + propName +":Number\","); - }else if(isBoolean){ - pstr.print("\"" + propName +":Boolean\","); - }else{ - if(nClassName.equals("[B")){ - pstr.print("\"" + propName +":Binary\","); - }else{ - pstr.print("\"" + propName +":" + nClassName +"\","); - } - } - prop.setProperty(propName,""); - propList.add(propName); - } - - } - } - } // End of section handling "setter" method - } // End of loop through Methods - } // End of section handling yang-generated class - - return prop; - } - - public static boolean isYangGenerated(Class c) { - if (c == null) { - return (false); - } else { - //System.out.println(c.getName()); - return (c.getName().startsWith("org.opendaylight.yang.gen.")); - } - } - - public static boolean isIpv4Address(Class c) { - - if (c == null ) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv4Address".equals(simpleName)) ; - } - - public static boolean isIpv6Address(Class c) { - - if (c == null ) { - return (false); - } - String simpleName = c.getSimpleName(); - return ("Ipv6Address".equals(simpleName)) ; - } - public static boolean isIpv4Prefix(Class c) { - - if (c == null ) { - return (false); - } - String simpleName = c.getSimpleName(); - //System.out.println("simpleName:" + simpleName); - return ("Ipv4Prefix".equals(simpleName)) ; - } - - public static boolean isIpv6Prefix(Class c) { - - if (c == null ) { - return (false); - } - String simpleName = c.getSimpleName(); - //System.out.println("simpleName:" + simpleName); - return ("Ipv6Prefix".equals(simpleName)) ; - } - - public static String toLowerHyphen(String inStr) { - if (inStr == null) { - return (null); - } - - String str = inStr.substring(0, 1).toLowerCase(); - if (inStr.length() > 1) { - str = str + inStr.substring(1); - } - - String regex = "(([a-z0-9])([A-Z]))"; - String replacement = "$2-$3"; - - String retval = str.replaceAll(regex, replacement).toLowerCase(); - - //LOG.debug("Converting " + inStr + " => " + str + " => " + retval); - return (retval); - } - - public static String toUpperCamelCase(String inStr) { - if (inStr == null) { - return (null); - } - - String[] terms = inStr.split("-"); - StringBuffer sbuff = new StringBuffer(); - // Check if string begins with a digit - if (Character.isDigit(inStr.charAt(0))) { - sbuff.append('_'); - } - for (String term : terms) { - sbuff.append(term.substring(0, 1).toUpperCase()); - if (term.length() > 1) { - sbuff.append(term.substring(1)); - } - } - return (sbuff.toString()); - - } - - public static boolean isGetter(Method m) { - //System.out.println(m); - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) - && (m.getParameterTypes().length == 0)) { - if ((m.getName().matches("^is[A-Z].*") || m.getName().matches("^get[A-Z].*")) - && m.getReturnType().equals(Boolean.class)) { - return (true); - } - if (m.getName().matches("^get[A-Z].*") - && !m.getReturnType().equals(void.class)) { - return (true); - } - - } - - return (false); - } - - public static boolean isSetter(Method m) { - if (m == null) { - return (false); - } - - if (Modifier.isPublic(m.getModifiers()) - && (m.getParameterTypes().length == 1)) { - if (m.getName().matches("^set[A-Z].*")) { - Class[] paramTypes = m.getParameterTypes(); - if (paramTypes[0].isAssignableFrom(Identifier.class) - || Identifier.class.isAssignableFrom(paramTypes[0])) { - return (false); - } else { - return (true); - } - } - - } - - return (false); - } - - public static void main(String[] args){ - - try(PrintStream ps = new PrintStream(new FileOutputStream(FileDescriptor.out))){ - PrintYangToProp printYangToProp = new PrintYangToProp(); - String className = args[0]; - //ClassLoader classLoader = PrintYangToProp.class.getClassLoader(); - //Class aClass = classLoader.loadClass(className); - Class cl = Class.forName(className); - //printPropertyList(ps,"",cl); - //JsonObject jsonObj = Json.createObjectBuilder().build(); - Properties p = getProperties(ps,"",cl); - //System.out.println(p); - - }catch(Exception e){ - e.printStackTrace(); - } - } - - -} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index aca904d14..b592c15f6 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -25,8 +25,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.Set; - -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -42,8 +40,6 @@ public class SvcLogicContext { private HashMap attributes; - private DOMDataBroker domDataBroker; - private String status = "success"; public SvcLogicContext() @@ -68,16 +64,6 @@ public class SvcLogicContext { } } - - - public DOMDataBroker getDomDataBroker() { - return domDataBroker; - } - - public void setDomDataBroker(DOMDataBroker domDataBroker) { - this.domDataBroker = domDataBroker; - } - public String getAttribute(String name) { if (attributes.containsKey(name)) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 94ffcd990..dc3a560eb 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -23,8 +23,6 @@ package org.onap.ccsdk.sli.core.sli; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.sql.Blob; @@ -35,52 +33,24 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Properties; import javax.sql.rowset.CachedRowSet; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SvcLogicDblibStore implements SvcLogicStore { - - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicDblibStore.class); - - private static final String DBLIB_SERVICE = "org.onap.ccsdk.sli.core.dblib.DbLibService"; - private DbLibService dbSvc; - public SvcLogicDblibStore() - { - // Does nothing, but needed so that argumentless constructor - // still works. - } - public SvcLogicDblibStore(DbLibService dbsvc) { this.dbSvc = dbsvc; } - public SvcLogicDblibStore(Properties props) { - try { - dbSvc = new DBResourceManager(props); - JavaSingleton.setInstance(dbSvc); - } catch (Exception e) { - LOG.warn("Caught exception trying to create DBResourceManager", e); - } - } - public Connection getConnection() throws SQLException { return(dbSvc.getConnection()); } @Override public void init(Properties props) throws ConfigurationException { - - dbSvc = getDbLibService(); if(dbSvc == null) { LOG.error("SvcLogic cannot acquire DBLIB_SERVICE"); return; @@ -334,101 +304,6 @@ public class SvcLogicDblibStore implements SvcLogicStore { } } - private DbLibService getDbLibService() { - - if (dbSvc != null) { - return dbSvc; - } - - // Get DbLibService interface object. - ServiceReference sref = null; - BundleContext bctx = null; - - Bundle bundle = FrameworkUtil.getBundle(SvcLogicDblibStore.class); - - if (bundle != null) { - bctx = bundle.getBundleContext(); - - if (bctx != null) { - sref = bctx.getServiceReference(DBLIB_SERVICE); - } - - if (sref == null) { - LOG.warn("Could not find service reference for DBLIB service ({})", DBLIB_SERVICE); - } else { - dbSvc = (DbLibService) bctx.getService(sref); - if (dbSvc == null) { - - LOG.warn("Could not find service reference for DBLIB service ({})", DBLIB_SERVICE); - } - } - } - - // initialize a stand-alone instance of dblib resource - else { - // Try to create a DbLibService object from dblib properties - if(JavaSingleton.getInstance() == null){ - Properties dblibProps = new Properties(); - - String propDir = System.getenv(SDNC_CONFIG_DIR); - if (propDir == null) { - - propDir = "/opt/sdnc/data/properties"; - } - String propPath = propDir + "/dblib.properties"; - - File propFile = new File(propPath); - - if (!propFile.exists()) { - - LOG.warn("Missing configuration properties file : {}", propFile); - return null; - } - - try { - - dblibProps.load(new FileInputStream(propFile)); - } catch (Exception e) { - LOG.warn( - "Could not load properties file " + propPath, e); - return null; - - } - - try { - dbSvc = new DBResourceManager(dblibProps); - JavaSingleton.setInstance(dbSvc); - } catch (Exception e) { - LOG.warn("Caught exception trying to create DBResourceManager", e); - } - } else { - dbSvc = JavaSingleton.getInstance(); - } - } - return dbSvc; - } - - - static class JavaSingleton { - /* Private constructor */ - private JavaSingleton() { - /* the body of the constructor here */ - } - - /* instance of the singleton declaration */ - private static volatile DbLibService INSTANCE ; - - /* Access point to the unique instance of the singleton */ - public static DbLibService getInstance() { - return INSTANCE; - } - - public static void setInstance(DbLibService dbresource) { - INSTANCE = dbresource; - } - } - - @Override public void activate(String module, String rpc, String version, String mode) throws SvcLogicException { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java index 9e9bfe0dc..727c84b19 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java @@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.core.sli; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; - import org.antlr.v4.runtime.ANTLRInputStream; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CommonTokenStream; @@ -72,27 +71,5 @@ public class SvcLogicExpressionFactory { return(listener.getParsedExpr()); } - - public static void main(String argv[]) { - - System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug"); - - StringBuffer sbuff = new StringBuffer(); - - for (int i = 0 ; i < argv.length ; i++) - { - if (sbuff.length() > 0) - { - sbuff.append(" "); - } - sbuff.append(argv[i]); - } - - try { - SvcLogicExpressionFactory.parse(sbuff.toString()); - } catch (IOException e) { - LOG.error("Exception in SvcLogicExpressionFactory.parse",e); - } - } } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index 532ad31b4..b73925dde 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -25,7 +25,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.Properties; - +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,7 +81,7 @@ public class SvcLogicStoreFactory { retval = new SvcLogicJdbcStore(); } else if ("dblib".equalsIgnoreCase(storeType)) { - retval = new SvcLogicDblibStore(); + retval = new SvcLogicDblibStore(new DBResourceManager(props)); } else { throw new ConfigurationException("unsupported dbtype (" + storeType + ")"); diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 6f303a598..50eb917f8 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -26,7 +26,6 @@ package org.onap.ccsdk.sli.core.sli; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -38,12 +37,12 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; - import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -155,7 +154,7 @@ public class ITCaseSvcLogicParser { props.load(propStr); - SvcLogicDblibStore dblibStore = new SvcLogicDblibStore(props); + SvcLogicDblibStore dblibStore = new SvcLogicDblibStore(new DBResourceManager(props)); Connection dbConn = dblibStore.getConnection(); diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java deleted file mode 100644 index 14b4dcb76..000000000 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/*- - 2 * ============LICENSE_START======================================================= - 3 * ONAP CCSDK - 4 * ================================================================================ - 5 * Copyright (C) 2019 AT&T Intellectual Property. All rights - 6 * reserved. - 7 * ================================================================================ - 8 * Licensed under the Apache License, Version 2.0 (the "License"); - 9 * you may not use this file except in compliance with the License. - 10 * You may obtain a copy of the License at - 11 * - 12 * http://www.apache.org/licenses/LICENSE-2.0 - 13 * - 14 * Unless required by applicable law or agreed to in writing, software - 15 * distributed under the License is distributed on an "AS IS" BASIS, - 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - 17 * See the License for the specific language governing permissions and - 18 * limitations under the License. - 19 * ============LICENSE_END============================================ - 20 * =================================================================== - 21 * - 22 */ -package org.onap.ccsdk.sli.core.sli; - -import java.util.Enumeration; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -import org.junit.Test; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResultsBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author dt5972 - * - */ -public class PrintYangToPropTest { - - private static final Logger LOG = LoggerFactory.getLogger(PrintYangToPropTest.class); - @Test - public void test() { - - Properties props = new Properties(); - - // Set up a builder with data - ExecuteGraphInputBuilder egBuilder = new ExecuteGraphInputBuilder(); - egBuilder.setMode(Mode.Sync); - egBuilder.setModuleName("my-module"); - egBuilder.setRpcName("my-rpc"); - - List pList = new LinkedList<>(); - - SliParameterBuilder pBuilder = new SliParameterBuilder(); - pBuilder.setParameterName("string-param"); - pBuilder.setStringValue("hi"); - pList.add(pBuilder.build()); - pBuilder.setParameterName("int-param"); - pBuilder.setIntValue(1); - pBuilder.setStringValue(null); - pList.add(pBuilder.build()); - pBuilder.setParameterName("bool-param"); - pBuilder.setIntValue(null); - pBuilder.setBooleanValue(true); - pList.add(pBuilder.build()); - pBuilder.setParameterName("ipaddress-value1"); - pBuilder.setBooleanValue(null); - pBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); - pList.add(pBuilder.build()); - pBuilder.setParameterName("ipaddress-value1"); - pBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("::1")); - pList.add(pBuilder.build()); - pBuilder.setParameterName("ipprefix-value1"); - pBuilder.setIpaddressValue(null); - pBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("192.168.0.0/16")); - pList.add(pBuilder.build()); - pBuilder.setParameterName("ipprefix-value2"); - pBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("2001:db8:3c4d::/48")); - pList.add(pBuilder.build()); - - - - egBuilder.setSliParameter(pList); - - - // Generate properties - props = PrintYangToProp.toProperties(props, egBuilder); - - Enumeration propNames = props.propertyNames(); - - while (propNames.hasMoreElements()) { - String propName = (String) propNames.nextElement(); - LOG.info("Property {} = {}", propName, props.getProperty(propName)); - } - - // Generate builder from properties just generated - PrintYangToProp.toBuilder(props, pBuilder); - - - } - - @Test - public void testWithList() { - TestResultsBuilder resultsBuilder = new TestResultsBuilder(); - TestResultBuilder resultBuilder = new TestResultBuilder(); - - // Set builder with values - List resultList = new LinkedList<>(); - resultBuilder.setTestIdentifier("test1"); - List results = new LinkedList<>(); - results.add("pass"); - resultBuilder.setResults(results); - resultList.add(resultBuilder.build()); - resultsBuilder.setTestResult(resultList); - - // Generate properties - Properties props = new Properties(); - props = PrintYangToProp.toProperties(props, resultsBuilder); - - Enumeration propNames = props.propertyNames(); - - while (propNames.hasMoreElements()) { - String propName = (String) propNames.nextElement(); - LOG.info("Property {} = {}", propName, props.getProperty(propName)); - } - - // Generate builder from properties just generated - PrintYangToProp.toBuilder(props, resultsBuilder); - - } - -} diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 265831da4..95099ed2f 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -70,7 +70,14 @@ org.opendaylight.controller sal-binding-api - + + org.opendaylight.mdsal.binding.model.ietf + rfc6991 + + + org.opendaylight.controller + sal-core-api + junit diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java new file mode 100644 index 000000000..a7f383f2c --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java @@ -0,0 +1,1355 @@ +/*- + * ============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.provider; + +import java.io.PrintStream; +import java.io.FileDescriptor; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; +import java.util.Arrays; +import java.util.ArrayList; +import java.io.*; +import org.opendaylight.yangtools.yang.binding.Identifier; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.google.common.base.Strings; + + +public class PrintYangToProp { + + private static final Logger LOG = LoggerFactory.getLogger(PrintYangToProp.class); + public static final String PROPERTIES_FILE=""; + private static Properties properties; + private static final String BUILDER="-builder"; + private static final String IMPL="-impl"; + private static final String TO_PROPERTIES_STRING="() to Properties entry"; + private static final String CAUGHT_EXCEPTION_MSG="Caught exception trying to convert value returned by "; + public static Properties prop = new Properties(); + public static ArrayList propList = new ArrayList<>(); + + + public static Properties toProperties(Properties props, Object fromObj) { + Class fromClass = null; + + if (fromObj != null) + { + fromClass = fromObj.getClass(); + } + return (toProperties(props, "", fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, Object fromObj) + { + Class fromClass = null; + + if (fromObj != null) + { + fromClass = fromObj.getClass(); + } + + return(toProperties(props, pfx, fromObj, fromClass)); + } + + public static Properties toProperties(Properties props, String pfx, + Object fromObj, Class fromClass) { + + if (fromObj == null) { + return (props); + } + + + String simpleName = fromClass.getSimpleName(); + + if (fromObj instanceof List) { + + + List fromList = (List) fromObj; + + for (int i = 0; i < fromList.size(); i++) { + toProperties(props, pfx + "[" + i + "]", fromList.get(i), fromClass); + } + props.setProperty(pfx + "_length", "" + fromList.size()); + + } else if (isYangGenerated(fromClass)) { + + String propNamePfx = null; + + // If called from a list (so prefix ends in ']'), don't + // add class name again + if (pfx.endsWith("]")) { + propNamePfx = pfx; + } else { + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx ; + } else { + propNamePfx = toLowerHyphen(fromClass.getSimpleName()); + } + + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - BUILDER.length()); + } + + if (propNamePfx.endsWith(IMPL)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - IMPL.length()); + } + } + + // Iterate through getter methods to figure out values we need to + // save from + + for (Method m : fromClass.getMethods()) { + + if (isGetter(m)) { + + Class returnType = m.getReturnType(); + String fieldName = toLowerHyphen(m.getName().substring(3)); + if(m != null && m.getName().matches("^is[A-Z].*")){ + fieldName = toLowerHyphen(m.getName().substring(2)); + } + + if(Strings.isNullOrEmpty(fieldName)) fieldName = fieldName.substring(0, 1).toLowerCase()+ fieldName.substring(1); + + + // Is the return type a yang generated class? + if (isYangGenerated(returnType)) { + + // Is it an enum? + if (returnType.isEnum()) { + // Return type is a typedef. Save its value. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + Object retValue = m.invoke(fromObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + String propName = propNamePfx + "." + + fieldName; + String propVal = retValue.toString(); + String yangProp = "yang." + fieldName + "." + propVal; + if ( properties.containsKey(yangProp)) { + propVal = properties.getProperty(yangProp); + } + props.setProperty(propName, propVal); + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated enum returned by " + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else if (isIpv4Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Address retValue = (Ipv4Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue(); + + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else if (isIpv6Address(returnType)) { + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Address retValue = (Ipv6Address) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue(); + + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else if (isIpv4Prefix(returnType)) { + + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv4Prefix retValue = (Ipv4Prefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue(); + + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else if (isIpv6Prefix(returnType)) { + //System.out.println("isIpv6Prefix"); + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Ipv6Prefix retValue = (Ipv6Prefix) m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (retValue != null) { + String propVal = retValue.getValue().toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retValue = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + if (retValue != null) { + toProperties(props, propNamePfx + "." + fieldName, retValue, returnType); + } + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert Yang-generated class returned by" + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } + } else if (returnType.equals(Class.class)) { + + //LOG.debug(m.getName() + // + " returns a Class object - not interested"); + + } else if (List.class.isAssignableFrom(returnType)) { + + // This getter method returns a list. + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object retList = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + // Figure out what type of elements are stored in this array. + Type paramType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) paramType) + .getActualTypeArguments()[0]; + toProperties(props, propNamePfx + "." + fieldName, + retList, (Class)elementType); + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert List returned by " + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + + } else { + + // Method returns something that is not a List and not + // yang-generated. + // Save its value + try { + String propName = propNamePfx + "." + fieldName; + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + Object propValObj = m.invoke(fromObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + + if (propValObj != null) { + String propVal = propValObj.toString(); + //LOG.debug("Setting property " + propName + // + " to " + propVal); + props.setProperty(propName, propVal); + + } + } catch (Exception e) { + LOG.error( + CAUGHT_EXCEPTION_MSG + + fromClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, e); + } + } + + } + } + + } else { + // Class is not yang generated and not a list + // Do nothing. + + } + + return (props); + } + + public static Object toBuilder(Properties props, Object toObj) { + + return (toBuilder(props, "", toObj)); + } + + public static List toList(Properties props, String pfx, List toObj, + Class elemType) { + + int maxIdx = -1; + boolean foundValue = false; + + //LOG.debug("Saving properties to List<" + elemType.getName() + // + "> from " + pfx); + + // Figure out array size + for (Object pNameObj : props.keySet()) { + String key = (String) pNameObj; + + if (key.startsWith(pfx + "[")) { + String idxStr = key.substring(pfx.length() + 1); + int endloc = idxStr.indexOf("]"); + if (endloc != -1) { + idxStr = idxStr.substring(0, endloc); + } + + try { + int curIdx = Integer.parseInt(idxStr); + if (curIdx > maxIdx) { + maxIdx = curIdx; + } + } catch (Exception e) { + LOG.error("Illegal subscript in property " + key); + } + + } + } + + //LOG.debug(pfx + " has max index of " + maxIdx); + for (int i = 0; i <= maxIdx; i++) { + + String curBase = pfx + "[" + i + "]"; + + if (isYangGenerated(elemType)) { + String builderName = elemType.getName() + "Builder"; + try { + Class builderClass = Class.forName(builderName); + Object builderObj = builderClass.newInstance(); + Method buildMethod = builderClass.getMethod("build"); + builderObj = toBuilder(props, curBase, builderObj, true); + if (builderObj != null) { + //LOG.debug("Calling " + builderObj.getClass().getName() + // + "." + buildMethod.getName() + "()"); + Object builtObj = buildMethod.invoke(builderObj); + toObj.add(builtObj); + foundValue = true; + } + + } catch (ClassNotFoundException e) { + LOG.warn("Could not find builder class " + builderName, e); + } catch (Exception e) { + LOG.error("Caught exception trying to populate list from " + + pfx); + } + } + + } + + if (foundValue) { + return (toObj); + } else { + return (null); + } + + } + + public static Object toBuilder(Properties props, String pfx, Object toObj) { + return(toBuilder(props, pfx, toObj, false)); + } + + public static Object toBuilder(Properties props, String pfx, Object toObj, boolean preservePfx) { + Class toClass = toObj.getClass(); + boolean foundValue = false; + + //LOG.debug("Saving properties to " + toClass.getName() + " class from " + // + pfx); + + Ipv4Address addr; + + if (isYangGenerated(toClass)) { + // Class is yang generated. + //LOG.debug(toClass.getName() + " is a Yang-generated class"); + + String propNamePfx = null; + if (preservePfx) { + propNamePfx = pfx; + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - BUILDER.length()); + } + + if (propNamePfx.endsWith(IMPL)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - IMPL.length()); + } + } + + if (toObj instanceof Identifier) { + //LOG.debug(toClass.getName() + " is a Key - skipping"); + return (toObj); + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + // LOG.debug("Is " + m.getName() + " method a setter?"); + if (isSetter(m)) { + // LOG.debug(m.getName() + " is a setter"); + Class paramTypes[] = m.getParameterTypes(); + Class paramClass = paramTypes[0]; + + String fieldName = toLowerHyphen(m.getName().substring(3)); + fieldName = fieldName.substring(0, 1).toLowerCase() + + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + + String paramValue = props.getProperty(propName); + if (paramValue == null) { + //LOG.debug(propName + " is unset"); + } else { + //LOG.debug(propName + " = " + paramValue); + } + + // Is the return type a yang generated class? + if (isYangGenerated(paramClass)) { + // Is it an enum? + if (paramClass.isEnum()) { + + //LOG.debug(m.getName() + " expects an Enum"); + // Param type is a typedef. + if (paramValue != null) { + Object paramObj = null; + + try { + paramObj = Enum.valueOf(paramClass, + toUpperCamelCase(paramValue)); + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert field " + + propName + " to enum " + + paramClass.getName(), e); + } + + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + //LOG.debug("Calling " + // + toObj.getClass().getName() + "." + // + m.getName() + "(" + paramValue + // + ")"); + m.invoke(toObj, paramObj); + + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to create Yang-generated enum expected by" + + toClass.getName() + + "." + + m.getName() + + "() from Properties entry", + e); + } + } + } else { + + String simpleName = paramClass.getSimpleName(); + LOG.info("simpleName:" + simpleName); + + if ("Ipv4Address".equals(simpleName) + || "Ipv6Address".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName)) { + + if (paramValue != null) { + if("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName)){ + try { + IpAddress ipAddr = IpAddressBuilder + .getDefaultInstance(paramValue); + + + if ("Ipv4Address".equals(simpleName)) + { + m.invoke(toObj, ipAddr.getIpv4Address()); + } + else + { + m.invoke(toObj, ipAddr.getIpv6Address()); + + } + foundValue = true; + } catch (Exception e) { + LOG.error( + "Caught exception calling " + + toClass.getName() + "." + + m.getName() + "(" + + paramValue + ")", e); + + } + }else if("Ipv4Prefix".equals(simpleName)|| "Ipv6Prefix".equals(simpleName)){ + try { + IpPrefix ipPrefix = IpPrefixBuilder + .getDefaultInstance(paramValue); + + + if ("Ipv4Prefix".equals(simpleName)) + { + m.invoke(toObj, ipPrefix.getIpv4Prefix()); + } + else + { + m.invoke(toObj, ipPrefix.getIpv6Prefix()); + + } + foundValue = true; + } catch (Exception e) { + LOG.error( + "Caught exception calling " + + toClass.getName() + "." + + m.getName() + "(" + + paramValue + ")", e); + + } + } + } + + } else { + // setter expects a yang-generated class. Need + // to + // create a builder to set it. + + String builderName = paramClass.getName() + + "Builder"; + Class builderClass = null; + Object builderObj = null; + Object paramObj = null; + + //LOG.debug(m.getName() + // + " expects a yang-generated class - looking for builder " + // + builderName); + try { + builderClass = Class.forName(builderName); + builderObj = builderClass.newInstance(); + paramObj = toBuilder(props, propNamePfx, + builderObj); + } catch (ClassNotFoundException e) { + Object constObj = null; + try { + // See if I can find a constructor I can + // use + Constructor[] constructors = paramClass + .getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (String.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (Long.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(Long + .parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error( + "Caught exception trying to call " + + m.getName(), + e2); + } + } + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + + paramClass.getName(), + e1); + } + + if (paramObj == null) { + LOG.warn("Could not find builder class " + + builderName + + " and could not find a String or Long constructor - trying just to set passing paramValue"); + + } + + } catch (Exception e) { + LOG.error( + "Caught exception trying to create builder " + + builderName, e); + } + + if (paramObj != null) { + + try { + + Method buildMethod = builderClass + .getMethod("build"); + //LOG.debug("Calling " + // + paramObj.getClass().getName() + // + "." + buildMethod.getName() + // + "()"); + Object builtObj = buildMethod + .invoke(paramObj); + + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + + //LOG.debug("Calling " + // + toObj.getClass().getName() + // + "." + m.getName() + "()"); + m.invoke(toObj, builtObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to set Yang-generated class expected by" + + toClass.getName() + + "." + + m.getName() + + "() from Properties entry", + e); + } + } else { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass().getName() + // + "." + m.getName() + "(" + // + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by" + + toClass.getName() + + "." + + m.getName() + + TO_PROPERTIES_STRING, + e); + } + } + } + } + }else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(paramClass)) { + + //LOG.debug("Parameter class " + paramClass.getName() + // + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type paramType = m.getGenericParameterTypes()[0]; + Type elementType = ((ParameterizedType) paramType) + .getActualTypeArguments()[0]; + Object paramObj = new LinkedList(); + try { + paramObj = toList(props, propName, + (List) paramObj, (Class) elementType); + } catch (Exception e) { + LOG.error("Caught exception trying to create list expected as argument to " + + toClass.getName() + "." + m.getName()); + } + + if (paramObj != null) { + try { + boolean isAccessible = m.isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass().getName() + "." + // + m.getName() + "(" + paramValue + // + ")"); + m.invoke(toObj, paramObj); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert List returned by" + + toClass.getName() + "." + + m.getName() + + TO_PROPERTIES_STRING, + e); + } + } + } else { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + //LOG.debug("Parameter class " + // + paramClass.getName() + // + " is not a yang-generated class or a List"); + + if (paramValue != null) { + + Object constObj = null; + + try { + // See if I can find a constructor I can use + Constructor[] constructors = paramClass + .getConstructors(); + // Is there a String constructor? + for (Constructor c : constructors) { + Class[] cParms = c.getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (String.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(paramValue); + } + } + } + + if (constObj == null) { + // Is there a Long constructor? + for (Constructor c : constructors) { + Class[] cParms = c + .getParameterTypes(); + if ((cParms != null) + && (cParms.length == 1)) { + if (Long.class + .isAssignableFrom(cParms[0])) { + constObj = c + .newInstance(Long + .parseLong(paramValue)); + } + } + } + + } + + if (constObj != null) { + try { + //LOG.debug("Calling " + // + toObj.getClass() + // .getName() + "." + // + m.getName() + "(" + // + constObj + ")"); + m.invoke(toObj, constObj); + foundValue = true; + } catch (Exception e2) { + LOG.error( + "Caught exception trying to call " + + m.getName(), e2); + } + } else { + try { + boolean isAccessible = m + .isAccessible(); + if (!isAccessible) { + m.setAccessible(true); + } + //LOG.debug("Calling " + // + toObj.getClass() + // .getName() + "." + // + m.getName() + "(" + // + paramValue + ")"); + m.invoke(toObj, paramValue); + if (!isAccessible) { + m.setAccessible(isAccessible); + } + foundValue = true; + + } catch (Exception e) { + LOG.error( + "Caught exception trying to convert value returned by" + + toClass.getName() + + "." + + m.getName() + + TO_PROPERTIES_STRING, + e); + } + } + } catch (Exception e1) { + LOG.warn( + "Could not find a suitable constructor for " + + paramClass.getName(), e1); + } + + /* + * try { boolean isAccessible = + * m.isAccessible(); if (!isAccessible) { + * m.setAccessible(true); } LOG.debug("Calling " + * + toObj.getClass().getName() + "." + + * m.getName() + "(" + paramValue + ")"); + * m.invoke(toObj, paramValue); if + * (!isAccessible) { + * m.setAccessible(isAccessible); } foundValue = + * true; + * + * } catch (Exception e) { LOG.error( + * "Caught exception trying to convert value returned by" + * + toClass.getName() + "." + m.getName() + + * "() to Properties entry", e); } + */ + } + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + if (foundValue) { + return (toObj); + } else { + return (null); + } + } + + public static Properties getProperties(PrintStream pstr, String pfx, + Class toClass) { + boolean foundValue = false; + + //LOG.debug("Analyzing " + toClass.getName() + " class : pfx " + pfx); + + if (isYangGenerated(toClass) + && (!Identifier.class.isAssignableFrom(toClass))) { + // Class is yang generated. + //LOG.debug(toClass.getName() + " is a Yang-generated class"); + + if (toClass.getName().endsWith("Key")) { + if (Identifier.class.isAssignableFrom(toClass)) { + //LOG.debug(Identifier.class.getName() + // + " is assignable from " + toClass.getName()); + } else { + + //LOG.debug(Identifier.class.getName() + // + " is NOT assignable from " + toClass.getName()); + } + } + + String propNamePfx = null; + if (pfx.endsWith("]")) { + propNamePfx = pfx; + }else if(pfx.indexOf(".CLASS_FOUND") != -1){ + pfx = pfx.replace(".CLASS_FOUND",""); + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + + if ((pfx != null) && (pfx.length() > 0)) { + propNamePfx = pfx + "." + + toLowerHyphen(toClass.getSimpleName()); + } else { + propNamePfx = toLowerHyphen(toClass.getSimpleName()); + } + + if (propNamePfx.endsWith(BUILDER)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - BUILDER.length()); + } + + if (propNamePfx.endsWith(IMPL)) { + propNamePfx = propNamePfx.substring(0, propNamePfx.length() + - IMPL.length()); + } + } + + // Iterate through getter methods to figure out values we need to + // set + + for (Method m : toClass.getMethods()) { + //LOG.debug("Is " + m.getName() + " method a getter?"); + if (isGetter(m)) { + // LOG.debug(m.getName() + " is a getter"); + Class returnClass = m.getReturnType(); + + String fieldName = toLowerHyphen(m.getName().substring(3)); + if(m != null && m.getName().matches("^is[A-Z].*")){ + fieldName = toLowerHyphen(m.getName().substring(2)); + } + fieldName = fieldName.substring(0, 1).toLowerCase() + + fieldName.substring(1); + + String propName = propNamePfx + "." + fieldName; + //System.out.println("****" + propName); + + // Is the return type a yang generated class? + if (isYangGenerated(returnClass)) { + // Is it an enum? + if (returnClass.isEnum()) { + + //LOG.debug(m.getName() + " is an Enum"); + //pstr.print("\n" + propName); + //pstr.print("\n" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\n"); + pstr.print("\"" + propName + ":Enum:" + Arrays.asList(returnClass.getEnumConstants()) + "\","); + prop.setProperty(propName,""); + propList.add(propName); + + } else { + + String simpleName = returnClass.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + + if ("Ipv4Address".equals(simpleName) || "Ipv6Address".equals(simpleName) || "IpAddress".equals(simpleName) || "Ipv4Prefix".equals(simpleName) || "Ipv6Prefix".equals(simpleName) || "IpPrefix".equals(simpleName)) { + //LOG.debug(m.getName()+" is an "+simpleName); + //pstr.print("\n" + propName); + //pstr.print("\n" + propName + ":" + simpleName + "\n"); + pstr.print("\"" + propName + ":" + simpleName + "\","); + prop.setProperty(propName,""); + propList.add(propName); + } else { + boolean isString = false; + boolean isNumber = false; + boolean isBoolean = false; + boolean isIdentifier = false; + //System.out.println("simpleName:" + simpleName); + //System.out.println("propName:" + propName); + for(Method mthd : returnClass.getMethods()){ + String methodName = mthd.getName(); + //System.out.println("methodName:" + methodName); + if(methodName.equals("getValue")){ + Class retType = mthd.getReturnType(); + //System.out.println("retType:" + retType); + isString = String.class.isAssignableFrom(retType); + isNumber = Number.class.isAssignableFrom(retType); + isBoolean = Boolean.class.isAssignableFrom(retType); + isIdentifier = Identifier.class.isAssignableFrom(retType); + //System.out.println("isString:" + isString); + //System.out.println("isNumber:" + isNumber); + //System.out.println("isNumber:" + isNumber); + break; + } + } + + if(isString){ + pstr.print("\"" + propName + ":String\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isNumber){ + pstr.print("\"" + propName + ":Number\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isBoolean){ + pstr.print("\"" + propName + ":Boolean\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(isIdentifier){ + //System.out.println("isIdentifier"); + //isIdentifer so skipping + continue; + }else{ + /* + System.out.println("fieldName:" + fieldName); + System.out.println("simpleName:" + simpleName); + System.out.println("returnClass:" + returnClass); + System.out.println("pstr:" + pstr); + System.out.println("propNamePfx:" + propNamePfx); + */ + getProperties(pstr, propNamePfx + ".CLASS_FOUND", returnClass); + } + } + + } + } else { + + // Setter's argument is not a yang-generated class. See + // if it is a List. + + if (List.class.isAssignableFrom(returnClass)) { + + //LOG.debug("Parameter class " + // + returnClass.getName() + " is a List"); + + // Figure out what type of args are in List and pass + // that to toList(). + + Type returnType = m.getGenericReturnType(); + Type elementType = ((ParameterizedType) returnType) + .getActualTypeArguments()[0]; + Class elementClass = (Class) elementType; + //LOG.debug("Calling printPropertyList on list type (" + //+ elementClass.getName() + // + "), pfx is (" + // + pfx + // + "), toClass is (" + // + toClass.getName() + ")"); + //System.out.println("List propNamePfx:" + propNamePfx+ "." + toLowerHyphen(elementClass.getSimpleName()) + "[]"); + if(String.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[String,String,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Number.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[Number,Number,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Boolean.class.isAssignableFrom(elementClass)){ + pstr.print("\"" + propName + ":[Boolean,Boolean,...]\","); + prop.setProperty(propName,""); + propList.add(propName); + }else if(Identifier.class.isAssignableFrom(elementClass)){ + continue; + }else{ + getProperties( + pstr, + propNamePfx + + "." + + toLowerHyphen(elementClass + .getSimpleName()) + "[]", + elementClass); + } + + } else if (!returnClass.equals(Class.class)) { + + // Setter expects something that is not a List and + // not yang-generated. Just pass the parameter value + + //LOG.debug("Parameter class " + // + returnClass.getName() + // + " is not a yang-generated class or a List"); + + //pstr.print("\n" + propName); + String className=returnClass.getName(); + int nClassNameIndex = className.lastIndexOf('.'); + String nClassName = className; + if(nClassNameIndex != -1){ + nClassName=className.substring(nClassNameIndex+1); + } + boolean isString = String.class.isAssignableFrom(returnClass); + boolean isNumber = Number.class.isAssignableFrom(returnClass); + boolean isBoolean = Boolean.class.isAssignableFrom(returnClass); + //pstr.print("\n" + propName +":" + nClassName +"\n"); + boolean isIdentifier = Identifier.class.isAssignableFrom(returnClass); + if(!isIdentifier && !nClassName.equals("[C")){ + if(isNumber){ + pstr.print("\"" + propName +":Number\","); + }else if(isBoolean){ + pstr.print("\"" + propName +":Boolean\","); + }else{ + if(nClassName.equals("[B")){ + pstr.print("\"" + propName +":Binary\","); + }else{ + pstr.print("\"" + propName +":" + nClassName +"\","); + } + } + prop.setProperty(propName,""); + propList.add(propName); + } + + } + } + } // End of section handling "setter" method + } // End of loop through Methods + } // End of section handling yang-generated class + + return prop; + } + + public static boolean isYangGenerated(Class c) { + if (c == null) { + return (false); + } else { + //System.out.println(c.getName()); + return (c.getName().startsWith("org.opendaylight.yang.gen.")); + } + } + + public static boolean isIpv4Address(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv4Address".equals(simpleName)) ; + } + + public static boolean isIpv6Address(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + return ("Ipv6Address".equals(simpleName)) ; + } + public static boolean isIpv4Prefix(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + return ("Ipv4Prefix".equals(simpleName)) ; + } + + public static boolean isIpv6Prefix(Class c) { + + if (c == null ) { + return (false); + } + String simpleName = c.getSimpleName(); + //System.out.println("simpleName:" + simpleName); + return ("Ipv6Prefix".equals(simpleName)) ; + } + + public static String toLowerHyphen(String inStr) { + if (inStr == null) { + return (null); + } + + String str = inStr.substring(0, 1).toLowerCase(); + if (inStr.length() > 1) { + str = str + inStr.substring(1); + } + + String regex = "(([a-z0-9])([A-Z]))"; + String replacement = "$2-$3"; + + String retval = str.replaceAll(regex, replacement).toLowerCase(); + + //LOG.debug("Converting " + inStr + " => " + str + " => " + retval); + return (retval); + } + + public static String toUpperCamelCase(String inStr) { + if (inStr == null) { + return (null); + } + + String[] terms = inStr.split("-"); + StringBuffer sbuff = new StringBuffer(); + // Check if string begins with a digit + if (Character.isDigit(inStr.charAt(0))) { + sbuff.append('_'); + } + for (String term : terms) { + sbuff.append(term.substring(0, 1).toUpperCase()); + if (term.length() > 1) { + sbuff.append(term.substring(1)); + } + } + return (sbuff.toString()); + + } + + public static boolean isGetter(Method m) { + //System.out.println(m); + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) + && (m.getParameterTypes().length == 0)) { + if ((m.getName().matches("^is[A-Z].*") || m.getName().matches("^get[A-Z].*")) + && m.getReturnType().equals(Boolean.class)) { + return (true); + } + if (m.getName().matches("^get[A-Z].*") + && !m.getReturnType().equals(void.class)) { + return (true); + } + + } + + return (false); + } + + public static boolean isSetter(Method m) { + if (m == null) { + return (false); + } + + if (Modifier.isPublic(m.getModifiers()) + && (m.getParameterTypes().length == 1)) { + if (m.getName().matches("^set[A-Z].*")) { + Class[] paramTypes = m.getParameterTypes(); + if (paramTypes[0].isAssignableFrom(Identifier.class) + || Identifier.class.isAssignableFrom(paramTypes[0])) { + return (false); + } else { + return (true); + } + } + + } + + return (false); + } + + public static void main(String[] args){ + + try(PrintStream ps = new PrintStream(new FileOutputStream(FileDescriptor.out))){ + PrintYangToProp printYangToProp = new PrintYangToProp(); + String className = args[0]; + //ClassLoader classLoader = PrintYangToProp.class.getClassLoader(); + //Class aClass = classLoader.loadClass(className); + Class cl = Class.forName(className); + //printPropertyList(ps,"",cl); + //JsonObject jsonObj = Json.createObjectBuilder().build(); + Properties p = getProperties(ps,"",cl); + //System.out.println(p); + + }catch(Exception e){ + e.printStackTrace(); + } + } + + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 9e91b7518..49d0a382c 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -64,12 +64,6 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL @Override public Properties execute(String module, String rpc, String version, String mode, Properties props) throws SvcLogicException { - return (execute(module, rpc, version, mode, props, null)); - } - - @Override - public Properties execute(String module, String rpc, String version, String mode, Properties props, - DOMDataBroker domDataBroker) throws SvcLogicException { SvcLogicGraph graph = store.fetch(module, rpc, version, mode); if (graph == null) { @@ -84,11 +78,18 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL ctx.setAttribute(CURRENT_GRAPH, graph.toString()); // To support legacy code we should not stop populating X-ECOMP-RequestID ctx.setAttribute("X-ECOMP-RequestID", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); - ctx.setDomDataBroker(domDataBroker); execute(graph, ctx); return (ctx.toProperties()); } + @Override + @Deprecated + // DomDataBroker is not being used, this should be removed eventually + public Properties execute(String module, String rpc, String version, String mode, Properties props, + DOMDataBroker domDataBroker) throws SvcLogicException { + return (execute(module, rpc, version, mode, props)); + } + @Override public SvcLogicStore getStore() throws SvcLogicException { // Create and initialize SvcLogicStore object - used to access diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToPropTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToPropTest.java new file mode 100644 index 000000000..50b7926a0 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToPropTest.java @@ -0,0 +1,142 @@ +/*- + 2 * ============LICENSE_START======================================================= + 3 * ONAP CCSDK + 4 * ================================================================================ + 5 * Copyright (C) 2019 AT&T Intellectual Property. All rights + 6 * reserved. + 7 * ================================================================================ + 8 * Licensed under the Apache License, Version 2.0 (the "License"); + 9 * you may not use this file except in compliance with the License. + 10 * You may obtain a copy of the License at + 11 * + 12 * http://www.apache.org/licenses/LICENSE-2.0 + 13 * + 14 * Unless required by applicable law or agreed to in writing, software + 15 * distributed under the License is distributed on an "AS IS" BASIS, + 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + 17 * See the License for the specific language governing permissions and + 18 * limitations under the License. + 19 * ============LICENSE_END============================================ + 20 * =================================================================== + 21 * + 22 */ +package org.onap.ccsdk.sli.core.sli.provider; + +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.provider.PrintYangToProp; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResultsBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResult; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.test.results.TestResultBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author dt5972 + * + */ +public class PrintYangToPropTest { + + private static final Logger LOG = LoggerFactory.getLogger(PrintYangToPropTest.class); + @Test + public void test() { + + Properties props = new Properties(); + + // Set up a builder with data + ExecuteGraphInputBuilder egBuilder = new ExecuteGraphInputBuilder(); + egBuilder.setMode(Mode.Sync); + egBuilder.setModuleName("my-module"); + egBuilder.setRpcName("my-rpc"); + + List pList = new LinkedList<>(); + + SliParameterBuilder pBuilder = new SliParameterBuilder(); + pBuilder.setParameterName("string-param"); + pBuilder.setStringValue("hi"); + pList.add(pBuilder.build()); + pBuilder.setParameterName("int-param"); + pBuilder.setIntValue(1); + pBuilder.setStringValue(null); + pList.add(pBuilder.build()); + pBuilder.setParameterName("bool-param"); + pBuilder.setIntValue(null); + pBuilder.setBooleanValue(true); + pList.add(pBuilder.build()); + pBuilder.setParameterName("ipaddress-value1"); + pBuilder.setBooleanValue(null); + pBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); + pList.add(pBuilder.build()); + pBuilder.setParameterName("ipaddress-value1"); + pBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("::1")); + pList.add(pBuilder.build()); + pBuilder.setParameterName("ipprefix-value1"); + pBuilder.setIpaddressValue(null); + pBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("192.168.0.0/16")); + pList.add(pBuilder.build()); + pBuilder.setParameterName("ipprefix-value2"); + pBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("2001:db8:3c4d::/48")); + pList.add(pBuilder.build()); + + + + egBuilder.setSliParameter(pList); + + + // Generate properties + props = PrintYangToProp.toProperties(props, egBuilder); + + Enumeration propNames = props.propertyNames(); + + while (propNames.hasMoreElements()) { + String propName = (String) propNames.nextElement(); + LOG.info("Property {} = {}", propName, props.getProperty(propName)); + } + + // Generate builder from properties just generated + PrintYangToProp.toBuilder(props, pBuilder); + + + } + + @Test + public void testWithList() { + TestResultsBuilder resultsBuilder = new TestResultsBuilder(); + TestResultBuilder resultBuilder = new TestResultBuilder(); + + // Set builder with values + List resultList = new LinkedList<>(); + resultBuilder.setTestIdentifier("test1"); + List results = new LinkedList<>(); + results.add("pass"); + resultBuilder.setResults(results); + resultList.add(resultBuilder.build()); + resultsBuilder.setTestResult(resultList); + + // Generate properties + Properties props = new Properties(); + props = PrintYangToProp.toProperties(props, resultsBuilder); + + Enumeration propNames = props.propertyNames(); + + while (propNames.hasMoreElements()) { + String propName = (String) propNames.nextElement(); + LOG.info("Property {} = {}", propName, props.getProperty(propName)); + } + + // Generate builder from properties just generated + PrintYangToProp.toBuilder(props, resultsBuilder); + + } + +} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 76862c499..f37f42ad6 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -17,20 +17,6 @@ ccsdk-sli-core :: sli :: ${project.artifactId} SLI Recording is an OSGi bundle that implements recording service for the service logic record node. - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - org.onap.ccsdk.sli.core @@ -38,43 +24,25 @@ ${project.version} compile - - org.osgi - org.osgi.core - provided - org.slf4j slf4j-api - - org.slf4j - jcl-over-slf4j - - commons-lang commons-lang compile - - - org.opendaylight.controller - sal-binding-api - - junit junit test - org.mockito mockito-core test - -- cgit 1.2.3-korg From 4a79f9d1e5066f9fafde81bf13004a61a4011fe7 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 17 Oct 2019 19:03:35 +0000 Subject: SliStringUtils additional functions in SliStringUtils added Issue-ID: CCSDK-1847 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I2e38258abe57d4fcd49cf226877cd38e9dd947d6 --- .../sli/core/slipluginutils/SliPluginUtils.java | 11 ++- .../sli/core/slipluginutils/SliStringUtils.java | 82 +++++++++++++++------- .../SliPluginUtils_StaticFunctionsTest.java | 21 +++++- .../core/slipluginutils/SliStringUtilsTest.java | 68 +++++++++++++++++- 4 files changed, 153 insertions(+), 29 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index fd3364ca4..b8e88f652 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -39,8 +39,8 @@ import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.UUID; -import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -1110,4 +1110,13 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { return changeFlag; } + public static String containsKey(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + String key = parameters.get("key"); + Boolean keyFound = ctx.getAttributeKeySet().contains(key); + if (keyFound) { + return "true"; + } + return "false"; + } + } diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index 888ef8834..269c3766c 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -39,10 +39,12 @@ import org.slf4j.LoggerFactory; */ public class SliStringUtils implements SvcLogicJavaPlugin { private static final Logger LOG = LoggerFactory.getLogger(SliStringUtils.class); - + public static final String INPUT_PARAM_KEY = "key"; public static final String INPUT_PARAM_SOURCE = "source"; public static final String INPUT_PARAM_TARGET = "target"; - + public static final String TRUE_CONSTANT = "true"; + public static final String FALSE_CONSTANT = "false"; + public SliStringUtils() {} /** @@ -125,11 +127,11 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static String equalsIgnoreCase(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"target"}, LOG); - if(parameters.get(INPUT_PARAM_SOURCE).equalsIgnoreCase(parameters.get("target"))){ - return "true"; + SliPluginUtils.checkParameters(parameters, new String[] {INPUT_PARAM_SOURCE, INPUT_PARAM_TARGET}, LOG); + if (parameters.get(INPUT_PARAM_SOURCE).equalsIgnoreCase(parameters.get(INPUT_PARAM_TARGET))) { + return TRUE_CONSTANT; } - return "false"; + return FALSE_CONSTANT; } /** @@ -189,11 +191,11 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static String contains(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"target"}, LOG); - if(parameters.get(INPUT_PARAM_SOURCE).contains(parameters.get("target"))){ - return "true"; + SliPluginUtils.checkParameters(parameters, new String[] {INPUT_PARAM_SOURCE, INPUT_PARAM_TARGET}, LOG); + if (parameters.get(INPUT_PARAM_SOURCE).contains(parameters.get(INPUT_PARAM_TARGET))) { + return TRUE_CONSTANT; } - return "false"; + return FALSE_CONSTANT; } /** @@ -213,11 +215,11 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static String endsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"target"}, LOG); - if(parameters.get(INPUT_PARAM_SOURCE).endsWith(parameters.get("target"))){ - return "true"; + SliPluginUtils.checkParameters(parameters, new String[] {INPUT_PARAM_SOURCE, INPUT_PARAM_TARGET}, LOG); + if (parameters.get(INPUT_PARAM_SOURCE).endsWith(parameters.get(INPUT_PARAM_TARGET))) { + return TRUE_CONSTANT; } - return "false"; + return FALSE_CONSTANT; } /** @@ -237,11 +239,11 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static String startsWith(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"target"}, LOG); - if(parameters.get(INPUT_PARAM_SOURCE).startsWith(parameters.get("target"))){ - return "true"; + SliPluginUtils.checkParameters(parameters, new String[] {INPUT_PARAM_SOURCE, INPUT_PARAM_TARGET}, LOG); + if (parameters.get(INPUT_PARAM_SOURCE).startsWith(parameters.get(INPUT_PARAM_TARGET))) { + return TRUE_CONSTANT; } - return "false"; + return FALSE_CONSTANT; } /** @@ -302,8 +304,10 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void replace(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"outputPath","target","replacement"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), (parameters.get(INPUT_PARAM_SOURCE).replace(parameters.get("target"), parameters.get("replacement")))); + SliPluginUtils.checkParameters(parameters, + new String[] {INPUT_PARAM_SOURCE, "outputPath", INPUT_PARAM_TARGET, "replacement"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), (parameters.get(INPUT_PARAM_SOURCE) + .replace(parameters.get(INPUT_PARAM_TARGET), parameters.get("replacement")))); } /** @@ -324,8 +328,10 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void replaceAll(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[]{INPUT_PARAM_SOURCE,"outputPath","target","replacement"}, LOG); - ctx.setAttribute(parameters.get("outputPath"), parameters.get(INPUT_PARAM_SOURCE).replaceAll(parameters.get("target"), parameters.get("replacement"))); + SliPluginUtils.checkParameters(parameters, + new String[] {INPUT_PARAM_SOURCE, "outputPath", INPUT_PARAM_TARGET, "replacement"}, LOG); + ctx.setAttribute(parameters.get("outputPath"), parameters.get(INPUT_PARAM_SOURCE) + .replaceAll(parameters.get(INPUT_PARAM_TARGET), parameters.get("replacement"))); } /** @@ -385,8 +391,9 @@ public class SliStringUtils implements SvcLogicJavaPlugin { * @since 11.0.2 */ public static void concat( Map parameters, SvcLogicContext ctx ) throws SvcLogicException { - SliPluginUtils.checkParameters( parameters, new String[]{INPUT_PARAM_SOURCE,"target","outputPath"}, LOG ); - String result = parameters.get(INPUT_PARAM_SOURCE).concat(parameters.get("target")); + SliPluginUtils.checkParameters(parameters, new String[] {INPUT_PARAM_SOURCE, INPUT_PARAM_TARGET, "outputPath"}, + LOG); + String result = parameters.get(INPUT_PARAM_SOURCE).concat(parameters.get(INPUT_PARAM_TARGET)); ctx.setAttribute(parameters.get("outputPath"), result); } @@ -475,4 +482,31 @@ public class SliStringUtils implements SvcLogicJavaPlugin { throw new SvcLogicException("problem with escapeJsonString", ex); } } + + public static String isBlank(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + String ctxLocation = parameters.get(INPUT_PARAM_KEY); + String str = ctx.getAttribute(ctxLocation); + if (str == null || str.isEmpty() || " ".equals(str)) { + return TRUE_CONSTANT; + } + return FALSE_CONSTANT; + } + + public static String isEmpty(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + String ctxLocation = parameters.get(INPUT_PARAM_KEY); + String str = ctx.getAttribute(ctxLocation); + if (str == null || str.isEmpty()) { + return TRUE_CONSTANT; + } + return FALSE_CONSTANT; + } + + public static String isNull(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + String ctxLocation = parameters.get(INPUT_PARAM_KEY); + String str = ctx.getAttribute(ctxLocation); + if (str == null) { + return TRUE_CONSTANT; + } + return FALSE_CONSTANT; + } } diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java index 774aa1c84..08adc9731 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java @@ -24,10 +24,8 @@ package org.onap.ccsdk.sli.core.slipluginutils; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; - import java.util.HashMap; import java.util.Map; - import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -247,4 +245,23 @@ public class SliPluginUtils_StaticFunctionsTest { SliPluginUtils.setTime(parameters, ctx); assertNotNull(ctx.getAttribute(outputPath)); } + + @Test + public void containsKey() throws Exception { + ctx = new SvcLogicContext(); + parameters.put(SliStringUtils.INPUT_PARAM_KEY, "key_does_not_exist"); + String result = SliPluginUtils.containsKey(parameters, ctx); + assertEquals(SliStringUtils.FALSE_CONSTANT, result); + + ctx.setAttribute("a", null); + parameters.put(SliStringUtils.INPUT_PARAM_KEY, "a"); + result = SliPluginUtils.containsKey(parameters, ctx); + assertEquals(SliStringUtils.FALSE_CONSTANT, result); + + ctx.setAttribute("a", "hellworld"); + parameters.put(SliStringUtils.INPUT_PARAM_KEY, "a"); + result = SliPluginUtils.containsKey(parameters, ctx); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + } + } diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index b88e8d2c9..d8d78a0b1 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -26,10 +26,8 @@ package org.onap.ccsdk.sli.core.slipluginutils; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; - import java.util.HashMap; import java.util.Map; - import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -317,4 +315,70 @@ public class SliStringUtilsTest { assertEquals("{\\\"image_name\\\":\\\"Ubuntu 14.04\\\",\\\"service-instance-id\\\":\\\"1\\\",\\\"vnf-model-customization-uuid\\\":\\\"2f\\\",\\\"vnf-id\\\":\\\"3b\\\"}", ctx.getAttribute(outputPath)); } + @Test + public void isEmpty() throws Exception { + ctx = new SvcLogicContext(); + param = new HashMap<>(); + String result = SliStringUtils.isEmpty(param, ctx); + param.put(SliStringUtils.INPUT_PARAM_KEY, "key_does_not_exist"); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + + ctx.setAttribute("a", null); + param.put(SliStringUtils.INPUT_PARAM_KEY, "a"); + result = SliStringUtils.isEmpty(param, ctx); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + + ctx.setAttribute("a", ""); + result = SliStringUtils.isEmpty(param, ctx); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + + ctx.setAttribute("a", " "); + result = SliStringUtils.isEmpty(param, ctx); + assertEquals(SliStringUtils.FALSE_CONSTANT, result); + } + + @Test + public void isBlank() throws Exception { + ctx = new SvcLogicContext(); + param = new HashMap<>(); + String result = SliStringUtils.isBlank(param, ctx); + param.put(SliStringUtils.INPUT_PARAM_KEY, "key_does_not_exist"); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + + ctx.setAttribute("a", null); + param.put(SliStringUtils.INPUT_PARAM_KEY, "a"); + result = SliStringUtils.isBlank(param, ctx); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + + ctx.setAttribute("a", ""); + result = SliStringUtils.isBlank(param, ctx); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + + ctx.setAttribute("a", " "); + result = SliStringUtils.isBlank(param, ctx); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + } + + @Test + public void isNull() throws Exception { + ctx = new SvcLogicContext(); + param = new HashMap<>(); + String result = SliStringUtils.isNull(param, ctx); + param.put(SliStringUtils.INPUT_PARAM_KEY, "key_does_not_exist"); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + + ctx.setAttribute("a", null); + param.put(SliStringUtils.INPUT_PARAM_KEY, "a"); + result = SliStringUtils.isNull(param, ctx); + assertEquals(SliStringUtils.TRUE_CONSTANT, result); + + ctx.setAttribute("a", ""); + result = SliStringUtils.isNull(param, ctx); + assertEquals(SliStringUtils.FALSE_CONSTANT, result); + + ctx.setAttribute("a", " "); + result = SliStringUtils.isNull(param, ctx); + assertEquals(SliStringUtils.FALSE_CONSTANT, result); + } + } -- cgit 1.2.3-korg From c9bf82b628b7d3f5f21f153538f950ac9a7d1294 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 17 Oct 2019 19:15:42 +0000 Subject: remove EncShellCommand remove EncShellCommand to separate dblib from karaf and odl Issue-ID: CCSDK-1848 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: If43abeceb556b4075d2866a18b8c9e92765e14a2 --- dblib/provider/pom.xml | 18 -------- .../sli/core/dblib/DBLIBResourceProvider.java | 49 ---------------------- .../onap/ccsdk/sli/core/dblib/EncShellCommand.java | 48 --------------------- .../OSGI-INF/blueprint/dblib-blueprint.xml | 6 --- .../ccsdk/sli/core/dblib/EncShellCommandTest.java | 41 ------------------ 5 files changed, 162 deletions(-) delete mode 100755 dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/EncShellCommand.java delete mode 100644 dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index a3bd00f3a..0af382506 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -15,11 +15,6 @@ bundle ccsdk-sli-core :: dblib :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - @@ -32,19 +27,10 @@ mariaDB4j test - - org.osgi - org.osgi.core - provided - org.slf4j slf4j-api - - org.slf4j - jcl-over-slf4j - org.slf4j slf4j-simple @@ -74,9 +60,5 @@ mockito-core test - - org.apache.karaf.shell - org.apache.karaf.shell.console - diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java index 6d36d6389..45e5a7870 100755 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBLIBResourceProvider.java @@ -23,19 +23,14 @@ package org.onap.ccsdk.sli.core.dblib; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.lang.reflect.Method; import java.util.Optional; import java.util.Properties; import java.util.Vector; - import org.onap.ccsdk.sli.core.utils.JREFileResolver; import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -99,20 +94,6 @@ public class DBLIBResourceProvider { try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { properties = new Properties(); properties.load(fileInputStream); - - if(properties.containsKey(DBLIB_PROPERTY_NAME)) { - String sensitive = properties.getProperty(DBLIB_PROPERTY_NAME); - if(sensitive != null && sensitive.startsWith("ENC:")) { - try { - sensitive = sensitive.substring(4); - String postsense = decrypt(sensitive); - properties.setProperty(DBLIB_PROPERTY_NAME, postsense); - } catch(Exception exc) { - LOG.error("Failed to translate property", exc); - } - } - } - } catch (final IOException e) { LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), new DblibConfigurationException("Failed to load properties for file: " @@ -121,36 +102,6 @@ public class DBLIBResourceProvider { } } - /** - * - * @param value - * @return decrypted string if successful or the original value if unsuccessful - */ - private String decrypt(String value) { - try { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - - ServiceReference sref = bctx.getServiceReference("org.opendaylight.aaa.encrypt.AAAEncryptionService"); - if(sref == null) { - LOG.warn("Could not acquire service reference for 'org.opendaylight.aaa.encrypt.AAAEncryptionService'"); - return value; - } - Object encrSvc = bctx.getService(sref); - if(encrSvc == null) { - LOG.warn("Could not access service for 'org.opendaylight.aaa.encrypt.AAAEncryptionService'"); - return value; - } - - Method gs2Method = encrSvc.getClass().getMethod("decrypt", new Class[] { "".getClass() }); - Object unmasked = gs2Method.invoke(encrSvc, new Object[] { value }); - return unmasked.toString(); - - } catch (Exception exc) { - LOG.error("Failure", exc); - return value; - } - } - /** * Extract db config properties. * diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/EncShellCommand.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/EncShellCommand.java deleted file mode 100755 index eaa5700c9..000000000 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/EncShellCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib; - -import java.lang.reflect.Method; - -/** - * https://karaf.apache.org/manual/latest-2.x/developers-guide/extending-console.html - * https://github.com/apache/karaf/tree/master/shell/console/src/main/java/org/apache/felix/gogo/commands - */ -import org.apache.karaf.shell.commands.Argument; -import org.apache.karaf.shell.commands.Command; -import org.apache.karaf.shell.console.OsgiCommandSupport; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Command(scope = "dblib", name = "encode", description="Says hello") -public class EncShellCommand extends OsgiCommandSupport { - private static Logger LOGGER = LoggerFactory.getLogger(EncShellCommand.class); - - @Argument(index = 0, name = "arg", description = "The command argument", required = true, multiValued = false) - String arg = null; - - @Override - protected Object doExecute() throws Exception { - System.out.println(String.format("Original value: %s", arg)); - System.out.println(String.format("Encrypted value: %s", encrypt(arg))); - return null; - } - - private String encrypt(String value) { - try { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - - ServiceReference sref = bctx.getServiceReference("org.opendaylight.aaa.encrypt.AAAEncryptionService"); - Object encrSvc = bctx.getService(sref); - - Method gs2Method = encrSvc.getClass().getMethod("encrypt", new Class[] { "".getClass() }); - Object unmasked = gs2Method.invoke(encrSvc, new Object[] { value }); - return String.format("ENC:%s", unmasked.toString()); - - } catch (Exception exc) { - LOGGER.error("Failure", exc); - return value; - } - } -} \ No newline at end of file diff --git a/dblib/provider/src/main/resources/OSGI-INF/blueprint/dblib-blueprint.xml b/dblib/provider/src/main/resources/OSGI-INF/blueprint/dblib-blueprint.xml index d9bb99c07..f1d5166db 100755 --- a/dblib/provider/src/main/resources/OSGI-INF/blueprint/dblib-blueprint.xml +++ b/dblib/provider/src/main/resources/OSGI-INF/blueprint/dblib-blueprint.xml @@ -15,10 +15,4 @@ - - - - - - \ No newline at end of file diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java deleted file mode 100644 index 740e69dba..000000000 --- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.onap.ccsdk.sli.core.dblib; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.Arrays; - -import static org.junit.Assert.*; - -public class EncShellCommandTest { - - private final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); - private final ByteArrayOutputStream errContent = new ByteArrayOutputStream(); - private final PrintStream originalOut = System.out; - private final PrintStream originalErr = System.err; - - @Before - public void setUp() { - System.setOut(new PrintStream(outContent)); - System.setErr(new PrintStream(errContent)); - } - - @After - public void tearDown() { - System.setOut(originalOut); - System.setErr(originalErr); - } - - @Test - public void testDoExecute() throws Exception { - String expected = "Original value: test" + System.getProperty("line.separator") + - "Encrypted value: test"; - EncShellCommand encShellCommand = new EncShellCommand(); - encShellCommand.arg = "test"; - encShellCommand.doExecute(); - assertEquals(expected.trim(), outContent.toString().trim()); - } -} \ No newline at end of file -- cgit 1.2.3-korg From 49a41adb9f709485ed259a6a4603f3adad1324e2 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 31 Oct 2019 14:36:33 +0000 Subject: pom updates inherit version for org.onap.logging-analytics artifacts Issue-ID: CCSDK-1882 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I9ab3e996f5f951dae8a00c9c7cf6fcd054905146 --- filters/provider/pom.xml | 1 - sli/common/pom.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index a5a6379e9..2215f44c9 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -20,7 +20,6 @@ org.onap.logging-analytics logging-filter-base - 1.5.0 javax.servlet diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 2166760de..2c6680a79 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -56,7 +56,6 @@ org.onap.logging-analytics logging-slf4j - 1.5.0 -- cgit 1.2.3-korg From 0f166dd572d7124ea9c46c97b6a1caf6c231d9a6 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 1 Nov 2019 14:38:49 +0000 Subject: SliProviderBaseUpdates SvcLogicServiceImplBase constructor should have SvcLogicResolver as a parameter,Added HashMapResolver to map svclogic instances without osgi,Added InMemorySvcLogicStore useful for simple demos or junit test Issue-ID: CCSDK-1891 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I3c3cdd33177ef10133db2672ddd4b308becefc90 --- artifacts/pom.xml | 5 ++ .../core/sli/provider/base/HashMapResolver.java | 52 +++++++++++++++++ .../sli/provider/base/InMemorySvcLogicStore.java | 66 ++++++++++++++++++++++ .../sli/provider/base/SvcLogicServiceImplBase.java | 42 +++++++------- .../sli/provider/base/ExecuteNodeExecutorTest.java | 9 +-- .../sli/provider/base/HashMapResolverTest.java | 51 +++++++++++++++++ .../provider/base/InMemorySvcLogicStoreTest.java | 35 ++++++++++++ .../sli/core/sli/provider/SvcLogicServiceImpl.java | 31 +--------- 8 files changed, 234 insertions(+), 57 deletions(-) create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolver.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStore.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolverTest.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStoreTest.java diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 1f0781b63..32d1ef737 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -146,6 +146,11 @@ utils-installer ${project.version} + + org.onap.ccsdk.sli.core + sli-recording + ${project.version} + diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolver.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolver.java new file mode 100644 index 000000000..d33312784 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolver.java @@ -0,0 +1,52 @@ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import java.util.HashMap; +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; + +public class HashMapResolver implements SvcLogicResolver { + Map svcLogicResourceMap = new HashMap(); + Map svcLogicJavaPluginMap = new HashMap(); + Map adaptorMap = new HashMap(); + Map recorderMap = new HashMap(); + + @Override + public SvcLogicResource getSvcLogicResource(String resourceName) { + return svcLogicResourceMap.get(resourceName); + } + + @Override + public SvcLogicRecorder getSvcLogicRecorder(String recorderName) { + return recorderMap.get(recorderName); + } + + @Override + public SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) { + return svcLogicJavaPluginMap.get(pluginName); + } + + @Override + public SvcLogicAdaptor getSvcLogicAdaptor(String adaptorName) { + return adaptorMap.get(adaptorName); + } + + public void addSvcLogicAdaptor(String adaptorName, SvcLogicAdaptor adaptor) { + adaptorMap.put(adaptorName, adaptor); + } + + public void addSvcLogicRecorder(String recorderName, SvcLogicRecorder recorder) { + recorderMap.put(recorderName, recorder); + } + + public void addSvcLogicSvcLogicJavaPlugin(String pluginName, SvcLogicJavaPlugin plugin) { + svcLogicJavaPluginMap.put(pluginName, plugin); + } + + public void addSvcLogicResource(String resourceName, SvcLogicResource resource) { + svcLogicResourceMap.put(resourceName, resource); + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStore.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStore.java new file mode 100644 index 000000000..ddf464fe7 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStore.java @@ -0,0 +1,66 @@ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class InMemorySvcLogicStore implements SvcLogicStore { + private static final Logger logger = LoggerFactory.getLogger(InMemorySvcLogicStore.class); + public Map graphStore; + + public InMemorySvcLogicStore() { + graphStore = new HashMap(); + } + + @Override + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException { + String storeId = new String(module + ":" + rpc); + return graphStore.containsKey(storeId); + } + + @Override + public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException { + String storeId = new String(module + ":" + rpc); + return graphStore.get(storeId); + } + + @Override + public void store(SvcLogicGraph graph) throws SvcLogicException { + if (graph != null) { + String storeId = new String(graph.getModule() + ":" + graph.getRpc()); + graphStore.put(storeId, graph); + logger.info(graph.toString() + " stored in InMemorySvcLogicStore."); + } + } + + @Override + public void init(Properties props) throws SvcLogicException { + // noop + } + + @Override + public void delete(String module, String rpc, String version, String mode) throws SvcLogicException { + String storeId = new String(module + ":" + rpc); + if (graphStore.containsKey(storeId)) { + graphStore.remove(storeId); + } + } + + @Override + public void activate(SvcLogicGraph graph) throws SvcLogicException { + // noop + } + + @Override + public void activate(String module, String rpc, String version, String mode) throws SvcLogicException { + // noop + } + +} diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java index 361ca708a..80d992f28 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java @@ -26,14 +26,13 @@ package org.onap.ccsdk.sli.core.sli.provider.base; import java.util.HashMap; import java.util.Map; import java.util.Properties; - import org.onap.ccsdk.sli.core.sli.ExitNodeException; -import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -72,8 +71,9 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { protected SvcLogicStore store; protected static final String CURRENT_GRAPH="currentGraph"; - public SvcLogicServiceImplBase(SvcLogicStore store) { + public SvcLogicServiceImplBase(SvcLogicStore store, SvcLogicResolver resolver) { this.store = store; + this.resolver = resolver; } protected void registerExecutors() { @@ -140,25 +140,25 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { } @Override - public Properties execute(String module, String rpc, String version, String mode, Properties props) - throws SvcLogicException { - LOG.info("Fetching service logic from data store"); - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - - if (graph == null) { - Properties retProps = new Properties(); - retProps.setProperty("error-code", "401"); - retProps.setProperty("error-message", - "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]"); - return (retProps); - } + public Properties execute(String module, String rpc, String version, String mode, Properties props) + throws SvcLogicException { + SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + + if (graph == null) { + Properties retProps = new Properties(); + retProps.setProperty("error-code", "401"); + retProps.setProperty("error-message", + "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]"); + return (retProps); + } - SvcLogicContext ctx = new SvcLogicContext(props); - ctx.setAttribute(CURRENT_GRAPH, graph.toString()); - ctx.setAttribute("X-ECOMP-RequestID", MDC.get("X-ECOMP-RequestID")); - execute(graph, ctx); - return (ctx.toProperties()); - } + SvcLogicContext ctx = new SvcLogicContext(props); + ctx.setAttribute(CURRENT_GRAPH, graph.toString()); + // To support legacy code we should not stop populating X-ECOMP-RequestID + ctx.setAttribute("X-ECOMP-RequestID", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); + execute(graph, ctx); + return (ctx.toProperties()); + } @Override public SvcLogicStore getStore() throws SvcLogicException { diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java index 474136d5b..9a929387f 100644 --- a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutorTest.java @@ -21,9 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; -import java.util.Map.Entry; import java.util.Properties; - import org.onap.ccsdk.sli.core.sli.DuplicateValueException; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -31,10 +29,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; -import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; - import junit.framework.TestCase; public class ExecuteNodeExecutorTest extends TestCase { @@ -63,7 +57,8 @@ public class ExecuteNodeExecutorTest extends TestCase { }; - execute.execute(new SvcLogicServiceImplBase(null), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext()); + execute.execute(new SvcLogicServiceImplBase(null, null), new SvcLogicNode(0, "", "", new SvcLogicGraph()), + new SvcLogicContext()); } } diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolverTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolverTest.java new file mode 100644 index 000000000..5a2140696 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/HashMapResolverTest.java @@ -0,0 +1,51 @@ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import static org.junit.Assert.assertNotNull; +import org.junit.Rule; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; + +public class HashMapResolverTest { + @Mock + SvcLogicResource myResource; + + @Mock + SvcLogicRecorder myRecorder; + + @Mock + SvcLogicJavaPlugin myJavaPlugin; + + @Mock + SvcLogicAdaptor myAdaptor; + + @Rule + public MockitoRule mockitoRule = MockitoJUnit.rule(); + + @Test + public void simpleTest() throws Exception { + + HashMapResolver resolver = new HashMapResolver(); + String resourceKey = "simple.resource"; + String recorderKey = "simple.record"; + String pluginKey = "simple.plugin"; + String adaptorKey = "simple.adaptor"; + + resolver.addSvcLogicAdaptor(adaptorKey, myAdaptor); + resolver.addSvcLogicRecorder(recorderKey, myRecorder); + resolver.addSvcLogicResource(resourceKey, myResource); + resolver.addSvcLogicSvcLogicJavaPlugin(pluginKey, myJavaPlugin); + + assertNotNull(resolver.getSvcLogicAdaptor(adaptorKey)); + assertNotNull(resolver.getSvcLogicJavaPlugin(pluginKey)); + assertNotNull(resolver.getSvcLogicRecorder(recorderKey)); + assertNotNull(resolver.getSvcLogicResource(resourceKey)); + + + } +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStoreTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStoreTest.java new file mode 100644 index 000000000..5f8757aa2 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/InMemorySvcLogicStoreTest.java @@ -0,0 +1,35 @@ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import java.util.Properties; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; + +public class InMemorySvcLogicStoreTest { + @Test + public void simpleTest() throws Exception { + InMemorySvcLogicStore store = new InMemorySvcLogicStore(); + store.init(new Properties()); + SvcLogicGraph graph = new SvcLogicGraph(); + String module = "TEST"; + String rpc = "NOTIFICATION"; + String mode = "sync"; + String version = "1"; + + graph.setModule(module); + graph.setRpc(rpc); + graph.setMode(mode); + graph.setVersion(version); + + store.store(graph); + assertTrue(store.hasGraph(module, rpc, version, mode)); + assertNotNull(store.fetch(module, rpc, version, mode)); + store.activate(graph); + store.activate(module, rpc, version, mode); + + store.delete(module, rpc, version, mode); + assertNull(store.fetch(module, rpc, version, mode)); + } +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 49d0a382c..92c2aa49a 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -26,20 +26,16 @@ package org.onap.ccsdk.sli.core.sli.provider; import java.util.Properties; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; 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.sli.provider.base.SvcLogicServiceImplBase; -import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.MDC; public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService { @@ -47,41 +43,18 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, SvcLogicResolver resolver) throws SvcLogicException { - super(null); - this.resolver = resolver; + super(null, resolver); properties = resourceProvider.getProperties(); this.store = getStore(); } public SvcLogicServiceImpl(SvcLogicPropertiesProvider resourceProvider, DbLibService dbSvc, SvcLogicResolver resolver) throws SvcLogicException { - super(null); - this.resolver = resolver; + super(null, resolver); properties = resourceProvider.getProperties(); this.store = new SvcLogicDblibStore(dbSvc); } - @Override - public Properties execute(String module, String rpc, String version, String mode, Properties props) - throws SvcLogicException { - SvcLogicGraph graph = store.fetch(module, rpc, version, mode); - - if (graph == null) { - Properties retProps = new Properties(); - retProps.setProperty("error-code", "401"); - retProps.setProperty("error-message", - "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]"); - return (retProps); - } - - SvcLogicContext ctx = new SvcLogicContext(props); - ctx.setAttribute(CURRENT_GRAPH, graph.toString()); - // To support legacy code we should not stop populating X-ECOMP-RequestID - ctx.setAttribute("X-ECOMP-RequestID", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); - execute(graph, ctx); - return (ctx.toProperties()); - } - @Override @Deprecated // DomDataBroker is not being used, this should be removed eventually -- cgit 1.2.3-korg From deac6fe2a23859c5cf9cf8c828045af5eff78868 Mon Sep 17 00:00:00 2001 From: "Agarwal, Ruchira (ra1926)" Date: Tue, 5 Nov 2019 19:50:30 +0000 Subject: minor updates to clean up code clean up code to sync with internal Issue-ID: CCSDK-1873 Signed-off-by: Agarwal, Ruchira (ra1926) Change-Id: I1043e3f34176aebf2531bf0581b207694264d6f2 --- .../onap/ccsdk/sli/core/dblib/config/DbConfigPool.java | 11 +++++++++-- .../org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java index 6cb1d9c33..ea7b3fdc8 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java @@ -27,14 +27,21 @@ import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * @version $Revision: 1.15 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ public class DbConfigPool { - private static Logger log = LoggerFactory.getLogger(DbConfigPool.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DbConfigPool.class); private final String type; private static final int timeOut=0; private ArrayList configurations = new ArrayList<>(); public DbConfigPool(Properties properties) { - log.debug("Initializing DbConfigType"); + LOGGER.debug("Initializing DbConfigType"); type = properties.getProperty(BaseDBConfiguration.DATABASE_TYPE, "JDBC").toUpperCase(); } diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java index 454af02bb..f66250676 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java @@ -34,9 +34,16 @@ import java.util.concurrent.atomic.AtomicLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * @version $Revision: 1.15 $ + * Change Log + * Author Date Comments + * ============== ======== ==================================================== + * Rich Tabedzki + */ public class PollingWorker implements Runnable { - private Logger logger = LoggerFactory.getLogger(PollingWorker.class); + private static final Logger LOGGER = LoggerFactory.getLogger(PollingWorker.class); private static PollingWorker self = null; @@ -116,7 +123,7 @@ public class PollingWorker implements Runnable { consume((TestSample) next); } else { System.out.println(next.getClass().getName()); - logger.error(next.getClass().getName()); + LOGGER.error(next.getClass().getName()); } } try { @@ -152,7 +159,7 @@ public class PollingWorker implements Runnable { } sb.append(tmp2[i].get()).append("\t"); } - logger.info(sb.toString()); + LOGGER.info(sb.toString()); } class MyTimerTask extends TimerTask { @@ -191,8 +198,8 @@ public class PollingWorker implements Runnable { } /** - * @author Rich Tabedzki A helper class to pass measured parameter to the - * counter. + * @author Rich Tabedzki + * A helper class to pass measured parameter to the counter. */ static class TestSample implements Comparable { private long starttime; -- cgit 1.2.3-korg From 497c52275416d7920a77da11f030fa3adce7a310 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Sat, 9 Nov 2019 11:07:30 -0500 Subject: Minor Logging Changes Change-Id: I3ecefccbd1bd5041b9d9b62fe1a0587e72b26c8a Issue-ID: CCSDK-1915 Signed-off-by: Singal, Kapil (ks220y) --- .../base/AbstractSvcLogicNodeExecutor.java | 15 ++-- .../core/sli/provider/base/SetNodeExecutor.java | 3 +- .../provider/base/SvcLogicExpressionResolver.java | 96 +++++++++++----------- 3 files changed, 56 insertions(+), 58 deletions(-) diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java index 9bab745b1..031beba2a 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/AbstractSvcLogicNodeExecutor.java @@ -42,8 +42,8 @@ public abstract class AbstractSvcLogicNodeExecutor { public abstract SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException; private static final Logger LOG = LoggerFactory.getLogger(AbstractSvcLogicNodeExecutor.class); - protected static final String PARAMETER_DEBUG_PATTERN = "Parameter: {} resolves to: {} which came from the expression: {}"; - protected static final String SETTING_DEBUG_PATTERN = "Setting context attribute: {} to: {} which came from the expression: {}"; + protected static final String PARAMETER_DEBUG_PATTERN = "Parameter: ({}) resolves to: ({}) which came from the expression: ({})"; + protected static final String SETTING_DEBUG_PATTERN = "Setting context attribute: ({}) to: ({}) which came from the expression: ({})"; protected String evaluateNodeTest(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { @@ -97,7 +97,7 @@ public abstract class AbstractSvcLogicNodeExecutor { } return (nextNode); } - + protected Map getResolvedParameters(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException{ Map parmMap = new HashMap<>(); @@ -108,13 +108,14 @@ public abstract class AbstractSvcLogicNodeExecutor { .iterator(); iter.hasNext();) { Map.Entry curEnt = iter.next(); String curName = curEnt.getKey(); + SvcLogicExpression curExpr = curEnt.getValue(); String curExprValue = SvcLogicExpressionResolver.evaluate(curExpr, node, ctx); - LOG.trace(PARAMETER_DEBUG_PATTERN, curName, curExprValue, curExpr.toString()); - parmMap.put(curName,curExprValue); + LOG.trace(PARAMETER_DEBUG_PATTERN, curName, curExprValue, curExpr); + parmMap.put(curName, curExprValue); } - + return parmMap; } - + } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java index 89074362f..7e07d29bf 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SetNodeExecutor.java @@ -167,9 +167,8 @@ public class SetNodeExecutor extends AbstractSvcLogicNodeExecutor { } if (setValue) { String curValue = SvcLogicExpressionResolver.evaluate(curEnt.getValue(), node, ctx); - if (LOG.isDebugEnabled()) { - LOG.debug(SETTING_DEBUG_PATTERN, lhsVarName, curValue, curEnt.getValue().toString()); + LOG.debug(SETTING_DEBUG_PATTERN, lhsVarName, curValue, curEnt.getValue()); } ctx.setAttribute(lhsVarName, curValue); } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java index e3c0ef205..a3507947f 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicExpressionResolver.java @@ -10,9 +10,9 @@ * 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. @@ -44,7 +44,7 @@ public class SvcLogicExpressionResolver { private static final Logger LOG = LoggerFactory .getLogger(SvcLogicExpressionResolver.class); private static final String INVALID_EXPRESSION_MSG= "Invalid expression ("; - private static final String EXPRESSION_DEBUG_PATTERN = "Expression: {} resolves to {}: which has the value {}"; + private static final String EXPRESSION_DEBUG_PATTERN = "Expression: ({}) resolves to: (${}) which has the value: ({})"; public static String evaluate(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { @@ -62,30 +62,28 @@ public class SvcLogicExpressionResolver { return (atom.toString()); case CONTEXT_VAR: case IDENTIFIER: - + String varName = resolveVariableName(atom, node, ctx); - + if (atomType == AtomType.CONTEXT_VAR) { - String varValue = ctx.getAttribute(varName); - if (varValue == null) { - LOG.trace("Context variable $"+varName+" unset - treating as empty string"); + LOG.trace("Context variable: ($"+varName+") unset - treating as empty string"); varValue = ""; } - LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,varValue); + LOG.trace(EXPRESSION_DEBUG_PATTERN, expr, varName, varValue); return (varValue); } + SvcLogicExpression parm = node.getParameter(varName); - if (parm != null) { + if (parm != null) { String value = evaluate(parm, node, ctx); - LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,value); + LOG.trace(EXPRESSION_DEBUG_PATTERN, expr, varName, value); return value; } - else - { - LOG.trace(EXPRESSION_DEBUG_PATTERN,expr.toString(),varName,varName); + else { + LOG.trace(EXPRESSION_DEBUG_PATTERN, expr, varName, varName); return(varName); } default: @@ -152,7 +150,7 @@ public class SvcLogicExpressionResolver { if (operands.size() != (operators.size()+1)) { throw new SvcLogicException(INVALID_EXPRESSION_MSG+binExpr+")"); - } + } String retval = evaluate(operands.get(0), node, ctx); String retsval = retval; long retlval = 0; @@ -161,7 +159,7 @@ public class SvcLogicExpressionResolver { int i = 1; try { - + if ((retval.length() > 0) && StringUtils.isNumeric(retval)) { retlval = Long.parseLong(retval); @@ -202,7 +200,7 @@ public class SvcLogicExpressionResolver { { throw new SvcLogicException("Illegal value in arithmetic expression", e1); } - + if (valueIsLong) { return("" + retlval); @@ -211,33 +209,33 @@ public class SvcLogicExpressionResolver { { return(retsval); } - + } - + private static String evalCompareExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { List operators = expr.getOperators(); List operands = expr.getOperands(); - + if ((operators.size() != 1) || (operands.size() != 2)) { throw new SvcLogicException ("Invalid comparison expression : "+expr); } - + OperatorType operator = operators.get(0); String op1Value = evaluate(operands.get(0), node, ctx); String op2Value = evaluate(operands.get(1), node, ctx); - + if ((StringUtils.isNotEmpty(op1Value) && StringUtils.isNumeric(op1Value) && StringUtils.isNotEmpty(op2Value) && StringUtils.isNumeric(op2Value))) { try { double op1dbl = Double.parseDouble(op1Value); double op2dbl = Double.parseDouble(op2Value); - + switch(operator) { case equalOp: @@ -263,9 +261,9 @@ public class SvcLogicExpressionResolver { } else { - + int compResult = 0; - + if (op1Value == null) { compResult = -1; } else if (op2Value == null ) { @@ -273,7 +271,7 @@ public class SvcLogicExpressionResolver { } else { compResult = op1Value.compareToIgnoreCase(op2Value); } - + switch(operator) { case equalOp: @@ -292,21 +290,21 @@ public class SvcLogicExpressionResolver { return(null); } } - + } - + private static String evalLogicExpression(SvcLogicBinaryExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { boolean retval; - + List operands = expr.getOperands(); List operators = expr.getOperators(); - + if (operands.size() != (operators.size()+1)) { throw new SvcLogicException(INVALID_EXPRESSION_MSG+expr+")"); } - + try { retval = Boolean.parseBoolean(evaluate(operands.get(0), node, ctx)); @@ -322,26 +320,26 @@ public class SvcLogicExpressionResolver { retval = retval || Boolean.parseBoolean(evaluate(operands.get(i++), node, ctx)); } - + } } catch (Exception e) { throw new SvcLogicException(INVALID_EXPRESSION_MSG+expr+")"); } - - + + return(Boolean.toString(retval)); } - + private static String evalFunctionCall(SvcLogicFunctionCall func, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { String funcName = func.getFunctionName(); List operands = func.getOperands(); - + if ("length".equalsIgnoreCase(funcName)) { - + if (operands.size() == 1) { String opValue = evaluate(operands.get(0), node, ctx); @@ -359,12 +357,12 @@ public class SvcLogicExpressionResolver { String op1Value = evaluate(operands.get(0), node, ctx); String op2Value = evaluate(operands.get(1), node, ctx); String op3Value = evaluate(operands.get(2), node, ctx); - + if (!StringUtils.isNumeric(op2Value) || !StringUtils.isNumeric(op3Value)) { throw new SvcLogicException("Invalid arguments to substr() function"); } - + try { return(op1Value.substring(Integer.parseInt(op2Value), Integer.parseInt(op3Value))); @@ -379,7 +377,7 @@ public class SvcLogicExpressionResolver { throw new SvcLogicException("Invalid call to substr() function"); } - + } else if ("toUpperCase".equalsIgnoreCase(funcName)) { @@ -417,7 +415,7 @@ public class SvcLogicExpressionResolver { int fromBase = 10; int toBase = 10; String srcString = ""; - + if (operands.size() == 2) { fromBase = 10; @@ -431,7 +429,7 @@ public class SvcLogicExpressionResolver { } else { throw new SvcLogicException("Invalid call to convertBase() function"); } - + long srcValue = Long.parseLong(srcString, fromBase); return(Long.toString(srcValue, toBase)); } @@ -439,16 +437,16 @@ public class SvcLogicExpressionResolver { { throw new SvcLogicException("Unrecognized function ("+funcName+")"); } - + } - + public static String evaluateAsKey(SvcLogicExpression expr, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { if (expr == null) { return (null); } - + if (expr instanceof SvcLogicAtom) { SvcLogicAtom atom = (SvcLogicAtom) expr; @@ -478,7 +476,7 @@ public class SvcLogicExpressionResolver { varNameBuff.append("["); varNameBuff.append(evaluate(vterm.getSubscript(), node, ctx)); varNameBuff.append("]"); - + } } else @@ -502,7 +500,7 @@ public class SvcLogicExpressionResolver { { return("'"+ctxValue+"'"); } - + default: return(null); } @@ -570,11 +568,11 @@ public class SvcLogicExpressionResolver { throw new SvcLogicException("Unrecognized expression type ["+expr+"]"); } } - + public static String resolveVariableName(SvcLogicExpression atom, SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException { StringBuffer varNameBuff = new StringBuffer(); - + boolean needDot = false; for (SvcLogicExpression term : atom.getOperands()) { -- cgit 1.2.3-korg From e459ddf5433853a5263c8cb9415dab701822f6e7 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 13 Nov 2019 09:37:28 -0500 Subject: Use 1.5.0 parent pom Use released 1.5.0 version of parent pom Change-Id: I92e2f71000a7d651f6a20167dd3861942ea27ced Issue-ID: CCSDK-1920 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/ccsdk-slicore-utils/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 47 files changed, 47 insertions(+), 47 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 32d1ef737..b4a10e09f 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 7011202f2..8d7d56690 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index e24b0f0e2..d9458a82c 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 25ab61bed..3956234d5 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 175d9fb9f..3ea76a2cb 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/dblib/pom.xml b/dblib/pom.xml index 1a2dc28e9..a64261eb7 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 0af382506..34f74f318 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 3c49170a6..b683a6025 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index e622944e5..13c4444bd 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index e8957b42e..3eed2c44d 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/features/pom.xml b/features/pom.xml index fc439b278..16734cf09 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index 08462a70b..c39034b80 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index 3273ffea5..cdf38980a 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/filters/features/pom.xml b/filters/features/pom.xml index ff153c9df..4f9ad5f25 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 3428c1b11..7d5539b2f 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/filters/pom.xml b/filters/pom.xml index 8c2d560fd..dfbd1b496 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 2215f44c9..221187a19 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/pom.xml b/pom.xml index a199b7278..b6de5114a 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 2c6680a79..f007a8983 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index 4ccebf892..ef43a8d19 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index 2b770e288..f0b505260 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/features/pom.xml b/sli/features/pom.xml index 2c74aa8bd..ac43c3b8c 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 9685176b6..ba3484b7f 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 048ba51c1..b63f52396 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/pom.xml b/sli/pom.xml index e1da778f3..19a37b7c2 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 93f207199..00065b5c6 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 95099ed2f..2759592ce 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index f37f42ad6..b4fbd814a 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index 98ffac4e7..ba337e45f 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index ec1650f39..1954f3cb6 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index d6dad16a1..5a89503a6 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 74d26d3a8..49bc52118 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 90cd5f35a..a3fcb63a8 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index be068e7fc..9af666c2a 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 9425161d1..7944eb3c3 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index 67f1c7009..d503222b6 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 1f7d8a3ee..a291f554f 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 0f3f9de98..e2d10e290 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 2bf3a3917..bd6cb57ab 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index dc4734576..4b616e845 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index f845ae0f3..df4f6fee7 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 661a43443..9b5397374 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index 4441b4fbb..abfba334e 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 537f68a1a..1503aade2 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index e5bb6eb16..ba1a88931 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/utils/pom.xml b/utils/pom.xml index 8448296e7..c480ad2d4 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0-SNAPSHOT + 1.5.0 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 1f1922bda..05d31ca3f 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0-SNAPSHOT + 1.5.0 -- cgit 1.2.3-korg From 6228b819e9b8977a4ae13fda563970b62920ca5f Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 15 Nov 2019 14:54:24 -0500 Subject: Add new committers Kevin and Kapil Add new committers Kevin Smokowski and Kapil Singal Change-Id: I2cd5cf5a50b9927dfd7c3e752fb90758aac66f31 Issue-ID: CCSDK-1934 Signed-off-by: Timoney, Dan (dt5972) --- INFO.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/INFO.yaml b/INFO.yaml index 3b7c1dfa4..99fdfe923 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -49,6 +49,16 @@ committers: company: 'IBM' id: 'brindasanthm' timezone: 'America/New_York' + - name: 'Kevin Smokowski' + email: 'ks6305@att.com' + company: 'ATT' + id: 'nullop' + timezone: 'America/New_York' + - name: 'Kapil Singal' + email: 'kaggarwal@in.ibm.com' + company: 'IBM' + id: 'kasingal' + timezone: 'America/New_York' repositories: - ccsdk/sli/core tsc: @@ -63,3 +73,9 @@ tsc: - type: 'Addition' name: 'Brinda Santh Muthuramalingam' link: 'https://lists.onap.org/g/onap-tsc/message/5208' + - type: 'Addition' + name: 'Kevin Smokowski' + link: 'https://lists.onap.org/g/onap-tsc/message/5635' + - type: 'Addition' + name: 'Kapil Singal' + link: 'https://lists.onap.org/g/onap-tsc/message/5635' -- cgit 1.2.3-korg From 1721b898757fd7dfb3463055c7a436ceae06d5c4 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 15 Nov 2019 15:34:02 -0500 Subject: Fix merge build Added missing tag to correct build error Change-Id: I5bb431f52a6e0336cf1e55675955c1a9894da9a6 Issue-ID: CCSDK-1935 Signed-off-by: Timoney, Dan (dt5972) --- utils/features/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 1503aade2..0602c0415 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -11,6 +11,7 @@ org.onap.ccsdk.sli.core utils-features-aggregator + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} -- cgit 1.2.3-korg From 167fe4fd2b213b27f1fb802c26bd5aca62dd0f69 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 19 Nov 2019 12:41:26 -0500 Subject: Add id for Kapil Add Kapil's ATT id as committer Change-Id: I429f58b13c9e38e6522ce1b3733af1a7baa78321 Issue-ID: CCSDK-1934 Signed-off-by: Timoney, Dan (dt5972) --- INFO.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/INFO.yaml b/INFO.yaml index 99fdfe923..287a2a886 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -59,6 +59,11 @@ committers: company: 'IBM' id: 'kasingal' timezone: 'America/New_York' + - name: 'Kapil Singal' + email: 'ks220y@att.com' + company: 'IBM' + id: 'ks220y' + timezone: 'America/New_York' repositories: - ccsdk/sli/core tsc: -- cgit 1.2.3-korg From f6dde48113e1ee382272f4ece15573bfb03121c2 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Mon, 2 Dec 2019 11:09:18 -0500 Subject: Use 1.5.1-SNAPSHOT version of parent pom Fixed version of parent pom to use snapshot version Change-Id: I128d3b55d0ae3adb4a1255a9b00fc129a9c9bc44 Issue-ID: CCSDK-1935 Signed-off-by: Timoney, Dan (dt5972) --- artifacts/pom.xml | 2 +- dblib/features/ccsdk-dblib/pom.xml | 2 +- dblib/features/features-dblib/pom.xml | 2 +- dblib/features/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/features/ccsdk-filters/pom.xml | 2 +- filters/features/features-filters/pom.xml | 2 +- filters/features/pom.xml | 3 ++- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/features/features-sli/pom.xml | 2 +- sli/features/odl-sli/pom.xml | 2 +- sli/features/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/features-sliPluginUtils/pom.xml | 2 +- sliPluginUtils/features/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/features/ccsdk-sliapi/pom.xml | 2 +- sliapi/features/features-sliapi/pom.xml | 2 +- sliapi/features/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/features/ccsdk-slicore-utils/pom.xml | 2 +- utils/features/features-util/pom.xml | 2 +- utils/features/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 47 files changed, 48 insertions(+), 47 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index b4a10e09f..4b996f306 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml index 8d7d56690..883cd1d86 100644 --- a/dblib/features/ccsdk-dblib/pom.xml +++ b/dblib/features/ccsdk-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml index d9458a82c..72af77776 100644 --- a/dblib/features/features-dblib/pom.xml +++ b/dblib/features/features-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml index 3956234d5..9addcdb41 100755 --- a/dblib/features/pom.xml +++ b/dblib/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 3ea76a2cb..0c5204b9b 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/dblib/pom.xml b/dblib/pom.xml index a64261eb7..23284604a 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 34f74f318..1c836637d 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index b683a6025..242e6bb4e 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 13c4444bd..6c334f386 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 3eed2c44d..32c177882 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/features/pom.xml b/features/pom.xml index 16734cf09..6e500172e 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml index c39034b80..ebe15f856 100644 --- a/filters/features/ccsdk-filters/pom.xml +++ b/filters/features/ccsdk-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml index cdf38980a..7ae082028 100644 --- a/filters/features/features-filters/pom.xml +++ b/filters/features/features-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/filters/features/pom.xml b/filters/features/pom.xml index 4f9ad5f25..985e446f6 100755 --- a/filters/features/pom.xml +++ b/filters/features/pom.xml @@ -5,12 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT org.onap.ccsdk.sli.core filters-features-aggregator + 0.7.0-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 7d5539b2f..6bef4c19a 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/filters/pom.xml b/filters/pom.xml index dfbd1b496..4cd8c759e 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 221187a19..f315cedae 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/pom.xml b/pom.xml index b6de5114a..959dcbd03 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/common/pom.xml b/sli/common/pom.xml index f007a8983..3083a8ac5 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml index ef43a8d19..80c4102ff 100644 --- a/sli/features/features-sli/pom.xml +++ b/sli/features/features-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml index f0b505260..f810e43a6 100644 --- a/sli/features/odl-sli/pom.xml +++ b/sli/features/odl-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/features/pom.xml b/sli/features/pom.xml index ac43c3b8c..6970f268c 100644 --- a/sli/features/pom.xml +++ b/sli/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index ba3484b7f..937e54c5b 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/model/pom.xml b/sli/model/pom.xml index b63f52396..5f969b2e0 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/pom.xml b/sli/pom.xml index 19a37b7c2..895fae1fa 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 00065b5c6..214cbe94b 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 2759592ce..66717b7ff 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index b4fbd814a..f1094d099 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml index ba337e45f..032d78252 100644 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml index 1954f3cb6..eec15e64a 100644 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml index 5a89503a6..c43c18d6e 100755 --- a/sliPluginUtils/features/pom.xml +++ b/sliPluginUtils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 49bc52118..82ee5d186 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index a3fcb63a8..22b4bd90f 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 9af666c2a..cd9ffbd03 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 7944eb3c3..80180c5ab 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index d503222b6..2acfad7b4 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index a291f554f..448c9da41 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index e2d10e290..3dddd2062 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index bd6cb57ab..91f9eeefe 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 4b616e845..71bb22e64 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index df4f6fee7..d34c4e79c 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml index 9b5397374..ae54dcfd5 100644 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ b/utils/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml index abfba334e..6e26d1dca 100644 --- a/utils/features/features-util/pom.xml +++ b/utils/features/features-util/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/utils/features/pom.xml b/utils/features/pom.xml index 0602c0415..594c6e1e3 100755 --- a/utils/features/pom.xml +++ b/utils/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index ba1a88931..cbe0596a6 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/utils/pom.xml b/utils/pom.xml index c480ad2d4..a5529f314 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.0 + 1.5.1-SNAPSHOT diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 05d31ca3f..554cef0f0 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.0 + 1.5.1-SNAPSHOT -- cgit 1.2.3-korg From 16cb0dd6b9ebe62ee6cb03629d3529057c5d00d3 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Wed, 4 Dec 2019 11:08:46 -0500 Subject: Clean up installers Clean up installers to install only ONAP code, not third party dependencies. Third party dependencies should be installed in ccsdk/distribution/dependencies only. Change-Id: I3459d2d5a82899ad21b1b25daae6f6d182d972af Issue-ID: CCSDK-1979 Signed-off-by: Timoney, Dan (dt5972) --- dblib/installer/pom.xml | 12 ++---------- sli/installer/pom.xml | 14 +------------- sliPluginUtils/installer/pom.xml | 6 +----- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 0c5204b9b..bf19ba0eb 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -45,14 +45,6 @@ ${project.version} - - org.slf4j - jcl-over-slf4j - - - org.apache.tomcat - tomcat-jdbc - @@ -111,8 +103,8 @@ true false false - org.onap.ccsdk.sli.core,org.apache.tomcat,org.slf4j - utils-provider,slf4j-api + org.onap.ccsdk.sli.core + utils-provider provided diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 937e54c5b..866e9b03f 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -66,18 +66,6 @@ sli-recording ${project.version} - - com.att.eelf - eelf-core - - - ch.qos.logback - logback-core - - - ch.qos.logback - logback-classic - @@ -137,7 +125,7 @@ true false false - org.onap.ccsdk.sli.core,com.att.eelf,ch.qos.logback + org.onap.ccsdk.sli.core utils-provider,dblib-provider provided diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 82ee5d186..9d71a964f 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -66,10 +66,6 @@ ${project.version} - - org.apache.commons - commons-text - @@ -128,7 +124,7 @@ true false false - sliPluginUtils-provider,ccsdk-sliPluginUtils,features-sliPluginUtils,commons-text + sliPluginUtils-provider,ccsdk-sliPluginUtils,features-sliPluginUtils provided -- cgit 1.2.3-korg From 6fd84f1422338180459ca6442be96440f116da44 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 10 Dec 2019 09:56:35 -0500 Subject: Generate dependency list Generate list of direct dependencies for repository and publish to Nexus. Change-Id: Ibce710d925b127353a7ca502809514c286969350 Issue-ID: CCSDK-1986 Signed-off-by: Timoney, Dan (dt5972) --- .gitignore | 1 + pom.xml | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9244b48b3..92a91c226 100755 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ derby.log # Generated file sliPluginUtils/provider/testFileName +direct-dependencies.txt diff --git a/pom.xml b/pom.xml index 959dcbd03..2eafc4163 100755 --- a/pom.xml +++ b/pom.xml @@ -74,14 +74,56 @@ + + - + + dependency-list + + + + com.github.ferstl + depgraph-maven-plugin + + + validate + false + + aggregate + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + package + false + + attach-artifact + + + + + ${dependency-list.file} + txt + dependencies + + + + + + + - + ecomp-site -- cgit 1.2.3-korg From a55a4e30507c25c21c7f1df830f5d5189e03c038 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 13 Dec 2019 10:24:29 -0500 Subject: Refactor features to separate installer Refactor karaf feature.xml files to separate installer Change-Id: I2afade9862227175853d9fe36c5bc9b113e3d582 Issue-ID: CCSDK-1754 Signed-off-by: Timoney, Dan (dt5972) --- dblib/features/ccsdk-dblib/pom.xml | 64 ----------------- .../ccsdk-dblib/src/main/feature/feature.xml | 13 ---- dblib/features/features-dblib/pom.xml | 29 -------- dblib/features/pom.xml | 23 ------ dblib/installer/pom.xml | 14 ---- dblib/pom.xml | 1 - features/ccsdk-dblib/pom.xml | 64 +++++++++++++++++ features/ccsdk-dblib/src/main/feature/feature.xml | 13 ++++ features/ccsdk-filters/pom.xml | 46 ++++++++++++ features/ccsdk-sli/pom.xml | 61 ++++++++++++++++ features/ccsdk-sliPluginUtils/pom.xml | 37 ++++++++++ features/ccsdk-sliapi/pom.xml | 37 ++++++++++ features/ccsdk-slicore-utils/pom.xml | 29 ++++++++ features/installer/pom.xml | 81 +++++++++++++++++++++- features/pom.xml | 6 ++ filters/features/ccsdk-filters/pom.xml | 46 ------------ filters/features/features-filters/pom.xml | 29 -------- filters/features/pom.xml | 23 ------ filters/installer/pom.xml | 17 ----- filters/pom.xml | 1 - sli/features/features-sli/pom.xml | 29 -------- sli/features/odl-sli/pom.xml | 61 ---------------- sli/features/pom.xml | 23 ------ sli/installer/pom.xml | 14 ---- sli/pom.xml | 1 - .../features/ccsdk-sliPluginUtils/pom.xml | 37 ---------- .../features/features-sliPluginUtils/pom.xml | 29 -------- sliPluginUtils/features/pom.xml | 23 ------ sliPluginUtils/installer/pom.xml | 14 ---- sliPluginUtils/pom.xml | 1 - sliapi/features/ccsdk-sliapi/pom.xml | 37 ---------- sliapi/features/features-sliapi/pom.xml | 29 -------- sliapi/features/pom.xml | 23 ------ sliapi/pom.xml | 1 - utils/features/ccsdk-slicore-utils/pom.xml | 29 -------- utils/features/features-util/pom.xml | 29 -------- utils/features/pom.xml | 23 ------ utils/installer/pom.xml | 14 ---- utils/pom.xml | 1 - 39 files changed, 372 insertions(+), 680 deletions(-) delete mode 100644 dblib/features/ccsdk-dblib/pom.xml delete mode 100644 dblib/features/ccsdk-dblib/src/main/feature/feature.xml delete mode 100644 dblib/features/features-dblib/pom.xml delete mode 100755 dblib/features/pom.xml create mode 100644 features/ccsdk-dblib/pom.xml create mode 100644 features/ccsdk-dblib/src/main/feature/feature.xml create mode 100644 features/ccsdk-filters/pom.xml create mode 100644 features/ccsdk-sli/pom.xml create mode 100644 features/ccsdk-sliPluginUtils/pom.xml create mode 100644 features/ccsdk-sliapi/pom.xml create mode 100644 features/ccsdk-slicore-utils/pom.xml delete mode 100644 filters/features/ccsdk-filters/pom.xml delete mode 100644 filters/features/features-filters/pom.xml delete mode 100755 filters/features/pom.xml delete mode 100644 sli/features/features-sli/pom.xml delete mode 100644 sli/features/odl-sli/pom.xml delete mode 100644 sli/features/pom.xml delete mode 100644 sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml delete mode 100644 sliPluginUtils/features/features-sliPluginUtils/pom.xml delete mode 100755 sliPluginUtils/features/pom.xml delete mode 100644 sliapi/features/ccsdk-sliapi/pom.xml delete mode 100644 sliapi/features/features-sliapi/pom.xml delete mode 100755 sliapi/features/pom.xml delete mode 100644 utils/features/ccsdk-slicore-utils/pom.xml delete mode 100644 utils/features/features-util/pom.xml delete mode 100755 utils/features/pom.xml diff --git a/dblib/features/ccsdk-dblib/pom.xml b/dblib/features/ccsdk-dblib/pom.xml deleted file mode 100644 index 883cd1d86..000000000 --- a/dblib/features/ccsdk-dblib/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-dblib - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: dblib :: ${project.artifactId} - - - - - - ${project.groupId} - dblib-provider - ${project.version} - - - - org.mariadb.jdbc - mariadb-java-client - - - org.apache.tomcat - tomcat-jdbc - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - - - - org.apache.derby - derby - - - - - - - org.apache.karaf.tooling - karaf-maven-plugin - true - - - slf4j-api - tomcat-jdbc - tomcat-juli - - - - - - diff --git a/dblib/features/ccsdk-dblib/src/main/feature/feature.xml b/dblib/features/ccsdk-dblib/src/main/feature/feature.xml deleted file mode 100644 index 771c37455..000000000 --- a/dblib/features/ccsdk-dblib/src/main/feature/feature.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - -
    Root POM to be used in place of odlparent for CCSDK based projects
    - wrap - mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} - mvn:org.mariadb.jdbc/mariadb-java-client/${mariadb.connector.version} - wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge - wrap:mvn:org.apache.tomcat/tomcat-juli/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge - mvn:org.onap.ccsdk.sli.core/utils-provider/${project.version} -
    -
    diff --git a/dblib/features/features-dblib/pom.xml b/dblib/features/features-dblib/pom.xml deleted file mode 100644 index 72af77776..000000000 --- a/dblib/features/features-dblib/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - features-dblib - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: dblib :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-dblib - ${project.version} - xml - features - - - - diff --git a/dblib/features/pom.xml b/dblib/features/pom.xml deleted file mode 100755 index 9addcdb41..000000000 --- a/dblib/features/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - dblib-feature-aggregator - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-core :: dblib :: ${project.artifactId} - - - features-dblib - ccsdk-dblib - - diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index bf19ba0eb..caa0c0be8 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -25,20 +25,6 @@ - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.core dblib-provider diff --git a/dblib/pom.xml b/dblib/pom.xml index 23284604a..2fb49cbf2 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -22,7 +22,6 @@ provider - features installer diff --git a/features/ccsdk-dblib/pom.xml b/features/ccsdk-dblib/pom.xml new file mode 100644 index 000000000..883cd1d86 --- /dev/null +++ b/features/ccsdk-dblib/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-core :: dblib :: ${project.artifactId} + + + + + + ${project.groupId} + dblib-provider + ${project.version} + + + + org.mariadb.jdbc + mariadb-java-client + + + org.apache.tomcat + tomcat-jdbc + + + org.onap.ccsdk.sli.core + utils-provider + ${project.version} + + + + org.apache.derby + derby + + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + true + + + slf4j-api + tomcat-jdbc + tomcat-juli + + + + + + diff --git a/features/ccsdk-dblib/src/main/feature/feature.xml b/features/ccsdk-dblib/src/main/feature/feature.xml new file mode 100644 index 000000000..771c37455 --- /dev/null +++ b/features/ccsdk-dblib/src/main/feature/feature.xml @@ -0,0 +1,13 @@ + + + + +
    Root POM to be used in place of odlparent for CCSDK based projects
    + wrap + mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version} + mvn:org.mariadb.jdbc/mariadb-java-client/${mariadb.connector.version} + wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge + wrap:mvn:org.apache.tomcat/tomcat-juli/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*,org.apache.derby.*&overwrite=merge + mvn:org.onap.ccsdk.sli.core/utils-provider/${project.version} +
    +
    diff --git a/features/ccsdk-filters/pom.xml b/features/ccsdk-filters/pom.xml new file mode 100644 index 000000000..ebe15f856 --- /dev/null +++ b/features/ccsdk-filters/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-filters + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-core :: filters :: ${project.artifactId} + + + + ${project.groupId} + filters-provider + ${project.version} + + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + true + + + + slf4j-api + javax.annotation-api + javax.servlet-api + javax.ws.rs-api + + + + + + + diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml new file mode 100644 index 000000000..f810e43a6 --- /dev/null +++ b/features/ccsdk-sli/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-sli + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-core :: sli :: ${project.artifactId} + + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + + org.onap.ccsdk.sli.core + sli-recording + ${project.version} + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + provided + + + + org.mariadb.jdbc + mariadb-java-client + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + ${project.version} + xml + features + + + + + diff --git a/features/ccsdk-sliPluginUtils/pom.xml b/features/ccsdk-sliPluginUtils/pom.xml new file mode 100644 index 000000000..032d78252 --- /dev/null +++ b/features/ccsdk-sliPluginUtils/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-sliPluginUtils + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} + + + + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + + ${project.groupId} + sliPluginUtils-provider + ${project.version} + + + + diff --git a/features/ccsdk-sliapi/pom.xml b/features/ccsdk-sliapi/pom.xml new file mode 100644 index 000000000..80180c5ab --- /dev/null +++ b/features/ccsdk-sliapi/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-sliapi + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-core :: sliapi :: ${project.artifactId} + + + + + + ${project.groupId} + ccsdk-sli + ${project.version} + xml + features + + + + ${project.groupId} + sliapi-provider + ${project.version} + + + + diff --git a/features/ccsdk-slicore-utils/pom.xml b/features/ccsdk-slicore-utils/pom.xml new file mode 100644 index 000000000..ae54dcfd5 --- /dev/null +++ b/features/ccsdk-slicore-utils/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + single-feature-parent + 1.5.1-SNAPSHOT + + + + org.onap.ccsdk.sli.core + ccsdk-slicore-utils + 0.7.0-SNAPSHOT + feature + + ccsdk-sli-core :: utils :: ${project.artifactId} + + + + + + ${project.groupId} + utils-provider + ${project.version} + + + + diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 32c177882..1cece6422 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -24,7 +24,84 @@
    - + + org.onap.ccsdk.sli.core + ccsdk-slicore-utils + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.core + ccsdk-dblib + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.core + ccsdk-filters + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.core + ccsdk-sli + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.core + ccsdk-sliapi + ${project.version} + xml + features + + + * + * + + + + + org.onap.ccsdk.sli.core + ccsdk-sliPluginUtils + ${project.version} + xml + features + + + * + * + + + org.onap.ccsdk.sli.core ${application.name} @@ -98,7 +175,7 @@ true false false - org.onap.ccsdk.sli.core,org.apache.tomcat,org.slf4j + org.onap.ccsdk.sli.core,org.apache.tomcat,org.slf4j utils-provider,slf4j-api provided diff --git a/features/pom.xml b/features/pom.xml index 6e500172e..1dd48d6db 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -17,6 +17,12 @@ ccsdk-sli-core :: features + ccsdk-slicore-utils + ccsdk-dblib + ccsdk-filters + ccsdk-sli + ccsdk-sliapi + ccsdk-sliPluginUtils ccsdk-sli-core-all features-sli-core installer diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml deleted file mode 100644 index ebe15f856..000000000 --- a/filters/features/ccsdk-filters/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-filters - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: filters :: ${project.artifactId} - - - - ${project.groupId} - filters-provider - ${project.version} - - - - - - - org.apache.karaf.tooling - karaf-maven-plugin - true - - - - slf4j-api - javax.annotation-api - javax.servlet-api - javax.ws.rs-api - - - - - - - diff --git a/filters/features/features-filters/pom.xml b/filters/features/features-filters/pom.xml deleted file mode 100644 index 7ae082028..000000000 --- a/filters/features/features-filters/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - features-filters - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: filters :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-filters - ${project.version} - xml - features - - - - diff --git a/filters/features/pom.xml b/filters/features/pom.xml deleted file mode 100755 index 985e446f6..000000000 --- a/filters/features/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - filters-features-aggregator - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-core :: filters :: ${project.artifactId} - - - features-filters - ccsdk-filters - - diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 6bef4c19a..089b2f430 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -24,28 +24,11 @@ - - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.core filters-provider ${project.version} - - diff --git a/filters/pom.xml b/filters/pom.xml index 4cd8c759e..005ce2f19 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -22,7 +22,6 @@ provider - features installer diff --git a/sli/features/features-sli/pom.xml b/sli/features/features-sli/pom.xml deleted file mode 100644 index 80c4102ff..000000000 --- a/sli/features/features-sli/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - features-sli - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: sli :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-sli - ${project.version} - xml - features - - - - diff --git a/sli/features/odl-sli/pom.xml b/sli/features/odl-sli/pom.xml deleted file mode 100644 index f810e43a6..000000000 --- a/sli/features/odl-sli/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-sli - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: sli :: ${project.artifactId} - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - provided - - - - org.mariadb.jdbc - mariadb-java-client - - - - org.onap.ccsdk.sli.core - ccsdk-dblib - ${project.version} - xml - features - - - - - diff --git a/sli/features/pom.xml b/sli/features/pom.xml deleted file mode 100644 index 6970f268c..000000000 --- a/sli/features/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sli-feature-aggregator - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-core :: sli :: ${project.artifactId} - - - features-sli - odl-sli - - diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 866e9b03f..8a39f79cc 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -35,20 +35,6 @@ - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.core sli-common diff --git a/sli/pom.xml b/sli/pom.xml index 895fae1fa..8ef0c9c90 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -26,7 +26,6 @@ common provider recording - features installer diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml deleted file mode 100644 index 032d78252..000000000 --- a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-sliPluginUtils - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - - - - - - ${project.groupId} - ccsdk-sli - ${project.version} - xml - features - - - - ${project.groupId} - sliPluginUtils-provider - ${project.version} - - - - diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml deleted file mode 100644 index eec15e64a..000000000 --- a/sliPluginUtils/features/features-sliPluginUtils/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - features-sliPluginUtils - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-sliPluginUtils - ${project.version} - xml - features - - - - diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml deleted file mode 100755 index c43c18d6e..000000000 --- a/sliPluginUtils/features/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sliPluginUtils-features - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - - - features-sliPluginUtils - ccsdk-sliPluginUtils - - diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 9d71a964f..fa99d4cc0 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -46,20 +46,6 @@ - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.core sliPluginUtils-provider diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 22b4bd90f..61e6c47b1 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -19,7 +19,6 @@ provider - features installer diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml deleted file mode 100644 index 80180c5ab..000000000 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-sliapi - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - - - - ${project.groupId} - ccsdk-sli - ${project.version} - xml - features - - - - ${project.groupId} - sliapi-provider - ${project.version} - - - - diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml deleted file mode 100644 index 2acfad7b4..000000000 --- a/sliapi/features/features-sliapi/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - features-sliapi - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-sliapi - ${project.version} - xml - features - - - - diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml deleted file mode 100755 index 448c9da41..000000000 --- a/sliapi/features/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sliapi-feature-aggregator - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - features-sliapi - ccsdk-sliapi - - diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 71bb22e64..d3dd4e215 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -18,7 +18,6 @@ model - features provider installer diff --git a/utils/features/ccsdk-slicore-utils/pom.xml b/utils/features/ccsdk-slicore-utils/pom.xml deleted file mode 100644 index ae54dcfd5..000000000 --- a/utils/features/ccsdk-slicore-utils/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - ccsdk-slicore-utils - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: utils :: ${project.artifactId} - - - - - - ${project.groupId} - utils-provider - ${project.version} - - - - diff --git a/utils/features/features-util/pom.xml b/utils/features/features-util/pom.xml deleted file mode 100644 index 6e26d1dca..000000000 --- a/utils/features/features-util/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - features-util - 0.7.0-SNAPSHOT - feature - - ccsdk-sli-core :: utils :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-slicore-utils - ${project.version} - xml - features - - - - diff --git a/utils/features/pom.xml b/utils/features/pom.xml deleted file mode 100755 index 594c6e1e3..000000000 --- a/utils/features/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.1-SNAPSHOT - - - - org.onap.ccsdk.sli.core - utils-features-aggregator - 0.7.0-SNAPSHOT - pom - - ccsdk-sli-core :: utils :: ${project.artifactId} - - - features-util - ccsdk-slicore-utils - - diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index cbe0596a6..d69cc74ad 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -25,20 +25,6 @@ - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - - org.onap.ccsdk.sli.core utils-provider diff --git a/utils/pom.xml b/utils/pom.xml index a5529f314..2c4211073 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -22,7 +22,6 @@ provider - features installer -- cgit 1.2.3-korg From 2fa35ec7af06c9f1d1982dc500726de703f7dede Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 17 Dec 2019 18:27:42 +0000 Subject: enhance SliPluginUtils writeJsonToCtx now supports top level json arrays, add urlDecode to SliStringUtils, rename CheckParametersTest and move unrelated methods into another test class and Add test cases to improve test coverage Issue-ID: CCSDK-2006 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: If1f654ea9c7046b00c977434f87740e54f15b7d3 --- .../sli/core/slipluginutils/SliPluginUtils.java | 40 ++- .../sli/core/slipluginutils/SliStringUtils.java | 15 + .../core/slipluginutils/CheckParametersTest.java | 216 ------------- .../SliPluginUtils_StaticFunctionsTest.java | 342 +++++++++++++++++++-- .../SliPluginUtils_checkParametersTest.java | 117 +++++++ .../core/slipluginutils/SliStringUtilsTest.java | 17 +- .../provider/src/test/resources/2dArray.json | 4 + .../provider/src/test/resources/3dArray.json | 4 + .../provider/src/test/resources/ArrayMenu.json | 41 +++ .../src/test/resources/EmbeddedEscapedJson.json | 16 + .../provider/src/test/resources/EscapedJson.json | 1 + .../provider/src/test/resources/ObjectMenu.json | 43 +++ .../provider/src/test/resources/Widget.json | 27 ++ 13 files changed, 626 insertions(+), 257 deletions(-) delete mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java create mode 100644 sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_checkParametersTest.java create mode 100644 sliPluginUtils/provider/src/test/resources/2dArray.json create mode 100644 sliPluginUtils/provider/src/test/resources/3dArray.json create mode 100644 sliPluginUtils/provider/src/test/resources/ArrayMenu.json create mode 100644 sliPluginUtils/provider/src/test/resources/EmbeddedEscapedJson.json create mode 100644 sliPluginUtils/provider/src/test/resources/EscapedJson.json create mode 100644 sliPluginUtils/provider/src/test/resources/ObjectMenu.json create mode 100644 sliPluginUtils/provider/src/test/resources/Widget.json diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index b8e88f652..1fc052532 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -821,32 +821,46 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { protected static void writeJsonToCtx(String resp, SvcLogicContext ctx, String prefix){ JsonParser jp = new JsonParser(); JsonElement element = jp.parse(resp); - writeJsonObject(element.getAsJsonObject(), ctx, prefix + "."); + String root = prefix + "."; + if (element.isJsonObject()) { + writeJsonObject(element.getAsJsonObject(), ctx, root); + } else if (element.isJsonArray()) { + handleJsonArray("", element.getAsJsonArray(), ctx, root); + } } protected static void writeJsonObject(JsonObject obj, SvcLogicContext ctx, String root) { for (Entry entry : obj.entrySet()) { + String key = entry.getKey(); if (entry.getValue().isJsonObject()) { - writeJsonObject(entry.getValue().getAsJsonObject(), ctx, root + entry.getKey() + "."); + writeJsonObject(entry.getValue().getAsJsonObject(), ctx, root + key + "."); } else if (entry.getValue().isJsonArray()) { JsonArray array = entry.getValue().getAsJsonArray(); - ctx.setAttribute(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 + "]."); - } else if (element.isJsonPrimitive()) { - ctx.setAttribute(root + entry.getKey() + "[" + arrayIdx + "]", element.getAsString()); - } - arrayIdx++; - } + handleJsonArray(key, array, ctx, root); } else { //Handles when a JSON obj is nested within a JSON obj if(!root.endsWith(".")){ root = root + "."; } - ctx.setAttribute(root + entry.getKey(), entry.getValue().getAsString()); + ctx.setAttribute(root + key, entry.getValue().getAsString()); + } + } + } + + protected static void handleJsonArray(String key, JsonArray array, SvcLogicContext ctx, String root) { + ctx.setAttribute(root + key + LENGTH, String.valueOf(array.size())); + Integer arrayIdx = 0; + for (JsonElement element : array) { + String prefix = root + key + "[" + arrayIdx + "]"; + + if (element.isJsonArray()) { + handleJsonArray(key, element.getAsJsonArray(), ctx, prefix); + } else if (element.isJsonObject()) { + writeJsonObject(element.getAsJsonObject(), ctx, prefix + "."); + } else if (element.isJsonPrimitive()) { + ctx.setAttribute(prefix, element.getAsString()); } + arrayIdx++; } } diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index 269c3766c..d343ce25f 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -24,6 +24,7 @@ package org.onap.ccsdk.sli.core.slipluginutils; import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; import java.net.URLEncoder; import java.util.Map; import org.apache.commons.lang3.StringEscapeUtils; @@ -427,6 +428,20 @@ public class SliStringUtils implements SvcLogicJavaPlugin { } } + public static void urlDecode(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + SliPluginUtils.checkParameters(parameters, new String[] {INPUT_PARAM_SOURCE, "outputPath"}, LOG); + String encoding = parameters.get("encoding"); + if (encoding == null) { + encoding = "UTF-8"; + } + try { + String result = URLDecoder.decode(parameters.get(INPUT_PARAM_SOURCE), encoding); + ctx.setAttribute(parameters.get("outputPath"), result); + } catch (UnsupportedEncodingException e) { + throw new SvcLogicException("Url decode failed.", e); + } + } + /** * xmlEscapeText() will be used to format input xml with text. * diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java deleted file mode 100644 index 21aa4a356..000000000 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/CheckParametersTest.java +++ /dev/null @@ -1,216 +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.slipluginutils; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils.LogLevel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.Marker; - -import com.google.gson.JsonObject; - -public class CheckParametersTest { - - @Test - public void nullRequiredParameters() throws Exception { - Map parametersMap = new HashMap(); - String[] requiredParams = null; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test(expected = SvcLogicException.class) - public void emptyParametersMap() throws Exception { - Map parametersMap = new HashMap(); - String[] requiredParams = new String[] { "param1", "param2", "param3" }; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test(expected = SvcLogicException.class) - public void paramNotFound() throws Exception { - Map parametersMap = new HashMap(); - parametersMap.put("tst", "me"); - String[] requiredParams = new String[] { "param1", "parm2", "param3" }; - Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); - SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); - } - - @Test - public void testSunnyRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param2", "world"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - parameters.put("param1", "dog"); - parameters.put("param2", "cat"); - parameters.put("param3", "fish"); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test - public void testSunnyRequiredParametersWithPrefix() throws Exception { - String prefixValue = "my.unique.path."; - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute(prefixValue + "param1", "hello"); - ctx.setAttribute(prefixValue + "param2", "world"); - ctx.setAttribute(prefixValue + "param3", "!"); - - Map parameters = new HashMap(); - parameters.put("prefix", prefixValue); - parameters.put("param1", "dog"); - parameters.put("param2", "cat"); - parameters.put("param3", "fish"); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testRainyMissingRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - parameters.put("param1", null); - parameters.put("param2", null); - parameters.put("param3", null); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testEmptyRequiredParameters() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("param1", "hello"); - ctx.setAttribute("param3", "!"); - - Map parameters = new HashMap(); - - SliPluginUtils.requiredParameters(parameters, ctx); - } - - @Test(expected = SvcLogicException.class) - public void testJsonStringToCtx() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters = new HashMap(); - parameters.put("outputPath", "testPath"); - parameters.put("isEscaped", "true"); - parameters.put("source", "//{/name1/:value1/}//"); - SliPluginUtils.jsonStringToCtx(parameters, ctx); - } - - @Test - public void testGetAttributeValue() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters = new HashMap(); - parameters.put("outputPath", "testPath"); - parameters.put("source", "testSource"); - SliPluginUtils.getAttributeValue(parameters, ctx); - assertNull(ctx.getAttribute(parameters.get("outputPath"))); - } - - @Test - public void testCtxListContains() throws Exception { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters = new HashMap(); - parameters.put("list", "10_length"); - parameters.put("keyName", "testName"); - parameters.put("keyValue", "testValue"); - ctx.setAttribute("10_length", "10"); - assertEquals("false", SliPluginUtils.ctxListContains(parameters, ctx)); - - } - - @Test(expected= SvcLogicException.class) - public void testPrintContextForNullParameters() throws SvcLogicException - { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters = new HashMap(); - SliPluginUtils.printContext(parameters, ctx); - } - - @Test - public void testPrintContext() throws SvcLogicException - { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters = new HashMap(); - parameters.put("filename","testFileName"); - SliPluginUtils.printContext(parameters, ctx); - } - - @Test - public void testWriteJsonObject() throws SvcLogicException - { - JsonObject obj=new JsonObject(); - obj.addProperty("name","testName"); - obj.addProperty("age",27); - obj.addProperty("salary",600000); - SvcLogicContext ctx = new SvcLogicContext(); - SliPluginUtils.writeJsonObject(obj, ctx,"root"); - assertEquals("testName", ctx.getAttribute("root.name")); - assertEquals("27", ctx.getAttribute("root.age")); - assertEquals("600000", ctx.getAttribute("root.salary")); - } - - @Test - public void testCtxKeyEmpty() - { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("key", ""); - assertTrue(SliPluginUtils.ctxKeyEmpty(ctx, "key")); - } - - @Test - public void testGetArrayLength() - { - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("key_length", "test"); - Logger log = LoggerFactory.getLogger(getClass()); - SliPluginUtils.getArrayLength(ctx, "key", log , LogLevel.INFO, "invalid input"); - } - - @Test - public void testSetPropertiesForRoot() - { - SvcLogicContext ctx = new SvcLogicContext(); - Map parameters= new HashMap<>(); - parameters.put("root","RootVal"); - parameters.put("valueRoot", "ValueRootVal"); - assertEquals("success",SliPluginUtils.setPropertiesForRoot(parameters,ctx)); - } -} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java index 08adc9731..64645b363 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java @@ -24,14 +24,20 @@ package org.onap.ccsdk.sli.core.slipluginutils; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils.LogLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.gson.JsonObject; public class SliPluginUtils_StaticFunctionsTest { private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils_StaticFunctionsTest.class); @@ -216,28 +222,6 @@ public class SliPluginUtils_StaticFunctionsTest { SliPluginUtils.ctxSetAttribute(ctx, "test", i, LOG, SliPluginUtils.LogLevel.TRACE); } - /*@Test - public void printContext() throws SvcLogicException, IOException { - String filePath = "/src/test/resources/printContext.txt"; - parameters.put("filename", filePath); - File f = new File(filePath); - assert (f.exists()); - assert (!f.isDirectory()); - ctx.setAttribute("hello", "world"); - ctx.setAttribute("name", "value"); - - SliPluginUtils.printContext(parameters, ctx); - BufferedReader br = new BufferedReader(new FileReader(f)); - String line = br.readLine(); - assertEquals("#######################################", line); - line = br.readLine(); - assertEquals("hello = world", line); - line = br.readLine(); - assertEquals("name = value", line); - br.close(); - Files.delete(Paths.get(filePath)); - }*/ - @Test public void setTime() throws SvcLogicException { String outputPath = "output"; @@ -264,4 +248,318 @@ public class SliPluginUtils_StaticFunctionsTest { assertEquals(SliStringUtils.TRUE_CONSTANT, result); } + @Test + public void testGetAttributeValue() throws Exception { + parameters.put("outputPath", "testPath"); + parameters.put("source", "testSource"); + SliPluginUtils.getAttributeValue(parameters, ctx); + assertNull(ctx.getAttribute(parameters.get("outputPath"))); + } + + @Test + public void testCtxListContains() throws Exception { + parameters.put("list", "10_length"); + parameters.put("keyName", "testName"); + parameters.put("keyValue", "testValue"); + ctx.setAttribute("10_length", "10"); + assertEquals("false", SliPluginUtils.ctxListContains(parameters, ctx)); + + } + + @Test(expected = SvcLogicException.class) + public void testPrintContextForEmptyParameters() throws SvcLogicException { + SliPluginUtils.printContext(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testPrintContextForNullParameters() throws SvcLogicException { + SliPluginUtils.printContext(null, ctx); + } + + @Test + public void testPrintContext() throws SvcLogicException { + parameters.put("filename", "testFileName"); + SliPluginUtils.printContext(parameters, ctx); + } + + @Test + public void testWriteJsonObject() throws SvcLogicException { + JsonObject obj = new JsonObject(); + obj.addProperty("name", "testName"); + obj.addProperty("age", 27); + obj.addProperty("salary", 600000); + SvcLogicContext ctx = new SvcLogicContext(); + SliPluginUtils.writeJsonObject(obj, ctx, "root"); + assertEquals("testName", ctx.getAttribute("root.name")); + assertEquals("27", ctx.getAttribute("root.age")); + assertEquals("600000", ctx.getAttribute("root.salary")); + } + + @Test + public void testCtxKeyEmpty() { + ctx.setAttribute("key", ""); + assertTrue(SliPluginUtils.ctxKeyEmpty(ctx, "key")); + } + + @Test + public void testGetArrayLength() { + ctx.setAttribute("key_length", "test"); + Logger log = LoggerFactory.getLogger(getClass()); + SliPluginUtils.getArrayLength(ctx, "key", log, LogLevel.INFO, "invalid input"); + } + + @Test + public void testSetPropertiesForRoot() { + Map parameters = new HashMap<>(); + parameters.put("root", "RootVal"); + parameters.put("valueRoot", "ValueRootVal"); + assertEquals("success", SliPluginUtils.setPropertiesForRoot(parameters, ctx)); + } + + @Test + public void testJsonStringToCtxToplevelArray() throws Exception { + String path = "src/test/resources/ArrayMenu.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input", content); + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "false"); + parameters.put("source", "input"); + + SliPluginUtils.jsonStringToCtx(parameters, ctx); + + assertEquals("1000", ctx.getAttribute("testPath.[0].calories")); + assertEquals("1", ctx.getAttribute("testPath.[0].id")); + assertEquals("plain", ctx.getAttribute("testPath.[0].name")); + assertEquals("pizza", ctx.getAttribute("testPath.[0].type")); + assertEquals("true", ctx.getAttribute("testPath.[0].vegetarian")); + assertEquals("2000", ctx.getAttribute("testPath.[1].calories")); + assertEquals("2", ctx.getAttribute("testPath.[1].id")); + assertEquals("Tuesday Special", ctx.getAttribute("testPath.[1].name")); + assertEquals("1", ctx.getAttribute("testPath.[1].topping[0].id")); + assertEquals("onion", ctx.getAttribute("testPath.[1].topping[0].name")); + assertEquals("2", ctx.getAttribute("testPath.[1].topping[1].id")); + assertEquals("pepperoni", ctx.getAttribute("testPath.[1].topping[1].name")); + assertEquals("2", ctx.getAttribute("testPath.[1].topping_length")); + assertEquals("pizza", ctx.getAttribute("testPath.[1].type")); + assertEquals("false", ctx.getAttribute("testPath.[1].vegetarian")); + assertEquals("1500", ctx.getAttribute("testPath.[2].calories")); + assertEquals("3", ctx.getAttribute("testPath.[2].id")); + assertEquals("House Special", ctx.getAttribute("testPath.[2].name")); + assertEquals("3", ctx.getAttribute("testPath.[2].topping[0].id")); + assertEquals("basil", ctx.getAttribute("testPath.[2].topping[0].name")); + assertEquals("4", ctx.getAttribute("testPath.[2].topping[1].id")); + assertEquals("fresh mozzarella", ctx.getAttribute("testPath.[2].topping[1].name")); + assertEquals("5", ctx.getAttribute("testPath.[2].topping[2].id")); + assertEquals("tomato", ctx.getAttribute("testPath.[2].topping[2].name")); + assertEquals("3", ctx.getAttribute("testPath.[2].topping_length")); + assertEquals("pizza", ctx.getAttribute("testPath.[2].type")); + assertEquals("true", ctx.getAttribute("testPath.[2].vegetarian")); + assertEquals("3", ctx.getAttribute("testPath._length")); + } + + @Test + public void testJsonStringToCtx() throws Exception { + String path = "src/test/resources/ObjectMenu.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input", content); + + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "false"); + parameters.put("source", "input"); + + SliPluginUtils.jsonStringToCtx(parameters, ctx); + + + assertEquals("1000", ctx.getAttribute("testPath.menu[0].calories")); + assertEquals("1", ctx.getAttribute("testPath.menu[0].id")); + assertEquals("plain", ctx.getAttribute("testPath.menu[0].name")); + assertEquals("pizza", ctx.getAttribute("testPath.menu[0].type")); + assertEquals("true", ctx.getAttribute("testPath.menu[0].vegetarian")); + assertEquals("2000", ctx.getAttribute("testPath.menu[1].calories")); + assertEquals("2", ctx.getAttribute("testPath.menu[1].id")); + assertEquals("Tuesday Special", ctx.getAttribute("testPath.menu[1].name")); + assertEquals("1", ctx.getAttribute("testPath.menu[1].topping[0].id")); + assertEquals("onion", ctx.getAttribute("testPath.menu[1].topping[0].name")); + assertEquals("2", ctx.getAttribute("testPath.menu[1].topping[1].id")); + assertEquals("pepperoni", ctx.getAttribute("testPath.menu[1].topping[1].name")); + assertEquals("2", ctx.getAttribute("testPath.menu[1].topping_length")); + assertEquals("pizza", ctx.getAttribute("testPath.menu[1].type")); + assertEquals("false", ctx.getAttribute("testPath.menu[1].vegetarian")); + assertEquals("1500", ctx.getAttribute("testPath.menu[2].calories")); + assertEquals("3", ctx.getAttribute("testPath.menu[2].id")); + assertEquals("House Special", ctx.getAttribute("testPath.menu[2].name")); + assertEquals("3", ctx.getAttribute("testPath.menu[2].topping[0].id")); + assertEquals("basil", ctx.getAttribute("testPath.menu[2].topping[0].name")); + assertEquals("4", ctx.getAttribute("testPath.menu[2].topping[1].id")); + assertEquals("fresh mozzarella", ctx.getAttribute("testPath.menu[2].topping[1].name")); + assertEquals("5", ctx.getAttribute("testPath.menu[2].topping[2].id")); + assertEquals("tomato", ctx.getAttribute("testPath.menu[2].topping[2].name")); + assertEquals("3", ctx.getAttribute("testPath.menu[2].topping_length")); + assertEquals("pizza", ctx.getAttribute("testPath.menu[2].type")); + assertEquals("true", ctx.getAttribute("testPath.menu[2].vegetarian")); + assertEquals("3", ctx.getAttribute("testPath.menu_length")); + } + + @Test + public void test2dJsonStringToCtx() throws Exception { + String path = "src/test/resources/2dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input", content); + + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "false"); + parameters.put("source", "input"); + + SliPluginUtils.jsonStringToCtx(parameters, ctx); + assertEquals("apple", ctx.getAttribute("testPath.[0][0]")); + assertEquals("orange", ctx.getAttribute("testPath.[0][1]")); + assertEquals("banana", ctx.getAttribute("testPath.[0][2]")); + assertEquals("3", ctx.getAttribute("testPath.[0]_length")); + assertEquals("squash", ctx.getAttribute("testPath.[1][0]")); + assertEquals("broccoli", ctx.getAttribute("testPath.[1][1]")); + assertEquals("cauliflower", ctx.getAttribute("testPath.[1][2]")); + assertEquals("3", ctx.getAttribute("testPath.[1]_length")); + assertEquals("2", ctx.getAttribute("testPath._length")); + } + + @Test + public void test3dJsonStringToCtx() throws Exception { + String path = "src/test/resources/3dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input", content); + + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "false"); + parameters.put("source", "input"); + + SliPluginUtils.jsonStringToCtx(parameters, ctx); + assertEquals("a", ctx.getAttribute("testPath.[0][0][0]")); + assertEquals("b", ctx.getAttribute("testPath.[0][0][1]")); + assertEquals("c", ctx.getAttribute("testPath.[0][0][2]")); + assertEquals("3", ctx.getAttribute("testPath.[0][0]_length")); + assertEquals("d", ctx.getAttribute("testPath.[0][1][0]")); + assertEquals("e", ctx.getAttribute("testPath.[0][1][1]")); + assertEquals("f", ctx.getAttribute("testPath.[0][1][2]")); + assertEquals("3", ctx.getAttribute("testPath.[0][1]_length")); + assertEquals("2", ctx.getAttribute("testPath.[0]_length")); + assertEquals("x", ctx.getAttribute("testPath.[1][0][0]")); + assertEquals("y", ctx.getAttribute("testPath.[1][0][1]")); + assertEquals("z", ctx.getAttribute("testPath.[1][0][2]")); + assertEquals("3", ctx.getAttribute("testPath.[1][0]_length")); + assertEquals("1", ctx.getAttribute("testPath.[1]_length")); + assertEquals("2", ctx.getAttribute("testPath._length")); + } + + @Test + public void testJsonWidgetStringToCtx() throws Exception { + String path = "src/test/resources/Widget.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input", content); + + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "false"); + parameters.put("source", "input"); + + SliPluginUtils.jsonStringToCtx(parameters, ctx); + assertEquals("false", ctx.getAttribute("testPath.widget.debug")); + assertEquals("center", ctx.getAttribute("testPath.widget.image.alignment")); + assertEquals("150", ctx.getAttribute("testPath.widget.image.hOffset")); + assertEquals("moon", ctx.getAttribute("testPath.widget.image.name")); + assertEquals("images/moon.png", ctx.getAttribute("testPath.widget.image.src")); + assertEquals("150", ctx.getAttribute("testPath.widget.image.vOffset")); + assertEquals("center", ctx.getAttribute("testPath.widget.text.alignment")); + assertEquals("Click Me", ctx.getAttribute("testPath.widget.text.data")); + assertEquals("350", ctx.getAttribute("testPath.widget.text.hOffset")); + assertEquals("text1", ctx.getAttribute("testPath.widget.text.name")); + assertEquals("21", ctx.getAttribute("testPath.widget.text.size")); + assertEquals("bold", ctx.getAttribute("testPath.widget.text.style")); + assertEquals("200", ctx.getAttribute("testPath.widget.text.vOffset")); + assertEquals("300", ctx.getAttribute("testPath.widget.window.height")); + assertEquals("main_window", ctx.getAttribute("testPath.widget.window.name")); + assertEquals("ONAP Widget", ctx.getAttribute("testPath.widget.window.title")); + assertEquals("200", ctx.getAttribute("testPath.widget.window.width")); + } + + @Test + public void testEmbeddedEscapedJsonJsonStringToCtx() throws Exception { + String path = "src/test/resources/EmbeddedEscapedJson.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input", content); + + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "false"); + parameters.put("source", "input"); + + SliPluginUtils.jsonStringToCtx(parameters, ctx); + + assertEquals("escapedJsonObject", ctx.getAttribute("testPath.input.parameters[0].name")); + assertEquals("[{\"id\":\"0.2.0.0/16\"},{\"id\":\"ge04::/64\"}]", + ctx.getAttribute("testPath.input.parameters[0].value")); + assertEquals("Hello/World", ctx.getAttribute("testPath.input.parameters[1].value")); + assertEquals("resourceName", ctx.getAttribute("testPath.input.parameters[2].name")); + assertEquals("The\t\"Best\"\tName", ctx.getAttribute("testPath.input.parameters[2].value")); + assertEquals("3", ctx.getAttribute("testPath.input.parameters_length")); + + + // Break the embedded json object into properties + parameters.put("outputPath", "testPath.input.parameters[0].value"); + parameters.put("source", "testPath.input.parameters[0].value"); + SliPluginUtils.jsonStringToCtx(parameters, ctx); + + assertEquals("0.2.0.0/16", ctx.getAttribute("testPath.input.parameters[0].value.[0].id")); + assertEquals("ge04::/64", ctx.getAttribute("testPath.input.parameters[0].value.[1].id")); + assertEquals("2", ctx.getAttribute("testPath.input.parameters[0].value._length")); + } + + @Test + public void testEscapedJsonStringToCtx() throws Exception { + String path = "src/test/resources/EscapedJson.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input", content); + + Map parameters = new HashMap(); + parameters.put("outputPath", "testPath"); + parameters.put("isEscaped", "true"); // set to true because the entire json content has been escaped + parameters.put("source", "input"); + + + SliPluginUtils.jsonStringToCtx(parameters, ctx); + assertEquals("false", ctx.getAttribute("testPath.widget.debug")); + assertEquals("center", ctx.getAttribute("testPath.widget.image.alignment")); + assertEquals("150", ctx.getAttribute("testPath.widget.image.hOffset")); + assertEquals("moon", ctx.getAttribute("testPath.widget.image.name")); + assertEquals("images/moon.png", ctx.getAttribute("testPath.widget.image.src")); + assertEquals("150", ctx.getAttribute("testPath.widget.image.vOffset")); + assertEquals("center", ctx.getAttribute("testPath.widget.text.alignment")); + assertEquals("Click Me", ctx.getAttribute("testPath.widget.text.data")); + assertEquals("350", ctx.getAttribute("testPath.widget.text.hOffset")); + assertEquals("text1", ctx.getAttribute("testPath.widget.text.name")); + assertEquals("21", ctx.getAttribute("testPath.widget.text.size")); + assertEquals("bold", ctx.getAttribute("testPath.widget.text.style")); + assertEquals("200", ctx.getAttribute("testPath.widget.text.vOffset")); + assertEquals("300", ctx.getAttribute("testPath.widget.window.height")); + assertEquals("main_window", ctx.getAttribute("testPath.widget.window.name")); + assertEquals("ONAP Widget", ctx.getAttribute("testPath.widget.window.title")); + assertEquals("200", ctx.getAttribute("testPath.widget.window.width")); + } + } diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_checkParametersTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_checkParametersTest.java new file mode 100644 index 000000000..f92271f7c --- /dev/null +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_checkParametersTest.java @@ -0,0 +1,117 @@ +/*- + * ============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.slipluginutils; + +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SliPluginUtils_checkParametersTest { + + @Test + public void nullRequiredParameters() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = null; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void emptyParametersMap() throws Exception { + Map parametersMap = new HashMap(); + String[] requiredParams = new String[] { "param1", "param2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test(expected = SvcLogicException.class) + public void paramNotFound() throws Exception { + Map parametersMap = new HashMap(); + parametersMap.put("tst", "me"); + String[] requiredParams = new String[] { "param1", "parm2", "param3" }; + Logger Log = LoggerFactory.getLogger(SliPluginUtils.class); + SliPluginUtils.checkParameters(parametersMap, requiredParams, Log); + } + + @Test + public void testSunnyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param2", "world"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test + public void testSunnyRequiredParametersWithPrefix() throws Exception { + String prefixValue = "my.unique.path."; + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(prefixValue + "param1", "hello"); + ctx.setAttribute(prefixValue + "param2", "world"); + ctx.setAttribute(prefixValue + "param3", "!"); + + Map parameters = new HashMap(); + parameters.put("prefix", prefixValue); + parameters.put("param1", "dog"); + parameters.put("param2", "cat"); + parameters.put("param3", "fish"); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testRainyMissingRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + parameters.put("param1", null); + parameters.put("param2", null); + parameters.put("param3", null); + + SliPluginUtils.requiredParameters(parameters, ctx); + } + + @Test(expected = SvcLogicException.class) + public void testEmptyRequiredParameters() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("param1", "hello"); + ctx.setAttribute("param3", "!"); + + Map parameters = new HashMap(); + + SliPluginUtils.requiredParameters(parameters, ctx); + } +} diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index d8d78a0b1..3a6c31a3c 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -271,6 +271,17 @@ public class SliStringUtilsTest { assertEquals("102%2FGE100%2FSNJSCAMCJP8%2FSNJSCAMCJT4", ctx.getAttribute(outputPath)); } + @Test + public void urlDecode() throws SvcLogicException { + String sourceString = "102%2FGE100%2FSNJSCAMCJP8%2FSNJSCAMCJT4"; + String outputPath = "out"; + + param.put("source", sourceString); + param.put("outputPath", outputPath); + SliStringUtils.urlDecode(param, ctx); + assertEquals("102/GE100/SNJSCAMCJP8/SNJSCAMCJT4", ctx.getAttribute(outputPath)); + } + @Test public void testXmlEscapeText() { param.put("source", "102/GE100/SNJSCAMCJP8/SNJSCAMCJT4"); @@ -317,8 +328,6 @@ public class SliStringUtilsTest { @Test public void isEmpty() throws Exception { - ctx = new SvcLogicContext(); - param = new HashMap<>(); String result = SliStringUtils.isEmpty(param, ctx); param.put(SliStringUtils.INPUT_PARAM_KEY, "key_does_not_exist"); assertEquals(SliStringUtils.TRUE_CONSTANT, result); @@ -339,8 +348,6 @@ public class SliStringUtilsTest { @Test public void isBlank() throws Exception { - ctx = new SvcLogicContext(); - param = new HashMap<>(); String result = SliStringUtils.isBlank(param, ctx); param.put(SliStringUtils.INPUT_PARAM_KEY, "key_does_not_exist"); assertEquals(SliStringUtils.TRUE_CONSTANT, result); @@ -361,8 +368,6 @@ public class SliStringUtilsTest { @Test public void isNull() throws Exception { - ctx = new SvcLogicContext(); - param = new HashMap<>(); String result = SliStringUtils.isNull(param, ctx); param.put(SliStringUtils.INPUT_PARAM_KEY, "key_does_not_exist"); assertEquals(SliStringUtils.TRUE_CONSTANT, result); diff --git a/sliPluginUtils/provider/src/test/resources/2dArray.json b/sliPluginUtils/provider/src/test/resources/2dArray.json new file mode 100644 index 000000000..b473864d8 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/2dArray.json @@ -0,0 +1,4 @@ +[ + ["apple", "orange", "banana"], + ["squash", "broccoli", "cauliflower"] +] \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/resources/3dArray.json b/sliPluginUtils/provider/src/test/resources/3dArray.json new file mode 100644 index 000000000..149955596 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/3dArray.json @@ -0,0 +1,4 @@ +[ + [["a","b","c"], ["d","e","f"]], + [["x","y","z"]] +] \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/resources/ArrayMenu.json b/sliPluginUtils/provider/src/test/resources/ArrayMenu.json new file mode 100644 index 000000000..b12f16315 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/ArrayMenu.json @@ -0,0 +1,41 @@ +[{ + "id": "1", + "type": "pizza", + "name": "plain", + "calories": 1000, + "vegetarian": true + }, { + "id": "2", + "type": "pizza", + "name": "Tuesday Special", + "calories": 2000, + "vegetarian": false, + "topping": + [{ + "id": "1", + "name": "onion" + }, { + "id": "2", + "name": "pepperoni" + } + ] + }, { + "id": "3", + "type": "pizza", + "name": "House Special", + "calories": 1500, + "vegetarian": true, + "topping": + [{ + "id": "3", + "name": "basil" + }, { + "id": "4", + "name": "fresh mozzarella" + }, { + "id": "5", + "name": "tomato" + } + ] + } +] diff --git a/sliPluginUtils/provider/src/test/resources/EmbeddedEscapedJson.json b/sliPluginUtils/provider/src/test/resources/EmbeddedEscapedJson.json new file mode 100644 index 000000000..dbb6d8d3a --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/EmbeddedEscapedJson.json @@ -0,0 +1,16 @@ +{ + "input": { + "parameters": + [{ + "name": "escapedJsonObject", + "value": "[{\"id\":\"0.2.0.0\/16\"},{\"id\":\"ge04::\/64\"}]" + }, { + "name": "password", + "value": "Hello\/World" + }, { + "name": "resourceName", + "value": "The\t\"Best\"\tName" + } + ] + } +} \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/resources/EscapedJson.json b/sliPluginUtils/provider/src/test/resources/EscapedJson.json new file mode 100644 index 000000000..a7719e819 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/EscapedJson.json @@ -0,0 +1 @@ +{\"widget\":{\"debug\":false,\"window\":{\"title\":\"ONAP Widget\",\"name\":\"main_window\",\"width\":200,\"height\":300},\"image\":{\"src\":\"images\/moon.png\",\"name\":\"moon\",\"hOffset\":150,\"vOffset\":150,\"alignment\":\"center\"},\"text\":{\"data\":\"Click Me\",\"size\":21,\"style\":\"bold\",\"name\":\"text1\",\"hOffset\":350,\"vOffset\":200,\"alignment\":\"center\"}}} \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/resources/ObjectMenu.json b/sliPluginUtils/provider/src/test/resources/ObjectMenu.json new file mode 100644 index 000000000..56f842d48 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/ObjectMenu.json @@ -0,0 +1,43 @@ +{ + "menu": [{ + "id": "1", + "type": "pizza", + "name": "plain", + "calories": 1000, + "vegetarian": true + }, { + "id": "2", + "type": "pizza", + "name": "Tuesday Special", + "calories": 2000, + "vegetarian": false, + "topping": + [{ + "id": "1", + "name": "onion" + }, { + "id": "2", + "name": "pepperoni" + } + ] + }, { + "id": "3", + "type": "pizza", + "name": "House Special", + "calories": 1500, + "vegetarian": true, + "topping": + [{ + "id": "3", + "name": "basil" + }, { + "id": "4", + "name": "fresh mozzarella" + }, { + "id": "5", + "name": "tomato" + } + ] + } + ] +} diff --git a/sliPluginUtils/provider/src/test/resources/Widget.json b/sliPluginUtils/provider/src/test/resources/Widget.json new file mode 100644 index 000000000..1e25282c2 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/Widget.json @@ -0,0 +1,27 @@ +{ + "widget": { + "debug": false, + "window": { + "title": "ONAP Widget", + "name": "main_window", + "width": 200, + "height": 300 + }, + "image": { + "src": "images/moon.png", + "name": "moon", + "hOffset": 150, + "vOffset": 150, + "alignment": "center" + }, + "text": { + "data": "Click Me", + "size": 21, + "style": "bold", + "name": "text1", + "hOffset": 350, + "vOffset": 200, + "alignment": "center" + } + } +} \ No newline at end of file -- cgit 1.2.3-korg From 4da70e483b8f177b9dad4ea59a80757e82b575c6 Mon Sep 17 00:00:00 2001 From: Enbo Wang Date: Wed, 15 Jan 2020 23:58:22 +0800 Subject: Fix issue of converting camel case to lower hyphen format Fix issue of converting camel case to lower hyphen format when there are continuous capital letters. Issue-ID: CCSDK-2026 Signed-off-by: Enbo Wang Change-Id: Ifd10b1e82c1f10476bbc6e15689e6025de57bbf4 --- .../main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 4 ++-- .../java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 5bd4bd938..89e4ee734 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -1149,8 +1149,8 @@ public class MdsalHelper { str = str + inStr.substring(1); } - String regex = "(([a-z0-9])([A-Z]))"; - String replacement = "$2-$3"; + String regex = "([a-z0-9A-Z])(?=[A-Z])"; + String replacement = "$1-"; String retval = str.replaceAll(regex, replacement).toLowerCase(); diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java index a7f383f2c..992ed64d4 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java @@ -1259,8 +1259,8 @@ public class PrintYangToProp { str = str + inStr.substring(1); } - String regex = "(([a-z0-9])([A-Z]))"; - String replacement = "$2-$3"; + String regex = "([a-z0-9A-Z])(?=[A-Z])"; + String replacement = "$1-"; String retval = str.replaceAll(regex, replacement).toLowerCase(); -- cgit 1.2.3-korg From bfff55a06c555babe476eab98d39e468c19063f9 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 21 Jan 2020 08:52:37 -0500 Subject: Add report aggregator For new Sonar scanner, need to add report aggregate so that tests run in sli/provider against classes in sli/provider-base will be counted correctly. Change-Id: I0a73a0a50353f995ea4b90c09649e55b057f024a Issue-ID: CCSDK-2029 Signed-off-by: Dan Timoney --- sli/provider-base/pom.xml | 11 ++++++----- sli/provider/pom.xml | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 214cbe94b..7f9e66b04 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -12,11 +12,11 @@ org.onap.ccsdk.sli.core sli-provider-base 0.7.0-SNAPSHOT - - - - target/code-coverage/jacoco-ut.exec,target/code-coverage/jacoco-it.exec,../provider/target/code-coverage/jacoco-ut.exec,../provider/target/code-coverage/jacoco-it.exec - + + + UTF-8 + ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml,${project.reporting.outputDirectory}/jacoco-it/jacoco.xml,../provider/target/site/jacoco-aggregate/jacoco.xml + @@ -61,4 +61,5 @@ + diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 66717b7ff..cf4e004b3 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -110,7 +110,31 @@ + + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + + + aggregate-report + verify + + report-aggregate + + + + target/code-coverage/jacoco-ut.exec, + target/code-coverage/jacoco-it.exec, + ../provider-base/target/code-coverage/jacoco-ut.exec, + ../provider-base/target/code-coverage/jacoco-it.exec + + + + + + -- cgit 1.2.3-korg From 34881ba6b5170ed0a76b77c9f07795bca5d93b21 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 23 Jan 2020 14:32:19 -0500 Subject: Use released parent pom Use released version of ccsdk/parent poms Change-Id: Ice9f18ee402e42f8e26c46640aeb0ae79343d105 Issue-ID: CCSDK-1963 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-dblib/pom.xml | 2 +- features/ccsdk-filters/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/ccsdk-sli/pom.xml | 2 +- features/ccsdk-sliPluginUtils/pom.xml | 2 +- features/ccsdk-sliapi/pom.xml | 2 +- features/ccsdk-slicore-utils/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sli/recording/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 35 files changed, 35 insertions(+), 35 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 4b996f306..43aed831f 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index caa0c0be8..606edd43e 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/dblib/pom.xml b/dblib/pom.xml index 2fb49cbf2..b955628c4 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 1c836637d..4f34a3bce 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-dblib/pom.xml b/features/ccsdk-dblib/pom.xml index 883cd1d86..fad14f677 100644 --- a/features/ccsdk-dblib/pom.xml +++ b/features/ccsdk-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-filters/pom.xml b/features/ccsdk-filters/pom.xml index ebe15f856..21f995f85 100644 --- a/features/ccsdk-filters/pom.xml +++ b/features/ccsdk-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 242e6bb4e..ad832ccbb 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml index f810e43a6..bdb0c9a9b 100644 --- a/features/ccsdk-sli/pom.xml +++ b/features/ccsdk-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-sliPluginUtils/pom.xml b/features/ccsdk-sliPluginUtils/pom.xml index 032d78252..504f9d485 100644 --- a/features/ccsdk-sliPluginUtils/pom.xml +++ b/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-sliapi/pom.xml b/features/ccsdk-sliapi/pom.xml index 80180c5ab..10d14afb2 100644 --- a/features/ccsdk-sliapi/pom.xml +++ b/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/ccsdk-slicore-utils/pom.xml b/features/ccsdk-slicore-utils/pom.xml index ae54dcfd5..c0789c9da 100644 --- a/features/ccsdk-slicore-utils/pom.xml +++ b/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 6c334f386..8eed5be5b 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 1cece6422..60e9461fc 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/features/pom.xml b/features/pom.xml index 1dd48d6db..e2d6adb18 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 089b2f430..74bacb195 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/filters/pom.xml b/filters/pom.xml index 005ce2f19..2665940f7 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index f315cedae..69be5bed7 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/pom.xml b/pom.xml index 2eafc4163..912f44adf 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 3083a8ac5..776f712ff 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 8a39f79cc..5db57942e 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 5f969b2e0..34ea71a08 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sli/pom.xml b/sli/pom.xml index 8ef0c9c90..1e108b355 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 7f9e66b04..a970c38cc 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index cf4e004b3..10c29868a 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index f1094d099..2f568e2ba 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index fa99d4cc0..0b201f1f2 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 61e6c47b1..edf64ef03 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index cd9ffbd03..f8457df12 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 3dddd2062..7e49526e1 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 91f9eeefe..eef598a3d 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index d3dd4e215..6623ec3c7 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index d34c4e79c..29acc427a 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index d69cc74ad..ea0972996 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/utils/pom.xml b/utils/pom.xml index 2c4211073..93ccf6e3d 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1-SNAPSHOT + 1.5.1 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 554cef0f0..6581cde75 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.1-SNAPSHOT + 1.5.1 -- cgit 1.2.3-korg From a65bd87c69cbb4d560e3e03c11c486bfcf7b77f4 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 24 Jan 2020 10:26:40 -0500 Subject: Release CCSDK version 0.7.0 Release version 0.7.0 of CCSDK maven artifacts. Change-Id: Iebe198f06a3f09c0743c3191939a891b15220f9e Issue-ID: CCSDK-1963 Signed-off-by: Dan Timoney --- releases/0.7.0.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.7.0.yaml diff --git a/releases/0.7.0.yaml b/releases/0.7.0.yaml new file mode 100644 index 000000000..50ec2b4d4 --- /dev/null +++ b/releases/0.7.0.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.7.0' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/300/' -- cgit 1.2.3-korg From ce33837a7d1904fa18c3a368d37d837d9c9b7397 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 24 Jan 2020 15:56:59 -0500 Subject: Roll versions to next snapshot Roll CCSDK to next snapshot version Change-Id: I24f5470165522a4311c611785b323c1f81d41a8a Issue-ID: CCSDK-1963 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 4 ++-- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-dblib/pom.xml | 4 ++-- features/ccsdk-filters/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/ccsdk-sli/pom.xml | 4 ++-- features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- features/ccsdk-sliapi/pom.xml | 4 ++-- features/ccsdk-slicore-utils/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sli/recording/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/installer/pom.xml | 4 ++-- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 2 +- 36 files changed, 71 insertions(+), 71 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 43aed831f..f6c883c13 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.1 + 1.5.2-SNAPSHOT diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 606edd43e..ecc73ec1e 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index b955628c4..cd2b87244 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 4f34a3bce..745671c1c 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-dblib/pom.xml b/features/ccsdk-dblib/pom.xml index fad14f677..664898a7a 100644 --- a/features/ccsdk-dblib/pom.xml +++ b/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-filters/pom.xml b/features/ccsdk-filters/pom.xml index 21f995f85..24cc33b77 100644 --- a/features/ccsdk-filters/pom.xml +++ b/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index ad832ccbb..576cff0f0 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml index bdb0c9a9b..87fa657b0 100644 --- a/features/ccsdk-sli/pom.xml +++ b/features/ccsdk-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/features/ccsdk-sliPluginUtils/pom.xml b/features/ccsdk-sliPluginUtils/pom.xml index 504f9d485..c92dafc2a 100644 --- a/features/ccsdk-sliPluginUtils/pom.xml +++ b/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/features/ccsdk-sliapi/pom.xml b/features/ccsdk-sliapi/pom.xml index 10d14afb2..b1bf1550c 100644 --- a/features/ccsdk-sliapi/pom.xml +++ b/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/features/ccsdk-slicore-utils/pom.xml b/features/ccsdk-slicore-utils/pom.xml index c0789c9da..daf8e135f 100644 --- a/features/ccsdk-slicore-utils/pom.xml +++ b/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 8eed5be5b..08c00c496 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 60e9461fc..092b88d89 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index e2d6adb18..ee1d01e51 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 74bacb195..b03bf7545 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 2665940f7..b7d7c5fac 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 69be5bed7..fd24dbedb 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 912f44adf..c65d6c6ad 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 776f712ff..7ba721928 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 5db57942e..38905caee 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 34ea71a08..4e551da7a 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 1e108b355..4f758a24d 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index a970c38cc..4c6c64122 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT UTF-8 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 10c29868a..638bb9bbf 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 2f568e2ba..3a5afd974 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sli-recording - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 0b201f1f2..8a5455e73 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index edf64ef03..0dd6dcc15 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index f8457df12..be7f8514c 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 7e49526e1..2f363ef5a 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index eef598a3d..f25714bf6 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 6623ec3c7..1d568a429 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 29acc427a..5b2779643 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index ea0972996..fde570bad 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 93ccf6e3d..83c94905d 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 6581cde75..e228e2f11 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.1 + 1.5.2-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.7.0-SNAPSHOT + 0.7.1-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index fc68f0298..b05a161f6 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=0 sprint_number=7 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 48c0cd8b7726436d876cbc86c91e92b80583531b Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 31 Jan 2020 17:52:01 +0000 Subject: minor sli provider base changes add more unit testing, use constants for success/failure and improve some logging calls Issue-ID: CCSDK-2064 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I2c7039c706de1172bd506a20e96eb987cc86f211 --- .../onap/ccsdk/sli/core/sli/SvcLogicConstants.java | 7 +++ .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 15 +++++- .../ccsdk/sli/core/sli/SvcLogicContextTest.java | 27 ++++++++-- .../core/sli/provider/base/BlockNodeExecutor.java | 5 +- .../sli/provider/base/ConfigureNodeExecutor.java | 21 ++++---- .../core/sli/provider/base/DeleteNodeExecutor.java | 5 +- .../sli/provider/base/ExecuteNodeExecutor.java | 17 +++--- .../core/sli/provider/base/ExistsNodeExecutor.java | 5 +- .../core/sli/provider/base/ForNodeExecutor.java | 5 +- .../sli/provider/base/GetResourceNodeExecutor.java | 9 ++-- .../sli/provider/base/IsAvailableNodeExecutor.java | 5 +- .../core/sli/provider/base/NotifyNodeExecutor.java | 9 ++-- .../core/sli/provider/base/RecordNodeExecutor.java | 5 +- .../sli/provider/base/ReleaseNodeExecutor.java | 9 ++-- .../sli/provider/base/ReserveNodeExecutor.java | 9 ++-- .../core/sli/provider/base/SaveNodeExecutor.java | 5 +- .../core/sli/provider/base/UpdateNodeExecutor.java | 9 ++-- .../core/sli/provider/base/WhileNodeExecutor.java | 2 +- .../sli/core/sli/provider/base/GraphTests.java | 61 ++++++++++++++++++++++ .../sli/core/sli/provider/base/PluginTest.java | 6 +-- .../src/test/resources/breakGraph.xml | 26 +++++++++ .../sli/core/slipluginutils/SliPluginUtils.java | 17 +++--- .../SliPluginUtils_StaticFunctionsTest.java | 3 +- .../slipluginutils/SliPluginUtils_ctxSortList.java | 5 +- .../ccsdk/sli/core/utils/JREFileResolverTest.java | 3 +- .../sli/core/utils/KarafRootFileResolverTest.java | 3 +- .../utils/common/BundleContexFileResolverTest.java | 6 +-- .../utils/common/CoreDefaultFileResolverTest.java | 4 +- .../common/SdncConfigEnvVarFileResolverTest.java | 4 +- .../utils/dblib/DblibDefaultFileResolverTest.java | 4 +- .../utils/dblib/DblibEnvVarFileResolverTest.java | 4 +- 31 files changed, 225 insertions(+), 90 deletions(-) create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicConstants.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/GraphTests.java create mode 100644 sli/provider-base/src/test/resources/breakGraph.xml diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicConstants.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicConstants.java new file mode 100644 index 000000000..61bfe7c20 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicConstants.java @@ -0,0 +1,7 @@ +package org.onap.ccsdk.sli.core.sli; + +public class SvcLogicConstants { + public final static String SUCCESS = "success"; + public final static String FAILURE = "failure"; + +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index b592c15f6..549e6364f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -40,7 +40,7 @@ public class SvcLogicContext { private HashMap attributes; - private String status = "success"; + private String status = SvcLogicConstants.SUCCESS; public SvcLogicContext() { @@ -91,15 +91,28 @@ public class SvcLogicContext { { return attributes.keySet(); } + public Boolean isSuccess() { + return status.equals(SvcLogicConstants.SUCCESS); + } + @Deprecated public String getStatus() { return status; } + @Deprecated public void setStatus(String status) { this.status = status; } + public void markFailed() { + this.status = SvcLogicConstants.FAILURE; + } + + public void markSuccess() { + this.status = SvcLogicConstants.SUCCESS; + } + public Properties toProperties() { Properties props = new Properties(); diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java index 3b9fff75e..bad1209b0 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java @@ -24,20 +24,17 @@ package org.onap.ccsdk.sli.core.sli; import java.io.InputStream; import java.util.Enumeration; import java.util.Properties; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; - import junit.framework.TestCase; public class SvcLogicContextTest extends TestCase { private static final Logger LOG = LoggerFactory .getLogger(SvcLogicContext.class); - + public void testMerge() { try { @@ -62,4 +59,26 @@ public class SvcLogicContextTest extends TestCase { } + public void testIsSuccess() { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setStatus(SvcLogicConstants.SUCCESS); + assertTrue(ctx.isSuccess()); + ctx.setStatus(SvcLogicConstants.FAILURE); + assertFalse(ctx.isSuccess()); + } + + public void testMarkSuccess() { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.markSuccess(); + assertTrue(ctx.isSuccess()); + assertEquals(SvcLogicConstants.SUCCESS, ctx.getStatus()); + } + + public void testMarkFailed() { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.markFailed(); + assertFalse(ctx.isSuccess()); + assertEquals(SvcLogicConstants.FAILURE, ctx.getStatus()); + } + } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java index fb1527901..7079e263b 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/BlockNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -42,12 +43,12 @@ public class BlockNodeExecutor extends AbstractSvcLogicNodeExecutor { boolean isAtomic = "true".equalsIgnoreCase(atomicStr); // Initialize status to success so that at least one outcome will execute - ctx.setStatus("success"); + ctx.markSuccess(); int numOutcomes = node.getNumOutcomes(); for (int i = 0; i < numOutcomes; i++) { - if ("failure".equals(ctx.getStatus()) && isAtomic) { + if (SvcLogicConstants.FAILURE.equals(ctx.getStatus()) && isAtomic) { LOG.info("Block - stopped executing nodes due to failure status"); return(null); } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java index 55afa8594..a0e3af189 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Set; import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -48,7 +49,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { String adaptorName = SvcLogicExpressionResolver.evaluate( node.getAttribute("adaptor"), node, ctx); - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("configure node encountered - looking for adaptor " @@ -82,7 +83,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { switch (confStatus) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; if ((activate != null) && (activate.length() > 0)) { if ("true".equalsIgnoreCase(activate)) { SvcLogicAdaptor.ConfigStatus activateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; @@ -108,7 +109,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else if ("false".equalsIgnoreCase(activate)) { SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; @@ -134,7 +135,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } } @@ -150,7 +151,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { if ((activate != null) && (activate.length() > 0)) { @@ -164,7 +165,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { } switch (activateStatus) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case ALREADY_ACTIVE: outValue = ALREADY_ACTIVE; @@ -177,7 +178,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else if ("false".equalsIgnoreCase(activate)) { SvcLogicAdaptor.ConfigStatus deactivateStatus = SvcLogicAdaptor.ConfigStatus.FAILURE; @@ -190,7 +191,7 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { } switch (deactivateStatus) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case ALREADY_ACTIVE: outValue = ALREADY_ACTIVE; @@ -203,12 +204,12 @@ public class ConfigureNodeExecutor extends AbstractSvcLogicNodeExecutor { break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } } else { LOG.warn("Nothing to configure - no parameters passed, and activate attribute is not set"); - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; } } } else { diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/DeleteNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/DeleteNodeExecutor.java index 2393a159d..00f0629cb 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/DeleteNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/DeleteNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; @@ -31,7 +32,7 @@ import org.slf4j.LoggerFactory; public class DeleteNodeExecutor extends AbstractSvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(DeleteNodeExecutor.class); - private static final String FAILURE="failure"; + private static final String FAILURE=SvcLogicConstants.FAILURE; @Override public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) @@ -52,7 +53,7 @@ public class DeleteNodeExecutor extends AbstractSvcLogicNodeExecutor { try { switch (resourcePlugin.delete(resourceType, key, ctx)) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case NOT_FOUND: outValue = "not-found"; diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java index 0fe179b7a..7f2674e51 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java @@ -25,11 +25,8 @@ package org.onap.ccsdk.sli.core.sli.provider.base; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.Set; - +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -41,7 +38,7 @@ import org.slf4j.LoggerFactory; public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory .getLogger(ExecuteNodeExecutor.class); - private static final String FAILURE="failure"; + private static final String FAILURE=SvcLogicConstants.FAILURE; private static final String pluginErrorMessage = "Could not execute plugin. SvcLogic status will be set to failure."; public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, @@ -93,15 +90,15 @@ public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { LOG.error(pluginErrorMessage, e); } outValue = FAILURE; - ctx.setStatus(FAILURE); + ctx.markFailed(); } catch (IllegalAccessException e) { LOG.error(pluginErrorMessage, e); outValue = FAILURE; - ctx.setStatus(FAILURE); + ctx.markFailed(); } catch (IllegalArgumentException e) { LOG.error(pluginErrorMessage, e); outValue = FAILURE; - ctx.setStatus(FAILURE); + ctx.markFailed(); } } @@ -119,10 +116,10 @@ public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { if (nodeEmitsOutcome) { return (String) o; } else { - return "success"; + return SvcLogicConstants.SUCCESS; } } else { - return "success"; + return SvcLogicConstants.SUCCESS; } } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExistsNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExistsNodeExecutor.java index 397c5f326..ca12e35d8 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExistsNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExistsNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; @@ -41,7 +42,7 @@ public class ExistsNodeExecutor extends AbstractSvcLogicNodeExecutor { String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("exists node encountered - looking for resource class " + plugin); @@ -64,7 +65,7 @@ public class ExistsNodeExecutor extends AbstractSvcLogicNodeExecutor { } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ForNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ForNodeExecutor.java index 8ca1f32d5..2d9721c7f 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ForNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ForNodeExecutor.java @@ -22,6 +22,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; import org.onap.ccsdk.sli.core.sli.BreakNodeException; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -79,7 +80,7 @@ public class ForNodeExecutor extends AbstractSvcLogicNodeExecutor { for (int i = 0; i < numOutcomes; i++) { - if ("failure".equals(ctx.getStatus()) && isAtomic) { + if (SvcLogicConstants.FAILURE.equals(ctx.getStatus()) && isAtomic) { LOG.info("For - stopped executing nodes due to failure status"); return(null); } @@ -101,7 +102,7 @@ public class ForNodeExecutor extends AbstractSvcLogicNodeExecutor { } } } catch (BreakNodeException br) { - LOG.error("ForNodeExecutor caught break",br); + LOG.trace("ForNodeExecutor caught break" + br.getMessage()); } return (null); } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/GetResourceNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/GetResourceNodeExecutor.java index a2f1c63d8..f7cfc66d2 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/GetResourceNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/GetResourceNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -65,7 +66,7 @@ public class GetResourceNodeExecutor extends AbstractSvcLogicNodeExecutor { orderBy = SvcLogicExpressionResolver.evaluateAsKey(orderByExpr, node, ctx); } - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; if (LOG.isDebugEnabled()) { LOG.debug(node.getNodeType() + " node encountered - looking for resource class " + plugin); @@ -77,18 +78,18 @@ public class GetResourceNodeExecutor extends AbstractSvcLogicNodeExecutor { try { switch (resourcePlugin.query(resourceType, localOnly, select, key, pfx, orderBy, ctx)) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case NOT_FOUND: outValue = "not-found"; break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/IsAvailableNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/IsAvailableNodeExecutor.java index a93c0d6f2..1d6e34e85 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/IsAvailableNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/IsAvailableNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; @@ -41,7 +42,7 @@ public class IsAvailableNodeExecutor extends AbstractSvcLogicNodeExecutor { String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); String pfx = SvcLogicExpressionResolver.evaluate(node.getAttribute("pfx"), node, ctx); - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; SvcLogicResource resourcePlugin = getSvcLogicResource(plugin); @@ -60,7 +61,7 @@ public class IsAvailableNodeExecutor extends AbstractSvcLogicNodeExecutor { } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/NotifyNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/NotifyNodeExecutor.java index de59a4b73..fb560db5f 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/NotifyNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/NotifyNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; @@ -41,7 +42,7 @@ public class NotifyNodeExecutor extends AbstractSvcLogicNodeExecutor { String action = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("action"), node, ctx); String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("release node encountered - looking for resource class " + plugin); @@ -52,18 +53,18 @@ public class NotifyNodeExecutor extends AbstractSvcLogicNodeExecutor { try { switch (resourcePlugin.notify(resourceType, action, key, ctx)) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case NOT_FOUND: outValue = "not-found"; break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java index d233a36d7..2dd5a081e 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/RecordNodeExecutor.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -44,7 +45,7 @@ public class RecordNodeExecutor extends AbstractSvcLogicNodeExecutor { throws SvcLogicException { String plugin = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx); - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; Map parmMap = getResolvedParameters(node,ctx); @@ -54,7 +55,7 @@ public class RecordNodeExecutor extends AbstractSvcLogicNodeExecutor { recorder.record(parmMap); } catch (SvcLogicException e) { LOG.error("Caught exception from recorder plugin", e); - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { LOG.warn("Could not find SvcLogicRecorder object for plugin " + plugin); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReleaseNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReleaseNodeExecutor.java index ed9d7d7d0..ee06031d6 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReleaseNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReleaseNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; @@ -40,7 +41,7 @@ public class ReleaseNodeExecutor extends AbstractSvcLogicNodeExecutor { String resourceType = SvcLogicExpressionResolver.evaluate(node.getAttribute("resource"), node, ctx); String key = SvcLogicExpressionResolver.evaluateAsKey(node.getAttribute("key"), node, ctx); - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("release node encountered - looking for resource class " + plugin); @@ -51,18 +52,18 @@ public class ReleaseNodeExecutor extends AbstractSvcLogicNodeExecutor { try { switch (resourcePlugin.release(resourceType, key, ctx)) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case NOT_FOUND: outValue = "not-found"; break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReserveNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReserveNodeExecutor.java index 8e21a4594..d22d36ebb 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReserveNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ReserveNodeExecutor.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -50,7 +51,7 @@ public class ReserveNodeExecutor extends AbstractSvcLogicNodeExecutor { select = SvcLogicExpressionResolver.evaluateAsKey(selectExpr, node, ctx); } - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("reserve node encountered - looking for resource class " + plugin); @@ -65,18 +66,18 @@ public class ReserveNodeExecutor extends AbstractSvcLogicNodeExecutor { try { switch (resourcePlugin.reserve(resourceType, select, key, pfx, ctx)) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case NOT_FOUND: outValue = "not-found"; break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java index 64a44b3b9..b0b70f1f2 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SaveNodeExecutor.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory; public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor { private static final Logger LOG = LoggerFactory.getLogger(SaveNodeExecutor.class); - private static final String FAILURE= "failure"; + private static final String FAILURE= SvcLogicConstants.FAILURE; @Override public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node, SvcLogicContext ctx) @@ -71,7 +72,7 @@ public class SaveNodeExecutor extends AbstractSvcLogicNodeExecutor { try { switch (resourcePlugin.save(resourceType, force, localOnly, key, parmMap, pfx, ctx)) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case NOT_FOUND: outValue = "not-found"; diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java index 104f36f5f..c22c573cd 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/UpdateNodeExecutor.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicExpression; @@ -51,7 +52,7 @@ public class UpdateNodeExecutor extends AbstractSvcLogicNodeExecutor { Map parmMap = getResolvedParameters(node,ctx); - String outValue = "failure"; + String outValue = SvcLogicConstants.FAILURE; if (LOG.isDebugEnabled()) { LOG.debug("save node encountered - looking for resource class " + plugin); @@ -66,18 +67,18 @@ public class UpdateNodeExecutor extends AbstractSvcLogicNodeExecutor { try { switch (resourcePlugin.update(resourceType, key, parmMap, pfx, ctx)) { case SUCCESS: - outValue = "success"; + outValue = SvcLogicConstants.SUCCESS; break; case NOT_FOUND: outValue = "not-found"; break; case FAILURE: default: - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } catch (SvcLogicException e) { LOG.error("Caught exception from resource plugin", e); - outValue = "failure"; + outValue = SvcLogicConstants.FAILURE; } } else { LOG.warn("Could not find SvcLogicResource object for plugin " + plugin); diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/WhileNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/WhileNodeExecutor.java index c01e2f51f..3078b3437 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/WhileNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/WhileNodeExecutor.java @@ -67,7 +67,7 @@ public class WhileNodeExecutor extends AbstractSvcLogicNodeExecutor { } LOG.debug("testResult was " + testResult + " which is not equal to true, exiting while loop."); } catch (BreakNodeException e) { - LOG.debug("WhileNodeExecutor caught break"); + LOG.debug("WhileNodeExecutor caught break" + e.getMessage()); } return (null); } diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/GraphTests.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/GraphTests.java new file mode 100644 index 000000000..3534d5f90 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/GraphTests.java @@ -0,0 +1,61 @@ +package org.onap.ccsdk.sli.core.sli.provider.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import java.util.LinkedList; +import java.util.Map; +import java.util.Map.Entry; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GraphTests { + + private static final Logger LOG = LoggerFactory.getLogger(GraphTests.class); + private static final SvcLogicStore store = new InMemorySvcLogicStore(); + private static final HashMapResolver resolver = new HashMapResolver(); + private static final SvcLogicServiceBase svc = new SvcLogicServiceImplBase(store, resolver); + private static final SvcLogicParser p = new SvcLogicParser(); + // Write a very simple recorder so record nodes can be used during debugging + private static final SvcLogicRecorder recorder = new SvcLogicRecorder() { + @Override + public void record(Map map) throws SvcLogicException { + map.remove("level"); + for (Entry entry : map.entrySet()) { + LOG.debug(entry.getKey() + " = " + entry.getValue()); + } + } + }; + + @Test + public void testBreakNode() throws Exception { + // This graph as a for node that will loop with start 0 and end 999 + // in the loop idx is printed and variable "a" is incremented by 1 + // there is an if block in the loop that when a equals 2 a break node should execute and break out of the for + // loop + SvcLogicContext ctx = executeGraph("src/test/resources/breakGraph.xml"); + assertTrue(ctx.isSuccess()); + assertEquals("2", ctx.getAttribute("idx")); // the break should happen when idx equals 2 + assertEquals("3", ctx.getAttribute("a")); // incrementing a happens before the break so a should be idx + 1 + } + + public SvcLogicContext executeGraph(String pathToGraph) throws SvcLogicException { + return executeGraph(pathToGraph, new SvcLogicContext()); + } + + public SvcLogicContext executeGraph(String pathToGraph, SvcLogicContext context) throws SvcLogicException { + resolver.addSvcLogicRecorder("org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder", recorder); + LinkedList graphList = p.parse(pathToGraph); + SvcLogicGraph graph = graphList.get(0); + store.store(graph); + store.activate(graph); + return svc.execute(graph, context); + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java index 8eb5755e9..b154ecf01 100644 --- a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/provider/base/PluginTest.java @@ -24,7 +24,7 @@ package org.onap.ccsdk.sli.core.sli.provider.base; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; - +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; @@ -58,7 +58,7 @@ public class PluginTest extends TestCase { SvcLogicNode node = new SvcLogicNode(1, "return", graph); String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); String outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("success",outValue); + assertEquals(SvcLogicConstants.SUCCESS,outValue); } //Newer plugins can set the attribute emitsOutcome to true, if so they should return a string @@ -107,7 +107,7 @@ public class PluginTest extends TestCase { SvcLogicNode node = new SvcLogicNode(1, "return", graph); String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx); String outValue = executor.mapOutcome(o, emitsOutcome); - assertEquals("success",outValue); + assertEquals(SvcLogicConstants.SUCCESS,outValue); } } diff --git a/sli/provider-base/src/test/resources/breakGraph.xml b/sli/provider-base/src/test/resources/breakGraph.xml new file mode 100644 index 000000000..e2b89e84f --- /dev/null +++ b/sli/provider-base/src/test/resources/breakGraph.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 1fc052532..0d9ab217e 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -41,6 +41,7 @@ import java.util.Set; import java.util.UUID; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; @@ -935,19 +936,19 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { try { checkParameters(parameters, new String[]{"root"}, LOG); } catch (Exception ex) { - return "failure"; + return SvcLogicConstants.FAILURE; } String root = parameters.get("root"); if (StringUtils.isEmpty(root)) { - return "failure"; + return SvcLogicConstants.FAILURE; } // set context memory to the the properties passed with root as prefix setParameterValuesToRoot(parameters, ctx, root); - return "success"; + return SvcLogicConstants.SUCCESS; } private static boolean setParameterValuesToRoot(Map parameters, SvcLogicContext ctx, String root) { @@ -1003,7 +1004,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { checkParameters(parameters, new String[]{"prefixKey", "keyName", "keyValue"}, LOG); } catch (Exception e) { LOG.error("a required parameter is missing"); - return "failure"; + return SvcLogicConstants.FAILURE; } String prefixKey = parameters.get("prefixKey"); @@ -1012,7 +1013,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { if (StringUtils.isEmpty(keyName) || StringUtils.isEmpty(keyValue) || StringUtils.isEmpty(prefixKey)) { LOG.error("a required parameters value is empty or null"); - return "failure"; + return SvcLogicConstants.FAILURE; } int listLength = getArrayLength(ctx, prefixKey); @@ -1037,7 +1038,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { + "but " + map.size() + " entries were found in context memory " + "where the key begins with: " + prefixKey); - return "failure"; + return SvcLogicConstants.FAILURE; } } else if (ctxListContains(containParams, ctx) == "false") { setNewEntryInList(parameters, ctx, keyName, keyValue, prefixKey, valuePrefixKey, listLength); @@ -1059,10 +1060,10 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { } catch (SvcLogicException e) { LOG.error("Call to ctxListContains failed: " + e.getMessage()); - return "failure"; + return SvcLogicConstants.FAILURE; } - return "success"; + return SvcLogicConstants.SUCCESS; } private static void setNewEntryInList(Map parameters, SvcLogicContext ctx, String keyName, diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java index 64645b363..5c222c83f 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils.LogLevel; @@ -313,7 +314,7 @@ public class SliPluginUtils_StaticFunctionsTest { Map parameters = new HashMap<>(); parameters.put("root", "RootVal"); parameters.put("valueRoot", "ValueRootVal"); - assertEquals("success", SliPluginUtils.setPropertiesForRoot(parameters, ctx)); + assertEquals(SvcLogicConstants.SUCCESS, SliPluginUtils.setPropertiesForRoot(parameters, ctx)); } @Test diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java index 78e846aef..3d4469bf2 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_ctxSortList.java @@ -25,12 +25,11 @@ package org.onap.ccsdk.sli.core.slipluginutils; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - import java.util.HashMap; import java.util.Random; - import org.junit.Before; import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.slf4j.Logger; @@ -144,7 +143,7 @@ public class SliPluginUtils_ctxSortList { parameters.put("keyName", "testKey"); parameters.put("keyValue", "testValue"); - assertEquals("success", SliPluginUtils.setPropertiesForList(parameters, ctx)); + assertEquals(SvcLogicConstants.SUCCESS, SliPluginUtils.setPropertiesForList(parameters, ctx)); } } diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java index e5051d65a..8a066f057 100644 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java @@ -1,7 +1,6 @@ package org.onap.ccsdk.sli.core.utils; -import static org.junit.Assert.*; - +import static org.junit.Assert.assertEquals; import org.junit.Test; public class JREFileResolverTest { diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java index 5e407daf6..df16b41d0 100644 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java @@ -1,7 +1,6 @@ package org.onap.ccsdk.sli.core.utils; -import static org.junit.Assert.*; - +import static org.junit.Assert.assertEquals; import org.junit.Test; public class KarafRootFileResolverTest { diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java index 4ec5e1b48..7ddf550b0 100644 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java @@ -1,7 +1,6 @@ package org.onap.ccsdk.sli.core.utils.common; -import static org.junit.Assert.*; - +import static org.junit.Assert.assertEquals; import org.junit.Test; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; @@ -9,7 +8,8 @@ public class BundleContexFileResolverTest { @Test public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new BundleContextFileResolver("success", BundleContexFileResolverTest.class); + final PropertiesFileResolver resolver = + new BundleContextFileResolver("success", BundleContexFileResolverTest.class); assertEquals("success", resolver.getSuccessfulResolutionMessage()); } diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java index a4f8817fa..f1f5f2244 100644 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java @@ -1,7 +1,7 @@ package org.onap.ccsdk.sli.core.utils.common; -import static org.junit.Assert.*; - +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.io.File; import java.util.Optional; import org.junit.Test; diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java index 0f3536b78..130dc0a1e 100644 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java @@ -1,7 +1,7 @@ package org.onap.ccsdk.sli.core.utils.common; -import static org.junit.Assert.*; - +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.io.File; import java.util.Optional; import org.junit.Test; diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java index 4b28d449d..834a8c449 100644 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java @@ -1,7 +1,7 @@ package org.onap.ccsdk.sli.core.utils.dblib; -import static org.junit.Assert.*; - +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.io.File; import java.util.Optional; import org.junit.Test; diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java index bae4168d8..b5150ab67 100644 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java +++ b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java @@ -1,7 +1,7 @@ package org.onap.ccsdk.sli.core.utils.dblib; -import static org.junit.Assert.*; - +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.io.File; import java.util.Optional; import org.junit.Test; -- cgit 1.2.3-korg From 599315984b449ca05f00b35037a103f1dc335030 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Mon, 3 Feb 2020 16:02:18 +0000 Subject: MdsalHelper testing and loggingh make one log statement quieter and add unit tests for MdsalHelper Issue-ID: CCSDK-2071 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I7af1b2c0dce47c2d5970de4950c951c58fa4fb65 --- .../ccsdk/sli/core/sli/provider/MdsalHelper.java | 3 +- .../sli/core/sli/provider/MdsalHelperTest.java | 1014 ++++++++++++++------ 2 files changed, 701 insertions(+), 316 deletions(-) diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 89e4ee734..122c8862d 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -695,7 +695,8 @@ public class MdsalHelper { builderObj = builderClass.newInstance(); paramObj = toBuilder(props, propNamePfx, builderObj); } catch (ClassNotFoundException e) { - LOG.info("Builder class {} not found ", builderName, e); + LOG.trace("Builder class {} not found catching ClassNotFoundException and trying other methods", + builderName); if (paramValue == null) { try { boolean isAccessible = m.isAccessible(); diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index cebb99663..50a6bbce2 100755 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -21,344 +21,728 @@ package org.onap.ccsdk.sli.core.sli.provider; +import java.math.BigDecimal; +import java.math.BigInteger; import java.net.Inet6Address; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; - import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.Builtin.SampleBits; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.Builtin.SampleEnumeration; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.Builtin.SampleUnion; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.Percentage; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.SampleContainer; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.SampleContainerBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.sample.container.LoginBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.sample.container.login.CustomerAddresses; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.testmodel.rev190723.sample.container.login.CustomerAddressesBuilder; import org.opendaylight.yang.gen.v1.test.TestObjectBuilder; import org.opendaylight.yang.gen.v1.test.WrapperObj; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.DomainName; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.HostBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZoneBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefixBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpVersion; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import junit.framework.TestCase; public class MdsalHelperTest extends TestCase { - private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTest.class); - public static final String pathToSdnPropertiesFile = "src/test/resources/l3sdn.properties"; - - public void testSdnProperties() { - - MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile); - assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "synccomplete")); - assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); - assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete")); - assertEquals("service-configuration-operation", - MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", "service-configuration-operation")); - } - - public void testNegativeSdnProperties() { - assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); - } - - public void testToProperties() { - - ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); - SliParameterBuilder parmBuilder = new SliParameterBuilder(); - List params = new LinkedList(); - - parmBuilder.setParameterName("boolean-parm"); - parmBuilder.setBooleanValue(Boolean.TRUE); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("int-parm"); - parmBuilder.setBooleanValue(null); - parmBuilder.setIntValue(1); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("str-parm"); - parmBuilder.setIntValue(null); - parmBuilder.setStringValue("hello"); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("ipaddress4-parm"); - parmBuilder.setStringValue(null); - parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("ipaddress6-parm"); - parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1")); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("ipprefix-parm"); - parmBuilder.setIpaddressValue(null); - parmBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("10.0.0.0/24")); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("portnumber-parm"); - parmBuilder.setIpprefixValue(null); - parmBuilder.setPortNumber(PortNumber.getDefaultInstance("8080")); - params.add(parmBuilder.build()); - - parmBuilder.setParameterName("dcsp-parm"); - parmBuilder.setPortNumber(null); - parmBuilder.setDscp(Dscp.getDefaultInstance("57")); - params.add(parmBuilder.build()); - - execBuilder.setMode(Mode.Sync); - execBuilder.setModuleName("my-module"); - execBuilder.setRpcName("do-it-now"); - execBuilder.setSliParameter(params); - - Properties props = new Properties(); - - MdsalHelperTesterUtil.toProperties(props, execBuilder); - - LOG.info("Converted to properties"); - for (Map.Entry e : props.entrySet()) { - LOG.info(e.getKey().toString() + " = " + e.getValue().toString()); - - } - - } - - public void testToBuilder() { - - Properties props = new Properties(); - - props.setProperty("execute-graph-input.mode", "Sync"); - props.setProperty("execute-graph-input.module", "my-module"); - props.setProperty("execute-graph-input.rpc", "do-it-now"); - props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm"); - props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true"); - props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param"); - props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1"); - props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param"); - props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello"); - props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param"); - props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1"); - props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param"); - props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1"); - ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); - - MdsalHelperTesterUtil.toBuilder(props, execBuilder); - - } - - public void testToJavaEnum() throws Exception { - assertEquals("VENDOR6500MODEL", MdsalHelper.toJavaEnum("VENDOR_6500_MODEL")); - assertEquals("_2018HelloWorld", MdsalHelper.toJavaEnum("2018Hello World")); - assertEquals("SomethingElse", MdsalHelper.toJavaEnum("Something.Else")); - assertEquals("MyTestString", MdsalHelper.toJavaEnum("my-test-string")); - } - - // During the default enumeration mapping no properties file is needed, the yang - // value is returned - // by the java object - public void testDefaultEnumerationMapping() throws Exception { - Properties props = new Properties(); - MdsalHelper.toProperties(props, new WrapperObj()); - assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type")); - } - - // When no properties file exists the default java value will be returned if - // legacy enumeration - // mapping is enabled - public void testLegacyEnumerationMappingNoProperties() throws Exception { - Properties props = new Properties(); - MdsalHelper.toProperties(props, new WrapperObj(), true); - assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type")); - } - - // When a properties file exists & legacy enumeration mapping is enabled the - // value from the - // properties file should be returned - public void testLegacyEnumerationMappingWithProperties() throws Exception { - MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties"); - Properties props = new Properties(); - MdsalHelper.toProperties(props, new WrapperObj(), true); - assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type")); - } - - public void testSingleIpAddressToProperties() throws Exception { - Properties props = new Properties(); - String ipAddress = "11.11.11.11"; - MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(ipAddress)); - assertEquals(ipAddress, props.getProperty("")); - ipAddress = "cafe::8888"; - MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(ipAddress)); - assertEquals(ipAddress, props.getProperty("")); - } - - - public void testSingleIpAddressToBuilder() throws Exception { - Properties props = new Properties(); - String ipAddress = "11.11.11.11"; - props.setProperty("test-object.single-ip", ipAddress); - TestObjectBuilder b = new TestObjectBuilder(); - MdsalHelper.toBuilder(props, b); - - assertEquals(ipAddress,String.valueOf(b.getSingleIp().stringValue())); - - ipAddress = "cafe::8888"; - props.setProperty("test-object.single-ip", ipAddress); - b = new TestObjectBuilder(); - MdsalHelper.toBuilder(props, b); - assertEquals(ipAddress,String.valueOf(b.getSingleIp().stringValue())); - } - - public void testIpAddressListToProperties() throws Exception { - Properties props = new Properties(); - String ipAddress = "11.11.11.11"; - TestObjectBuilder b = new TestObjectBuilder(); - List ipAddressList = new ArrayList(); - ipAddressList.add(IpAddressBuilder.getDefaultInstance(ipAddress)); - b.setFloatingIp(ipAddressList ); - MdsalHelper.toProperties(props, b.build()); - assertEquals(ipAddress, props.getProperty("test-object.floating-ip[0]")); - assertEquals("1", props.getProperty("test-object.floating-ip_length")); - } - - public void testIpAddressListToBuilder() throws Exception { - Properties props = new Properties(); - String ipaddress = "11.11.11.12"; - props.setProperty("test-object.floating-ip_length", "1"); - props.setProperty("test-object.floating-ip[0]", ipaddress); - TestObjectBuilder b = new TestObjectBuilder(); - MdsalHelper.toBuilder(props, b); - assertEquals(ipaddress,String.valueOf(b.getFloatingIp().get(0).stringValue())); - - props = new Properties(); - ipaddress = "cafe::8888"; - props.setProperty("test-object.floating-ip_length", "1"); - props.setProperty("test-object.floating-ip[0]", ipaddress); - b = new TestObjectBuilder(); - MdsalHelper.toBuilder(props, b); - assertEquals(ipaddress,String.valueOf(b.getFloatingIp().get(0).stringValue())); - } - - - public void testSingleIpv4AddressToProperties() throws Exception { - Properties props = new Properties(); - String v4address = "11.11.11.11"; - MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(v4address).getIpv4Address()); - assertEquals(v4address, props.getProperty("")); - } - - public void testSingleIpv4AddressToBuilder() throws Exception { - Properties props = new Properties(); - String v4address = "11.11.11.11"; - props.setProperty("test-object.single-ip-v4", v4address); - TestObjectBuilder b = new TestObjectBuilder(); - MdsalHelper.toBuilder(props, b); - assertEquals(v4address,b.getSingleIpV4().getValue()); - } - - public void testIpv4AddressListToProperties() throws Exception { - Properties props = new Properties(); - String v4address = "11.11.11.11"; - - TestObjectBuilder b = new TestObjectBuilder(); - List v4list = new ArrayList(); - v4list.add(IpAddressBuilder.getDefaultInstance(v4address).getIpv4Address()); - b.setFloatingIpV4(v4list ); - MdsalHelper.toProperties(props, b.build()); - assertEquals(v4address, props.getProperty("test-object.floating-ip-v4[0]")); - assertEquals("1", props.getProperty("test-object.floating-ip-v4_length")); - } - - public void testIpv4AddressListToBuilder() throws Exception { - Properties props = new Properties(); - String v4address = "11.11.11.12"; - props.setProperty("test-object.floating-ip-v4_length", "1"); - props.setProperty("test-object.floating-ip-v4[0]", v4address); - TestObjectBuilder b = new TestObjectBuilder(); - MdsalHelper.toBuilder(props, b); - assertEquals(v4address,b.getFloatingIpV4().get(0).getValue()); - } - - public void testSingleIpv6AddressToProperties() throws Exception { - Properties props = new Properties(); - String v6address = "cafe::8888"; - MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(v6address).getIpv6Address()); - MdsalHelper.toBuilder(props, IpAddressBuilder.getDefaultInstance("cafe::8887")); - assertEquals(v6address, props.getProperty("")); - } - - public void testSingleIpv6AddressToBuilder() throws Exception { - Properties props = new Properties(); - String v6address = "cafe::8888"; - props.setProperty("test-object.single-ip-v6", v6address); - TestObjectBuilder b = new TestObjectBuilder(); - MdsalHelper.toBuilder(props, b); - assertEquals(v6address,b.getSingleIpV6().getValue()); - } - - public void testIpv6AddressListToProperties() throws Exception { - Properties props = new Properties(); - String v6address = "cafe::8888"; - - TestObjectBuilder b = new TestObjectBuilder(); - List v6list = new ArrayList(); - v6list.add(IpAddressBuilder.getDefaultInstance(v6address).getIpv6Address()); - b.setFloatingIpV6(v6list); - MdsalHelper.toProperties(props, b.build()); - assertEquals(v6address, props.getProperty("test-object.floating-ip-v6[0]")); - assertEquals("1", props.getProperty("test-object.floating-ip-v6_length")); - } - - public void testIpv6AddressListToBuilder() throws Exception { - Properties props = new Properties(); - String v6address = "cafe::8888"; - props.setProperty("test-object.floating-ip-v6_length", "1"); - props.setProperty("test-object.floating-ip-v6[0]", v6address); - TestObjectBuilder b = new TestObjectBuilder(); - MdsalHelper.toBuilder(props, b); - assertEquals(v6address,b.getFloatingIpV6().get(0).getValue()); - } - - public void testIpPrefix() throws Exception { - String ipPrefix = "10.0.0.0/24"; - Properties props = new Properties(); - MdsalHelper.toProperties(props, IpPrefixBuilder.getDefaultInstance(ipPrefix)); - assertEquals(ipPrefix, props.getProperty("")); - } - - public void testPortNumber() throws Exception { - Properties props = new Properties(); - String portNumber = "5"; - MdsalHelper.toProperties(props, PortNumber.getDefaultInstance(portNumber)); - assertEquals(portNumber, props.getProperty("")); - } - - public void testDscp() throws Exception { - Properties props = new Properties(); - String dscp = "1"; - MdsalHelper.toProperties(props, Dscp.getDefaultInstance(dscp)); - assertEquals(dscp, props.getProperty("")); - } - - public void testIetfInet() throws Exception { - Properties props = new Properties(); - Inet6Address address = IetfInetUtil.INSTANCE - .inet6AddressFor(IpAddressBuilder.getDefaultInstance("cafe::8888").getIpv6Address()); - MdsalHelper.toProperties(props, address); - assertEquals("/cafe:0:0:0:0:0:0:8888", props.getProperty("")); - } - - public void testGetFullPropertiesPath() { - String propertiesName = "l3ucpe.properties"; - String path = MdsalHelper.getFullPropertiesPath(propertiesName); - //verify the default works - assertEquals("/opt/lsc/controller/configuration/l3ucpe.properties",path); - System.setProperty("karaf.home", "/opt/opendaylight/current"); - path = MdsalHelper.getFullPropertiesPath(propertiesName); - //verify the system property is read - assertEquals("/opt/opendaylight/current/configuration/l3ucpe.properties",path); - } + private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTest.class); + public static final String pathToSdnPropertiesFile = "src/test/resources/l3sdn.properties"; + + public void testSdnProperties() { + + MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile); + assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "synccomplete")); + assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete")); + assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete")); + assertEquals("service-configuration-operation", + MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", "service-configuration-operation")); + } + + public void testNegativeSdnProperties() { + assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete")); + } + + public void testToProperties() { + + ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); + SliParameterBuilder parmBuilder = new SliParameterBuilder(); + List params = new LinkedList(); + + parmBuilder.setParameterName("boolean-parm"); + parmBuilder.setBooleanValue(Boolean.TRUE); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("int-parm"); + parmBuilder.setBooleanValue(null); + parmBuilder.setIntValue(1); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("str-parm"); + parmBuilder.setIntValue(null); + parmBuilder.setStringValue("hello"); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("ipaddress4-parm"); + parmBuilder.setStringValue(null); + parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1")); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("ipaddress6-parm"); + parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1")); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("ipprefix-parm"); + parmBuilder.setIpaddressValue(null); + parmBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("10.0.0.0/24")); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("portnumber-parm"); + parmBuilder.setIpprefixValue(null); + parmBuilder.setPortNumber(PortNumber.getDefaultInstance("8080")); + params.add(parmBuilder.build()); + + parmBuilder.setParameterName("dcsp-parm"); + parmBuilder.setPortNumber(null); + parmBuilder.setDscp(Dscp.getDefaultInstance("57")); + params.add(parmBuilder.build()); + + execBuilder.setMode(Mode.Sync); + execBuilder.setModuleName("my-module"); + execBuilder.setRpcName("do-it-now"); + execBuilder.setSliParameter(params); + + Properties props = new Properties(); + + MdsalHelperTesterUtil.toProperties(props, execBuilder); + + LOG.info("Converted to properties"); + for (Map.Entry e : props.entrySet()) { + LOG.info(e.getKey().toString() + " = " + e.getValue().toString()); + + } + + } + + public void testToBuilder() { + + Properties props = new Properties(); + + props.setProperty("execute-graph-input.mode", "Sync"); + props.setProperty("execute-graph-input.module", "my-module"); + props.setProperty("execute-graph-input.rpc", "do-it-now"); + props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm"); + props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true"); + props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param"); + props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1"); + props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param"); + props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello"); + props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param"); + props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1"); + props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param"); + props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1"); + ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder(); + + MdsalHelperTesterUtil.toBuilder(props, execBuilder); + + } + + public void testToJavaEnum() throws Exception { + assertEquals("VENDOR6500MODEL", MdsalHelper.toJavaEnum("VENDOR_6500_MODEL")); + assertEquals("_2018HelloWorld", MdsalHelper.toJavaEnum("2018Hello World")); + assertEquals("SomethingElse", MdsalHelper.toJavaEnum("Something.Else")); + assertEquals("MyTestString", MdsalHelper.toJavaEnum("my-test-string")); + } + + // During the default enumeration mapping no properties file is needed, the yang + // value is returned + // by the java object + public void testDefaultEnumerationMapping() throws Exception { + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj()); + assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type")); + } + + // When no properties file exists the default java value will be returned if + // legacy enumeration + // mapping is enabled + public void testLegacyEnumerationMappingNoProperties() throws Exception { + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj(), true); + assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type")); + } + + // When a properties file exists & legacy enumeration mapping is enabled the + // value from the + // properties file should be returned + public void testLegacyEnumerationMappingWithProperties() throws Exception { + MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties"); + Properties props = new Properties(); + MdsalHelper.toProperties(props, new WrapperObj(), true); + assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type")); + } + + public void testSingleIpAddressToProperties() throws Exception { + Properties props = new Properties(); + String ipAddress = "11.11.11.11"; + MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(ipAddress)); + assertEquals(ipAddress, props.getProperty("")); + ipAddress = "cafe::8888"; + MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(ipAddress)); + assertEquals(ipAddress, props.getProperty("")); + } + + public void testSingleIpAddressToBuilder() throws Exception { + Properties props = new Properties(); + String ipAddress = "11.11.11.11"; + props.setProperty("test-object.single-ip", ipAddress); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + + assertEquals(ipAddress, String.valueOf(b.getSingleIp().stringValue())); + + ipAddress = "cafe::8888"; + props.setProperty("test-object.single-ip", ipAddress); + b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(ipAddress, String.valueOf(b.getSingleIp().stringValue())); + } + + public void testIpAddressListToProperties() throws Exception { + Properties props = new Properties(); + String ipAddress = "11.11.11.11"; + TestObjectBuilder b = new TestObjectBuilder(); + List ipAddressList = new ArrayList(); + ipAddressList.add(IpAddressBuilder.getDefaultInstance(ipAddress)); + b.setFloatingIp(ipAddressList); + MdsalHelper.toProperties(props, b.build()); + assertEquals(ipAddress, props.getProperty("test-object.floating-ip[0]")); + assertEquals("1", props.getProperty("test-object.floating-ip_length")); + } + + public void testIpAddressListToBuilder() throws Exception { + Properties props = new Properties(); + String ipaddress = "11.11.11.12"; + props.setProperty("test-object.floating-ip_length", "1"); + props.setProperty("test-object.floating-ip[0]", ipaddress); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(ipaddress, String.valueOf(b.getFloatingIp().get(0).stringValue())); + + props = new Properties(); + ipaddress = "cafe::8888"; + props.setProperty("test-object.floating-ip_length", "1"); + props.setProperty("test-object.floating-ip[0]", ipaddress); + b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(ipaddress, String.valueOf(b.getFloatingIp().get(0).stringValue())); + } + + public void testSingleIpv4AddressToProperties() throws Exception { + Properties props = new Properties(); + String v4address = "11.11.11.11"; + MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(v4address).getIpv4Address()); + assertEquals(v4address, props.getProperty("")); + } + + public void testSingleIpv4AddressToBuilder() throws Exception { + Properties props = new Properties(); + String v4address = "11.11.11.11"; + props.setProperty("test-object.single-ip-v4", v4address); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(v4address, b.getSingleIpV4().getValue()); + } + + public void testIpv4AddressListToProperties() throws Exception { + Properties props = new Properties(); + String v4address = "11.11.11.11"; + + TestObjectBuilder b = new TestObjectBuilder(); + List v4list = new ArrayList(); + v4list.add(IpAddressBuilder.getDefaultInstance(v4address).getIpv4Address()); + b.setFloatingIpV4(v4list); + MdsalHelper.toProperties(props, b.build()); + assertEquals(v4address, props.getProperty("test-object.floating-ip-v4[0]")); + assertEquals("1", props.getProperty("test-object.floating-ip-v4_length")); + } + + public void testIpv4AddressListToBuilder() throws Exception { + Properties props = new Properties(); + String v4address = "11.11.11.12"; + props.setProperty("test-object.floating-ip-v4_length", "1"); + props.setProperty("test-object.floating-ip-v4[0]", v4address); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(v4address, b.getFloatingIpV4().get(0).getValue()); + } + + public void testSingleIpv6AddressToProperties() throws Exception { + Properties props = new Properties(); + String v6address = "cafe::8888"; + MdsalHelper.toProperties(props, IpAddressBuilder.getDefaultInstance(v6address).getIpv6Address()); + MdsalHelper.toBuilder(props, IpAddressBuilder.getDefaultInstance("cafe::8887")); + assertEquals(v6address, props.getProperty("")); + } + + public void testSingleIpv6AddressToBuilder() throws Exception { + Properties props = new Properties(); + String v6address = "cafe::8888"; + props.setProperty("test-object.single-ip-v6", v6address); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(v6address, b.getSingleIpV6().getValue()); + } + + public void testIpv6AddressListToProperties() throws Exception { + Properties props = new Properties(); + String v6address = "cafe::8888"; + + TestObjectBuilder b = new TestObjectBuilder(); + List v6list = new ArrayList(); + v6list.add(IpAddressBuilder.getDefaultInstance(v6address).getIpv6Address()); + b.setFloatingIpV6(v6list); + MdsalHelper.toProperties(props, b.build()); + assertEquals(v6address, props.getProperty("test-object.floating-ip-v6[0]")); + assertEquals("1", props.getProperty("test-object.floating-ip-v6_length")); + } + + public void testIpv6AddressListToBuilder() throws Exception { + Properties props = new Properties(); + String v6address = "cafe::8888"; + props.setProperty("test-object.floating-ip-v6_length", "1"); + props.setProperty("test-object.floating-ip-v6[0]", v6address); + TestObjectBuilder b = new TestObjectBuilder(); + MdsalHelper.toBuilder(props, b); + assertEquals(v6address, b.getFloatingIpV6().get(0).getValue()); + } + + public void testIpPrefix() throws Exception { + String ipPrefix = "10.0.0.0/24"; + Properties props = new Properties(); + MdsalHelper.toProperties(props, IpPrefixBuilder.getDefaultInstance(ipPrefix)); + assertEquals(ipPrefix, props.getProperty("")); + } + + public void testPortNumber() throws Exception { + Properties props = new Properties(); + String portNumber = "5"; + MdsalHelper.toProperties(props, PortNumber.getDefaultInstance(portNumber)); + assertEquals(portNumber, props.getProperty("")); + } + + public void testDscp() throws Exception { + Properties props = new Properties(); + String dscp = "1"; + MdsalHelper.toProperties(props, Dscp.getDefaultInstance(dscp)); + assertEquals(dscp, props.getProperty("")); + } + + public void testIetfInet() throws Exception { + Properties props = new Properties(); + Inet6Address address = + IetfInetUtil.INSTANCE.inet6AddressFor(IpAddressBuilder.getDefaultInstance("cafe::8888").getIpv6Address()); + MdsalHelper.toProperties(props, address); + assertEquals("/cafe:0:0:0:0:0:0:8888", props.getProperty("")); + } + + public void testAsNumber() throws Exception { + String value = "1"; + Properties props = new Properties(); + AsNumber num = AsNumber.getDefaultInstance(value); + MdsalHelper.toProperties(props, num); + assertEquals(value, props.getProperty("as-number")); + assertEquals(value, props.getProperty("as-number.value")); + + } + + public void testGetFullPropertiesPath() { + String propertiesName = "l3ucpe.properties"; + String path = MdsalHelper.getFullPropertiesPath(propertiesName); + // verify the default works + assertEquals("/opt/lsc/controller/configuration/l3ucpe.properties", path); + System.setProperty("karaf.home", "/opt/opendaylight/current"); + path = MdsalHelper.getFullPropertiesPath(propertiesName); + // verify the system property is read + assertEquals("/opt/opendaylight/current/configuration/l3ucpe.properties", path); + } + + public void testToPropertiesWithBinary() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Properties props = new Properties(); + byte arr[] = new byte[] {1, 6, 3}; + sampleBuilder.setSampleBinary(arr); + MdsalHelper.toProperties(props, sampleBuilder); + assertNotNull(props.get("sample-container.sample-binary")); + } + + public void testToPropertiesWithBits() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Boolean fanRunning = true; + Boolean hdLed = false; + Boolean powerLed = false; + SampleBits sampleBits = new SampleBits(fanRunning, hdLed, powerLed); + sampleBuilder.setSampleBits(sampleBits); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(fanRunning.toString(), props.get("sample-container.sample-bits.fan-running")); + assertEquals(hdLed.toString(), props.get("sample-container.sample-bits.hd-led")); + assertEquals(powerLed.toString(), props.get("sample-container.sample-bits.power-led")); + } + + public void testToPropertiesWithBoolean() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Boolean myBoolean = true; + sampleBuilder.setSampleBoolean(myBoolean); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myBoolean.toString(), props.get("sample-container.sample-boolean")); + } + + public void testToPropertiesWithDecimal64() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + BigDecimal myBigDecimal = new BigDecimal(".0000000000000000000000000000001"); + sampleBuilder.setSampleDecimal64(myBigDecimal); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + // note toString() value is 1E-31 + assertEquals(myBigDecimal.toString(), props.get("sample-container.sample-decimal64")); + } + + public void testToPropertiesWithEmpty() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Boolean isEmpty = true; + sampleBuilder.setSampleEmpty(isEmpty); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(isEmpty.toString(), props.get("sample-container.sample-empty")); + } + + public void testToPropertiesWithEnumeration() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Properties props = new Properties(); + SampleEnumeration currentEnum = SampleEnumeration.ShelfSlotPort; + sampleBuilder.setSampleEnumeration(currentEnum); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals("shelf.slot.port", props.get("sample-container.sample-enumeration")); + + currentEnum = SampleEnumeration.NotAvailable; + sampleBuilder.setSampleEnumeration(currentEnum); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals("not available", props.get("sample-container.sample-enumeration")); + + currentEnum = SampleEnumeration.CURRENTLYAVAILABLE; + sampleBuilder.setSampleEnumeration(currentEnum); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals("CURRENTLY_AVAILABLE", props.get("sample-container.sample-enumeration")); + + currentEnum = SampleEnumeration._200OK; + sampleBuilder.setSampleEnumeration(currentEnum); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals("200OK", props.get("sample-container.sample-enumeration")); + + currentEnum = SampleEnumeration.HyphenSeparatedValue; + sampleBuilder.setSampleEnumeration(currentEnum); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals("hyphen-separated-value", props.get("sample-container.sample-enumeration")); + } + + // TODO test sampleBuilder.setSampleIdentityref(value); + + public void testToPropertiesWithInt8() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Byte myByte = new Byte("-128"); + sampleBuilder.setSampleInt8(myByte); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myByte.toString(), props.get("sample-container.sample-int8")); + } + + public void testToPropertiesWithInt16() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Short myShort = new Short("-32768"); + sampleBuilder.setSampleInt16(myShort); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myShort.toString(), props.get("sample-container.sample-int16")); + } + + public void testToPropertiesWithInt32() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Integer myInt = new Integer("-32768"); + sampleBuilder.setSampleInt32(myInt); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myInt.toString(), props.get("sample-container.sample-int32")); + } + + public void testToPropertiesWithInt64() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Long myLong = new Long("-9223372036854775808"); + sampleBuilder.setSampleInt64(myLong); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myLong.toString(), props.get("sample-container.sample-int64")); + } + + public void testToPropertiesWithLeafRef() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Boolean myBool = false; + sampleBuilder.setSampleLeafref(myBool); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myBool.toString(), props.get("sample-container.sample-leafref")); + } + + public void testToPropertiesWithString() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + String myString = "Hello World!"; + sampleBuilder.setSampleString(myString); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myString.toString(), props.get("sample-container.sample-string")); + } + + public void testToPropertiesWithuInt8() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Short myShort = new Short("255"); + sampleBuilder.setSampleUint8(myShort); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myShort.toString(), props.get("sample-container.sample-uint8")); + } + + public void testToPropertiesWithuInt16() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Integer myInt = new Integer("65535"); + sampleBuilder.setSampleUint16(myInt); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myInt.toString(), props.get("sample-container.sample-uint16")); + } + + public void testToPropertiesWithuInt32() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Long myLong = new Long("4294967295"); + sampleBuilder.setSampleUint32(myLong); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myLong.toString(), props.get("sample-container.sample-uint32")); + } + + public void testToPropertiesWithuInt64() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + BigInteger myBigInt = new BigInteger("2432902008176640000"); + sampleBuilder.setSampleUint64(myBigInt); + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myBigInt.toString(), props.get("sample-container.sample-uint64")); + } + + public void testToPropertiesFromBuilderUnion() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Properties props = new Properties(); + + Integer myInt = new Integer("1"); + SampleUnion test = new SampleUnion(myInt); + sampleBuilder.setSampleUnion(test); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(test.getInt32().toString(), props.get("sample-container.sample-union.int32")); + + test = new SampleUnion(SampleUnion.Enumeration.Unbounded); + sampleBuilder.setSampleUnion(test); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals("unbounded", props.get("sample-container.sample-union.enumeration")); + } + + public void testToPropertiesWithCustomType() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + Properties props = new Properties(); + + Short myShort = new Short("99"); + Percentage myPercent = new Percentage(myShort); + sampleBuilder.setPercentCompleted(myPercent); + MdsalHelper.toProperties(props, sampleBuilder); + assertEquals(myShort.toString(), props.get("sample-container.percent-completed")); + assertEquals(myShort.toString(), props.get("sample-container.percent-completed.value")); + } + + public void testToPropertiesWithLeaftList() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + List nickNames = new ArrayList(); + sampleBuilder.setCustomerNicknames(nickNames); + String nameOne = "coffee"; + String nameTwo = "java"; + String nameThree = "mud"; + + nickNames.add(nameOne); + nickNames.add(nameTwo); + nickNames.add(nameThree); + + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + + assertEquals(nameOne, props.get("sample-container.customer-nicknames[0]")); + assertEquals(nameTwo, props.get("sample-container.customer-nicknames[1]")); + assertEquals(nameThree, props.get("sample-container.customer-nicknames[2]")); + assertEquals(String.valueOf(nickNames.size()), props.get("sample-container.customer-nicknames_length")); + } + + public void testToPropertiesWithComplexContainer() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + LoginBuilder lb = new LoginBuilder(); + lb.setMessage("WELCOME!"); + List addresses = new ArrayList(); + CustomerAddressesBuilder cab = new CustomerAddressesBuilder(); + cab.setAddressName("home"); + cab.setState("NJ"); + cab.setStreetAddress("yellowbrick road"); + + CustomerAddresses addressOne = cab.build(); + addresses.add(addressOne); + + cab.setAddressName("vacation house"); + cab.setState("FL"); + cab.setStreetAddress("ocean ave"); + + CustomerAddresses addressTwo = cab.build(); + addresses.add(addressTwo); + + lb.setCustomerAddresses(addresses); + sampleBuilder.setLogin(lb.build()); + + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + + assertEquals("WELCOME!", props.get("sample-container.login.message")); + assertEquals("NJ", props.get("sample-container.login.customer-addresses[0].state")); + assertEquals("home", props.get("sample-container.login.customer-addresses[0].address-name")); + assertEquals("yellowbrick road", props.get("sample-container.login.customer-addresses[0].street-address")); + assertEquals("FL", props.get("sample-container.login.customer-addresses[1].state")); + assertEquals("vacation house", props.get("sample-container.login.customer-addresses[1].address-name")); + assertEquals("ocean ave", props.get("sample-container.login.customer-addresses[1].street-address")); + assertEquals("2", props.get("sample-container.login.customer-addresses_length")); + } + + public void testToPropertiesIetf() throws Exception { + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + sampleBuilder.setIpVersion(IpVersion.Ipv4); + sampleBuilder.setDscp(Dscp.getDefaultInstance("1")); + sampleBuilder.setPortNumber(PortNumber.getDefaultInstance("2")); + sampleBuilder.setIpv6FlowLabel(Ipv6FlowLabel.getDefaultInstance("3")); + sampleBuilder.setAsNumber(AsNumber.getDefaultInstance("4")); + sampleBuilder.setIpv6Address(Ipv6Address.getDefaultInstance("fdda:5cc1:23:4::1f")); + sampleBuilder.setIpAddressNoZone(IpAddressNoZoneBuilder.getDefaultInstance("fdda:5cc1:23:4::1f")); + sampleBuilder.setIpv4Address(Ipv4Address.getDefaultInstance("192.168.1.2")); + sampleBuilder.setIpv4AddressNoZone(Ipv4AddressNoZone.getDefaultInstance("192.168.1.3")); + sampleBuilder.setIpv6AddressNoZone(Ipv6AddressNoZone.getDefaultInstance("fdda:5cc1:23:4::1f")); + sampleBuilder.setIpv4Prefix(Ipv4Prefix.getDefaultInstance("198.51.100.0/24")); + sampleBuilder.setIpv6Prefix(Ipv6Prefix.getDefaultInstance("2001:db8:aaaa:1111::100/64")); + sampleBuilder.setDomainName(DomainName.getDefaultInstance("onap.org")); + sampleBuilder.setHost(HostBuilder.getDefaultInstance("machine.onap.org")); + sampleBuilder.setUri(Uri.getDefaultInstance("http://wiki.onap.org:8080")); + + Properties props = new Properties(); + MdsalHelper.toProperties(props, sampleBuilder); + + assertEquals("4", props.get("sample-container.as-number")); + assertEquals("4", props.get("sample-container.as-number.value")); + assertEquals("onap.org", props.get("sample-container.domain-name")); + assertEquals("onap.org", props.get("sample-container.domain-name.value")); + assertEquals("1", props.get("sample-container.dscp")); + assertEquals("machine.onap.org", props.get("sample-container.host.domain-name")); + assertEquals("machine.onap.org", props.get("sample-container.host.domain-name.value")); + assertEquals("fdda:5cc1:23:4::1f", props.get("sample-container.ip-address-no-zone.ipv6-address-no-zone")); + assertEquals("fdda:5cc1:23:4::1f", props.get("sample-container.ip-address-no-zone.ipv6-address-no-zone.value")); + assertEquals("ipv4", props.get("sample-container.ip-version")); + assertEquals("192.168.1.2", props.get("sample-container.ipv4-address")); + assertEquals("192.168.1.3", props.get("sample-container.ipv4-address-no-zone")); + assertEquals("192.168.1.3", props.get("sample-container.ipv4-address-no-zone.value")); + assertEquals("198.51.100.0/24", props.get("sample-container.ipv4-prefix")); + assertEquals("198.51.100.0/24", props.get("sample-container.ipv4-prefix.value")); + assertEquals("fdda:5cc1:23:4::1f", props.get("sample-container.ipv6-address")); + assertEquals("fdda:5cc1:23:4::1f", props.get("sample-container.ipv6-address-no-zone")); + assertEquals("fdda:5cc1:23:4::1f", props.get("sample-container.ipv6-address-no-zone.value")); + assertEquals("3", props.get("sample-container.ipv6-flow-label")); + assertEquals("3", props.get("sample-container.ipv6-flow-label.value")); + assertEquals("2001:db8:aaaa:1111::100/64", props.get("sample-container.ipv6-prefix")); + assertEquals("2001:db8:aaaa:1111::100/64", props.get("sample-container.ipv6-prefix.value")); + assertEquals("2", props.get("sample-container.port-number")); + assertEquals("http://wiki.onap.org:8080", props.get("sample-container.uri")); + assertEquals("http://wiki.onap.org:8080", props.get("sample-container.uri.value")); + } + + public void testIetfToBuilder() throws Exception { + Properties props = new Properties(); + props.put("sample-container.as-number", "4"); + props.put("sample-container.as-number.value", "4"); + props.put("sample-container.domain-name", "onap.org"); + props.put("sample-container.domain-name.value", "onap.org"); + props.put("sample-container.dscp", "1"); + props.put("sample-container.host.domain-name", "machine.onap.org"); + props.put("sample-container.host.domain-name.value", "machine.onap.org"); + props.put("sample-container.ip-address-no-zone.ipv6-address-no-zone", "fdda:5cc1:23:4::1f"); + props.put("sample-container.ip-address-no-zone.ipv6-address-no-zone.value", "fdda:5cc1:23:4::1f"); + props.put("sample-container.ip-version", "ipv4"); + props.put("sample-container.ipv4-address", "192.168.1.2"); + props.put("sample-container.ipv4-address-no-zone", "192.168.1.3"); + props.put("sample-container.ipv4-address-no-zone.value", "192.168.1.3"); + props.put("sample-container.ipv4-prefix", "198.51.100.0/24"); + props.put("sample-container.ipv4-prefix.value", "198.51.100.0/24"); + props.put("sample-container.ipv6-address", "fdda:5cc1:23:4::1f"); + props.put("sample-container.ipv6-address-no-zone", "fdda:5cc1:23:4::1f"); + props.put("sample-container.ipv6-address-no-zone.value", "fdda:5cc1:23:4::1f"); + props.put("sample-container.ipv6-flow-label", "3"); + props.put("sample-container.ipv6-flow-label.value", "3"); + props.put("sample-container.ipv6-prefix", "2001:db8:aaaa:1111::100/64"); + props.put("sample-container.ipv6-prefix.value", "2001:db8:aaaa:1111::100/64"); + props.put("sample-container.port-number", "2"); + props.put("sample-container.uri", "http://wiki.onap.org:8080"); + props.put("sample-container.uri.value", "http://wiki.onap.org:8080"); + SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); + + MdsalHelper.toBuilder(props, sampleBuilder); + SampleContainer result = sampleBuilder.build(); + assertEquals(AsNumber.getDefaultInstance("4"), result.getAsNumber()); + assertEquals(DomainName.getDefaultInstance("onap.org"), result.getDomainName()); + assertEquals(Dscp.getDefaultInstance("1"), result.getDscp()); + // assertEquals(HostBuilder.getDefaultInstance("machine.onap.org").getDomainName(), + // result.getHost().getDomainName()); + assertEquals(Ipv6AddressNoZone.getDefaultInstance("fdda:5cc1:23:4::1f").getValue(), + result.getIpv6AddressNoZone().getValue()); + assertEquals(IpVersion.Ipv4, result.getIpVersion()); + assertEquals(Ipv4Address.getDefaultInstance("192.168.1.2"), result.getIpv4Address()); + assertEquals(Ipv4AddressNoZone.getDefaultInstance("192.168.1.3"), result.getIpv4AddressNoZone()); + assertEquals(Ipv4Prefix.getDefaultInstance("198.51.100.0/24"), result.getIpv4Prefix()); + assertEquals(Ipv6Address.getDefaultInstance("fdda:5cc1:23:4::1f"), result.getIpv6Address()); + assertEquals(IpAddressNoZoneBuilder.getDefaultInstance("fdda:5cc1:23:4::1f").getIpv6AddressNoZone().getValue(), + result.getIpv6AddressNoZone().getValue()); + assertEquals(Ipv6FlowLabel.getDefaultInstance("3"), result.getIpv6FlowLabel()); + assertEquals(Ipv6Prefix.getDefaultInstance("2001:db8:aaaa:1111::100/64"), result.getIpv6Prefix()); + assertEquals(PortNumber.getDefaultInstance("2"), result.getPortNumber()); + assertEquals(Uri.getDefaultInstance("http://wiki.onap.org:8080"), result.getUri()); + } + } -- cgit 1.2.3-korg From 7c2f57f8efc971f1d93a544256c084f52f7c3ed2 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Mon, 17 Feb 2020 17:46:59 -0500 Subject: Refactoring deprecated lang3.StringEscapeUtils Replace deprecated org.apache.commons.lang3.StringEscapeUtils with org.apache.commons.text.StringEscapeUtils Change-Id: Ib0303919d883a577effbb6fa15ddeb289cb936fc Issue-ID: CCSDK-2104 Signed-off-by: Singal, Kapil (ks220y) --- sli/common/pom.xml | 6 +- .../org/onap/ccsdk/sli/core/sli/SvcLogicNode.java | 108 ++++++++++----------- .../sli/core/slipluginutils/SliStringUtils.java | 6 +- 3 files changed, 62 insertions(+), 58 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 7ba721928..8290a42b4 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -42,6 +42,10 @@ org.apache.commons commons-lang3 + + org.apache.commons + commons-text + org.onap.ccsdk.sli.core dblib-provider @@ -56,7 +60,7 @@ org.onap.logging-analytics logging-slf4j - + junit diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java index 72cfea500..b0d4fc058 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java @@ -10,9 +10,9 @@ * 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. @@ -22,7 +22,7 @@ */ /** - * + * */ package org.onap.ccsdk.sli.core.sli; @@ -36,17 +36,17 @@ import java.util.Set; import java.util.HashSet; import java.util.TreeMap; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SvcLogicNode implements Serializable { - + private static final Logger LOG = LoggerFactory .getLogger(SvcLogicExprListener.class); - + private static final long serialVersionUID = 2L; - + private String nodeName; private int nodeId; private String nodeType; @@ -57,7 +57,7 @@ public class SvcLogicNode implements Serializable { private HashMap attributes; private HashMap outcomes; private HashMap parameters; - + public SvcLogicNode(int nodeId, String nodeType, SvcLogicGraph graph) { this.nodeId = nodeId; @@ -67,9 +67,9 @@ public class SvcLogicNode implements Serializable { attributes = new HashMap<> (); parameters = new HashMap<> (); outcomes = null; - + } - + public SvcLogicNode(int nodeId, String nodeType, String nodeName, SvcLogicGraph graph) throws DuplicateValueException { this.nodeId = nodeId; @@ -81,28 +81,28 @@ public class SvcLogicNode implements Serializable { outcomes = null; graph.setNamedNode(nodeName, this); } - - + + public int getNodeId() { return nodeId; } - + public String getNodeName() { return nodeName; } - + public String getNodeType() { return nodeType; } - + public SvcLogicGraph getGraph() { return graph; } - + public int getNumOutcomes() { if (outcomes == null) @@ -114,7 +114,7 @@ public class SvcLogicNode implements Serializable { return outcomes.size(); } } - + public SvcLogicExpression getAttribute(String name) { if (attributes.containsKey(name)) @@ -125,28 +125,28 @@ public class SvcLogicNode implements Serializable { { return null; } - + } - + public void setAttribute(String name, String value) throws SvcLogicException { setAttribute(name, new SvcLogicAtom("STRING", value)); } - + public void setAttribute(String name, SvcLogicExpression value) throws SvcLogicException { if (attributes.containsKey(name)) { throw new DuplicateValueException("Duplicate attribute "+name); } - + attributes.put(name, value); } - + public void mapParameter(String name, String value) throws SvcLogicException { - + if (parameters.containsKey(name)) { throw new DuplicateValueException("Duplicate parameter "+name); @@ -163,7 +163,7 @@ public class SvcLogicNode implements Serializable { int lastParen = value.lastIndexOf("`"); String evalExpr = value.trim().substring(1, lastParen); parmValue = SvcLogicExpressionFactory.parse(evalExpr); - + } else { @@ -185,7 +185,7 @@ public class SvcLogicNode implements Serializable { throw new SvcLogicException(e.getMessage()); } } - + public SvcLogicExpression getParameter(String name) { if (parameters.containsKey(name)) @@ -197,23 +197,23 @@ public class SvcLogicNode implements Serializable { return null; } } - + public boolean isVisited() { return visited; } public void setVisited(boolean visited, boolean recursive) { this.visited = visited; - + if (recursive) { Set> outcomeSet = getOutcomeSet(); - + if (outcomeSet == null) { return; } - + for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) { Map.Entry curOutcome = iter.next(); @@ -222,14 +222,14 @@ public class SvcLogicNode implements Serializable { } } } - + public void addOutcome(String outcomeValue, SvcLogicNode node) throws SvcLogicException { if (outcomes == null) { outcomes = new HashMap<>(); } - + if (outcomeValue.length() == 0) { outcomeValue = "\"\""; } @@ -237,35 +237,35 @@ public class SvcLogicNode implements Serializable { { throw new DuplicateValueException("Duplicate outcome value "+outcomeValue); } - + outcomes.put(outcomeValue, node); } - + public Set> getOutcomeSet() { if (outcomes == null) { return new HashSet<>(); } - + return outcomes.entrySet(); - + } - + public Set> getParameterSet() { if (parameters == null) { return new HashSet<>(); } - + return parameters.entrySet(); - + } - + public void printAsGv(PrintStream pstr) { - + if (visited) { return; @@ -274,9 +274,9 @@ public class SvcLogicNode implements Serializable { { visited = true; } - + StringBuffer sbuff = new StringBuffer(); - + sbuff.append("node"); sbuff.append(nodeId); sbuff.append(" [ shape=none, margin=0, label=<"); @@ -292,7 +292,7 @@ public class SvcLogicNode implements Serializable { sbuff.append(nodeName); sbuff.append(""); } - + Set> attrSet = attributes.entrySet(); for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) { @@ -304,15 +304,15 @@ public class SvcLogicNode implements Serializable { sbuff.append(""); } sbuff.append("
    >];"); - + pstr.println(sbuff.toString()); - - + + if (outcomes != null) { TreeMap sortedOutcomes = new TreeMap<>(outcomes); Set> outcomeSet = sortedOutcomes.entrySet(); - + for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) { Map.Entry curOutcome = iter.next(); @@ -323,7 +323,7 @@ public class SvcLogicNode implements Serializable { } } } - + public void printAsXml(PrintStream pstr, int indentLvl) { if (visited) @@ -337,7 +337,7 @@ public class SvcLogicNode implements Serializable { } pstr.print("<"); pstr.print(this.getNodeType()); - + Set> attrSet = attributes.entrySet(); for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) { @@ -348,7 +348,7 @@ public class SvcLogicNode implements Serializable { pstr.print(curAttr.getValue()); pstr.print("'`"); } - + if ((parameters == null || parameters.isEmpty()) && (outcomes == null || outcomes.isEmpty())) { @@ -360,7 +360,7 @@ public class SvcLogicNode implements Serializable { { pstr.print(">\n"); } - + // Print parameters (if any) if (parameters != null) { @@ -405,7 +405,7 @@ public class SvcLogicNode implements Serializable { pstr.print("\n"); } } - + // Print node end tag for (int i = 0 ; i < indentLvl ; i++) { @@ -415,7 +415,7 @@ public class SvcLogicNode implements Serializable { pstr.print(this.getNodeType()); pstr.print(">\n"); pstr.flush(); - + } @@ -429,7 +429,7 @@ public class SvcLogicNode implements Serializable { { return null; } - + if (outcomes.containsKey(value)) { return outcomes.get(value); diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index d343ce25f..fdc057b23 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -27,7 +27,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.Map; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -334,7 +334,7 @@ public class SliStringUtils implements SvcLogicJavaPlugin { ctx.setAttribute(parameters.get("outputPath"), parameters.get(INPUT_PARAM_SOURCE) .replaceAll(parameters.get(INPUT_PARAM_TARGET), parameters.get("replacement"))); } - + /** * Provides substring functionality to Directed Graphs. *

    @@ -456,7 +456,7 @@ public class SliStringUtils implements SvcLogicJavaPlugin { public static void xmlEscapeText(Map inParams, SvcLogicContext ctx) { String source = inParams.get(INPUT_PARAM_SOURCE); String target = inParams.get(INPUT_PARAM_TARGET); - source = StringEscapeUtils.escapeXml(source); + source = StringEscapeUtils.escapeXml10(source); ctx.setAttribute(target, source); } -- cgit 1.2.3-korg From a688a2cfd24526348f0510768371fc788670b465 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 19 Feb 2020 14:55:39 +0000 Subject: unit test for MdsalHelper add testToLowerHyphen to MdsalHelper Issue-ID: CCSDK-2106 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I851c3887d61ec2ce520a7fa187a1b65dc3616e6c --- .../onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index 50a6bbce2..5f8c4c22c 100755 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -745,4 +745,18 @@ public class MdsalHelperTest extends TestCase { assertEquals(Uri.getDefaultInstance("http://wiki.onap.org:8080"), result.getUri()); } + public void testToLowerHyphen() throws Exception { + String camelCase = "HelloWorld"; + String hypenCase = MdsalHelper.toLowerHyphen(camelCase); + assertEquals("hello-world", hypenCase); + + camelCase = "L2SwitchInterfaces"; + hypenCase = MdsalHelper.toLowerHyphen(camelCase); + assertEquals("l2-switch-interfaces", hypenCase); + + camelCase = "ABC"; + hypenCase = MdsalHelper.toLowerHyphen(camelCase); + assertEquals("a-b-c", hypenCase); + } + } -- cgit 1.2.3-korg 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 92a91c226..610f89024 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 87fa657b0..14c823128 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 4f758a24d..7363f5b7c 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 000000000..37e4fe877 --- /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 000000000..e3f4f1b7e --- /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 000000000..d0cc83182 --- /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 000000000..c696f25b5 --- /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 d88cf3312..fb3ab9a03 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 d88cf3312..fb3ab9a03 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 3a5afd974..000000000 --- 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 37e4fe877..000000000 --- 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 e3f4f1b7e..000000000 --- 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 6786b955b..000000000 --- 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 6786b955b..000000000 --- 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 0ae6be71c..000000000 --- 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 d0cc83182..000000000 --- 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 c696f25b5..000000000 --- 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 b73caf31e..1558a77c4 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 000000000..db60aa1e4 --- /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 1d568a429..c8bc164c7 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 000000000..d14d7b944 --- /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 000000000..5737072ef --- /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 000000000..be6bb629e --- /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 000000000..6c024108b --- /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 000000000..1c22da476 --- /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 000000000..6218d11f6 --- /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 000000000..9c53eb2c1 --- /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 000000000..bc8e2f700 --- /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 000000000..426960f76 --- /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 cc164d042..9ae094f1a 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 From 3a325d8192addf27423494d8ed8b621dedcf7888 Mon Sep 17 00:00:00 2001 From: Enbo Wang Date: Fri, 21 Feb 2020 14:57:01 +0800 Subject: Support updating JSON object string for sliPluginUtils Issue-ID: CCSDK-2111 Signed-off-by: Enbo Wang Change-Id: Ide6bb06a05fcbb3b88e73cc0fbec6fd46bd29033 --- .../sli/core/slipluginutils/SliPluginUtils.java | 55 ++++++++++++++++++++++ .../SliPluginUtils_StaticFunctionsTest.java | 37 +++++++++++++++ .../provider/src/test/resources/JsonObject.json | 5 ++ 3 files changed, 97 insertions(+) create mode 100644 sliPluginUtils/provider/src/test/resources/JsonObject.json diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 0d9ab217e..ce0f50800 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -33,12 +33,15 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; + import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicConstants; @@ -865,6 +868,58 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { } } + /** + * updateJsonObjectString takes a json object string, and adds or deletes the properties of it + * @param parameters - requires source, outputPath and keys to be added or deleted. + * The key of parameter starts with "add.", e.g. "add.A", and then "A" and its value will be added + * to the JSON object. + * The key of parameter starts with "delete.", e.g. "delete.B", and then "B" will be deleted from + * the JSON object. + * @param ctx Reference to context memory + * @throws SvcLogicException if a required parameter is missing an exception is thrown + */ + public static void updateJsonObjectString(Map parameters, SvcLogicContext ctx) throws SvcLogicException { + checkParameters(parameters, new String[] {"source", "outputPath"}, LOG); + try { + String source = ctx.getAttribute(parameters.get("source")); + JsonParser jp = new JsonParser(); + JsonElement element = jp.parse(source); + if (element.isJsonObject()) { + JsonObject jsonObject = element.getAsJsonObject(); + updateJsonObject(jsonObject, parameters); + + String target = jsonObject.toString(); + ctx.setAttribute(parameters.get("outputPath"), target); + } else { + throw new SvcLogicException("just update JSON object string"); + } + } catch (Exception ex) { + throw new SvcLogicException("problem with updateJsonObjectString", ex); + } + } + + protected static void updateJsonObject(JsonObject jsonObject, Map parameters) throws SvcLogicException { + List deleted_params = parameters.keySet().stream().filter(param -> param.startsWith("delete.")). + collect(Collectors.toList()); + for (String param: deleted_params) { + String[] action_key = param.split("\\.", 2); + if (action_key.length < 2) { + throw new SvcLogicException("error parameter format: " + param + ", must be \"delete.\""); + } + jsonObject.remove(action_key[1]); + } + + List added_params = parameters.keySet().stream().filter(param -> param.startsWith("add.")). + collect(Collectors.toList()); + for (String param: added_params) { + String[] action_key = param.split("\\.", 2); + if (action_key.length < 2) { + throw new SvcLogicException("error parameter format: " + param + ", must be \"add.\""); + } + jsonObject.addProperty(action_key[1], parameters.get(param)); + } + } + /** * getAttributeValue takes a ctx memory path as a string, gets the value stored at this path and set this value in context memory at * outputPath diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java index 5c222c83f..ad039d7f4 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java @@ -495,6 +495,43 @@ public class SliPluginUtils_StaticFunctionsTest { assertEquals("200", ctx.getAttribute("testPath.widget.window.width")); } + @Test + public void testUpdateJsonObjectString() throws Exception { + String path = "src/test/resources/JsonObject.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("input", content); + + Map parametersUpdateJson = new HashMap(); + parametersUpdateJson.put("source", "input"); + parametersUpdateJson.put("outputPath", "newJsonString"); + + // add key "ccc" and its value + parametersUpdateJson.put("add.ccc", "abcxyz"); + + // update keys and their values of "aaa" and "c.d" + parametersUpdateJson.put("add.aaa", "4567"); + parametersUpdateJson.put("add.c.d", "defg"); + + // delete key "bbb" + parametersUpdateJson.put("delete.bbb", ""); + + SliPluginUtils.updateJsonObjectString(parametersUpdateJson, ctx); + + Map parametersJsonToCtx = new HashMap(); + parametersJsonToCtx.put("source", "newJsonString"); + parametersJsonToCtx.put("outputPath", "testPath"); + parametersJsonToCtx.put("isEscaped", "false"); + + SliPluginUtils.jsonStringToCtx(parametersJsonToCtx, ctx); + + assertEquals("abcxyz", ctx.getAttribute("testPath.ccc")); + assertEquals("4567", ctx.getAttribute("testPath.aaa")); + assertEquals("defg", ctx.getAttribute("testPath.c.d")); + assertEquals(null, ctx.getAttribute("testPath.bbb")); + } + @Test public void testEmbeddedEscapedJsonJsonStringToCtx() throws Exception { String path = "src/test/resources/EmbeddedEscapedJson.json"; diff --git a/sliPluginUtils/provider/src/test/resources/JsonObject.json b/sliPluginUtils/provider/src/test/resources/JsonObject.json new file mode 100644 index 000000000..0578368f8 --- /dev/null +++ b/sliPluginUtils/provider/src/test/resources/JsonObject.json @@ -0,0 +1,5 @@ +{ + "aaa": "123", + "bbb": "xyz", + "c.d": "abc" +} \ No newline at end of file -- cgit 1.2.3-korg From 7b5d3d08876124b713b12a0b5983752af4b5921b Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Mon, 24 Feb 2020 18:33:27 +0000 Subject: minor logging updates create error logger, integrate with record node and improve slf4jrecorder Issue-ID: CCSDK-2115 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I857ce0fac070278a195204195eaae0c53d2d0d52 --- artifacts/pom.xml | 5 -- .../org/onap/ccsdk/sli/core/sli/ErrorLogger.java | 100 +++++++++++++++++++++ .../onap/ccsdk/sli/core/sli/ErrorLoggerTest.java | 56 ++++++++++++ sli/installer/pom.xml | 5 -- .../sli/core/sli/recording/Slf4jRecorder.java | 54 ++++++++--- 5 files changed, 198 insertions(+), 22 deletions(-) create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ErrorLogger.java create mode 100644 sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ErrorLoggerTest.java diff --git a/artifacts/pom.xml b/artifacts/pom.xml index f6c883c13..a5ed37993 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -146,11 +146,6 @@ utils-installer ${project.version} - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ErrorLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ErrorLogger.java new file mode 100644 index 000000000..47f6526e9 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/ErrorLogger.java @@ -0,0 +1,100 @@ +package org.onap.ccsdk.sli.core.sli; + +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +public class ErrorLogger { + public static final int ERROR_CODE_100 = 100; + public static final int ERROR_CODE_200 = 200; + public static final int ERROR_CODE_300 = 300; + public static final int ERROR_CODE_400 = 400; + public static final int ERROR_CODE_500 = 500; + public static final int ERROR_CODE_900 = 900; + + private static final String DEFAULT_100_DESCRIPTION = "Permission Error"; + private static final String DEFAULT_200_DESCRIPTION = "Availability Error or Timeout"; + private static final String DEFAULT_300_DESCRIPTION = "Data Error"; + private static final String DEFAULT_400_DESCRIPTION = "Schema Error"; + private static final String DEFAULT_500_DESCRIPTION = "Business Process Error"; + private static final String DEFAULT_900_DESCRIPTION = "Unknown Error"; + private Logger log; + + public ErrorLogger() { + this.log = LoggerFactory.getLogger(ErrorLogger.class); + } + + public ErrorLogger(Logger log) { + this.log = log; + } + + public void logError(String message, int errorCode) { + createLogEntry(message, errorCode, null, null); + } + + public void logError(String message, int errorCode, Exception e) { + createLogEntry(message, errorCode, null, e); + } + + public void logError(String message, int errorCode, String description) { + createLogEntry(message, errorCode, description, null); + } + + public void logError(String message, int errorCode, String description, Exception e) { + createLogEntry(message, errorCode, description, e); + } + + public void createLogEntry(String message, int errorCode, String description, Exception e) { + //If the error code isn't valid default it to unknown error code + if(!isValidCode(errorCode)) { + errorCode = 900; + } + + MDC.put(ONAPLogConstants.MDCs.ERROR_CODE, String.valueOf(errorCode)); + + if (description == null || description.isEmpty()) { + description = getDefaultDescription(errorCode); + } + + MDC.put(ONAPLogConstants.MDCs.ERROR_DESC, description); + if (e != null) { + log.error(message, e); + } else { + log.error(message); + } + clearKeys(); + } + + public boolean isValidCode(int errorCode) { + if (errorCode == ERROR_CODE_100 || errorCode == ERROR_CODE_200 || errorCode == ERROR_CODE_300 || errorCode == ERROR_CODE_400 || errorCode == ERROR_CODE_500 + || errorCode == ERROR_CODE_900) { + return true; + } + return false; + } + + public String getDefaultDescription(int errorCode) { + if (errorCode == ERROR_CODE_100) { + return DEFAULT_100_DESCRIPTION; + } + if (errorCode == ERROR_CODE_200) { + return DEFAULT_200_DESCRIPTION; + } + if (errorCode == ERROR_CODE_300) { + return DEFAULT_300_DESCRIPTION; + } + if (errorCode == ERROR_CODE_400) { + return DEFAULT_400_DESCRIPTION; + } + if (errorCode == ERROR_CODE_500) { + return DEFAULT_500_DESCRIPTION; + } + return DEFAULT_900_DESCRIPTION; + } + + public void clearKeys() { + MDC.remove(ONAPLogConstants.MDCs.ERROR_CODE); + MDC.remove(ONAPLogConstants.MDCs.ERROR_DESC); + } +} diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ErrorLoggerTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ErrorLoggerTest.java new file mode 100644 index 000000000..d95ff3075 --- /dev/null +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ErrorLoggerTest.java @@ -0,0 +1,56 @@ +package org.onap.ccsdk.sli.core.sli; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ErrorLoggerTest { + private Logger log = LoggerFactory.getLogger(ErrorLoggerTest.class); + + @Test + public void testOverloads() throws Exception { + ErrorLogger e = new ErrorLogger(); + Exception exc = new Exception(); + e.logError("failure", 200); + e.logError("failure", 200, exc); + e.logError("failure", 200, "Timeout during HTTP operation"); + e.logError("failure", 200, "Timeout during HTTP operation", exc); + } + + @Test + public void testInvalidErrorCode() throws Exception { + ErrorLogger e = new ErrorLogger(); + e.logError("failure", 0); + } + + @Test + public void testDescriptionMapping() throws Exception { + ErrorLogger e = new ErrorLogger(); + e.logError("failure", 100); + e.logError("failure", 200); + e.logError("failure", 300); + e.logError("failure", 400); + e.logError("failure", 500); + e.logError("failure", 900); + } + + @Test + public void testIsValidCode() throws Exception { + ErrorLogger e = new ErrorLogger(log); + assertTrue(e.isValidCode(ErrorLogger.ERROR_CODE_100)); + assertTrue(e.isValidCode(ErrorLogger.ERROR_CODE_200)); + assertTrue(e.isValidCode(ErrorLogger.ERROR_CODE_300)); + assertTrue(e.isValidCode(ErrorLogger.ERROR_CODE_400)); + assertTrue(e.isValidCode(ErrorLogger.ERROR_CODE_500)); + assertTrue(e.isValidCode(ErrorLogger.ERROR_CODE_900)); + + assertFalse(e.isValidCode(0)); + assertFalse(e.isValidCode(204)); + assertFalse(e.isValidCode(404)); + assertFalse(e.isValidCode(501)); + } + +} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 38905caee..dcbe6b8d2 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -47,11 +47,6 @@ ${project.version} - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - 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 index e3f4f1b7e..4f67c5d9a 100644 --- 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 @@ -28,14 +28,16 @@ import java.util.Map; import java.util.TimeZone; import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.ErrorLogger; 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 { - - + protected DateFormat dateFmt; + protected static final String messageLogName = "message-log"; + public enum Level { ERROR, WARN, @@ -44,13 +46,17 @@ public class Slf4jRecorder implements SvcLogicRecorder { TRACE } + protected Logger defaultLogger = LoggerFactory.getLogger(Slf4jRecorder.class); + protected Logger messageLogger = LoggerFactory.getLogger(messageLogName); + + public Slf4jRecorder() { + TimeZone tz = TimeZone.getTimeZone("UTC"); + dateFmt = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); + dateFmt.setTimeZone(tz); + } + @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"; @@ -98,12 +104,20 @@ public class Slf4jRecorder implements SvcLogicRecorder { throw new ConfigurationException("No record/fields passed in record node"); } - Logger logger = LoggerFactory.getLogger(loggerName); + String loggerName = parmMap.get("logger"); + Logger logger = null; + if (loggerName == null) { + logger = defaultLogger; + }else { + if(loggerName.equals(messageLogName)){ + logger = messageLogger; + }else { + 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)); @@ -111,7 +125,23 @@ public class Slf4jRecorder implements SvcLogicRecorder { switch (level) { case ERROR: - logger.error(record); + String errorCode = parmMap.get("errorCode"); + String errorDescription = parmMap.get("errorDescription"); + + if ((errorCode != null && !errorCode.isEmpty()) + || (errorDescription != null && !errorDescription.isEmpty())) { + ErrorLogger e = new ErrorLogger(logger); + + Integer integerCode = 0; + try { + integerCode = Integer.valueOf(errorCode); + } catch (NumberFormatException nfe) { + // do nothing + } + e.createLogEntry(record, integerCode, errorDescription, null); + } else { + logger.error(record); + } break; case WARN: logger.warn(record); -- cgit 1.2.3-korg From 2c78899f04fd40115d3c4cc606e8380c00cdda0b Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 26 Feb 2020 18:42:16 +0000 Subject: update sliapi-springboot format source, use provider base and minor changes Issue-ID: CCSDK-2121 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I4066ce5e15b1fa298b6e3de6ed8d7d1794b12013 --- sliapi/springboot/README.md | 25 ++- sliapi/springboot/pom.xml | 184 +++++++++--------- .../sliapi/springboot/ExecuteGraphController.java | 153 ++++++++------- .../sliapi/springboot/RestconfApiController.java | 216 ++++++++++----------- 4 files changed, 298 insertions(+), 280 deletions(-) diff --git a/sliapi/springboot/README.md b/sliapi/springboot/README.md index 5737072ef..3e47f341f 100644 --- a/sliapi/springboot/README.md +++ b/sliapi/springboot/README.md @@ -1,10 +1,29 @@ 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 +mvn -DserviceLogicDirectory=src/main/resources spring-boot:run 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 +curl http://127.0.0.1:8080/restconf/operations/SLI-API:healthcheck -X POST -H "Content-Type: application/json" + +Requests can also be sent to `http://localhost:8080/executeGraph` + +The graph details need to match a graph which has been loaded and activated + +An example request +``` +{ + "graphDetails": { + "module": "prov", + "rpc": "test", + "mode": "sync" + }, + "input": { + "name": "Hello World", + "test": "one", + "mixed": "cAsE" + } +} +``` \ No newline at end of file diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index be6bb629e..e9d5a9d8b 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -1,100 +1,100 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - spring-boot-starter-parent - 1.5.2-SNAPSHOT - + + org.onap.ccsdk.parent + spring-boot-starter-parent + 1.5.2-SNAPSHOT + - org.onap.ccsdk.sli.core - sliapi-springboot - 0.7.1-SNAPSHOT - jar + org.onap.ccsdk.sli.core + sliapi-springboot + 0.7.1-SNAPSHOT + jar - sliapi-springboot + 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.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-base + ${project.version} + + + com.google.code.gson + gson + + + org.apache.derby + derby + runtime + + - - 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 - - - - - - + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + + generate + + + target/generated-sources + ${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 index 6c024108b..79499d565 100644 --- 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 @@ -1,19 +1,16 @@ 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.HashMapResolver; import org.onap.ccsdk.sli.core.sli.provider.base.InMemorySvcLogicStore; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; @@ -24,87 +21,89 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; @Controller @EnableAutoConfiguration public class ExecuteGraphController { - static SvcLogicService svc; - private static final Logger LOGGER = LoggerFactory.getLogger(ExecuteGraphController.class); + static SvcLogicServiceBase 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); + @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(); + 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(); + hash.put("status", "success"); + JsonObject jsonInput = new Gson().fromJson(input, JsonObject.class); + JsonObject passthroughObj = jsonInput.get("input").getAsJsonObject(); - writeResponseToCtx(passthroughObj.toString(), parms, "input"); + 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; - } + 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 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 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); - } + 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 HashMapResolver(); + svc = new SvcLogicServiceImplBase(store, 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 index 1c22da476..8d2553a9e 100644 --- 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 @@ -1,126 +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 java.io.FileInputStream; +import java.io.IOException; +import java.util.Optional; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; + +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver; 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.sli.provider.base.SvcLogicServiceBase; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; 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; + +import com.fasterxml.jackson.databind.ObjectMapper; @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); - } - - - - + private final ObjectMapper objectMapper; + private final HttpServletRequest request; + private static SvcLogicServiceBase svc; + private static final 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 SvcLogicPropertiesProvider() { + + @Override + public Properties getProperties() { + Properties props = new Properties(); + String propPath = "src/main/resources/svclogic.properties"; + System.out.println(propPath); + try (FileInputStream fileInputStream = new FileInputStream(propPath)) { + props = new Properties(); + props.load(fileInputStream); + } catch (final IOException e) { + log.error("Failed to load properties for file: {}", propPath, + new ConfigurationException("Failed to load properties for file: " + propPath, e)); + } + return props; + } + }; + + 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 HashMapResolver(); + + svc = new SvcLogicServiceImplBase(store, resolver); + + } + + @Override + public ResponseEntity healthcheck() { + 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); + } } -- cgit 1.2.3-korg From ec7aa8b8c9fbe23f7628eb61bea93c0136cff6c5 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 26 Feb 2020 16:07:53 -0500 Subject: Add execute-graph and vlbcheck to swagger-codegen code Add implementation for execute-graph and vlbcheck RPCs. Also, added junit tests. Change-Id: Id2a31c033d25ef12c455bfee98c5aea8439fc2f9 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney --- .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 2 +- .../model/src/main/resources/sli-api.20161110.yaml | 43 ++--- sliapi/springboot/pom.xml | 196 +++++++++++---------- .../sliapi/springboot/RestconfApiController.java | 147 +++++++++++++++- .../src/main/resources/application.properties | 2 +- .../springboot/src/main/resources/graph.versions | 1 + .../springboot/src/main/resources/sli_vlbcheck.xml | 27 +++ .../src/main/resources/svclogic.properties | 2 + .../springboot/RestconfApiControllerTest.java | 99 +++++++++++ 9 files changed, 387 insertions(+), 132 deletions(-) create mode 100644 sliapi/springboot/src/main/resources/sli_vlbcheck.xml create mode 100644 sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index 549e6364f..3681e1e11 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -91,7 +91,7 @@ public class SvcLogicContext { { return attributes.keySet(); } - public Boolean isSuccess() { + public Boolean isSuccess() { return status.equals(SvcLogicConstants.SUCCESS); } diff --git a/sliapi/model/src/main/resources/sli-api.20161110.yaml b/sliapi/model/src/main/resources/sli-api.20161110.yaml index db60aa1e4..3420c66b5 100644 --- a/sliapi/model/src/main/resources/sli-api.20161110.yaml +++ b/sliapi/model/src/main/resources/sli-api.20161110.yaml @@ -164,12 +164,6 @@ paths: produces: - application/json - application/xml -# parameters: -# - in: body -# name: healthcheckInput -# required: false -# schema: -# $ref: '#/definitions/healthcheck-input' responses: '200': description: No response was specified @@ -184,12 +178,6 @@ paths: produces: - application/json - application/xml - parameters: - - in: body - name: vlbcheckInput - required: false - schema: - $ref: '#/definitions/vlbcheck-input' responses: '200': description: No response was specified @@ -242,28 +230,23 @@ definitions: execute-graph-input: properties: - 'mode': - type: string - 'module-name': - type: string - 'rpc-name': - type: string - 'sli-parameter': - items: - $ref: '#/definitions/parameter-setting' - type: array + 'input': + type: object + 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 diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index e9d5a9d8b..d7962c572 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -1,100 +1,112 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - spring-boot-starter-parent - 1.5.2-SNAPSHOT - + + org.onap.ccsdk.parent + spring-boot-starter-parent + 1.5.2-SNAPSHOT + - org.onap.ccsdk.sli.core - sliapi-springboot - 0.7.1-SNAPSHOT - jar + org.onap.ccsdk.sli.core + sliapi-springboot + 0.7.1-SNAPSHOT + jar - sliapi-springboot + 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-base - ${project.version} - - - com.google.code.gson - gson - - - org.apache.derby - derby - runtime - - + + + io.swagger + swagger-annotations + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-data-jpa + + + io.springfox + springfox-swagger2 + 2.9.2 + - - - - io.swagger - swagger-codegen-maven-plugin - 2.3.1 - - - - generate - - - target/generated-sources - ${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 - - - - - - + + io.springfox + springfox-swagger-ui + 2.9.2 + + + ${project.groupId} + sli-provider-base + ${project.version} + + + com.google.code.gson + gson + + + org.apache.derby + derby + runtime + + + junit + junit + test + + + + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + + generate + + + target/generated-sources + ${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/RestconfApiController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java index 8d2553a9e..e2cd864d7 100644 --- 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 @@ -2,11 +2,16 @@ package org.onap.ccsdk.sli.core.sliapi.springboot; import java.io.FileInputStream; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import java.util.Properties; import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.gson.*; import org.onap.ccsdk.sli.core.sli.ConfigurationException; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; @@ -17,6 +22,7 @@ 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.sli.provider.base.SvcLogicServiceBase; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; +import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +39,8 @@ public class RestconfApiController implements RestconfApi { private final ObjectMapper objectMapper; private final HttpServletRequest request; + + private static SvcLogicServiceBase svc; private static final Logger log = LoggerFactory.getLogger(RestconfApiController.class); @@ -90,17 +98,11 @@ public class RestconfApiController implements RestconfApi { 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")); + resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); return (new ResponseEntity<>(resp, HttpStatus.OK)); } catch (Exception e) { @@ -113,6 +115,32 @@ public class RestconfApiController implements RestconfApi { return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); } + @Override + public ResponseEntity vlbcheck() { + ResponseFields resp = new ResponseFields(); + + try { + log.info("Calling SLI-API:vlbcheck DG"); + Properties inputProps = new Properties(); + Properties respProps = svc.execute("sli", "vlbcheck", null, "sync", inputProps); + + resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); + resp.setResponseCode(respProps.getProperty("error-code", "200")); + resp.setResponseMessage(respProps.getProperty("error-message", "Success")); + resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); + + return (new ResponseEntity<>(resp, HttpStatus.OK)); + } catch (Exception e) { + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage(e.getMessage()); + log.error("Error calling vlbcheck directed graph", e); + + } + return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); + } + + @Override public Optional getObjectMapper() { return Optional.ofNullable(objectMapper); @@ -123,4 +151,107 @@ public class RestconfApiController implements RestconfApi { return Optional.ofNullable(request); } + @Override + public ResponseEntity executeGraph(@Valid ExecuteGraphInput executeGraphInput) { + Properties parms = new Properties(); + ResponseFields resp = new ResponseFields(); + String executeGraphInputJson = null; + + try { + executeGraphInputJson = objectMapper.writeValueAsString(executeGraphInput); + log.info("Input as JSON is "+executeGraphInputJson); + } catch (JsonProcessingException e) { + + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage(e.getMessage()); + log.error("Cannot create JSON from input object", e); + return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); + + } + JsonObject jsonInput = new Gson().fromJson(executeGraphInputJson, JsonObject.class); + JsonObject passthroughObj = jsonInput.get("input").getAsJsonObject(); + + writeResponseToCtx(passthroughObj.toString(), parms, "input"); + + + try { + // Any of these can throw a nullpointer exception + String calledModule = executeGraphInput.getInput().getModuleName(); + String calledRpc = executeGraphInput.getInput().getRpcName(); + String modeStr = executeGraphInput.getInput().getMode(); + // execute should only throw a SvcLogicException + Properties respProps = svc.execute(calledModule, calledRpc, null, modeStr, parms); + + resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); + resp.setResponseCode(respProps.getProperty("error-code", "200")); + resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); + resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); + return (new ResponseEntity<>(resp, HttpStatus.valueOf(Integer.parseInt(resp.getResponseCode())))); + + } catch (NullPointerException npe) { + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); + + return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); + } catch (SvcLogicException e) { + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage(e.getMessage()); + + return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + + 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 (Map.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 { + if (entry.getValue() instanceof JsonNull) { + log.info("Skipping parameter "+entry.getKey()+" with null value"); + + } else { + ctx.put(root + entry.getKey(), entry.getValue().getAsString()); + } + } + } + } + + public static String propsToJson(Properties props, String root) + { + StringBuffer sbuff = new StringBuffer(); + + sbuff.append("{ \""+root+"\" : { "); + boolean needComma = false; + for (Map.Entry prop : props.entrySet()) { + sbuff.append("\""+(String) prop.getKey()+"\" : \""+(String)prop.getValue()+"\""); + if (needComma) { + sbuff.append(" , "); + } else { + needComma = true; + } + } + sbuff.append(" } }"); + + return(sbuff.toString()); + } + } diff --git a/sliapi/springboot/src/main/resources/application.properties b/sliapi/springboot/src/main/resources/application.properties index 6218d11f6..64415bd34 100644 --- a/sliapi/springboot/src/main/resources/application.properties +++ b/sliapi/springboot/src/main/resources/application.properties @@ -5,4 +5,4 @@ spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.RFC3339Date 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 +spring.jpa.hibernate.ddl-auto=update diff --git a/sliapi/springboot/src/main/resources/graph.versions b/sliapi/springboot/src/main/resources/graph.versions index 9c53eb2c1..7f75be4c8 100644 --- a/sliapi/springboot/src/main/resources/graph.versions +++ b/sliapi/springboot/src/main/resources/graph.versions @@ -1 +1,2 @@ sli healthcheck 0.7.0 sync +sli vlbcheck 0.7.0 sync diff --git a/sliapi/springboot/src/main/resources/sli_vlbcheck.xml b/sliapi/springboot/src/main/resources/sli_vlbcheck.xml new file mode 100644 index 000000000..820a85c10 --- /dev/null +++ b/sliapi/springboot/src/main/resources/sli_vlbcheck.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/sliapi/springboot/src/main/resources/svclogic.properties b/sliapi/springboot/src/main/resources/svclogic.properties index 426960f76..1d90ab9b4 100644 --- a/sliapi/springboot/src/main/resources/svclogic.properties +++ b/sliapi/springboot/src/main/resources/svclogic.properties @@ -25,3 +25,5 @@ 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 + +sliapi.serviceLogicDirectory=/opt/onap/sdnc/svclogic/graphs diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java new file mode 100644 index 000000000..af55a5181 --- /dev/null +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java @@ -0,0 +1,99 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; +import org.onap.ccsdk.sli.core.sliapi.model.ExecutegraphinputInput; +import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@WebMvcTest(RestconfApiController.class) +public class RestconfApiControllerTest { + + @Autowired + private MockMvc mvc; + + @MockBean + private RestconfApiController restconfApiController; + + @Test + public void testHealthcheck() throws Exception { + String url = "/restconf/operations/SLI-API:healthcheck"; + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content("")).andReturn(); + + assertEquals(200, mvcResult.getResponse().getStatus()); + } + + @Test + public void testVlbcheck() throws Exception { + String url = "/restconf/operations/SLI-API:vlbcheck"; + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content("")).andReturn(); + + assertEquals(200, mvcResult.getResponse().getStatus()); + } + + @Test + public void testExecuteHealthcheck() throws Exception { + String url = "/restconf/operations/SLI-API:execute-graph"; + + ExecuteGraphInput executeGraphInput = new ExecuteGraphInput(); + ExecutegraphinputInput executeGraphData = new ExecutegraphinputInput(); + + executeGraphData.setModuleName("sli"); + executeGraphData.setRpcName("healthcheck"); + executeGraphData.setMode("sync"); + executeGraphInput.setInput(executeGraphData); + + String jsonString = mapToJson(executeGraphInput); + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andReturn(); + + assertEquals(200, mvcResult.getResponse().getStatus()); + + } + + @Test + public void testExecuteMissingDg() throws Exception { + String url = "/restconf/operations/SLI-API:execute-graph"; + + ExecuteGraphInput executeGraphInput = new ExecuteGraphInput(); + ExecutegraphinputInput executeGraphData = new ExecutegraphinputInput(); + + executeGraphData.setModuleName("sli"); + executeGraphData.setRpcName("noSuchRPC"); + executeGraphData.setMode("sync"); + executeGraphInput.setInput(executeGraphData); + + String jsonString = mapToJson(executeGraphInput); + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andReturn(); + + // Note: this really should return 401 (and truly does), but mockito always returns a 200. + assertEquals(200, mvcResult.getResponse().getStatus()); + + } + + private String mapToJson(Object obj) throws JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.writeValueAsString(obj); + } + + private ResponseFields respFromJson(String jsonString) throws JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + return(objectMapper.readValue(jsonString, ResponseFields.class)); + } +} -- cgit 1.2.3-korg From c1c724e3d3db47b40db0a98670a2caa5ee2b2a9f Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 27 Feb 2020 14:54:42 -0500 Subject: Fixed junit testing Fixed junit testing (was incorrectly mocking the class to be tested) Change-Id: I275a6aca53b9a14fb151b020d1b7287f3e234417 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney --- .../sliapi/springboot/RestconfApiController.java | 33 ++++++++-------------- .../springboot/RestconfApiControllerTest.java | 6 +--- 2 files changed, 12 insertions(+), 27 deletions(-) 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 index e2cd864d7..7c4717da8 100644 --- 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 @@ -1,27 +1,10 @@ package org.onap.ccsdk.sli.core.sliapi.springboot; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Properties; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.*; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver; -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.sli.provider.base.SvcLogicServiceBase; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; +import org.onap.ccsdk.sli.core.sli.*; +import org.onap.ccsdk.sli.core.sli.provider.base.*; import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; import org.slf4j.Logger; @@ -30,7 +13,13 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import com.fasterxml.jackson.databind.ObjectMapper; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.io.FileInputStream; +import java.io.IOException; +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") @@ -75,7 +64,7 @@ public class RestconfApiController implements RestconfApi { return; } - String serviceLogicDirectory = System.getProperty("serviceLogicDirectory"); + String serviceLogicDirectory = System.getProperty("serviceLogicDirectory", "src/main/resources"); System.out.println("serviceLogicDirectory is " + serviceLogicDirectory); SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, store); diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java index af55a5181..701cb3eb3 100644 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java @@ -9,7 +9,6 @@ import org.onap.ccsdk.sli.core.sliapi.model.ExecutegraphinputInput; import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; @@ -25,8 +24,6 @@ public class RestconfApiControllerTest { @Autowired private MockMvc mvc; - @MockBean - private RestconfApiController restconfApiController; @Test public void testHealthcheck() throws Exception { @@ -82,8 +79,7 @@ public class RestconfApiControllerTest { MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andReturn(); - // Note: this really should return 401 (and truly does), but mockito always returns a 200. - assertEquals(200, mvcResult.getResponse().getStatus()); + assertEquals(401, mvcResult.getResponse().getStatus()); } -- cgit 1.2.3-korg From de26ce8cdf4a64e690e7409319c6d738e8666135 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Fri, 28 Feb 2020 10:43:35 -0500 Subject: Adding missing parent relativePath and name tag Change-Id: Id093df2ca432b91f7003196bdeceb928caf60010 Issue-ID: CCSDK-2128 Signed-off-by: Singal, Kapil (ks220y) --- sli/provider-base/pom.xml | 4 +++- sliapi/springboot/pom.xml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 4c6c64122..fd97a7177 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -13,6 +13,8 @@ sli-provider-base 0.7.1-SNAPSHOT + ccsdk-sli-core :: sli :: ${project.artifactId} + UTF-8 ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml,${project.reporting.outputDirectory}/jacoco-it/jacoco.xml,../provider/target/site/jacoco-aggregate/jacoco.xml @@ -27,7 +29,7 @@ - + org.onap.ccsdk.sli.core diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index d7962c572..6b182db3d 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -6,6 +6,7 @@ org.onap.ccsdk.parent spring-boot-starter-parent 1.5.2-SNAPSHOT + org.onap.ccsdk.sli.core @@ -13,7 +14,7 @@ 0.7.1-SNAPSHOT jar - sliapi-springboot + ccsdk-sli-core :: sliapi :: ${project.artifactId} -- cgit 1.2.3-korg From ce993645564e2ba43c80fdc80a7265dc4032ceae Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 27 Feb 2020 16:27:37 -0500 Subject: Support merge JSON to SvcLogicContext Add support for merging JSON into SvcLogicContext Change-Id: If13fd6328a36ccff6393d0829319bbd99cd2a1f0 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney --- sli/common/pom.xml | 4 ++ .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 34 +++++++++++++++ .../sli/provider/base/SvcLogicServiceBase.java | 14 ++++++ .../sli/provider/base/SvcLogicServiceImplBase.java | 26 ++++++++--- .../sliapi/springboot/RestconfApiController.java | 50 +++++----------------- .../springboot/RestconfApiControllerTest.java | 8 ++++ 6 files changed, 89 insertions(+), 47 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 8290a42b4..2570f33bc 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -61,6 +61,10 @@ org.onap.logging-analytics logging-slf4j + + com.google.code.gson + gson + junit diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index 3681e1e11..fcd51d14b 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -25,6 +25,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.Set; + +import com.google.gson.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -207,6 +209,38 @@ public class SvcLogicContext { } + public void mergeJson(String pfx, String jsonString) { + JsonParser jp = new JsonParser(); + JsonElement element = jp.parse(jsonString); + + mergeJsonObject(element.getAsJsonObject(), pfx+"."); + } + + public void mergeJsonObject(JsonObject jsonObject, String pfx) { + for (Map.Entry entry : jsonObject.entrySet()) { + if (entry.getValue().isJsonObject()) { + mergeJsonObject(entry.getValue().getAsJsonObject(), pfx + entry.getKey() + "."); + } else if (entry.getValue().isJsonArray()) { + JsonArray array = entry.getValue().getAsJsonArray(); + this.setAttribute(pfx + entry.getKey() + "_length", String.valueOf(array.size())); + Integer arrayIdx = 0; + for (JsonElement element : array) { + if (element.isJsonObject()) { + mergeJsonObject(element.getAsJsonObject(), pfx + entry.getKey() + "[" + arrayIdx + "]."); + } + arrayIdx++; + } + } else { + if (entry.getValue() instanceof JsonNull) { + LOG.debug("Skipping parameter {} with null value",entry.getKey()); + + } else { + this.setAttribute(pfx + entry.getKey(), entry.getValue().getAsString()); + } + } + } + } + public String resolve(String ctxVarName) { if (ctxVarName.indexOf('[') == -1) { diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceBase.java index 8c436fef7..3bade8132 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceBase.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceBase.java @@ -56,6 +56,20 @@ public interface SvcLogicServiceBase { * */ Properties execute(String module, String rpc, String version, String mode, Properties parms) throws SvcLogicException; + /** + * Execute a directed graph + * + * @param module - module name + * @param rpc - rpc name + * @param version - version. If null, use active version + * @param mode - mode (sync/async) + * @param ctx - parameters, as a SvcLogicContext object + * @return final values of attributes from SvcLogicContext, as Properties + * @throws SvcLogicException + * + * + */ + SvcLogicContext execute(String module, String rpc, String version, String mode, SvcLogicContext ctx) throws SvcLogicException; SvcLogicStore getStore() throws SvcLogicException; diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java index 80d992f28..75673f756 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/SvcLogicServiceImplBase.java @@ -142,25 +142,37 @@ public class SvcLogicServiceImplBase implements SvcLogicServiceBase { @Override public Properties execute(String module, String rpc, String version, String mode, Properties props) throws SvcLogicException { + + SvcLogicContext ctx = new SvcLogicContext(props); + + return(execute(module, rpc, version, mode, ctx).toProperties()); + } + + @Override + public SvcLogicContext execute(String module, String rpc, String version, String mode, SvcLogicContext ctx) throws SvcLogicException { SvcLogicGraph graph = store.fetch(module, rpc, version, mode); + if (ctx == null) { + ctx = new SvcLogicContext(); + } + if (graph == null) { - Properties retProps = new Properties(); - retProps.setProperty("error-code", "401"); - retProps.setProperty("error-message", + ctx.setAttribute("error-code", "401"); + ctx.setAttribute("error-message", "No service logic found for [" + module + "," + rpc + "," + version + "," + mode + "]"); - return (retProps); + return (ctx); } - SvcLogicContext ctx = new SvcLogicContext(props); + + ctx.setAttribute(CURRENT_GRAPH, graph.toString()); // To support legacy code we should not stop populating X-ECOMP-RequestID ctx.setAttribute("X-ECOMP-RequestID", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); execute(graph, ctx); - return (ctx.toProperties()); + return (ctx); } - @Override + @Override public SvcLogicStore getStore() throws SvcLogicException { return this.store; } 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 index 7c4717da8..2da5490ae 100644 --- 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 @@ -85,8 +85,9 @@ public class RestconfApiController implements RestconfApi { try { log.info("Calling SLI-API:healthcheck DG"); - Properties inputProps = new Properties(); - Properties respProps = svc.execute("sli", "healthcheck", null, "sync", inputProps); + SvcLogicContext ctxIn = new SvcLogicContext(); + SvcLogicContext ctxOut = svc.execute("sli", "healthcheck", null, "sync", ctxIn); + Properties respProps = ctxOut.toProperties(); resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); resp.setResponseCode(respProps.getProperty("error-code", "200")); @@ -110,9 +111,9 @@ public class RestconfApiController implements RestconfApi { try { log.info("Calling SLI-API:vlbcheck DG"); - Properties inputProps = new Properties(); - Properties respProps = svc.execute("sli", "vlbcheck", null, "sync", inputProps); - + SvcLogicContext ctxIn = new SvcLogicContext(); + SvcLogicContext ctxOut = svc.execute("sli", "vlbcheck", null, "sync", ctxIn); + Properties respProps = ctxOut.toProperties(); resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); resp.setResponseCode(respProps.getProperty("error-code", "200")); resp.setResponseMessage(respProps.getProperty("error-message", "Success")); @@ -142,7 +143,7 @@ public class RestconfApiController implements RestconfApi { @Override public ResponseEntity executeGraph(@Valid ExecuteGraphInput executeGraphInput) { - Properties parms = new Properties(); + SvcLogicContext ctxIn = new SvcLogicContext(); ResponseFields resp = new ResponseFields(); String executeGraphInputJson = null; @@ -161,8 +162,7 @@ public class RestconfApiController implements RestconfApi { JsonObject jsonInput = new Gson().fromJson(executeGraphInputJson, JsonObject.class); JsonObject passthroughObj = jsonInput.get("input").getAsJsonObject(); - writeResponseToCtx(passthroughObj.toString(), parms, "input"); - + ctxIn.mergeJson("input", passthroughObj.toString()); try { // Any of these can throw a nullpointer exception @@ -170,7 +170,8 @@ public class RestconfApiController implements RestconfApi { String calledRpc = executeGraphInput.getInput().getRpcName(); String modeStr = executeGraphInput.getInput().getMode(); // execute should only throw a SvcLogicException - Properties respProps = svc.execute(calledModule, calledRpc, null, modeStr, parms); + SvcLogicContext ctxOut = svc.execute(calledModule, calledRpc, null, modeStr, ctxIn); + Properties respProps = ctxOut.toProperties(); resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); resp.setResponseCode(respProps.getProperty("error-code", "200")); @@ -193,37 +194,6 @@ public class RestconfApiController implements RestconfApi { } } - 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 (Map.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 { - if (entry.getValue() instanceof JsonNull) { - log.info("Skipping parameter "+entry.getKey()+" with null value"); - - } else { - ctx.put(root + entry.getKey(), entry.getValue().getAsString()); - } - } - } - } - public static String propsToJson(Properties props, String root) { StringBuffer sbuff = new StringBuffer(); diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java index 701cb3eb3..13f5939c5 100644 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java @@ -7,6 +7,8 @@ import org.junit.runner.RunWith; import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; import org.onap.ccsdk.sli.core.sliapi.model.ExecutegraphinputInput; import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.http.MediaType; @@ -21,6 +23,9 @@ import static org.junit.Assert.assertEquals; @WebMvcTest(RestconfApiController.class) public class RestconfApiControllerTest { + + private static final Logger log = LoggerFactory.getLogger(RestconfApiControllerTest.class); + @Autowired private MockMvc mvc; @@ -56,6 +61,7 @@ public class RestconfApiControllerTest { executeGraphInput.setInput(executeGraphData); String jsonString = mapToJson(executeGraphInput); + log.error("jsonString is {}", jsonString); MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andReturn(); @@ -77,6 +83,8 @@ public class RestconfApiControllerTest { String jsonString = mapToJson(executeGraphInput); + log.error("jsonString is {}", jsonString); + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andReturn(); assertEquals(401, mvcResult.getResponse().getStatus()); -- cgit 1.2.3-korg From 2ca6b604042735c56797a2eebd5472a6adaf44d4 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Tue, 3 Mar 2020 21:53:18 +0000 Subject: update sliapi-springboot organize sli api spring boot project Issue-ID: CCSDK-2154 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: Ic1690b8addf0134220b49a01d04e41eaeabf7bb6 --- sliapi/springboot/pom.xml | 188 +++++++++--------- .../onap/ccsdk/sli/core/sliapi/springboot/App.java | 12 ++ .../sliapi/springboot/ExecuteGraphController.java | 109 ----------- .../sliapi/springboot/RestconfApiController.java | 216 --------------------- .../controllers/ExecuteGraphController.java | 96 +++++++++ .../controllers/swagger/RestconfApiController.java | 177 +++++++++++++++++ .../sliapi/springboot/core/SvcLogicFactory.java | 71 +++++++ .../src/main/resources/application.properties | 4 +- .../springboot/RestconfApiControllerTest.java | 125 ++++++------ 9 files changed, 520 insertions(+), 478 deletions(-) create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index 6b182db3d..e3cca4bdf 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -1,113 +1,115 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - spring-boot-starter-parent - 1.5.2-SNAPSHOT + + org.onap.ccsdk.parent + spring-boot-starter-parent + 1.5.2-SNAPSHOT - + - org.onap.ccsdk.sli.core - sliapi-springboot - 0.7.1-SNAPSHOT - jar + org.onap.ccsdk.sli.core + sliapi-springboot + 0.7.1-SNAPSHOT + jar ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - io.swagger - swagger-annotations - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot + + org.onap.ccsdk.sli.core.sliapi.springboot.App + + + + + io.swagger + swagger-annotations + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot spring-boot-starter-test test 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-base - ${project.version} - - - com.google.code.gson - gson - - - org.apache.derby - derby - runtime - + spring-boot-starter-data-jpa + + + io.springfox + springfox-swagger2 + 2.9.2 + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + ${project.groupId} + sli-provider-base + ${project.version} + + + com.google.code.gson + gson + + + org.apache.derby + derby + runtime + junit junit test - - - - - - io.swagger - swagger-codegen-maven-plugin - 2.3.1 - - - - generate - - - target/generated-sources - ${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 - - - - - - + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + + generate + + + target/generated-sources + ${project.basedir}/../model/src/main/resources/sli-api.20161110.yaml + spring + org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger + org.onap.ccsdk.sli.core.sliapi.model + org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger + 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/App.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java new file mode 100644 index 000000000..941c1d518 --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java @@ -0,0 +1,12 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class App { + + public static void main(String[] args) throws Exception { + SpringApplication.run(App.class, args); + } +} 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 deleted file mode 100644 index 79499d565..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.onap.ccsdk.sli.core.sliapi.springboot; - -import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Properties; - -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; -import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver; -import org.onap.ccsdk.sli.core.sli.provider.base.InMemorySvcLogicStore; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; -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; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -@Controller -@EnableAutoConfiguration -public class ExecuteGraphController { - static SvcLogicServiceBase 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 HashMapResolver(); - svc = new SvcLogicServiceImplBase(store, 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 deleted file mode 100644 index 2da5490ae..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.onap.ccsdk.sli.core.sliapi.springboot; - -import com.fasterxml.jackson.core.JsonProcessingException; -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.base.*; -import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; -import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -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.FileInputStream; -import java.io.IOException; -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 SvcLogicServiceBase svc; - private static final 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 SvcLogicPropertiesProvider() { - - @Override - public Properties getProperties() { - Properties props = new Properties(); - String propPath = "src/main/resources/svclogic.properties"; - System.out.println(propPath); - try (FileInputStream fileInputStream = new FileInputStream(propPath)) { - props = new Properties(); - props.load(fileInputStream); - } catch (final IOException e) { - log.error("Failed to load properties for file: {}", propPath, - new ConfigurationException("Failed to load properties for file: " + propPath, e)); - } - return props; - } - }; - - SvcLogicStore store = null; - try { - store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties()); - } catch (SvcLogicException e) { - log.error("Cannot create SvcLogicStore", e); - return; - } - - String serviceLogicDirectory = System.getProperty("serviceLogicDirectory", "src/main/resources"); - 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 HashMapResolver(); - - svc = new SvcLogicServiceImplBase(store, resolver); - - } - - @Override - public ResponseEntity healthcheck() { - ResponseFields resp = new ResponseFields(); - - try { - log.info("Calling SLI-API:healthcheck DG"); - SvcLogicContext ctxIn = new SvcLogicContext(); - SvcLogicContext ctxOut = svc.execute("sli", "healthcheck", null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "Success")); - resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); - - 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 ResponseEntity vlbcheck() { - ResponseFields resp = new ResponseFields(); - - try { - log.info("Calling SLI-API:vlbcheck DG"); - SvcLogicContext ctxIn = new SvcLogicContext(); - SvcLogicContext ctxOut = svc.execute("sli", "vlbcheck", null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "Success")); - resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); - - return (new ResponseEntity<>(resp, HttpStatus.OK)); - } catch (Exception e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - log.error("Error calling vlbcheck 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); - } - - @Override - public ResponseEntity executeGraph(@Valid ExecuteGraphInput executeGraphInput) { - SvcLogicContext ctxIn = new SvcLogicContext(); - ResponseFields resp = new ResponseFields(); - String executeGraphInputJson = null; - - try { - executeGraphInputJson = objectMapper.writeValueAsString(executeGraphInput); - log.info("Input as JSON is "+executeGraphInputJson); - } catch (JsonProcessingException e) { - - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - log.error("Cannot create JSON from input object", e); - return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); - - } - JsonObject jsonInput = new Gson().fromJson(executeGraphInputJson, JsonObject.class); - JsonObject passthroughObj = jsonInput.get("input").getAsJsonObject(); - - ctxIn.mergeJson("input", passthroughObj.toString()); - - try { - // Any of these can throw a nullpointer exception - String calledModule = executeGraphInput.getInput().getModuleName(); - String calledRpc = executeGraphInput.getInput().getRpcName(); - String modeStr = executeGraphInput.getInput().getMode(); - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(calledModule, calledRpc, null, modeStr, ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); - return (new ResponseEntity<>(resp, HttpStatus.valueOf(Integer.parseInt(resp.getResponseCode())))); - - } catch (NullPointerException npe) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - - return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); - } catch (SvcLogicException e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - - return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); - } - } - - public static String propsToJson(Properties props, String root) - { - StringBuffer sbuff = new StringBuffer(); - - sbuff.append("{ \""+root+"\" : { "); - boolean needComma = false; - for (Map.Entry prop : props.entrySet()) { - sbuff.append("\""+(String) prop.getKey()+"\" : \""+(String)prop.getValue()+"\""); - if (needComma) { - sbuff.append(" , "); - } else { - needComma = true; - } - } - sbuff.append(" } }"); - - return(sbuff.toString()); - } - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java new file mode 100644 index 000000000..efdefbd6f --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java @@ -0,0 +1,96 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot.controllers; + +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Properties; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +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; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +@Controller +@EnableAutoConfiguration +public class ExecuteGraphController { + @Autowired + protected SvcLogicServiceBase 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()); + } + } + } + + +} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java new file mode 100644 index 000000000..10442d432 --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java @@ -0,0 +1,177 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger; + +import java.util.Map; +import java.util.Optional; +import java.util.Properties; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; +import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; +import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; +import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RestconfApi; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.JsonObject; + +@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; + + @Autowired + protected SvcLogicServiceBase svc; + private static final Logger log = LoggerFactory.getLogger(RestconfApiController.class); + + @org.springframework.beans.factory.annotation.Autowired + public RestconfApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public ResponseEntity healthcheck() { + ResponseFields resp = new ResponseFields(); + + try { + log.info("Calling SLI-API:healthcheck DG"); + SvcLogicContext ctxIn = new SvcLogicContext(); + SvcLogicContext ctxOut = svc.execute("sli", "healthcheck", null, "sync", ctxIn); + Properties respProps = ctxOut.toProperties(); + + resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); + resp.setResponseCode(respProps.getProperty("error-code", "200")); + resp.setResponseMessage(respProps.getProperty("error-message", "Success")); + resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); + + 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 ResponseEntity vlbcheck() { + ResponseFields resp = new ResponseFields(); + + try { + log.info("Calling SLI-API:vlbcheck DG"); + SvcLogicContext ctxIn = new SvcLogicContext(); + SvcLogicContext ctxOut = svc.execute("sli", "vlbcheck", null, "sync", ctxIn); + Properties respProps = ctxOut.toProperties(); + resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); + resp.setResponseCode(respProps.getProperty("error-code", "200")); + resp.setResponseMessage(respProps.getProperty("error-message", "Success")); + resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); + + return (new ResponseEntity<>(resp, HttpStatus.OK)); + } catch (Exception e) { + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage(e.getMessage()); + log.error("Error calling vlbcheck 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); + } + + @Override + public ResponseEntity executeGraph(@Valid ExecuteGraphInput executeGraphInput) { + SvcLogicContext ctxIn = new SvcLogicContext(); + ResponseFields resp = new ResponseFields(); + String executeGraphInputJson = null; + + try { + executeGraphInputJson = objectMapper.writeValueAsString(executeGraphInput); + log.info("Input as JSON is "+executeGraphInputJson); + } catch (JsonProcessingException e) { + + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage(e.getMessage()); + log.error("Cannot create JSON from input object", e); + return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); + + } + JsonObject jsonInput = new Gson().fromJson(executeGraphInputJson, JsonObject.class); + JsonObject passthroughObj = jsonInput.get("input").getAsJsonObject(); + + ctxIn.mergeJson("input", passthroughObj.toString()); + + try { + // Any of these can throw a nullpointer exception + String calledModule = executeGraphInput.getInput().getModuleName(); + String calledRpc = executeGraphInput.getInput().getRpcName(); + String modeStr = executeGraphInput.getInput().getMode(); + // execute should only throw a SvcLogicException + SvcLogicContext ctxOut = svc.execute(calledModule, calledRpc, null, modeStr, ctxIn); + Properties respProps = ctxOut.toProperties(); + + resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); + resp.setResponseCode(respProps.getProperty("error-code", "200")); + resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); + resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); + return (new ResponseEntity<>(resp, HttpStatus.valueOf(Integer.parseInt(resp.getResponseCode())))); + + } catch (NullPointerException npe) { + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); + + return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); + } catch (SvcLogicException e) { + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage(e.getMessage()); + + return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); + } + } + + public static String propsToJson(Properties props, String root) + { + StringBuffer sbuff = new StringBuffer(); + + sbuff.append("{ \""+root+"\" : { "); + boolean needComma = false; + for (Map.Entry prop : props.entrySet()) { + sbuff.append("\""+(String) prop.getKey()+"\" : \""+(String)prop.getValue()+"\""); + if (needComma) { + sbuff.append(" , "); + } else { + needComma = true; + } + } + sbuff.append(" } }"); + + return(sbuff.toString()); + } + +} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java new file mode 100644 index 000000000..f39fc229c --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java @@ -0,0 +1,71 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot.core; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver; +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.sli.provider.base.SvcLogicServiceBase; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SvcLogicFactory { + private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class); + + @Bean + public SvcLogicStore getStore() throws Exception { + SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() { + + @Override + public Properties getProperties() { + Properties props = new Properties(); + String propPath = "src/main/resources/svclogic.properties"; + System.out.println(propPath); + try (FileInputStream fileInputStream = new FileInputStream(propPath)) { + props = new Properties(); + props.load(fileInputStream); + } catch (final IOException e) { + log.error("Failed to load properties for file: {}", propPath, + new ConfigurationException("Failed to load properties for file: " + propPath, e)); + } + return props; + } + }; + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties()); + return store; + } + + @Bean + public SvcLogicLoader createLoader() throws Exception { + String serviceLogicDirectory = System.getProperty("serviceLogicDirectory"); + if (serviceLogicDirectory == null) { + serviceLogicDirectory = "src/main/resources"; + } + + System.out.println("serviceLogicDirectory is " + serviceLogicDirectory); + SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, getStore()); + + try { + loader.loadAndActivate(); + } catch (IOException e) { + log.error("Cannot load directed graphs", e); + } + return loader; + } + + @Bean + public SvcLogicServiceBase createService() throws Exception { + SvcLogicResolver resolver = new HashMapResolver(); + return new SvcLogicServiceImplBase(getStore(), resolver); + } + +} diff --git a/sliapi/springboot/src/main/resources/application.properties b/sliapi/springboot/src/main/resources/application.properties index 64415bd34..851488b9a 100644 --- a/sliapi/springboot/src/main/resources/application.properties +++ b/sliapi/springboot/src/main/resources/application.properties @@ -1,8 +1,10 @@ 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.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.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 +logging.level.com.att=TRACE +logging.level.org.onap=TRACE \ No newline at end of file diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java index 13f5939c5..e34d11877 100644 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java @@ -1,7 +1,6 @@ package org.onap.ccsdk.sli.core.sliapi.springboot; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; @@ -10,94 +9,102 @@ import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; - -import static org.junit.Assert.assertEquals; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(SpringRunner.class) -@WebMvcTest(RestconfApiController.class) +@SpringBootTest +@AutoConfigureMockMvc public class RestconfApiControllerTest { + private static final Logger log = LoggerFactory.getLogger(RestconfApiControllerTest.class); - private static final Logger log = LoggerFactory.getLogger(RestconfApiControllerTest.class); - - @Autowired - private MockMvc mvc; - + @Autowired + private MockMvc mvc; - @Test - public void testHealthcheck() throws Exception { - String url = "/restconf/operations/SLI-API:healthcheck"; + @Test + public void testHealthcheck() throws Exception { + String url = "/restconf/operations/SLI-API:healthcheck"; - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content("")).andReturn(); + MvcResult mvcResult = + mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content("")) + .andReturn(); - assertEquals(200, mvcResult.getResponse().getStatus()); - } + assertEquals(200, mvcResult.getResponse().getStatus()); + } - @Test - public void testVlbcheck() throws Exception { - String url = "/restconf/operations/SLI-API:vlbcheck"; + @Test + public void testVlbcheck() throws Exception { + String url = "/restconf/operations/SLI-API:vlbcheck"; - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content("")).andReturn(); + MvcResult mvcResult = + mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content("")) + .andReturn(); - assertEquals(200, mvcResult.getResponse().getStatus()); - } + assertEquals(200, mvcResult.getResponse().getStatus()); + } - @Test - public void testExecuteHealthcheck() throws Exception { - String url = "/restconf/operations/SLI-API:execute-graph"; + @Test + public void testExecuteHealthcheck() throws Exception { + String url = "/restconf/operations/SLI-API:execute-graph"; - ExecuteGraphInput executeGraphInput = new ExecuteGraphInput(); - ExecutegraphinputInput executeGraphData = new ExecutegraphinputInput(); + ExecuteGraphInput executeGraphInput = new ExecuteGraphInput(); + ExecutegraphinputInput executeGraphData = new ExecutegraphinputInput(); - executeGraphData.setModuleName("sli"); - executeGraphData.setRpcName("healthcheck"); - executeGraphData.setMode("sync"); - executeGraphInput.setInput(executeGraphData); + executeGraphData.setModuleName("sli"); + executeGraphData.setRpcName("healthcheck"); + executeGraphData.setMode("sync"); + executeGraphInput.setInput(executeGraphData); - String jsonString = mapToJson(executeGraphInput); - log.error("jsonString is {}", jsonString); + String jsonString = mapToJson(executeGraphInput); + log.error("jsonString is {}", jsonString); - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andReturn(); + MvcResult mvcResult = + mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)) + .andReturn(); - assertEquals(200, mvcResult.getResponse().getStatus()); + assertEquals(200, mvcResult.getResponse().getStatus()); - } + } - @Test - public void testExecuteMissingDg() throws Exception { - String url = "/restconf/operations/SLI-API:execute-graph"; + @Test + public void testExecuteMissingDg() throws Exception { + String url = "/restconf/operations/SLI-API:execute-graph"; - ExecuteGraphInput executeGraphInput = new ExecuteGraphInput(); - ExecutegraphinputInput executeGraphData = new ExecutegraphinputInput(); + ExecuteGraphInput executeGraphInput = new ExecuteGraphInput(); + ExecutegraphinputInput executeGraphData = new ExecutegraphinputInput(); - executeGraphData.setModuleName("sli"); - executeGraphData.setRpcName("noSuchRPC"); - executeGraphData.setMode("sync"); - executeGraphInput.setInput(executeGraphData); + executeGraphData.setModuleName("sli"); + executeGraphData.setRpcName("noSuchRPC"); + executeGraphData.setMode("sync"); + executeGraphInput.setInput(executeGraphData); - String jsonString = mapToJson(executeGraphInput); + String jsonString = mapToJson(executeGraphInput); - log.error("jsonString is {}", jsonString); + log.error("jsonString is {}", jsonString); - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)).andReturn(); + MvcResult mvcResult = + mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)) + .andReturn(); - assertEquals(401, mvcResult.getResponse().getStatus()); + assertEquals(401, mvcResult.getResponse().getStatus()); - } + } - private String mapToJson(Object obj) throws JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.writeValueAsString(obj); - } + private String mapToJson(Object obj) throws JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.writeValueAsString(obj); + } - private ResponseFields respFromJson(String jsonString) throws JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - return(objectMapper.readValue(jsonString, ResponseFields.class)); - } + private ResponseFields respFromJson(String jsonString) throws JsonProcessingException { + ObjectMapper objectMapper = new ObjectMapper(); + return (objectMapper.readValue(jsonString, ResponseFields.class)); + } } -- cgit 1.2.3-korg From a0f9f9bf12b06c894b980d4438ddae4cf5a4abd2 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 3 Mar 2020 10:56:20 -0500 Subject: Use released 1.5.2 CCSDK parent Update to use released version of CCSDK parent pom Change-Id: I573d5c30a799c1bf828b195aa0dff1b85c9a44ad Issue-ID: CCSDK-2152 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-dblib/pom.xml | 2 +- features/ccsdk-filters/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/ccsdk-sli/pom.xml | 2 +- features/ccsdk-sliPluginUtils/pom.xml | 2 +- features/ccsdk-sliapi/pom.xml | 2 +- features/ccsdk-slicore-utils/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- sli/common/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- sliapi/springboot/pom.xml | 194 ++++++++++++++++++---------------- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- 35 files changed, 137 insertions(+), 125 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index a5ed37993..a99345c82 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -17,7 +17,7 @@ org.onap.ccsdk.parent parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index ecc73ec1e..2b150e26f 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/dblib/pom.xml b/dblib/pom.xml index cd2b87244..6cf7cee2b 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 745671c1c..409f15000 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-dblib/pom.xml b/features/ccsdk-dblib/pom.xml index 664898a7a..eea935575 100644 --- a/features/ccsdk-dblib/pom.xml +++ b/features/ccsdk-dblib/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-filters/pom.xml b/features/ccsdk-filters/pom.xml index 24cc33b77..8ba8c1c63 100644 --- a/features/ccsdk-filters/pom.xml +++ b/features/ccsdk-filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 576cff0f0..e58760019 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml index 14c823128..f32fd591d 100644 --- a/features/ccsdk-sli/pom.xml +++ b/features/ccsdk-sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-sliPluginUtils/pom.xml b/features/ccsdk-sliPluginUtils/pom.xml index c92dafc2a..df843c041 100644 --- a/features/ccsdk-sliPluginUtils/pom.xml +++ b/features/ccsdk-sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-sliapi/pom.xml b/features/ccsdk-sliapi/pom.xml index b1bf1550c..f7ffe28af 100644 --- a/features/ccsdk-sliapi/pom.xml +++ b/features/ccsdk-sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/ccsdk-slicore-utils/pom.xml b/features/ccsdk-slicore-utils/pom.xml index daf8e135f..929400655 100644 --- a/features/ccsdk-slicore-utils/pom.xml +++ b/features/ccsdk-slicore-utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 08c00c496..f524ca5de 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 092b88d89..12fc962a5 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/features/pom.xml b/features/pom.xml index ee1d01e51..9e927d47b 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index b03bf7545..3a90de580 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/filters/pom.xml b/filters/pom.xml index b7d7c5fac..73f1fa99e 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index fd24dbedb..4dc25a706 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/pom.xml b/pom.xml index c65d6c6ad..6ce852711 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 2570f33bc..d1dde52f6 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index dcbe6b8d2..5e5d099eb 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 4e551da7a..c330646cc 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sli/pom.xml b/sli/pom.xml index 7363f5b7c..d21a6cfbc 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index fd97a7177..8d59b507b 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 638bb9bbf..eb3dc27d8 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 8a5455e73..0a3c62c3f 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 0dd6dcc15..85d232a5a 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index be7f8514c..a568e0abb 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 2f363ef5a..304e03580 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index f25714bf6..fee78a6fa 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sliapi/pom.xml b/sliapi/pom.xml index c8bc164c7..585893057 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 5b2779643..0ad2ce759 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index e3cca4bdf..602c20afc 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -1,18 +1,18 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - spring-boot-starter-parent - 1.5.2-SNAPSHOT + + org.onap.ccsdk.parent + spring-boot-starter-parent + 1.5.2 - + - org.onap.ccsdk.sli.core - sliapi-springboot - 0.7.1-SNAPSHOT - jar + org.onap.ccsdk.sli.core + sliapi-springboot + 0.7.1-SNAPSHOT + jar ccsdk-sli-core :: sliapi :: ${project.artifactId} @@ -20,96 +20,108 @@ org.onap.ccsdk.sli.core.sliapi.springboot.App - - - io.swagger - swagger-annotations - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot + + + io.swagger + swagger-annotations + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot spring-boot-starter-test test 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-base - ${project.version} - - - com.google.code.gson - gson - - - org.apache.derby - derby - runtime - + spring-boot-starter-data-jpa + + + io.springfox + springfox-swagger2 + 2.9.2 + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + + + ${project.groupId} + dblib-provider + ${project.version} + + + ${project.groupId} + sli-common + ${project.version} + + + ${project.groupId} + sli-provider-base + ${project.version} + + + com.google.code.gson + gson + + + org.apache.derby + derby + runtime + junit junit test - + - - - - io.swagger - swagger-codegen-maven-plugin - 2.3.1 - - - - generate - - - target/generated-sources - ${project.basedir}/../model/src/main/resources/sli-api.20161110.yaml - spring - org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger - org.onap.ccsdk.sli.core.sliapi.model - org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger - true - true - ${project.basedir}/.swagger-codegen-ignore - true - - true - 2.2.4-RELEASE - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + + generate + + + target/generated-sources + ${project.basedir}/../model/src/main/resources/sli-api.20161110.yaml + spring + org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger + org.onap.ccsdk.sli.core.sliapi.model + org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger + true + true + ${project.basedir}/.swagger-codegen-ignore + true + + true + 2.2.4-RELEASE + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index fde570bad..eb5dd0e82 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/utils/pom.xml b/utils/pom.xml index 83c94905d..c1bfe1eac 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2-SNAPSHOT + 1.5.2 diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index e228e2f11..20cb30fc0 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,7 +5,7 @@ org.onap.ccsdk.parent binding-parent - 1.5.2-SNAPSHOT + 1.5.2 -- cgit 1.2.3-korg From 958ebf9ce643c6b5da6bce84e38bd2acafea9aec Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 4 Mar 2020 15:53:31 -0500 Subject: Release 0.7.1 version of sli/core Release Frankfurt M4 version of sli/core Change-Id: Id3b0e3bf00287288a55fccb94ea841d8f7e80c3e Issue-ID: CCSDK-2152 Signed-off-by: Dan Timoney --- releases/0.7.1.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/0.7.1.yaml diff --git a/releases/0.7.1.yaml b/releases/0.7.1.yaml new file mode 100644 index 000000000..0cdbee453 --- /dev/null +++ b/releases/0.7.1.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '0.7.1' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/301/' -- cgit 1.2.3-korg From 99889c1924876d65cf3402c5ddb299a7e4177aad Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 5 Mar 2020 11:48:38 -0500 Subject: Roll master to Guilin Roll versions of master for early Guilin development Change-Id: I9ad7859eb294120542bce6faadb83b383e963fa7 Issue-ID: CCSDK-2152 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 15 +++++++-------- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-dblib/pom.xml | 5 ++--- features/ccsdk-filters/pom.xml | 5 ++--- features/ccsdk-sli-core-all/pom.xml | 6 ++---- features/ccsdk-sli/pom.xml | 5 ++--- features/ccsdk-sliPluginUtils/pom.xml | 5 ++--- features/ccsdk-sliapi/pom.xml | 5 ++--- features/ccsdk-slicore-utils/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 6 +++--- pom.xml | 24 +++++++++++------------- sli/common/pom.xml | 5 ++--- sli/installer/pom.xml | 7 +++---- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 8 ++------ sli/provider/pom.xml | 9 ++------- sliPluginUtils/installer/pom.xml | 5 ++--- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 5 +++-- sliapi/installer/pom.xml | 6 +++--- sliapi/model/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 9 ++++----- sliapi/springboot/pom.xml | 4 ++-- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 6 +++--- 36 files changed, 93 insertions(+), 115 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index a99345c82..cf6eb6b18 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -2,9 +2,15 @@ 4.0.0 + + org.onap.ccsdk.parent + parent + 2.0.0-SNAPSHOT + + org.onap.ccsdk.sli.core sli-core-artifacts - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts @@ -14,12 +20,6 @@ ONAP - - org.onap.ccsdk.parent - parent - 1.5.2 - - @@ -148,5 +148,4 @@ - diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 2b150e26f..59e143d2b 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 6cf7cee2b..af139d06d 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core dblib - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 409f15000..edccd380b 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-dblib/pom.xml b/features/ccsdk-dblib/pom.xml index eea935575..83ec56756 100644 --- a/features/ccsdk-dblib/pom.xml +++ b/features/ccsdk-dblib/pom.xml @@ -5,18 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} - diff --git a/features/ccsdk-filters/pom.xml b/features/ccsdk-filters/pom.xml index 8ba8c1c63..03fe524c5 100644 --- a/features/ccsdk-filters/pom.xml +++ b/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} @@ -42,5 +42,4 @@ - diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index e58760019..192db84d3 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,18 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} - @@ -36,7 +35,6 @@ - ${project.groupId} diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml index f32fd591d..c96b93c88 100644 --- a/features/ccsdk-sli/pom.xml +++ b/features/ccsdk-sli/pom.xml @@ -5,18 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} - org.onap.ccsdk.sli.core diff --git a/features/ccsdk-sliPluginUtils/pom.xml b/features/ccsdk-sliPluginUtils/pom.xml index df843c041..8b9c67147 100644 --- a/features/ccsdk-sliPluginUtils/pom.xml +++ b/features/ccsdk-sliPluginUtils/pom.xml @@ -5,18 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} - diff --git a/features/ccsdk-sliapi/pom.xml b/features/ccsdk-sliapi/pom.xml index f7ffe28af..2dc873d67 100644 --- a/features/ccsdk-sliapi/pom.xml +++ b/features/ccsdk-sliapi/pom.xml @@ -5,18 +5,17 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} - diff --git a/features/ccsdk-slicore-utils/pom.xml b/features/ccsdk-slicore-utils/pom.xml index 929400655..200fc46ac 100644 --- a/features/ccsdk-slicore-utils/pom.xml +++ b/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index f524ca5de..019c3611f 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 12fc962a5..3a7f0cd74 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 9e927d47b..9408c0325 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index 3a90de580..bc0c56d12 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 73f1fa99e..3dec6563e 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core filters - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 4dc25a706..57d9387f8 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,17 +5,17 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} - + org.onap.logging-analytics diff --git a/pom.xml b/pom.xml index 6ce852711..2ad066f11 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core @@ -20,10 +20,6 @@ ONAP - - - content/sites/site/org/onap/ccsdk/sli/core/${project.version}/ - utils @@ -42,7 +38,16 @@ ${onap.git.protocol}://${onap.git.host}/projects/${onap.git.project}/repos/sdnc-core/browse sdnc-core-1.1.0 + + + ecomp-site + dav:${onap.nexus.url}/${sitePath} + + + + content/sites/site/org/onap/ccsdk/sli/core/${project.version}/ + @@ -123,11 +128,4 @@ - - - - ecomp-site - dav:${onap.nexus.url}/${sitePath} - - diff --git a/sli/common/pom.xml b/sli/common/pom.xml index d1dde52f6..5fb0b5ff0 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} @@ -23,7 +23,6 @@ - org.apache.derby diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 5e5d099eb..3061253b3 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} @@ -22,7 +22,7 @@ mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false - + @@ -32,7 +32,6 @@ - diff --git a/sli/model/pom.xml b/sli/model/pom.xml index c330646cc..6951b89ca 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index d21a6cfbc..b57f80e71 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sli - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 8d59b507b..abd33b468 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT ccsdk-sli-core :: sli :: ${project.artifactId} @@ -29,7 +29,6 @@ - org.onap.ccsdk.sli.core @@ -61,7 +60,4 @@ - - - diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index eb3dc27d8..5dc327f16 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} @@ -21,7 +21,6 @@ UTF-8 - @@ -31,7 +30,6 @@ - org.onap.ccsdk.sli.core @@ -108,7 +106,6 @@ * - @@ -134,7 +131,5 @@ - - diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 0a3c62c3f..e877daf5c 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} @@ -43,7 +43,6 @@ - diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 85d232a5a..458941d27 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index a568e0abb..21ed4cd66 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} @@ -20,6 +20,7 @@ UTF-8 + diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 304e03580..7571e2dca 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} @@ -22,6 +22,7 @@ mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features false + @@ -42,7 +43,6 @@ - diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index fee78a6fa..dfe7753a6 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 585893057..e2c910801 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 0ad2ce759..e726b24f2 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,18 +5,18 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} - - + + org.onap.ccsdk.sli.core @@ -25,7 +25,6 @@ - org.onap.ccsdk.sli.core diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index 602c20afc..dc2c16d6b 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent spring-boot-starter-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-springboot - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT jar ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index eb5dd0e82..e7380f0f6 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index c1bfe1eac..85b18c68c 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core utils - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 20cb30fc0..d5c07eba5 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 1.5.2 + 2.0.0-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 0.7.1-SNAPSHOT + 1.0.0-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index b05a161f6..1da7b9a35 100644 --- a/version.properties +++ b/version.properties @@ -4,9 +4,9 @@ # because they are used in Jenkins, whose plug-in doesn't support -release_name=0 -sprint_number=7 -feature_revision=1 +release_name=1 +sprint_number=0 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From c46ebbb0f011a1587c3fe506c5029ce550b07ed2 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Thu, 5 Mar 2020 15:30:45 +0000 Subject: update sliapi-springboot add sample log4j2 config for spring boot sli api Issue-ID: CCSDK-2161 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: If24315ad6cad1061d1e65e080f4122605b05df47 --- sliapi/springboot/pom.xml | 21 ++- .../onap/ccsdk/sli/core/sliapi/springboot/App.java | 20 +++ .../controllers/ExecuteGraphController.java | 24 +++- .../controllers/swagger/RestconfApiController.java | 20 +++ .../sliapi/springboot/core/ServletFilters.java | 42 ++++++ .../sliapi/springboot/core/SvcLogicFactory.java | 20 +++ .../sli/core/sliapi/springboot/core/WebConfig.java | 43 ++++++ .../src/main/resources/log4j2.properties | 160 +++++++++++++++++++++ .../springboot/RestconfApiControllerTest.java | 20 +++ 9 files changed, 365 insertions(+), 5 deletions(-) create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java create mode 100644 sliapi/springboot/src/main/resources/log4j2.properties diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index dc2c16d6b..6bdb1395f 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -28,7 +28,17 @@ org.springframework.boot spring-boot-starter-web - + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + org.springframework.boot spring-boot-starter-test @@ -78,6 +88,15 @@ junit junit test + + + org.onap.logging-analytics + logging-filter-spring + 1.6.4 + + + javax.ws.rs + javax.ws.rs-api diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java index 941c1d518..67f549145 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2020 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.sliapi.springboot; import org.springframework.boot.SpringApplication; diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java index efdefbd6f..809cfe59c 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2020 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.sliapi.springboot.controllers; import java.util.HashMap; @@ -25,14 +45,10 @@ import com.google.gson.JsonParser; public class ExecuteGraphController { @Autowired protected SvcLogicServiceBase 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(); diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java index 10442d432..2972cd791 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2020 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.sliapi.springboot.controllers.swagger; import java.util.Map; diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java new file mode 100644 index 000000000..c56cf3bf1 --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2020 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.sliapi.springboot.core; + +import javax.servlet.ServletException; + +import org.onap.logging.filter.base.PayloadLoggingServletFilter; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ServletFilters { + + @Bean + public FilterRegistrationBean payloadFilterRegistration() throws ServletException { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setFilter(new PayloadLoggingServletFilter()); + registration.addUrlPatterns("/*"); + registration.setName("payloadFilter"); + registration.setOrder(0); + return registration; + } +} \ No newline at end of file diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java index f39fc229c..a6bda81ae 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2020 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.sliapi.springboot.core; import java.io.FileInputStream; diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java new file mode 100644 index 000000000..fb4fe0858 --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2020 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.sliapi.springboot.core; + +import org.onap.logging.filter.spring.LoggingInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@EnableWebMvc +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Bean + LoggingInterceptor loggingInterceptor() { + return new LoggingInterceptor(); + } + + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(loggingInterceptor()); // handles audit log entries + } + +} \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/log4j2.properties b/sliapi/springboot/src/main/resources/log4j2.properties new file mode 100644 index 000000000..40d18d157 --- /dev/null +++ b/sliapi/springboot/src/main/resources/log4j2.properties @@ -0,0 +1,160 @@ + #- + # ============LICENSE_START======================================================= + # ONAP - CCSDK + # ================================================================================ + # Copyright (C) 2020 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========================================================= + # + +property.logDir = ${sys:LOG_PATH:-./target} + +property.pattern = %d{ISO8601} | %-5p | %-16t | %-32c{1} | %X{currentGraph} - %X{nodeId} | %m%n + +#default mdc values +property.ServiceName = INTERNAL +property.ErrorCode = 900 +property.ErrorDesc = UnknownError + +rootLogger.level = INFO +rootLogger.appenderRef.AppFile.ref = AppFile +rootLogger.appenderRef.Console.ref = Console +rootLogger.appenderRef.DebugFile.ref = DebugFile +rootLogger.appenderRef.ErrorFile.ref = ErrorFile +rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter +rootLogger.appenderRef.Console.filter.threshold.level = DEBUG + +appender.console.type = Console +appender.console.name = Console +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = ${pattern} + +appender.app.type = RollingRandomAccessFile +appender.app.name = AppFile +appender.app.fileName = ${logDir}/app.log +appender.app.filePattern = ${logDir}/app.log.%i +appender.app.immediateFlush = true +appender.app.append = true +appender.app.layout.type = PatternLayout +appender.app.layout.pattern = ${pattern} +appender.app.policies.type = Policies +appender.app.policies.size.type = SizeBasedTriggeringPolicy +appender.app.policies.size.size = 10MB +appender.app.strategy.type = DefaultRolloverStrategy +appender.app.strategy.max = 100 +appender.app.strategy.fileIndex = min + +appender.debug.type = RollingRandomAccessFile +appender.debug.name = DebugFile +appender.debug.fileName = ${logDir}/debug.log +appender.debug.filePattern = ${logDir}/debug.log.%i +appender.debug.immediateFlush = true +appender.debug.append = true +appender.debug.layout.type = PatternLayout +appender.debug.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%-16.16t|%-5.5p|%-32.32c{1}|%X{currentGraph} - %X{nodeId}|%m%n +appender.debug.policies.type = Policies +appender.debug.policies.size.type = SizeBasedTriggeringPolicy +appender.debug.policies.size.size = 10MB +appender.debug.strategy.type = DefaultRolloverStrategy +appender.debug.strategy.max = 200 +appender.debug.strategy.fileIndex = min + +appender.error.type = RollingRandomAccessFile +appender.error.name = ErrorFile +appender.error.fileName = ${logDir}/error.log +appender.error.filePattern = ${logDir}/error.log.%i +appender.error.immediateFlush = true +appender.error.append = true +appender.error.layout.type = PatternLayout +appender.error.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%-16.16t|$${ctx:ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%p|$${ctx:ErrorCode}|$${ctx:ErrorDesc}|%m%n + +appender.error.policies.type = Policies +appender.error.policies.size.type = SizeBasedTriggeringPolicy +appender.error.policies.size.size = 10MB +appender.error.strategy.type = DefaultRolloverStrategy +appender.error.strategy.max = 100 +appender.error.strategy.fileIndex = min +appender.error.filter.threshold.type = ThresholdFilter +appender.error.filter.threshold.level = WARN + +appender.metric.type = RollingRandomAccessFile +appender.metric.name = MetricFile +appender.metric.fileName = ${logDir}/metric.log +appender.metric.filePattern = ${logDir}/metric.log.%i +appender.metric.immediateFlush = true +appender.metric.append = true +appender.metric.layout.type = PatternLayout +appender.metric.layout.pattern=%X{InvokeTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%-16.16t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceID}|%p|%X{Severity}|192.168.23.111|%X{ElapsedTime}|${hostName}|%X{ClientIPAddress}|%C{1}|||%X{TargetElement}|%markerSimpleName|%X|%X{currentGraph} - %X{nodeId}||%m%n +appender.metric.policies.type = Policies +appender.metric.policies.size.type = SizeBasedTriggeringPolicy +appender.metric.policies.size.size = 10MB +appender.metric.strategy.type = DefaultRolloverStrategy +appender.metric.strategy.max = 100 +appender.metric.strategy.fileIndex = min + +appender.audit.type = RollingRandomAccessFile +appender.audit.name = AuditFile +appender.audit.fileName = ${logDir}/audit.log +appender.audit.filePattern = ${logDir}/audit.log.%i +appender.audit.immediateFlush = true +appender.audit.append = true +appender.audit.layout.type = PatternLayout +appender.audit.layout.pattern=%X{EntryTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%-16.16t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceID}|INFO|%X{Severity}|192.168.23.111|%X{ElapsedTime}|${hostName}|%X{ClientIPAddress}|%C{1}|%X{AUDIT-Unused}|%X{AUDIT-ProcessKey}|%markerSimpleName|%X|||%m%n +appender.audit.policies.type = Policies +appender.audit.policies.size.type = SizeBasedTriggeringPolicy +appender.audit.policies.size.size = 10MB +appender.audit.strategy.type = DefaultRolloverStrategy +appender.audit.strategy.max = 200 +appender.audit.strategy.fileIndex = min + +appender.rr.name = RequestResponseFile +appender.rr.type = RollingRandomAccessFile +appender.rr.fileName = ${logDir}/request-response.log +appender.rr.filePattern = ${logDir}/request-response.log.%i +appender.rr.immediateFlush = true +appender.rr.append = true +appender.rr.layout.type = PatternLayout +appender.rr.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%X{PartnerName}|%m%n +appender.rr.policies.type = Policies +appender.rr.policies.size.type = SizeBasedTriggeringPolicy +appender.rr.policies.size.size = 10MB +appender.rr.strategy.type = DefaultRolloverStrategy +appender.rr.strategy.max = 100 +appender.rr.strategy.fileIndex = min + +logger.metric.name = org.onap.ccsdk.sli.core.filters.metric +logger.metric.level = INFO +logger.metric.additivity = false +logger.metric.appenderRef.MetricFile.ref = MetricFile + +logger.metric2.name = org.onap.logging.filter.base.AbstractMetricLogFilter +logger.metric2.level = INFO +logger.metric2.additivity = false +logger.metric2.appenderRef.MetricFile.ref = MetricFile + +logger.audit.name = org.onap.logging.filter.base.AbstractAuditLogFilter +logger.audit.level = INFO +logger.audit.additivity = false +logger.audit.appenderRef.AuditFile.ref = AuditFile + +logger.rr.name = org.onap.logging.filter.base.PayloadLoggingServletFilter +logger.rr.level = INFO +logger.rr.additivity = false +logger.rr.appenderRef.RequestResponseFile.ref = RequestResponseFile + +logger.ccsdk.name = org.onap.ccsdk +logger.ccsdk.level = DEBUG + +logger.onaplogging.name = org.onap.logging +logger.onaplogging.level = DEBUG \ No newline at end of file diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java index e34d11877..a61a470ed 100644 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - CCSDK + * ================================================================================ + * Copyright (C) 2020 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.sliapi.springboot; import static org.junit.Assert.assertEquals; -- cgit 1.2.3-korg From 88f749277195998d150925e14e12021cc2e9292b Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 11 Mar 2020 15:54:10 -0400 Subject: Add data persistence Add code to persist MD-SAL data (test-results) Change-Id: I2c6d3e94e9e46ccbfad479c6d89507ec37939496 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney --- .../onap/ccsdk/sli/core/sliapi/springboot/App.java | 5 + .../controllers/data/TestResultConfig.java | 50 ++++++ .../controllers/data/TestResultOperational.java | 51 ++++++ .../data/TestResultsConfigRepository.java | 12 ++ .../data/TestResultsOperationalRepository.java | 12 ++ .../controllers/swagger/RestconfApiController.java | 191 +++++++++++++++++++-- .../sliapi/springboot/core/ServletFilters.java | 4 +- .../sli/core/sliapi/springboot/core/WebConfig.java | 49 +++++- .../src/main/resources/application.properties | 2 +- .../springboot/RestconfApiControllerTest.java | 28 +++ 10 files changed, 388 insertions(+), 16 deletions(-) create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultConfig.java create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultOperational.java create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsConfigRepository.java create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsOperationalRepository.java diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java index 67f549145..ed3ee0446 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java @@ -22,8 +22,13 @@ package org.onap.ccsdk.sli.core.sliapi.springboot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication +@EnableSwagger2 +@ComponentScan(basePackages = { "org.onap.ccsdk.sli.core.sliapi.springboot.*" }) + public class App { public static void main(String[] args) throws Exception { diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultConfig.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultConfig.java new file mode 100644 index 000000000..f8ed1b4ce --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultConfig.java @@ -0,0 +1,50 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +@Entity +public class TestResultConfig { + + + @Id + @GeneratedValue(strategy= GenerationType.AUTO) + private Long id; + + private String testIdentifier; + private String results; + + public TestResultConfig() + { + + } + public TestResultConfig(String testIdentifier, String results) { + this.testIdentifier = testIdentifier; + this.results = results; + } + + public String getTestIdentifier() { + return testIdentifier; + } + + public void setTestIdentifier(String testIdentifier) { + this.testIdentifier = testIdentifier; + } + + public String getResults() { + return results; + } + + public void setResults(String results) { + this.results = results; + } + + + + +} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultOperational.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultOperational.java new file mode 100644 index 000000000..4c3709e6e --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultOperational.java @@ -0,0 +1,51 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +@Entity +public class TestResultOperational { + + + @Id + @GeneratedValue(strategy= GenerationType.AUTO) + private Long id; + + private String testIdentifier; + private String results; + + public TestResultOperational() + { + + } + + public TestResultOperational(String testIdentifier, String results) { + this.testIdentifier = testIdentifier; + this.results = results; + } + + public String getTestIdentifier() { + return testIdentifier; + } + + public void setTestIdentifier(String testIdentifier) { + this.testIdentifier = testIdentifier; + } + + public String getResults() { + return results; + } + + public void setResults(String results) { + this.results = results; + } + + + + +} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsConfigRepository.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsConfigRepository.java new file mode 100644 index 000000000..1a73b3f50 --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsConfigRepository.java @@ -0,0 +1,12 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data; + +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface TestResultsConfigRepository extends CrudRepository { + + List findByTestIdentifier(String testIdentifier); + + +} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsOperationalRepository.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsOperationalRepository.java new file mode 100644 index 000000000..d81c02b23 --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsOperationalRepository.java @@ -0,0 +1,12 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data; + +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface TestResultsOperationalRepository extends CrudRepository { + + List findByTestIdentifier(String testIdentifier); + + +} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java index 2972cd791..aa9a9d7e8 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java @@ -20,38 +20,53 @@ package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger; -import java.util.Map; -import java.util.Optional; -import java.util.Properties; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.JsonObject; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; -import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RestconfApi; +import org.onap.ccsdk.sli.core.sliapi.model.TestResult; +import org.onap.ccsdk.sli.core.sliapi.model.TestResults; +import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data.TestResultConfig; +import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data.TestResultsConfigRepository; +import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data.TestResultsOperationalRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.ComponentScan; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.JsonObject; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.*; @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-02-20T12:50:11.207-05:00") @Controller +@ComponentScan(basePackages = {"org.onap.ccsdk.sli.core.sliapi.springboot.*"}) +@EntityScan("org.onap.ccsdk.sli.core.sliapi.springboot.*") public class RestconfApiController implements RestconfApi { private final ObjectMapper objectMapper; private final HttpServletRequest request; - @Autowired - protected SvcLogicServiceBase svc; + @Autowired + protected SvcLogicServiceBase svc; + + @Autowired + private TestResultsConfigRepository testResultsConfigRepository; + + @Autowired + private TestResultsOperationalRepository testResultsOperationalRepository; + private static final Logger log = LoggerFactory.getLogger(RestconfApiController.class); @org.springframework.beans.factory.annotation.Autowired @@ -175,6 +190,158 @@ public class RestconfApiController implements RestconfApi { } } + @Override + public ResponseEntity deleteTestResult(String testIdentifier) { + + List testResultConfigs = testResultsConfigRepository.findByTestIdentifier(testIdentifier); + + if (testResultConfigs != null) { + Iterator testResultConfigIterator = testResultConfigs.iterator(); + while (testResultConfigIterator.hasNext()) { + testResultsConfigRepository.delete(testResultConfigIterator.next()); + } + } + + return (new ResponseEntity<>(HttpStatus.OK)); + } + + @Override + public ResponseEntity deleteTestResults() { + + testResultsConfigRepository.deleteAll(); + + return (new ResponseEntity<>(HttpStatus.OK)); + } + + @Override + public ResponseEntity gETTestResults() { + + TestResults results = new TestResults(); + + testResultsOperationalRepository.findAll().forEach(testResult -> { + TestResult item = null; + try { + item = objectMapper.readValue(testResult.getResults(), TestResult.class); + results.addTestResultsItem(item); + } catch (JsonProcessingException e) { + log.error("Could not convert testResult", e); + } + }); + + + return new ResponseEntity<>(results, HttpStatus.OK); + } + + @Override + public ResponseEntity getTestResult(String testIdentifier) { + List testResultConfigs = testResultsConfigRepository.findByTestIdentifier(testIdentifier); + + if ((testResultConfigs == null) || (testResultConfigs.size() == 0)) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } else { + TestResultConfig testResultConfig = testResultConfigs.get(0); + TestResult testResult = null; + try { + testResult = objectMapper.readValue(testResultConfig.getResults(), TestResult.class); + } catch (JsonProcessingException e) { + log.error("Cannot convert test result", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + return new ResponseEntity<>(testResult, HttpStatus.OK); + } + } + + @Override + public ResponseEntity getTestResults() { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default RestconfApi interface so no example is generated"); + } + + TestResults results = new TestResults(); + + testResultsConfigRepository.findAll().forEach(testResult -> { + TestResult item = null; + try { + item = objectMapper.readValue(testResult.getResults(), TestResult.class); + results.addTestResultsItem(item); + } catch (JsonProcessingException e) { + log.error("Could not convert testResult", e); + } + }); + + + return new ResponseEntity<>(results, HttpStatus.OK); + } + + @Override + public ResponseEntity pUTTestResult(String testIdentifier, @Valid TestResult testResult) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default RestconfApi interface so no example is generated"); + } + + List testResultConfigs = testResultsConfigRepository.findByTestIdentifier(testIdentifier); + Iterator testResultIter = testResultConfigs.iterator(); + while (testResultIter.hasNext()) { + testResultsConfigRepository.delete(testResultIter.next()); + } + + TestResultConfig testResultConfig = null; + try { + testResultConfig = new TestResultConfig(testResult.getTestIdentifier(), objectMapper.writeValueAsString(testResult)); + testResultsConfigRepository.save(testResultConfig); + } catch (JsonProcessingException e) { + log.error("Could not save test result", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + return new ResponseEntity<>(testResult, HttpStatus.OK); + } + + @Override + public ResponseEntity postTestResults(@Valid TestResults testResults) { + List resultList = testResults.getTestResults(); + + Iterator resultIterator = resultList.iterator(); + + while (resultIterator.hasNext()) { + TestResult curResult = resultIterator.next(); + try { + testResultsConfigRepository.save(new TestResultConfig(curResult.getTestIdentifier(), objectMapper.writeValueAsString(curResult))); + } catch (JsonProcessingException e) { + log.error("Could not save test result", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<>(testResults, HttpStatus.OK); + } + + @Override + public ResponseEntity putTestResults(@Valid TestResults testResults) { + testResultsConfigRepository.deleteAll(); + + List resultList = testResults.getTestResults(); + + Iterator resultIterator = resultList.iterator(); + + + while (resultIterator.hasNext()) { + TestResult curResult = resultIterator.next(); + try { + testResultsConfigRepository.save(new TestResultConfig(curResult.getTestIdentifier(), objectMapper.writeValueAsString(curResult))); + } catch (JsonProcessingException e) { + log.error("Could not save test result", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + return new ResponseEntity<>(testResults, HttpStatus.OK); + } + public static String propsToJson(Properties props, String root) { StringBuffer sbuff = new StringBuffer(); diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java index c56cf3bf1..bfec1c935 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java @@ -30,7 +30,7 @@ import org.springframework.context.annotation.Configuration; @Configuration public class ServletFilters { - @Bean +/* @Bean public FilterRegistrationBean payloadFilterRegistration() throws ServletException { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new PayloadLoggingServletFilter()); @@ -38,5 +38,5 @@ public class ServletFilters { registration.setName("payloadFilter"); registration.setOrder(0); return registration; - } + }*/ } \ No newline at end of file diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java index fb4fe0858..41d3791b4 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java @@ -21,23 +21,70 @@ package org.onap.ccsdk.sli.core.sliapi.springboot.core; import org.onap.logging.filter.spring.LoggingInterceptor; +import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + @EnableWebMvc @Configuration +@EnableJpaRepositories("org.onap.ccsdk.sli.core.sliapi.springboot.*") +@ComponentScan(basePackages = {"org.onap.ccsdk.sli.core.sliapi.springboot.*"}) +@EntityScan("org.onap.ccsdk.sli.core.sliapi.springboot.*") +@EnableTransactionManagement public class WebConfig implements WebMvcConfigurer { - @Bean +/* @Bean LoggingInterceptor loggingInterceptor() { return new LoggingInterceptor(); } public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(loggingInterceptor()); // handles audit log entries + }*/ + + @Bean + public DataSource dataSource() { + + EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); + builder.setName("sdnctl"); + return builder.setType(EmbeddedDatabaseType.DERBY).build(); + } + + @Bean + public EntityManagerFactory entityManagerFactory() { + + HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + vendorAdapter.setGenerateDdl(true); + + LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); + factory.setJpaVendorAdapter(vendorAdapter); + factory.setPackagesToScan("org.onap.ccsdk.sli.core.sliapi.springboot.*"); + factory.setDataSource(dataSource()); + factory.afterPropertiesSet(); + + return factory.getObject(); } + @Bean + public PlatformTransactionManager transactionManager() { + + JpaTransactionManager txManager = new JpaTransactionManager(); + txManager.setEntityManagerFactory(entityManagerFactory()); + return txManager; + } } \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/application.properties b/sliapi/springboot/src/main/resources/application.properties index 851488b9a..6a4acc7e9 100644 --- a/sliapi/springboot/src/main/resources/application.properties +++ b/sliapi/springboot/src/main/resources/application.properties @@ -3,7 +3,7 @@ server.contextPath=/restconf server.port=8080 spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RFC3339DateFormat spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false -spring.datasource.url=jdbc:derby:sdnctl;create=true +spring.datasource.url=jdbc:derby:memory:datasource spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyTenSevenDialect spring.jpa.hibernate.ddl-auto=update logging.level.com.att=TRACE diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java index a61a470ed..b4c629097 100644 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java @@ -118,6 +118,34 @@ public class RestconfApiControllerTest { } + @Test + public void testTestResultAdd() throws Exception { + String url = "/restconf/config/SLI-API:test-results"; + + MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(url)).andReturn(); + + assertEquals(200, mvcResult.getResponse().getStatus()); + + String jsonString = "{\n" + + " \"test-results\" : [\n" + + " {\n" + + " \"test-identifier\" : \"test-1\",\n" + + " \"results\" : [\"test result 1\"]\n" + + " }\n" + + " ]\n" + + "}"; + + mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)) + .andReturn(); + + assertEquals(200, mvcResult.getResponse().getStatus()); + + mvcResult = mvc.perform(MockMvcRequestBuilders.get(url)).andReturn(); + + assertEquals(200, mvcResult.getResponse().getStatus()); + assertEquals(jsonString.replaceAll("\\s+",""), mvcResult.getResponse().getContentAsString().replaceAll("\\s+","")); + } + private String mapToJson(Object obj) throws JsonProcessingException { ObjectMapper objectMapper = new ObjectMapper(); return objectMapper.writeValueAsString(obj); -- cgit 1.2.3-korg From d8bda45b7e8feccaa521d0ae35b72ae3b87c5a89 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 18 Mar 2020 15:58:52 +0000 Subject: update sliapi-springboot add base plugins to spring boot sli Issue-ID: CCSDK-2179 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I1e80e3a8b67ced5c2ff72c9569d6aac970c72ddf --- sliapi/springboot/pom.xml | 28 ++++++++++-- .../sliapi/springboot/core/ServletFilters.java | 42 ------------------ .../sliapi/springboot/core/SvcLogicFactory.java | 50 +++++++++++++++++++++- sliapi/springboot/src/main/resources/DEMO_DEMO.xml | 35 +++++++++++++++ .../springboot/src/main/resources/graph.versions | 1 + 5 files changed, 109 insertions(+), 47 deletions(-) delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java create mode 100755 sliapi/springboot/src/main/resources/DEMO_DEMO.xml diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index 6bdb1395f..8e8894597 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -94,10 +94,30 @@ logging-filter-spring 1.6.4 - - javax.ws.rs - javax.ws.rs-api - + + javax.ws.rs + javax.ws.rs-api + + + org.onap.ccsdk.sli.core + sliPluginUtils-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + restapi-call-node-provider + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + + org.glassfish.jersey.inject + jersey-hk2 + diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java deleted file mode 100644 index bfec1c935..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/ServletFilters.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2020 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.sliapi.springboot.core; - -import javax.servlet.ServletException; - -import org.onap.logging.filter.base.PayloadLoggingServletFilter; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ServletFilters { - -/* @Bean - public FilterRegistrationBean payloadFilterRegistration() throws ServletException { - FilterRegistrationBean registration = new FilterRegistrationBean(); - registration.setFilter(new PayloadLoggingServletFilter()); - registration.addUrlPatterns("/*"); - registration.setName("payloadFilter"); - registration.setOrder(0); - return registration; - }*/ -} \ No newline at end of file diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java index a6bda81ae..9b521e4e7 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java @@ -22,9 +22,12 @@ package org.onap.ccsdk.sli.core.sliapi.springboot.core; import java.io.FileInputStream; import java.io.IOException; +import java.util.List; import java.util.Properties; import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver; @@ -32,8 +35,14 @@ 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.sli.provider.base.SvcLogicServiceBase; import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; +import org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; +import org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils; +import org.onap.ccsdk.sli.plugins.prop.PropertiesNode; +import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -41,6 +50,12 @@ import org.springframework.context.annotation.Configuration; public class SvcLogicFactory { private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class); + @Autowired + List recorders; + + @Autowired + List plugins; + @Bean public SvcLogicStore getStore() throws Exception { SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() { @@ -84,8 +99,41 @@ public class SvcLogicFactory { @Bean public SvcLogicServiceBase createService() throws Exception { - SvcLogicResolver resolver = new HashMapResolver(); + HashMapResolver resolver = new HashMapResolver(); + for (SvcLogicRecorder recorder : recorders) { + resolver.addSvcLogicRecorder(recorder.getClass().getName(), recorder); + + } + for (SvcLogicJavaPlugin plugin : plugins) { + resolver.addSvcLogicSvcLogicJavaPlugin(plugin.getClass().getName(), plugin); + + } return new SvcLogicServiceImplBase(getStore(), resolver); } + @Bean + public Slf4jRecorder slf4jRecorderNode() { + return new Slf4jRecorder(); + } + + @Bean + public SliPluginUtils sliPluginUtil() { + return new SliPluginUtils(); + } + + @Bean + public SliStringUtils sliStringUtils() { + return new SliStringUtils(); + } + + @Bean + public RestapiCallNode restapiCallNode() { + return new RestapiCallNode(); + } + + @Bean + public PropertiesNode propertiesNode() { + return new PropertiesNode(); + } + } diff --git a/sliapi/springboot/src/main/resources/DEMO_DEMO.xml b/sliapi/springboot/src/main/resources/DEMO_DEMO.xml new file mode 100755 index 000000000..1b304f18a --- /dev/null +++ b/sliapi/springboot/src/main/resources/DEMO_DEMO.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/graph.versions b/sliapi/springboot/src/main/resources/graph.versions index 7f75be4c8..d21278aa4 100644 --- a/sliapi/springboot/src/main/resources/graph.versions +++ b/sliapi/springboot/src/main/resources/graph.versions @@ -1,2 +1,3 @@ sli healthcheck 0.7.0 sync sli vlbcheck 0.7.0 sync +DEMO DEMO 1 sync -- cgit 1.2.3-korg From 35d9348ab67b6dc3c8e90a2a479f75fcd0af9228 Mon Sep 17 00:00:00 2001 From: David Stilwell Date: Wed, 18 Mar 2020 10:02:50 -0400 Subject: Springboot integration with AAF Changes made: pom.xml updates, App.java add Beans for realm and filterchain Issue-ID: CCSDK-2178 Change-Id: I29aa242ceff6a2f840b93a8d18ca5385190ca6d2 Signed-off-by: David Stilwell --- sliapi/springboot/README.md | 8 +++-- sliapi/springboot/pom.xml | 13 ++++++-- .../onap/ccsdk/sli/core/sliapi/springboot/App.java | 37 ++++++++++++++++++++ .../src/main/resources/shiro-users.properties | 3 ++ .../ccsdk/sli/core/sliapi/springboot/AppTest.java | 39 ++++++++++++++++++++++ 5 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 sliapi/springboot/src/main/resources/shiro-users.properties create mode 100644 sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java diff --git a/sliapi/springboot/README.md b/sliapi/springboot/README.md index 3e47f341f..38be1c2f9 100644 --- a/sliapi/springboot/README.md +++ b/sliapi/springboot/README.md @@ -1,8 +1,12 @@ This directory contains a demo springboot implementation of the SLI-API healthcheck method. -To start this server, run: +To start this server with out AAF authentication, run: mvn -DserviceLogicDirectory=src/main/resources spring-boot:run +To start this server with AAF authentication, run: +mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dcadi_prop_files=/opt/onap/sdnc/data/properties/org.onap.sdnc.props -DserviceLogicDirectory=src/main/resources" + + This will start a servlet on port 8080. To test to that servlet, post a blank message to that port: @@ -26,4 +30,4 @@ An example request "mixed": "cAsE" } } -``` \ No newline at end of file +``` diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index 8e8894597..2a3fbcb06 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -18,6 +18,8 @@ org.onap.ccsdk.sli.core.sliapi.springboot.App + 1.5.0 + 2.1.13 @@ -26,8 +28,9 @@ swagger-annotations - org.springframework.boot - spring-boot-starter-web + org.apache.shiro + shiro-spring-boot-web-starter + ${shiro.version} org.springframework.boot @@ -39,6 +42,12 @@ org.springframework.boot spring-boot-starter-log4j2 + + org.onap.aaf.cadi + aaf-cadi-shiro + ${aaf-shiro-bundle.version} + + org.springframework.boot spring-boot-starter-test diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java index ed3ee0446..2892430b1 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java @@ -24,6 +24,13 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; import springfox.documentation.swagger2.annotations.EnableSwagger2; +import org.apache.shiro.realm.Realm; +import org.apache.shiro.realm.text.PropertiesRealm; +import org.apache.shiro.realm.text.TextConfigurationRealm; +import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition; +import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; +import org.springframework.context.annotation.Bean; +import org.onap.aaf.cadi.shiro.AAFRealm; @SpringBootApplication @EnableSwagger2 @@ -34,4 +41,34 @@ public class App { public static void main(String[] args) throws Exception { SpringApplication.run(App.class, args); } + + @Bean + public Realm realm() { + + // If cadi prop files is not defined use local properties realm + // src/main/resources/shiro-users.properties + if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { + PropertiesRealm realm = new PropertiesRealm(); + return realm; + } else { + AAFRealm realm = new AAFRealm(); + return realm; + } + + } + + @Bean + public ShiroFilterChainDefinition shiroFilterChainDefinition() { + DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition(); + + // if cadi prop files is not set disable authentication + if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { + chainDefinition.addPathDefinition("/**", "anon"); + } else { + chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc:odl-api]"); + } + + return chainDefinition; + } + } diff --git a/sliapi/springboot/src/main/resources/shiro-users.properties b/sliapi/springboot/src/main/resources/shiro-users.properties new file mode 100644 index 000000000..df4b1ae7a --- /dev/null +++ b/sliapi/springboot/src/main/resources/shiro-users.properties @@ -0,0 +1,3 @@ +user.admin = Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U,service +role.service = odl-api:* + diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java new file mode 100644 index 000000000..c5f452cb8 --- /dev/null +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java @@ -0,0 +1,39 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot; + +import org.apache.shiro.realm.Realm; +import org.apache.shiro.realm.text.PropertiesRealm; +import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; +import org.junit.Before; +import org.junit.Test; +import org.onap.aaf.cadi.shiro.AAFRealm; + +import java.util.Map; + +import static org.junit.Assert.*; + +public class AppTest { + + App app; + + @Before + public void setUp() throws Exception { + app = new App(); + } + + @Test + public void realm() { + Realm realm = app.realm(); + assertTrue(realm instanceof PropertiesRealm); + + + } + + @Test + public void shiroFilterChainDefinition() { + ShiroFilterChainDefinition chainDefinition = app.shiroFilterChainDefinition(); + Map chainMap = chainDefinition.getFilterChainMap(); + assertEquals("anon", chainMap.get("/**")); + + + } +} \ No newline at end of file -- cgit 1.2.3-korg From aee68f0187cbd919ffb544cdd00653d02fd7e991 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 24 Mar 2020 14:30:24 -0400 Subject: Add env var for svclogic props Added system property serviceLogicProperties to specify location of svclogic.properties. If unset, check environment variable SVCLOGIC_PROPERTIES for the same. If both are unset, defaults to src/main/resources/svclogic.properties Change-Id: I8c31a58b69131b08c95a673e0071976f013f941a Issue-ID: CCSDK-2179 Signed-off-by: Dan Timoney --- .../sli/core/sliapi/springboot/core/SvcLogicFactory.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java index 9b521e4e7..cf8dc5e37 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java @@ -63,7 +63,16 @@ public class SvcLogicFactory { @Override public Properties getProperties() { Properties props = new Properties(); - String propPath = "src/main/resources/svclogic.properties"; + + String propPath = System.getProperty("serviceLogicProperties", ""); + + if ("".equals(propPath)) { + propPath = System.getenv("SVCLOGIC_PROPERTIES"); + } + + if ((propPath == null) || propPath.length() == 0) { + propPath = "src/main/resources/svclogic.properties"; + } System.out.println(propPath); try (FileInputStream fileInputStream = new FileInputStream(propPath)) { props = new Properties(); -- cgit 1.2.3-korg From b80471e4f68e6d5ba670d03b12b92029e58c0bc7 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 24 Mar 2020 14:30:24 -0400 Subject: Use MariaDB instead of Derby Use MariaDB instead of Derby as backing store for sliboot Change-Id: Ib9fa4abaaf88bcb1eac2276bc974474f067a06d3 Issue-ID: CCSDK-2188 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 1 + .../onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java | 2 +- sliapi/springboot/pom.xml | 8 +- .../sliapi/springboot/core/SvcLogicFactory.java | 2 + .../sli/core/sliapi/springboot/core/WebConfig.java | 41 +----- .../src/main/resources/application.properties | 16 ++- .../src/main/resources/svclogic.properties | 8 +- .../ccsdk/sli/core/sliapi/springboot/AppTest.java | 1 + .../springboot/RestconfApiControllerTest.java | 4 + sliapi/springboot/src/test/resources/DEMO_DEMO.xml | 35 +++++ .../src/test/resources/application.properties | 18 +++ .../springboot/src/test/resources/graph.versions | 3 + .../src/test/resources/log4j2.properties | 160 +++++++++++++++++++++ .../src/test/resources/shiro-users.properties | 3 + .../src/test/resources/sli_healthcheck.xml | 27 ++++ .../springboot/src/test/resources/sli_vlbcheck.xml | 27 ++++ .../src/test/resources/svclogic.properties | 29 ++++ 17 files changed, 336 insertions(+), 49 deletions(-) create mode 100755 sliapi/springboot/src/test/resources/DEMO_DEMO.xml create mode 100644 sliapi/springboot/src/test/resources/application.properties create mode 100644 sliapi/springboot/src/test/resources/graph.versions create mode 100644 sliapi/springboot/src/test/resources/log4j2.properties create mode 100644 sliapi/springboot/src/test/resources/shiro-users.properties create mode 100644 sliapi/springboot/src/test/resources/sli_healthcheck.xml create mode 100644 sliapi/springboot/src/test/resources/sli_vlbcheck.xml create mode 100644 sliapi/springboot/src/test/resources/svclogic.properties diff --git a/artifacts/pom.xml b/artifacts/pom.xml index cf6eb6b18..6d6d6b95c 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -6,6 +6,7 @@ org.onap.ccsdk.parent parent 2.0.0-SNAPSHOT + org.onap.ccsdk.sli.core diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java index 5db2a8c91..f23456fee 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java @@ -106,7 +106,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore { String crTableCmd = "CREATE TABLE " + dbName + ".SVC_LOGIC (" + "module varchar(80) NOT NULL," + "rpc varchar(80) NOT NULL," + "version varchar(40) NOT NULL," + "mode varchar(5) NOT NULL," + "active varchar(1) NOT NULL,graph BLOB," - + "modified_timestamp timestamp DEFAULT NULL," + + "modified_timestamp timestamp ," + "md5sum varchar(128) DEFAULT NULL," + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))"; diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml index 2a3fbcb06..269caa47f 100644 --- a/sliapi/springboot/pom.xml +++ b/sliapi/springboot/pom.xml @@ -91,7 +91,11 @@ org.apache.derby derby - runtime + test + + + org.mariadb.jdbc + mariadb-java-client junit @@ -101,7 +105,7 @@ org.onap.logging-analytics logging-filter-spring - 1.6.4 + 1.6.6 javax.ws.rs diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java index cf8dc5e37..0c8480e11 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java @@ -64,12 +64,14 @@ public class SvcLogicFactory { public Properties getProperties() { Properties props = new Properties(); + String propPath = System.getProperty("serviceLogicProperties", ""); if ("".equals(propPath)) { propPath = System.getenv("SVCLOGIC_PROPERTIES"); } + if ((propPath == null) || propPath.length() == 0) { propPath = "src/main/resources/svclogic.properties"; } diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java index 41d3791b4..558a82a11 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java @@ -21,11 +21,14 @@ package org.onap.ccsdk.sli.core.sliapi.springboot.core; import org.onap.logging.filter.spring.LoggingInterceptor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.orm.jpa.JpaTransactionManager; @@ -48,43 +51,5 @@ import javax.sql.DataSource; @EnableTransactionManagement public class WebConfig implements WebMvcConfigurer { -/* @Bean - LoggingInterceptor loggingInterceptor() { - return new LoggingInterceptor(); - } - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(loggingInterceptor()); // handles audit log entries - }*/ - - @Bean - public DataSource dataSource() { - - EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); - builder.setName("sdnctl"); - return builder.setType(EmbeddedDatabaseType.DERBY).build(); - } - - @Bean - public EntityManagerFactory entityManagerFactory() { - - HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - vendorAdapter.setGenerateDdl(true); - - LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); - factory.setJpaVendorAdapter(vendorAdapter); - factory.setPackagesToScan("org.onap.ccsdk.sli.core.sliapi.springboot.*"); - factory.setDataSource(dataSource()); - factory.afterPropertiesSet(); - - return factory.getObject(); - } - - @Bean - public PlatformTransactionManager transactionManager() { - - JpaTransactionManager txManager = new JpaTransactionManager(); - txManager.setEntityManagerFactory(entityManagerFactory()); - return txManager; - } } \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/application.properties b/sliapi/springboot/src/main/resources/application.properties index 6a4acc7e9..f083ed5e9 100644 --- a/sliapi/springboot/src/main/resources/application.properties +++ b/sliapi/springboot/src/main/resources/application.properties @@ -3,8 +3,16 @@ server.contextPath=/restconf server.port=8080 spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RFC3339DateFormat spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false -spring.datasource.url=jdbc:derby:memory:datasource -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyTenSevenDialect -spring.jpa.hibernate.ddl-auto=update logging.level.com.att=TRACE -logging.level.org.onap=TRACE \ No newline at end of file +logging.level.org.onap=TRACE +spring.datasource.url=jdbc:mariadb://localhost:3306/sdnctl +spring.datasource.username=sli +spring.datasource.password=abc123 +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.datasource.testWhileIdle=true +spring.datasource.validationQuery=SELECT 1 +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl +spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy +spring.jpa.database=mysql \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/svclogic.properties b/sliapi/springboot/src/main/resources/svclogic.properties index 1d90ab9b4..ae396adde 100644 --- a/sliapi/springboot/src/main/resources/svclogic.properties +++ b/sliapi/springboot/src/main/resources/svclogic.properties @@ -20,10 +20,10 @@ ### 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.url=jdbc:mariadb://localhost:3306/sdnctl +org.onap.ccsdk.sli.jdbc.driver=org.mariadb.jdbc.Driver org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = test -org.onap.ccsdk.sli.jdbc.password = test +org.onap.ccsdk.sli.jdbc.user = sli +org.onap.ccsdk.sli.jdbc.password = abc123 sliapi.serviceLogicDirectory=/opt/onap/sdnc/svclogic/graphs diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java index c5f452cb8..5ad6da9fd 100644 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java @@ -18,6 +18,7 @@ public class AppTest { @Before public void setUp() throws Exception { app = new App(); + System.setProperty("serviceLogicProperties", "src/test/resources/svclogic.properties"); } @Test diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java index b4c629097..ae21cef5f 100644 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java +++ b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java @@ -126,6 +126,10 @@ public class RestconfApiControllerTest { assertEquals(200, mvcResult.getResponse().getStatus()); + // Delete any existing content before testing insert + mvcResult = mvc.perform(MockMvcRequestBuilders.delete(url)).andReturn(); + assertEquals(200, mvcResult.getResponse().getStatus()); + String jsonString = "{\n" + " \"test-results\" : [\n" + " {\n" + diff --git a/sliapi/springboot/src/test/resources/DEMO_DEMO.xml b/sliapi/springboot/src/test/resources/DEMO_DEMO.xml new file mode 100755 index 000000000..1b304f18a --- /dev/null +++ b/sliapi/springboot/src/test/resources/DEMO_DEMO.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sliapi/springboot/src/test/resources/application.properties b/sliapi/springboot/src/test/resources/application.properties new file mode 100644 index 000000000..dbe2633d4 --- /dev/null +++ b/sliapi/springboot/src/test/resources/application.properties @@ -0,0 +1,18 @@ +springfox.documentation.swagger.v2.path=/api-docs +server.contextPath=/restconf +server.port=8080 +spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false +logging.level.com.att=TRACE +logging.level.org.onap=TRACE +spring.datasource.url=jdbc:derby:sdnctl;create=true +spring.datasource.username=sli +spring.datasource.password=abc123 +spring.datasource.driver-class-name=org.apache.derby.jdbc.EmbeddedDriver +spring.datasource.testWhileIdle=true +spring.datasource.validationQuery=SELECT 1 +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl +spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy +spring.jpa.database=derby \ No newline at end of file diff --git a/sliapi/springboot/src/test/resources/graph.versions b/sliapi/springboot/src/test/resources/graph.versions new file mode 100644 index 000000000..d21278aa4 --- /dev/null +++ b/sliapi/springboot/src/test/resources/graph.versions @@ -0,0 +1,3 @@ +sli healthcheck 0.7.0 sync +sli vlbcheck 0.7.0 sync +DEMO DEMO 1 sync diff --git a/sliapi/springboot/src/test/resources/log4j2.properties b/sliapi/springboot/src/test/resources/log4j2.properties new file mode 100644 index 000000000..40d18d157 --- /dev/null +++ b/sliapi/springboot/src/test/resources/log4j2.properties @@ -0,0 +1,160 @@ + #- + # ============LICENSE_START======================================================= + # ONAP - CCSDK + # ================================================================================ + # Copyright (C) 2020 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========================================================= + # + +property.logDir = ${sys:LOG_PATH:-./target} + +property.pattern = %d{ISO8601} | %-5p | %-16t | %-32c{1} | %X{currentGraph} - %X{nodeId} | %m%n + +#default mdc values +property.ServiceName = INTERNAL +property.ErrorCode = 900 +property.ErrorDesc = UnknownError + +rootLogger.level = INFO +rootLogger.appenderRef.AppFile.ref = AppFile +rootLogger.appenderRef.Console.ref = Console +rootLogger.appenderRef.DebugFile.ref = DebugFile +rootLogger.appenderRef.ErrorFile.ref = ErrorFile +rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter +rootLogger.appenderRef.Console.filter.threshold.level = DEBUG + +appender.console.type = Console +appender.console.name = Console +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = ${pattern} + +appender.app.type = RollingRandomAccessFile +appender.app.name = AppFile +appender.app.fileName = ${logDir}/app.log +appender.app.filePattern = ${logDir}/app.log.%i +appender.app.immediateFlush = true +appender.app.append = true +appender.app.layout.type = PatternLayout +appender.app.layout.pattern = ${pattern} +appender.app.policies.type = Policies +appender.app.policies.size.type = SizeBasedTriggeringPolicy +appender.app.policies.size.size = 10MB +appender.app.strategy.type = DefaultRolloverStrategy +appender.app.strategy.max = 100 +appender.app.strategy.fileIndex = min + +appender.debug.type = RollingRandomAccessFile +appender.debug.name = DebugFile +appender.debug.fileName = ${logDir}/debug.log +appender.debug.filePattern = ${logDir}/debug.log.%i +appender.debug.immediateFlush = true +appender.debug.append = true +appender.debug.layout.type = PatternLayout +appender.debug.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%-16.16t|%-5.5p|%-32.32c{1}|%X{currentGraph} - %X{nodeId}|%m%n +appender.debug.policies.type = Policies +appender.debug.policies.size.type = SizeBasedTriggeringPolicy +appender.debug.policies.size.size = 10MB +appender.debug.strategy.type = DefaultRolloverStrategy +appender.debug.strategy.max = 200 +appender.debug.strategy.fileIndex = min + +appender.error.type = RollingRandomAccessFile +appender.error.name = ErrorFile +appender.error.fileName = ${logDir}/error.log +appender.error.filePattern = ${logDir}/error.log.%i +appender.error.immediateFlush = true +appender.error.append = true +appender.error.layout.type = PatternLayout +appender.error.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%-16.16t|$${ctx:ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%p|$${ctx:ErrorCode}|$${ctx:ErrorDesc}|%m%n + +appender.error.policies.type = Policies +appender.error.policies.size.type = SizeBasedTriggeringPolicy +appender.error.policies.size.size = 10MB +appender.error.strategy.type = DefaultRolloverStrategy +appender.error.strategy.max = 100 +appender.error.strategy.fileIndex = min +appender.error.filter.threshold.type = ThresholdFilter +appender.error.filter.threshold.level = WARN + +appender.metric.type = RollingRandomAccessFile +appender.metric.name = MetricFile +appender.metric.fileName = ${logDir}/metric.log +appender.metric.filePattern = ${logDir}/metric.log.%i +appender.metric.immediateFlush = true +appender.metric.append = true +appender.metric.layout.type = PatternLayout +appender.metric.layout.pattern=%X{InvokeTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%-16.16t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceID}|%p|%X{Severity}|192.168.23.111|%X{ElapsedTime}|${hostName}|%X{ClientIPAddress}|%C{1}|||%X{TargetElement}|%markerSimpleName|%X|%X{currentGraph} - %X{nodeId}||%m%n +appender.metric.policies.type = Policies +appender.metric.policies.size.type = SizeBasedTriggeringPolicy +appender.metric.policies.size.size = 10MB +appender.metric.strategy.type = DefaultRolloverStrategy +appender.metric.strategy.max = 100 +appender.metric.strategy.fileIndex = min + +appender.audit.type = RollingRandomAccessFile +appender.audit.name = AuditFile +appender.audit.fileName = ${logDir}/audit.log +appender.audit.filePattern = ${logDir}/audit.log.%i +appender.audit.immediateFlush = true +appender.audit.append = true +appender.audit.layout.type = PatternLayout +appender.audit.layout.pattern=%X{EntryTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%-16.16t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceID}|INFO|%X{Severity}|192.168.23.111|%X{ElapsedTime}|${hostName}|%X{ClientIPAddress}|%C{1}|%X{AUDIT-Unused}|%X{AUDIT-ProcessKey}|%markerSimpleName|%X|||%m%n +appender.audit.policies.type = Policies +appender.audit.policies.size.type = SizeBasedTriggeringPolicy +appender.audit.policies.size.size = 10MB +appender.audit.strategy.type = DefaultRolloverStrategy +appender.audit.strategy.max = 200 +appender.audit.strategy.fileIndex = min + +appender.rr.name = RequestResponseFile +appender.rr.type = RollingRandomAccessFile +appender.rr.fileName = ${logDir}/request-response.log +appender.rr.filePattern = ${logDir}/request-response.log.%i +appender.rr.immediateFlush = true +appender.rr.append = true +appender.rr.layout.type = PatternLayout +appender.rr.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%X{PartnerName}|%m%n +appender.rr.policies.type = Policies +appender.rr.policies.size.type = SizeBasedTriggeringPolicy +appender.rr.policies.size.size = 10MB +appender.rr.strategy.type = DefaultRolloverStrategy +appender.rr.strategy.max = 100 +appender.rr.strategy.fileIndex = min + +logger.metric.name = org.onap.ccsdk.sli.core.filters.metric +logger.metric.level = INFO +logger.metric.additivity = false +logger.metric.appenderRef.MetricFile.ref = MetricFile + +logger.metric2.name = org.onap.logging.filter.base.AbstractMetricLogFilter +logger.metric2.level = INFO +logger.metric2.additivity = false +logger.metric2.appenderRef.MetricFile.ref = MetricFile + +logger.audit.name = org.onap.logging.filter.base.AbstractAuditLogFilter +logger.audit.level = INFO +logger.audit.additivity = false +logger.audit.appenderRef.AuditFile.ref = AuditFile + +logger.rr.name = org.onap.logging.filter.base.PayloadLoggingServletFilter +logger.rr.level = INFO +logger.rr.additivity = false +logger.rr.appenderRef.RequestResponseFile.ref = RequestResponseFile + +logger.ccsdk.name = org.onap.ccsdk +logger.ccsdk.level = DEBUG + +logger.onaplogging.name = org.onap.logging +logger.onaplogging.level = DEBUG \ No newline at end of file diff --git a/sliapi/springboot/src/test/resources/shiro-users.properties b/sliapi/springboot/src/test/resources/shiro-users.properties new file mode 100644 index 000000000..df4b1ae7a --- /dev/null +++ b/sliapi/springboot/src/test/resources/shiro-users.properties @@ -0,0 +1,3 @@ +user.admin = Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U,service +role.service = odl-api:* + diff --git a/sliapi/springboot/src/test/resources/sli_healthcheck.xml b/sliapi/springboot/src/test/resources/sli_healthcheck.xml new file mode 100644 index 000000000..bc8e2f700 --- /dev/null +++ b/sliapi/springboot/src/test/resources/sli_healthcheck.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/sliapi/springboot/src/test/resources/sli_vlbcheck.xml b/sliapi/springboot/src/test/resources/sli_vlbcheck.xml new file mode 100644 index 000000000..820a85c10 --- /dev/null +++ b/sliapi/springboot/src/test/resources/sli_vlbcheck.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/sliapi/springboot/src/test/resources/svclogic.properties b/sliapi/springboot/src/test/resources/svclogic.properties new file mode 100644 index 000000000..1d90ab9b4 --- /dev/null +++ b/sliapi/springboot/src/test/resources/svclogic.properties @@ -0,0 +1,29 @@ +### +# ============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 + +sliapi.serviceLogicDirectory=/opt/onap/sdnc/svclogic/graphs -- cgit 1.2.3-korg From 4cbff49506b31844ccda7ca38b3ba7283974475a Mon Sep 17 00:00:00 2001 From: Rahul_cool Date: Wed, 1 Apr 2020 15:49:25 +0530 Subject: Added code for decoding base64 encoded value Issue-ID: SDNC-899 Signed-off-by: Rahul_cool Change-Id: I231f891118dabf59518bcf4dbe456df97cd3e5b2 --- .../sli/core/slipluginutils/SliStringUtils.java | 32 ++++++++++++++++++++++ .../core/slipluginutils/SliStringUtilsTest.java | 9 ++++++ 2 files changed, 41 insertions(+) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index fdc057b23..9e3367d45 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -27,6 +27,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.Map; +import java.util.Base64; import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -311,6 +312,37 @@ public class SliStringUtils implements SvcLogicJavaPlugin { .replace(parameters.get(INPUT_PARAM_TARGET), parameters.get("replacement")))); } +/** + * exposes base64decoding algo + * writes the length of source to outputPath + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + *
    parameterMandatory/Optionaldescription
    encodedValueMandatorysource string
    decodedValueMandatoryDestination path
    + * @param ctx Reference to context memory + * @throws SvcLogicException + * @since 11.0.2 + */ + public static void base64DecodingAlgo(Map parameters, SvcLogicContext ctx) throws SvcLogicException{ + try { + SliPluginUtils.checkParameters(parameters, new String[]{"encodedValue","decodedValue"}, LOG); + + Base64.Decoder decoder = Base64.getDecoder(); + byte[] decodedByteArray = decoder.decode(parameters.get("encodedValue")); + //Verify the decoded string + String decodeVal = new String(decodedByteArray); + ctx.setAttribute(parameters.get("decodedValue"), decodeVal); + }catch (Exception exc){ + LOG.error("Exception occure "+exc.getMessage()); + throw new SvcLogicException(exc.getMessage()); + } + } + + /** * exposes replaceAll to directed graph * writes the length of source to outputPath diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java index 3a6c31a3c..da7046f43 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java @@ -386,4 +386,13 @@ public class SliStringUtilsTest { assertEquals(SliStringUtils.FALSE_CONSTANT, result); } + @Test + public void testBase64DecodingAlgo() throws Exception{ + String input = "MDUxMDAw"; + String decodeVal = "decodedPath"; + param.put("encodedValue",input); + param.put("decodedValue", decodeVal); + SliStringUtils.base64DecodingAlgo(param,ctx); + assertEquals("051000",ctx.getAttribute(decodeVal)); + } } -- cgit 1.2.3-korg From b970a7b46fac32e626acfa23b1e2de9b22da7ff7 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 1 Apr 2020 19:58:23 +0000 Subject: SliPluginUtils jsonStringToCtx fix Support null values in jsonStringToCtx in Slipluginutils Issue-ID: CCSDK-2250 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I3316fa9e80c9e684fc27d83356bbfad9b1151992 --- .../org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java | 9 ++++++++- .../core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java | 7 ++++--- sliPluginUtils/provider/src/test/resources/2dArray.json | 2 +- sliPluginUtils/provider/src/test/resources/ArrayMenu.json | 2 +- sliPluginUtils/provider/src/test/resources/Widget.json | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index ce0f50800..60bb4fd31 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -70,6 +70,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { private static final String LOG_MSG="extracting list from context memory"; private static final String LOG_MSG1="removing elements from list"; private static final String LENGTH="_length"; + public static final String CTX_NULL_VALUE=""; // ========== CONSTRUCTORS ========== @@ -846,7 +847,11 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { if(!root.endsWith(".")){ root = root + "."; } - ctx.setAttribute(root + key, entry.getValue().getAsString()); + if(entry.getValue().isJsonNull()) { + ctx.setAttribute(root + key, CTX_NULL_VALUE); + }else { + ctx.setAttribute(root + key, entry.getValue().getAsString()); + } } } } @@ -861,6 +866,8 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { handleJsonArray(key, element.getAsJsonArray(), ctx, prefix); } else if (element.isJsonObject()) { writeJsonObject(element.getAsJsonObject(), ctx, prefix + "."); + } else if (element.isJsonNull()) { + ctx.setAttribute(prefix, CTX_NULL_VALUE); } else if (element.isJsonPrimitive()) { ctx.setAttribute(prefix, element.getAsString()); } diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java index ad039d7f4..bc2c9226d 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java @@ -335,7 +335,7 @@ public class SliPluginUtils_StaticFunctionsTest { assertEquals("plain", ctx.getAttribute("testPath.[0].name")); assertEquals("pizza", ctx.getAttribute("testPath.[0].type")); assertEquals("true", ctx.getAttribute("testPath.[0].vegetarian")); - assertEquals("2000", ctx.getAttribute("testPath.[1].calories")); + assertEquals(SliPluginUtils.CTX_NULL_VALUE, ctx.getAttribute("testPath.[1].calories")); assertEquals("2", ctx.getAttribute("testPath.[1].id")); assertEquals("Tuesday Special", ctx.getAttribute("testPath.[1].name")); assertEquals("1", ctx.getAttribute("testPath.[1].topping[0].id")); @@ -423,7 +423,8 @@ public class SliPluginUtils_StaticFunctionsTest { assertEquals("apple", ctx.getAttribute("testPath.[0][0]")); assertEquals("orange", ctx.getAttribute("testPath.[0][1]")); assertEquals("banana", ctx.getAttribute("testPath.[0][2]")); - assertEquals("3", ctx.getAttribute("testPath.[0]_length")); + assertEquals(SliPluginUtils.CTX_NULL_VALUE, ctx.getAttribute("testPath.[0][3]")); + assertEquals("4", ctx.getAttribute("testPath.[0]_length")); assertEquals("squash", ctx.getAttribute("testPath.[1][0]")); assertEquals("broccoli", ctx.getAttribute("testPath.[1][1]")); assertEquals("cauliflower", ctx.getAttribute("testPath.[1][2]")); @@ -488,7 +489,7 @@ public class SliPluginUtils_StaticFunctionsTest { assertEquals("text1", ctx.getAttribute("testPath.widget.text.name")); assertEquals("21", ctx.getAttribute("testPath.widget.text.size")); assertEquals("bold", ctx.getAttribute("testPath.widget.text.style")); - assertEquals("200", ctx.getAttribute("testPath.widget.text.vOffset")); + assertEquals(SliPluginUtils.CTX_NULL_VALUE, ctx.getAttribute("testPath.widget.text.vOffset")); assertEquals("300", ctx.getAttribute("testPath.widget.window.height")); assertEquals("main_window", ctx.getAttribute("testPath.widget.window.name")); assertEquals("ONAP Widget", ctx.getAttribute("testPath.widget.window.title")); diff --git a/sliPluginUtils/provider/src/test/resources/2dArray.json b/sliPluginUtils/provider/src/test/resources/2dArray.json index b473864d8..2a94b46f4 100644 --- a/sliPluginUtils/provider/src/test/resources/2dArray.json +++ b/sliPluginUtils/provider/src/test/resources/2dArray.json @@ -1,4 +1,4 @@ [ - ["apple", "orange", "banana"], + ["apple", "orange", "banana", null], ["squash", "broccoli", "cauliflower"] ] \ No newline at end of file diff --git a/sliPluginUtils/provider/src/test/resources/ArrayMenu.json b/sliPluginUtils/provider/src/test/resources/ArrayMenu.json index b12f16315..26a24f292 100644 --- a/sliPluginUtils/provider/src/test/resources/ArrayMenu.json +++ b/sliPluginUtils/provider/src/test/resources/ArrayMenu.json @@ -8,7 +8,7 @@ "id": "2", "type": "pizza", "name": "Tuesday Special", - "calories": 2000, + "calories": null, "vegetarian": false, "topping": [{ diff --git a/sliPluginUtils/provider/src/test/resources/Widget.json b/sliPluginUtils/provider/src/test/resources/Widget.json index 1e25282c2..6b90907ce 100644 --- a/sliPluginUtils/provider/src/test/resources/Widget.json +++ b/sliPluginUtils/provider/src/test/resources/Widget.json @@ -20,7 +20,7 @@ "style": "bold", "name": "text1", "hOffset": 350, - "vOffset": 200, + "vOffset": null, "alignment": "center" } } -- cgit 1.2.3-korg From 970c94e1494ca80ba92a25a13a44ba4b589feff9 Mon Sep 17 00:00:00 2001 From: "Agarwal, Ruchira (ra1926)" Date: Thu, 9 Apr 2020 15:05:09 +0000 Subject: set auth perm for AAF Realm set spring SLI container shiro filter perms for authorization Issue-ID: CCSDK-2304 Signed-off-by: Agarwal, Ruchira (ra1926) Change-Id: Ib99223ba1921f656a0e64f62745271bc6aa0bdf7 --- .../main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java index 2892430b1..f4e78bebe 100644 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java @@ -20,6 +20,8 @@ package org.onap.ccsdk.sli.core.sliapi.springboot; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; @@ -38,6 +40,8 @@ import org.onap.aaf.cadi.shiro.AAFRealm; public class App { + private static final Logger log = LoggerFactory.getLogger(App.class); + public static void main(String[] args) throws Exception { SpringApplication.run(App.class, args); } @@ -48,6 +52,7 @@ public class App { // If cadi prop files is not defined use local properties realm // src/main/resources/shiro-users.properties if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { + log.info("cadi_prop_files undefined, AAF Realm will not be set"); PropertiesRealm realm = new PropertiesRealm(); return realm; } else { @@ -65,7 +70,8 @@ public class App { if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { chainDefinition.addPathDefinition("/**", "anon"); } else { - chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc:odl-api]"); + log.info("Loaded property cadi_prop_files, AAF REALM set"); + chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc.odl:odl-api]"); } return chainDefinition; -- cgit 1.2.3-korg From 83744b7572d30eca01bd122c798a9e9e5bd9353e Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 9 Apr 2020 13:56:45 -0400 Subject: Add special handling for BGP RouteDistinguisher Add special case code in MdsalHelper for BGP RouteDistinguisher class - a custom class implemented by OpenDaylight that does NOT follow the pattern of data object classes generated from Yang models by Yangtools Note: this depends on the following ccsdk/parent change to add OpenDaylight BGP dependencies to the dependencyManagement section of our parent poms: https://gerrit.onap.org/r/c/ccsdk/parent/+/105774 Change-Id: Ifebd03091d9ed9225e37c7242ecf7810abca1feb Issue-ID: CCSDK-2307 Signed-off-by: Dan Timoney --- sli/provider/pom.xml | 10 +++++++++- .../onap/ccsdk/sli/core/sli/provider/MdsalHelper.java | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 5dc327f16..056d748f7 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -67,14 +67,22 @@ org.opendaylight.controller sal-binding-api + provided org.opendaylight.mdsal.binding.model.ietf rfc6991 - + provided +
    + + org.opendaylight.bgpcep + bgp-concepts + provided + org.opendaylight.controller sal-core-api + provided diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java index 122c8862d..d3ab6c33a 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java @@ -43,6 +43,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisherBuilder; import org.opendaylight.yangtools.yang.binding.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -678,7 +680,19 @@ public class MdsalHelper { + "(" + paramValue + ")", e); } } - } else { + } else if ("RouteDistinguisher".equals(simpleName)) { + if ((paramValue != null) && (paramValue.length() > 0)) { + try { + RouteDistinguisher routeDistinguisher = RouteDistinguisherBuilder.getDefaultInstance(paramValue); + m.invoke(toObj, routeDistinguisher); + foundValue = true; + } catch (Exception e) { + LOG.error("Caught exception calling " + toClass.getName() + "." + m.getName() + + "(" + paramValue + ")", e); + } + } + } + else { // setter expects a yang-generated class. Need // to // create a builder to set it. -- cgit 1.2.3-korg From 180d84761326fae9c222211d09b4f7496a40f974 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 24 Apr 2020 18:53:31 +0000 Subject: metric logger change fix elapsed time in metric logger Issue-ID: CCSDK-2337 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I81c27bbead8614e2927aa9eddef3621559eb7cc0 --- sli/common/pom.xml | 11 ++++++++ .../org/onap/ccsdk/sli/core/sli/MetricLogger.java | 33 ++++++++++++++++------ .../onap/ccsdk/sli/core/sli/TestMetricLogger.java | 23 +++++++++++---- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 5fb0b5ff0..16efd0e56 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -60,6 +60,17 @@ org.onap.logging-analytics logging-slf4j + + + org.apache.logging.log4j + log4j-slf4j-impl + test + + + org.apache.logging.log4j + log4j-core + test + com.google.code.gson gson diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 518316d56..0966c0bfe 100755 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -26,6 +26,10 @@ package org.onap.ccsdk.sli.core.sli; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.TimeZone; import org.onap.logging.ref.slf4j.ONAPLogConstants; @@ -55,6 +59,7 @@ public class MetricLogger { } + @Deprecated public static String asIso8601(Date date) { TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss.SS'+00:00'"); @@ -62,6 +67,7 @@ public class MetricLogger { return df.format(date); } + @Deprecated public static String asIso8601(long tsInMillis) { return MetricLogger.asIso8601(new Date(tsInMillis)); } @@ -74,9 +80,10 @@ public class MetricLogger { public void logRequest(String svcInstanceId, String targetEntity, String targetServiceName, String targetElement, String msg) { - long start = System.currentTimeMillis(); - MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, MetricLogger.asIso8601(start)); - + String timeNow = ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT); + MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, timeNow); + MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, timeNow); + if (svcInstanceId != null) { MDC.put(ONAPLogConstants.MDCs.SERVICE_INSTANCE_ID, svcInstanceId); } @@ -97,9 +104,9 @@ public class MetricLogger { METRIC.info(INVOKE, "Invoke"); } - public void logResponse(String statusCode, String responseCode, String responseDescription) { - long start = System.currentTimeMillis(); - MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, MetricLogger.asIso8601(start)); + public void logResponse(String statusCode, String responseCode, String responseDescription) { + String timeNow = ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT); + MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, timeNow); if (statusCode != null) { MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); @@ -110,9 +117,17 @@ public class MetricLogger { if (responseDescription != null) { MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, formatString(responseDescription)); } - long end = System.currentTimeMillis(); - MDC.put(ONAPLogConstants.MDCs.LOG_TIMESTAMP, MetricLogger.asIso8601(end)); - MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME, Long.toString(end - start)); + ZonedDateTime endTime = ZonedDateTime.now(ZoneOffset.UTC); + MDC.put(ONAPLogConstants.MDCs.LOG_TIMESTAMP, endTime.format(DateTimeFormatter.ISO_INSTANT)); + try { + DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME; + ZonedDateTime entryTimestamp = + ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), timeFormatter); + String elapedTime = Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTime)); + MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME,elapedTime); + } catch (Exception e) { + //pass + } METRIC.info(INVOKE_RETURN, formatString(lastMsg)); resetContext(); } diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java index 4b371cf8f..b5090eaa2 100755 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java @@ -2,8 +2,12 @@ package org.onap.ccsdk.sli.core.sli; import static org.junit.Assert.*; import java.util.Date; +import java.util.UUID; + import org.junit.Before; import org.junit.Test; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.slf4j.MDC; public class TestMetricLogger { @@ -11,17 +15,24 @@ public class TestMetricLogger { @Before public void setUp() throws Exception { - logger = new MetricLogger(); - logger.resetContext(); - logger.logRequest("svcInstance1", "svcName", "svcPartner", "targetEntity", "targetServiceName", "targetVirtualEntity", "hello-world"); - logger.logResponse("200", "200", "SUCCESS"); - + MetricLogger.resetContext(); } @Test public final void testGetRequestID() { - logger.getRequestID(); + UUID uuid = UUID.randomUUID(); + MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, uuid.toString()); + assertEquals(uuid.toString(),logger.getRequestID()); + } + + @Test + public final void elapsedTime() { + logger.logRequest("svcInstance1", "svcName", "svcPartner", "targetEntity", "targetServiceName", "targetVirtualEntity", "hello-world"); + logger.logResponse("200", "200", "SUCCESS"); + Long elapsedTime = Long.valueOf(MDC.get(ONAPLogConstants.MDCs.ELAPSED_TIME)); + assertNotNull(elapsedTime); + assertTrue(elapsedTime > 1); } @Test -- cgit 1.2.3-korg From 4ddd6ac987341285d5f10636018e84afb9751b27 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 4 Jun 2020 15:10:06 -0400 Subject: Refactor sliapi springboot Move springboot implementation of sliapi from sli/core to apps repository. Change-Id: I6e1dfdc39704935ba7e46d047149071defc101a6 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney --- sliapi/model/pom.xml | 17 +- .../model/src/main/resources/sli-api.20161110.json | 554 --------------------- sliapi/model/src/main/yang/sliapi.yang | 130 ----- sliapi/model/swagger/pom.xml | 222 +++++++++ sliapi/model/swagger/src/main/json/sliapi.json | 1 + sliapi/model/swagger/src/main/yaml/sliapi.yaml | 378 ++++++++++++++ sliapi/model/yang/pom.xml | 27 + .../yang/src/main/resources/sli-api.20161110.json | 554 +++++++++++++++++++++ .../yang/src/main/resources/sli-api.20161110.yaml | 254 ++++++++++ sliapi/model/yang/src/main/yang/sliapi.yang | 117 +++++ sliapi/pom.xml | 1 - sliapi/provider/pom.xml | 2 +- sliapi/springboot/.swagger-codegen-ignore | 1 - sliapi/springboot/README.md | 33 -- sliapi/springboot/pom.xml | 179 ------- .../onap/ccsdk/sli/core/sliapi/springboot/App.java | 80 --- .../controllers/ExecuteGraphController.java | 112 ----- .../controllers/data/TestResultConfig.java | 50 -- .../controllers/data/TestResultOperational.java | 51 -- .../data/TestResultsConfigRepository.java | 12 - .../data/TestResultsOperationalRepository.java | 12 - .../controllers/swagger/RestconfApiController.java | 364 -------------- .../sliapi/springboot/core/SvcLogicFactory.java | 150 ------ .../sli/core/sliapi/springboot/core/WebConfig.java | 55 -- sliapi/springboot/src/main/resources/DEMO_DEMO.xml | 35 -- .../src/main/resources/application.properties | 18 - .../springboot/src/main/resources/graph.versions | 3 - .../src/main/resources/log4j2.properties | 160 ------ .../src/main/resources/shiro-users.properties | 3 - .../src/main/resources/sli_healthcheck.xml | 27 - .../springboot/src/main/resources/sli_vlbcheck.xml | 27 - .../src/main/resources/svclogic.properties | 29 -- .../ccsdk/sli/core/sliapi/springboot/AppTest.java | 40 -- .../springboot/RestconfApiControllerTest.java | 162 ------ sliapi/springboot/src/test/resources/DEMO_DEMO.xml | 35 -- .../src/test/resources/application.properties | 18 - .../springboot/src/test/resources/graph.versions | 3 - .../src/test/resources/log4j2.properties | 160 ------ .../src/test/resources/shiro-users.properties | 3 - .../src/test/resources/sli_healthcheck.xml | 27 - .../springboot/src/test/resources/sli_vlbcheck.xml | 27 - .../src/test/resources/svclogic.properties | 29 -- 42 files changed, 1561 insertions(+), 2601 deletions(-) delete mode 100644 sliapi/model/src/main/resources/sli-api.20161110.json delete mode 100755 sliapi/model/src/main/yang/sliapi.yang create mode 100644 sliapi/model/swagger/pom.xml create mode 100644 sliapi/model/swagger/src/main/json/sliapi.json create mode 100644 sliapi/model/swagger/src/main/yaml/sliapi.yaml create mode 100755 sliapi/model/yang/pom.xml create mode 100644 sliapi/model/yang/src/main/resources/sli-api.20161110.json create mode 100644 sliapi/model/yang/src/main/resources/sli-api.20161110.yaml create mode 100755 sliapi/model/yang/src/main/yang/sliapi.yang delete mode 100644 sliapi/springboot/.swagger-codegen-ignore delete mode 100644 sliapi/springboot/README.md delete mode 100644 sliapi/springboot/pom.xml delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultConfig.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultOperational.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsConfigRepository.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsOperationalRepository.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java delete mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java delete mode 100755 sliapi/springboot/src/main/resources/DEMO_DEMO.xml delete mode 100644 sliapi/springboot/src/main/resources/application.properties delete mode 100644 sliapi/springboot/src/main/resources/graph.versions delete mode 100644 sliapi/springboot/src/main/resources/log4j2.properties delete mode 100644 sliapi/springboot/src/main/resources/shiro-users.properties delete mode 100644 sliapi/springboot/src/main/resources/sli_healthcheck.xml delete mode 100644 sliapi/springboot/src/main/resources/sli_vlbcheck.xml delete mode 100644 sliapi/springboot/src/main/resources/svclogic.properties delete mode 100644 sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java delete mode 100644 sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java delete mode 100755 sliapi/springboot/src/test/resources/DEMO_DEMO.xml delete mode 100644 sliapi/springboot/src/test/resources/application.properties delete mode 100644 sliapi/springboot/src/test/resources/graph.versions delete mode 100644 sliapi/springboot/src/test/resources/log4j2.properties delete mode 100644 sliapi/springboot/src/test/resources/shiro-users.properties delete mode 100644 sliapi/springboot/src/test/resources/sli_healthcheck.xml delete mode 100644 sliapi/springboot/src/test/resources/sli_vlbcheck.xml delete mode 100644 sliapi/springboot/src/test/resources/svclogic.properties diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index dfe7753a6..4ac5a8510 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -4,7 +4,7 @@ org.onap.ccsdk.parent - binding-parent + odlparent-lite 2.0.0-SNAPSHOT @@ -12,16 +12,13 @@ org.onap.ccsdk.sli.core sliapi-model 1.0.0-SNAPSHOT - bundle + pom - ccsdk-sli-core :: sliapi :: ${project.artifactId} + ccsdk-sli-core :: sliapi - - - org.opendaylight.mdsal.binding.model.ietf - rfc6991 - + + yang + swagger + - - diff --git a/sliapi/model/src/main/resources/sli-api.20161110.json b/sliapi/model/src/main/resources/sli-api.20161110.json deleted file mode 100644 index 1c6cdabfe..000000000 --- a/sliapi/model/src/main/resources/sli-api.20161110.json +++ /dev/null @@ -1,554 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0" - }, - "basePath": "/restconf", - "paths": { - "/config": { - "post": { - "consumes": [ - "application/json", - "application/xml" - ], - "produces": [ - "application/json", - "application/xml" - ], - "parameters": [ - { - "in": "body", - "name": "**(config)test-results", - "required": false, - "schema": { - "$ref": "#/definitions/SLI-API(config)test-results-TOP" - } - } - ], - "responses": { - "200": { - "description": "No response was specified", - "schema": { - "$ref": "#/definitions/(config)SLI-API_modulePOST" - } - } - }, - "description": "Defines API to service logic interpreter", - "operationId": "POST-SLI-API_module" - } - }, - "/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/(config)test-results" - } - } - }, - "description": "Test results", - "operationId": "GET-test-results" - }, - "post": { - "consumes": [ - "application/json", - "application/xml" - ], - "produces": [ - "application/json", - "application/xml" - ], - "parameters": [ - { - "in": "body", - "name": "**(config)test-result", - "required": false, - "schema": { - "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" - } - } - ], - "responses": { - "200": { - "description": "No response was specified", - "schema": { - "$ref": "#/definitions/(config)test-resultsPOST" - } - } - }, - "description": "Test results", - "operationId": "POST-test-results" - }, - "put": { - "consumes": [ - "application/json", - "application/xml" - ], - "produces": [ - "application/json", - "application/xml" - ], - "parameters": [ - { - "in": "body", - "name": "(config)test-results", - "required": false, - "schema": { - "$ref": "#/definitions/SLI-API(config)test-results-TOP" - } - } - ], - "responses": { - "200": { - "description": "No response was specified", - "schema": { - "$ref": "#/definitions/SLI-API(config)test-results-TOP" - } - } - }, - "description": "Test results", - "operationId": "PUT-test-results" - } - }, - "/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/(config)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": "(config)test-result", - "required": false, - "schema": { - "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" - } - } - ], - "responses": { - "200": { - "description": "No response was specified", - "schema": { - "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" - } - } - }, - "operationId": "PUT-test-result" - } - }, - "/operational/SLI-API:test-results": { - "get": { - "produces": [ - "application/json", - "application/xml" - ], - "responses": { - "200": { - "description": "No response was specified", - "schema": { - "$ref": "#/definitions/(operational)test-results" - } - } - }, - "description": "Test results", - "operationId": "GET-test-results" - } - }, - "/operations/SLI-API:execute-graph": { - "post": { - "consumes": [ - "application/json", - "application/xml" - ], - "produces": [ - "application/json", - "application/xml" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "required": false, - "schema": { - "$ref": "#/definitions/(execute-graph)input-TOP" - } - } - ], - "responses": { - "200": { - "description": "No response was specified", - "schema": { - "$ref": "#/definitions/(execute-graph)output-TOP" - } - } - }, - "description": " Method to add a new parameter.", - "operationId": "execute-graph" - } - }, - "/operations/SLI-API:healthcheck": { - "post": { - "produces": [ - "application/json", - "application/xml" - ], - "responses": { - "200": { - "description": "No response was specified", - "schema": { - "$ref": "#/definitions/(healthcheck)output-TOP" - } - } - }, - "operationId": "healthcheck" - } - }, - "/operations/SLI-API:vlbcheck": { - "post": { - "produces": [ - "application/json", - "application/xml" - ], - "responses": { - "200": { - "description": "No response was specified", - "schema": { - "$ref": "#/definitions/(vlbcheck)output-TOP" - } - } - }, - "operationId": "vlbcheck" - } - } - }, - "definitions": { - "(config)SLI-API_modulePOST": { - "properties": { - "test-results": { - "items": { - "$ref": "#/definitions/SLI-API(config)test-results" - }, - "type": "object" - } - }, - "type": "object" - }, - "(config)sli-parameterPOST": { - "properties": { - "boolean-value": { - "$ref": "#/definitions/Optional.empty" - }, - "int-value": { - "$ref": "#/definitions/Optional.empty" - }, - "parameter-name": { - "$ref": "#/definitions/Optional.empty", - "description": "Parameter name" - }, - "string-value": { - "$ref": "#/definitions/Optional.empty" - } - }, - "type": "object" - }, - "(config)test-resultPOST": { - "properties": { - "test-identifier": { - "$ref": "#/definitions/Optional.empty" - } - }, - "type": "object" - }, - "(config)test-resultsPOST": { - "properties": { - "test-result": { - "items": { - "$ref": "#/definitions/SLI-API/test-results(config)test-result" - }, - "type": "array" - } - }, - "type": "object" - }, - "(execute-graph)input": { - "properties": { - "SLI-API:mode": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:module-name": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:rpc-name": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:sli-parameter": { - "items": { - "$ref": "#/definitions/SLI-API(config)sli-parameter" - }, - "type": "array" - } - }, - "type": "object" - }, - "(execute-graph)input-TOP": { - "properties": { - "SLI-API:input": { - "items": { - "$ref": "#/definitions/(execute-graph)input" - }, - "type": "object" - } - }, - "type": "object" - }, - "(execute-graph)output": { - "properties": { - "SLI-API:ack-final-indicator": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:context-memory-json": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:response-code": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:response-message": { - "$ref": "#/definitions/Optional.empty" - } - }, - "type": "object" - }, - "(execute-graph)output-TOP": { - "properties": { - "SLI-API:output": { - "items": { - "$ref": "#/definitions/(execute-graph)output" - }, - "type": "object" - } - }, - "type": "object" - }, - "(healthcheck)output": { - "properties": { - "SLI-API:ack-final-indicator": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:context-memory-json": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:response-code": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:response-message": { - "$ref": "#/definitions/Optional.empty" - } - }, - "type": "object" - }, - "(healthcheck)output-TOP": { - "properties": { - "SLI-API:output": { - "items": { - "$ref": "#/definitions/(healthcheck)output" - }, - "type": "object" - } - }, - "type": "object" - }, - "(vlbcheck)output": { - "properties": { - "SLI-API:ack-final-indicator": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:context-memory-json": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:response-code": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:response-message": { - "$ref": "#/definitions/Optional.empty" - } - }, - "type": "object" - }, - "(vlbcheck)output-TOP": { - "properties": { - "SLI-API:output": { - "items": { - "$ref": "#/definitions/(vlbcheck)output" - }, - "type": "object" - } - }, - "type": "object" - }, - "SLI-API(config)sli-parameter": { - "properties": { - "SLI-API:boolean-value": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:int-value": { - "$ref": "#/definitions/Optional.empty" - }, - "SLI-API:parameter-name": { - "$ref": "#/definitions/Optional.empty", - "description": "Parameter name" - }, - "SLI-API:string-value": { - "$ref": "#/definitions/Optional.empty" - } - }, - "type": "object" - }, - "SLI-API(config)sli-parameter-TOP": { - "properties": { - "SLI-API:sli-parameter": { - "items": { - "$ref": "#/definitions/SLI-API(config)sli-parameter" - }, - "type": "array" - } - }, - "type": "object" - }, - "SLI-API(config)test-results": { - "properties": { - "SLI-API:test-result": { - "items": { - "$ref": "#/definitions/SLI-API/test-results(config)test-result" - }, - "type": "array" - } - }, - "type": "object" - }, - "SLI-API(config)test-results-TOP": { - "properties": { - "SLI-API:test-results": { - "description": "Test results", - "items": { - "$ref": "#/definitions/SLI-API(config)test-results" - }, - "type": "object" - } - }, - "type": "object" - }, - "SLI-API(operational)test-results": { - "type": "object" - }, - "SLI-API(operational)test-results-TOP": { - "properties": { - "SLI-API:test-results": { - "description": "Test results", - "items": { - "$ref": "#/definitions/SLI-API(operational)test-results" - }, - "type": "object" - } - }, - "type": "object" - }, - "SLI-API/test-results(config)test-result": { - "properties": { - "SLI-API:results": { - "items": { - "$ref": "#/definitions/Optional.empty" - }, - "type": "array" - }, - "SLI-API:test-identifier": { - "$ref": "#/definitions/Optional.empty" - } - }, - "type": "object" - }, - "SLI-API/test-results(config)test-result-TOP": { - "properties": { - "SLI-API:test-result": { - "items": { - "$ref": "#/definitions/SLI-API/test-results(config)test-result" - }, - "type": "array" - } - }, - "type": "object" - }, - "unique_empty_identifier": {} - } -} diff --git a/sliapi/model/src/main/yang/sliapi.yang b/sliapi/model/src/main/yang/sliapi.yang deleted file mode 100755 index b3272be80..000000000 --- a/sliapi/model/src/main/yang/sliapi.yang +++ /dev/null @@ -1,130 +0,0 @@ -module SLI-API { - - yang-version 1; - - namespace "org:onap:ccsdk:sli:core:sliapi"; - - prefix sample; - - import ietf-inet-types { prefix "inet"; revision-date 2013-07-15; } - - organization "ONAP"; - - contact - "Dan Timoney"; - - description - "Defines API to service logic interpreter"; - - revision "2016-11-10" { - description - "REST API to Service Logic Interpreter"; - } - - grouping parameter-setting { - description - "Parameter setting"; - - leaf parameter-name { - type string; - description "Parameter name"; - } - - leaf int-value { - type int32; - } - leaf string-value { - type string; - } - leaf boolean-value { - type boolean; - } - } - - grouping response-fields { - leaf response-code { - type string; - } - leaf ack-final-indicator { - type string; - } - leaf response-message { - type string; - } - leaf context-memory-json { - type string; - } - } - - container test-results { - description "Test results"; - - list test-result { - key "test-identifier"; - - leaf test-identifier { - type string; - } - - leaf-list results { - type string; - } - } - } - - rpc execute-graph { - description " Method to add a new parameter."; - input { - - leaf module-name { - type string; - } - - leaf rpc-name { - type string; - } - - leaf mode { - type enumeration { - enum sync; - enum async; - } - } - - list sli-parameter { - key "parameter-name"; - uses parameter-setting; - } - } - - output { - uses response-fields; - } - } - - rpc healthcheck { - // OpenDaylight Fluorine version of restconf cannot handle RPCs with no input - input { - leaf dummy { - type string; - } - } - output { - uses response-fields; - } - } - - rpc vlbcheck { - // OpenDaylight Fluorine version of restconf cannot handle RPCs with no input - input { - leaf dummy - { - type string; - } - } - output { - uses response-fields; - } - } - -} diff --git a/sliapi/model/swagger/pom.xml b/sliapi/model/swagger/pom.xml new file mode 100644 index 000000000..544f4f9e5 --- /dev/null +++ b/sliapi/model/swagger/pom.xml @@ -0,0 +1,222 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + oparent + 2.0.0-SNAPSHOT + + + org.onap.ccsdk.sli.core + sliapi-model-swagger + 1.0.0-SNAPSHOT + jar + + ccsdk-sli-core :: sliapi :: ${project.artifactId} + Generates swagger model from yang model + http://wiki.onap.org + + + sliapi + 2.9.5 + + + + + + ${project.groupId} + sliapi-model-yang + ${project.version} + + + + + + + >bintray-yang2swagger-yang2swagge + bintray + https://dl.bintray.com/yang2swagger/yang2swagger + + false + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + ${project.build.directory}/dependency + **\/*.yang + org.opendaylight.mdsal.model,org.opendaylight.mdsal.binding.model.ietf,org.onap.ccsdk.sli.core + + + + unpack-shared-resources + + unpack-dependencies + + initialize + + + + + maven-antrun-plugin + 1.8 + + + initialize + + run + + + + + + + + + + + + + + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + 1.2.3 + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + com.fasterxml.jackson.module + jackson-module-jaxb-annotations + ${jackson.version} + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-base + ${jackson.version} + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + ${jackson.version} + + + com.mrv.yangtools + swagger-maven-plugin + 1.1.12 + + + com.github.romix + java-concurrent-hash-trie-map + 0.2.23 + + + + + yang2swagger-json + + generate-sources + + + + + com.mrv.yangtools.maven.gen.swagger.MavenSwaggerGenerator + ${project.basedir}/src/main/json + ${project.build.directory}/yang + + ${project.version} + ${api.name} + json + odl + true + + + + false + ${project.build.directory}/yang + + + + yang2swagger-yaml + + generate-sources + + + + + com.mrv.yangtools.maven.gen.swagger.MavenSwaggerGenerator + ${project.basedir}/src/main/yaml + ${project.build.directory}/yang + + ${project.version} + ${api.name} + yaml + odl + true + + + + false + ${project.build.directory}/yang + + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + attach-artifacts + package + + attach-artifact + + + + + src/main/json/${api.name}.json + json + + + src/main/yaml/${api.name}.yaml + yaml + + + + + + + + + diff --git a/sliapi/model/swagger/src/main/json/sliapi.json b/sliapi/model/swagger/src/main/json/sliapi.json new file mode 100644 index 000000000..99a69861e --- /dev/null +++ b/sliapi/model/swagger/src/main/json/sliapi.json @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"description":"Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.0.0-SNAPSHOT","title":"SLI-API,ietf-yang-types,ietf-inet-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"},"responseSchema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"},"responseSchema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"$ref":"#/definitions/sli.api.executegraph.Input","originalRef":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"$ref":"#/definitions/sli.api.ExecuteGraph","originalRef":"#/definitions/sli.api.ExecuteGraph"},"responseSchema":{"$ref":"#/definitions/sli.api.ExecuteGraph","originalRef":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"$ref":"#/definitions/sli.api.Healthcheck","originalRef":"#/definitions/sli.api.Healthcheck"},"responseSchema":{"$ref":"#/definitions/sli.api.Healthcheck","originalRef":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"$ref":"#/definitions/sli.api.Vlbcheck","originalRef":"#/definitions/sli.api.Vlbcheck"},"responseSchema":{"$ref":"#/definitions/sli.api.Vlbcheck","originalRef":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"$ref":"#/definitions/sli.api.ModeEnumeration","originalRef":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"$ref":"#/definitions/sli.api.ParameterSetting","originalRef":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file diff --git a/sliapi/model/swagger/src/main/yaml/sliapi.yaml b/sliapi/model/swagger/src/main/yaml/sliapi.yaml new file mode 100644 index 000000000..c8f2997eb --- /dev/null +++ b/sliapi/model/swagger/src/main/yaml/sliapi.yaml @@ -0,0 +1,378 @@ +--- +swagger: "2.0" +info: + description: "Defines API to service logic interpreter,This module contains a collection\ + \ of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust\ + \ and the persons identified as\nauthors of the code. All rights reserved.\n\n\ + Redistribution and use in source and binary forms, with or\nwithout modification,\ + \ is permitted pursuant to, and subject\nto the license terms contained in, the\ + \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ + Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ + \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ + \ notices.,This module contains a collection of generally useful derived\nYANG\ + \ data types for Internet addresses and related things.\n\nCopyright (c) 2013\ + \ IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\ + \nRedistribution and use in source and binary forms, with or\nwithout modification,\ + \ is permitted pursuant to, and subject\nto the license terms contained in, the\ + \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ + Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ + \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ + \ notices." + version: "1.0.0-SNAPSHOT" + title: "SLI-API,ietf-yang-types,ietf-inet-types API" +consumes: +- "application/json" +- "application/xml" +produces: +- "application/json" +- "application/xml" +paths: + /config/SLI-API:test-results/: + get: + tags: + - "SLI-API" + description: "returns sli.api.TestResults" + parameters: [] + responses: + 400: + description: "Internal error" + 200: + description: "sli.api.TestResults" + schema: + $ref: "#/definitions/sli.api.TestResults" + originalRef: "#/definitions/sli.api.TestResults" + responseSchema: + $ref: "#/definitions/sli.api.TestResults" + originalRef: "#/definitions/sli.api.TestResults" + post: + tags: + - "SLI-API" + description: "creates sli.api.TestResults" + parameters: + - in: "body" + name: "sli.api.TestResults.body-param" + description: "sli.api.TestResults to be added to list" + required: false + schema: + $ref: "#/definitions/sli.api.TestResults" + originalRef: "#/definitions/sli.api.TestResults" + responses: + 400: + description: "Internal error" + 201: + description: "Object created" + 409: + description: "Object already exists" + put: + tags: + - "SLI-API" + description: "creates or updates sli.api.TestResults" + parameters: + - in: "body" + name: "sli.api.TestResults.body-param" + description: "sli.api.TestResults to be added or updated" + required: false + schema: + $ref: "#/definitions/sli.api.TestResults" + originalRef: "#/definitions/sli.api.TestResults" + responses: + 400: + description: "Internal error" + 201: + description: "Object created" + 204: + description: "Object modified" + delete: + tags: + - "SLI-API" + description: "removes sli.api.TestResults" + parameters: [] + responses: + 400: + description: "Internal error" + 204: + description: "Object deleted" + /config/SLI-API:test-results/SLI-API:test-result/: + post: + description: "creates sli.api.testresults.TestResult" + parameters: + - in: "body" + name: "sli.api.testresults.TestResult.body-param" + description: "sli.api.testresults.TestResult to be added to list" + required: false + schema: + $ref: "#/definitions/sli.api.testresults.TestResult" + originalRef: "#/definitions/sli.api.testresults.TestResult" + responses: + 400: + description: "Internal error" + 201: + description: "Object created" + 409: + description: "Object already exists" + /config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/: + get: + tags: + - "SLI-API" + description: "returns sli.api.testresults.TestResult" + parameters: + - name: "test-identifier" + in: "path" + description: "Id of test-result" + required: true + type: "string" + responses: + 400: + description: "Internal error" + 200: + description: "sli.api.testresults.TestResult" + schema: + $ref: "#/definitions/sli.api.testresults.TestResult" + originalRef: "#/definitions/sli.api.testresults.TestResult" + responseSchema: + $ref: "#/definitions/sli.api.testresults.TestResult" + originalRef: "#/definitions/sli.api.testresults.TestResult" + post: + tags: + - "SLI-API" + description: "creates sli.api.testresults.TestResult" + parameters: + - name: "test-identifier" + in: "path" + description: "Id of test-result" + required: true + type: "string" + - in: "body" + name: "sli.api.testresults.TestResult.body-param" + description: "sli.api.testresults.TestResult to be added to list" + required: false + schema: + $ref: "#/definitions/sli.api.testresults.TestResult" + originalRef: "#/definitions/sli.api.testresults.TestResult" + responses: + 400: + description: "Internal error" + 201: + description: "Object created" + 409: + description: "Object already exists" + put: + tags: + - "SLI-API" + description: "creates or updates sli.api.testresults.TestResult" + parameters: + - name: "test-identifier" + in: "path" + description: "Id of test-result" + required: true + type: "string" + - in: "body" + name: "sli.api.testresults.TestResult.body-param" + description: "sli.api.testresults.TestResult to be added or updated" + required: false + schema: + $ref: "#/definitions/sli.api.testresults.TestResult" + originalRef: "#/definitions/sli.api.testresults.TestResult" + responses: + 400: + description: "Internal error" + 201: + description: "Object created" + 204: + description: "Object modified" + delete: + tags: + - "SLI-API" + description: "removes sli.api.testresults.TestResult" + parameters: + - name: "test-identifier" + in: "path" + description: "Id of test-result" + required: true + type: "string" + responses: + 400: + description: "Internal error" + 204: + description: "Object deleted" + /operational/SLI-API:test-results/: + get: + tags: + - "SLI-API" + description: "returns sli.api.TestResults" + parameters: [] + responses: + 400: + description: "Internal error" + 200: + description: "sli.api.TestResults" + schema: + $ref: "#/definitions/sli.api.TestResults" + originalRef: "#/definitions/sli.api.TestResults" + responseSchema: + $ref: "#/definitions/sli.api.TestResults" + originalRef: "#/definitions/sli.api.TestResults" + /operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/: + get: + tags: + - "SLI-API" + description: "returns sli.api.testresults.TestResult" + parameters: + - name: "test-identifier" + in: "path" + description: "Id of test-result" + required: true + type: "string" + responses: + 400: + description: "Internal error" + 200: + description: "sli.api.testresults.TestResult" + schema: + $ref: "#/definitions/sli.api.testresults.TestResult" + originalRef: "#/definitions/sli.api.testresults.TestResult" + responseSchema: + $ref: "#/definitions/sli.api.testresults.TestResult" + originalRef: "#/definitions/sli.api.testresults.TestResult" + /operations/SLI-API:execute-graph/: + post: + tags: + - "SLI-API" + parameters: + - in: "body" + name: "sli.api.executegraph.Input.body-param" + required: false + schema: + properties: + input: + $ref: "#/definitions/sli.api.executegraph.Input" + originalRef: "#/definitions/sli.api.executegraph.Input" + responses: + 400: + description: "Internal error" + 200: + description: "Correct response" + schema: + $ref: "#/definitions/sli.api.ExecuteGraph" + originalRef: "#/definitions/sli.api.ExecuteGraph" + responseSchema: + $ref: "#/definitions/sli.api.ExecuteGraph" + originalRef: "#/definitions/sli.api.ExecuteGraph" + 201: + description: "No response" + /operations/SLI-API:healthcheck/: + post: + tags: + - "SLI-API" + parameters: [] + responses: + 400: + description: "Internal error" + 200: + description: "Correct response" + schema: + $ref: "#/definitions/sli.api.Healthcheck" + originalRef: "#/definitions/sli.api.Healthcheck" + responseSchema: + $ref: "#/definitions/sli.api.Healthcheck" + originalRef: "#/definitions/sli.api.Healthcheck" + 201: + description: "No response" + /operations/SLI-API:vlbcheck/: + post: + tags: + - "SLI-API" + parameters: [] + responses: + 400: + description: "Internal error" + 200: + description: "Correct response" + schema: + $ref: "#/definitions/sli.api.Vlbcheck" + originalRef: "#/definitions/sli.api.Vlbcheck" + responseSchema: + $ref: "#/definitions/sli.api.Vlbcheck" + originalRef: "#/definitions/sli.api.Vlbcheck" + 201: + description: "No response" +definitions: + sli.api.ExecuteGraph: + type: "object" + properties: + output: + $ref: "#/definitions/sli.api.ResponseFields" + originalRef: "#/definitions/sli.api.ResponseFields" + sli.api.Healthcheck: + type: "object" + properties: + output: + $ref: "#/definitions/sli.api.ResponseFields" + originalRef: "#/definitions/sli.api.ResponseFields" + sli.api.ModeEnumeration: + type: "string" + enum: + - "sync" + - "async" + sli.api.ParameterSetting: + type: "object" + properties: + string-value: + type: "string" + boolean-value: + type: "boolean" + parameter-name: + type: "string" + description: "Parameter name" + int-value: + type: "integer" + format: "int32" + sli.api.ResponseFields: + type: "object" + properties: + response-code: + type: "string" + response-message: + type: "string" + context-memory-json: + type: "string" + ack-final-indicator: + type: "string" + sli.api.TestResults: + type: "object" + properties: + test-result: + type: "array" + items: + $ref: "#/definitions/sli.api.testresults.TestResult" + originalRef: "#/definitions/sli.api.testresults.TestResult" + sli.api.Vlbcheck: + type: "object" + properties: + output: + $ref: "#/definitions/sli.api.ResponseFields" + originalRef: "#/definitions/sli.api.ResponseFields" + sli.api.executegraph.Input: + type: "object" + properties: + mode: + $ref: "#/definitions/sli.api.ModeEnumeration" + originalRef: "#/definitions/sli.api.ModeEnumeration" + module-name: + type: "string" + sli-parameter: + type: "array" + items: + $ref: "#/definitions/sli.api.ParameterSetting" + originalRef: "#/definitions/sli.api.ParameterSetting" + rpc-name: + type: "string" + sli.api.testresults.TestResult: + type: "object" + properties: + results: + type: "array" + items: + type: "string" + test-identifier: + type: "string" diff --git a/sliapi/model/yang/pom.xml b/sliapi/model/yang/pom.xml new file mode 100755 index 000000000..420d2ee0d --- /dev/null +++ b/sliapi/model/yang/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + binding-parent + 2.0.0-SNAPSHOT + + + + org.onap.ccsdk.sli.core + sliapi-model-yang + 1.0.0-SNAPSHOT + bundle + + ccsdk-sli-core :: sliapi :: ${project.artifactId} + + + + org.opendaylight.mdsal.binding.model.ietf + rfc6991 + + + + + diff --git a/sliapi/model/yang/src/main/resources/sli-api.20161110.json b/sliapi/model/yang/src/main/resources/sli-api.20161110.json new file mode 100644 index 000000000..1c6cdabfe --- /dev/null +++ b/sliapi/model/yang/src/main/resources/sli-api.20161110.json @@ -0,0 +1,554 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0" + }, + "basePath": "/restconf", + "paths": { + "/config": { + "post": { + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "**(config)test-results", + "required": false, + "schema": { + "$ref": "#/definitions/SLI-API(config)test-results-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(config)SLI-API_modulePOST" + } + } + }, + "description": "Defines API to service logic interpreter", + "operationId": "POST-SLI-API_module" + } + }, + "/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/(config)test-results" + } + } + }, + "description": "Test results", + "operationId": "GET-test-results" + }, + "post": { + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "**(config)test-result", + "required": false, + "schema": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(config)test-resultsPOST" + } + } + }, + "description": "Test results", + "operationId": "POST-test-results" + }, + "put": { + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "(config)test-results", + "required": false, + "schema": { + "$ref": "#/definitions/SLI-API(config)test-results-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/SLI-API(config)test-results-TOP" + } + } + }, + "description": "Test results", + "operationId": "PUT-test-results" + } + }, + "/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/(config)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": "(config)test-result", + "required": false, + "schema": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result-TOP" + } + } + }, + "operationId": "PUT-test-result" + } + }, + "/operational/SLI-API:test-results": { + "get": { + "produces": [ + "application/json", + "application/xml" + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(operational)test-results" + } + } + }, + "description": "Test results", + "operationId": "GET-test-results" + } + }, + "/operations/SLI-API:execute-graph": { + "post": { + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "required": false, + "schema": { + "$ref": "#/definitions/(execute-graph)input-TOP" + } + } + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(execute-graph)output-TOP" + } + } + }, + "description": " Method to add a new parameter.", + "operationId": "execute-graph" + } + }, + "/operations/SLI-API:healthcheck": { + "post": { + "produces": [ + "application/json", + "application/xml" + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(healthcheck)output-TOP" + } + } + }, + "operationId": "healthcheck" + } + }, + "/operations/SLI-API:vlbcheck": { + "post": { + "produces": [ + "application/json", + "application/xml" + ], + "responses": { + "200": { + "description": "No response was specified", + "schema": { + "$ref": "#/definitions/(vlbcheck)output-TOP" + } + } + }, + "operationId": "vlbcheck" + } + } + }, + "definitions": { + "(config)SLI-API_modulePOST": { + "properties": { + "test-results": { + "items": { + "$ref": "#/definitions/SLI-API(config)test-results" + }, + "type": "object" + } + }, + "type": "object" + }, + "(config)sli-parameterPOST": { + "properties": { + "boolean-value": { + "$ref": "#/definitions/Optional.empty" + }, + "int-value": { + "$ref": "#/definitions/Optional.empty" + }, + "parameter-name": { + "$ref": "#/definitions/Optional.empty", + "description": "Parameter name" + }, + "string-value": { + "$ref": "#/definitions/Optional.empty" + } + }, + "type": "object" + }, + "(config)test-resultPOST": { + "properties": { + "test-identifier": { + "$ref": "#/definitions/Optional.empty" + } + }, + "type": "object" + }, + "(config)test-resultsPOST": { + "properties": { + "test-result": { + "items": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result" + }, + "type": "array" + } + }, + "type": "object" + }, + "(execute-graph)input": { + "properties": { + "SLI-API:mode": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:module-name": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:rpc-name": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:sli-parameter": { + "items": { + "$ref": "#/definitions/SLI-API(config)sli-parameter" + }, + "type": "array" + } + }, + "type": "object" + }, + "(execute-graph)input-TOP": { + "properties": { + "SLI-API:input": { + "items": { + "$ref": "#/definitions/(execute-graph)input" + }, + "type": "object" + } + }, + "type": "object" + }, + "(execute-graph)output": { + "properties": { + "SLI-API:ack-final-indicator": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:context-memory-json": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:response-code": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:response-message": { + "$ref": "#/definitions/Optional.empty" + } + }, + "type": "object" + }, + "(execute-graph)output-TOP": { + "properties": { + "SLI-API:output": { + "items": { + "$ref": "#/definitions/(execute-graph)output" + }, + "type": "object" + } + }, + "type": "object" + }, + "(healthcheck)output": { + "properties": { + "SLI-API:ack-final-indicator": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:context-memory-json": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:response-code": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:response-message": { + "$ref": "#/definitions/Optional.empty" + } + }, + "type": "object" + }, + "(healthcheck)output-TOP": { + "properties": { + "SLI-API:output": { + "items": { + "$ref": "#/definitions/(healthcheck)output" + }, + "type": "object" + } + }, + "type": "object" + }, + "(vlbcheck)output": { + "properties": { + "SLI-API:ack-final-indicator": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:context-memory-json": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:response-code": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:response-message": { + "$ref": "#/definitions/Optional.empty" + } + }, + "type": "object" + }, + "(vlbcheck)output-TOP": { + "properties": { + "SLI-API:output": { + "items": { + "$ref": "#/definitions/(vlbcheck)output" + }, + "type": "object" + } + }, + "type": "object" + }, + "SLI-API(config)sli-parameter": { + "properties": { + "SLI-API:boolean-value": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:int-value": { + "$ref": "#/definitions/Optional.empty" + }, + "SLI-API:parameter-name": { + "$ref": "#/definitions/Optional.empty", + "description": "Parameter name" + }, + "SLI-API:string-value": { + "$ref": "#/definitions/Optional.empty" + } + }, + "type": "object" + }, + "SLI-API(config)sli-parameter-TOP": { + "properties": { + "SLI-API:sli-parameter": { + "items": { + "$ref": "#/definitions/SLI-API(config)sli-parameter" + }, + "type": "array" + } + }, + "type": "object" + }, + "SLI-API(config)test-results": { + "properties": { + "SLI-API:test-result": { + "items": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result" + }, + "type": "array" + } + }, + "type": "object" + }, + "SLI-API(config)test-results-TOP": { + "properties": { + "SLI-API:test-results": { + "description": "Test results", + "items": { + "$ref": "#/definitions/SLI-API(config)test-results" + }, + "type": "object" + } + }, + "type": "object" + }, + "SLI-API(operational)test-results": { + "type": "object" + }, + "SLI-API(operational)test-results-TOP": { + "properties": { + "SLI-API:test-results": { + "description": "Test results", + "items": { + "$ref": "#/definitions/SLI-API(operational)test-results" + }, + "type": "object" + } + }, + "type": "object" + }, + "SLI-API/test-results(config)test-result": { + "properties": { + "SLI-API:results": { + "items": { + "$ref": "#/definitions/Optional.empty" + }, + "type": "array" + }, + "SLI-API:test-identifier": { + "$ref": "#/definitions/Optional.empty" + } + }, + "type": "object" + }, + "SLI-API/test-results(config)test-result-TOP": { + "properties": { + "SLI-API:test-result": { + "items": { + "$ref": "#/definitions/SLI-API/test-results(config)test-result" + }, + "type": "array" + } + }, + "type": "object" + }, + "unique_empty_identifier": {} + } +} diff --git a/sliapi/model/yang/src/main/resources/sli-api.20161110.yaml b/sliapi/model/yang/src/main/resources/sli-api.20161110.yaml new file mode 100644 index 000000000..3420c66b5 --- /dev/null +++ b/sliapi/model/yang/src/main/resources/sli-api.20161110.yaml @@ -0,0 +1,254 @@ +--- +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 + 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 + 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: + 'input': + type: object + properties: + 'mode': + type: string + 'module-name': + type: string + 'rpc-name': + type: string + 'sli-parameter': + items: + $ref: '#/definitions/parameter-setting' + type: array + type: object + + + + + + + unique_empty_identifier: {} + diff --git a/sliapi/model/yang/src/main/yang/sliapi.yang b/sliapi/model/yang/src/main/yang/sliapi.yang new file mode 100755 index 000000000..98cbb2aa7 --- /dev/null +++ b/sliapi/model/yang/src/main/yang/sliapi.yang @@ -0,0 +1,117 @@ +module SLI-API { + + yang-version 1; + + namespace "org:onap:ccsdk:sli:core:sliapi"; + + prefix sample; + + import ietf-inet-types { prefix "inet"; revision-date 2013-07-15; } + + organization "ONAP"; + + contact + "Dan Timoney"; + + description + "Defines API to service logic interpreter"; + + revision "2016-11-10" { + description + "REST API to Service Logic Interpreter"; + } + + grouping parameter-setting { + description + "Parameter setting"; + + leaf parameter-name { + type string; + description "Parameter name"; + } + + leaf int-value { + type int32; + } + leaf string-value { + type string; + } + leaf boolean-value { + type boolean; + } + } + + grouping response-fields { + leaf response-code { + type string; + } + leaf ack-final-indicator { + type string; + } + leaf response-message { + type string; + } + leaf context-memory-json { + type string; + } + } + + container test-results { + description "Test results"; + + list test-result { + key "test-identifier"; + + leaf test-identifier { + type string; + } + + leaf-list results { + type string; + } + } + } + + rpc execute-graph { + description " Method to add a new parameter."; + input { + + leaf module-name { + type string; + } + + leaf rpc-name { + type string; + } + + leaf mode { + type enumeration { + enum sync; + enum async; + } + } + + list sli-parameter { + key "parameter-name"; + uses parameter-setting; + } + } + + output { + uses response-fields; + } + } + + rpc healthcheck { + output { + uses response-fields; + } + } + + rpc vlbcheck { + output { + uses response-fields; + } + } + +} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index e2c910801..367d82cf2 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -19,7 +19,6 @@ model provider - springboot installer diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index e726b24f2..f80003766 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -28,7 +28,7 @@ org.onap.ccsdk.sli.core - sliapi-model + sliapi-model-yang ${project.version} diff --git a/sliapi/springboot/.swagger-codegen-ignore b/sliapi/springboot/.swagger-codegen-ignore deleted file mode 100644 index d14d7b944..000000000 --- a/sliapi/springboot/.swagger-codegen-ignore +++ /dev/null @@ -1 +0,0 @@ -**/RestconfApiController.java diff --git a/sliapi/springboot/README.md b/sliapi/springboot/README.md deleted file mode 100644 index 38be1c2f9..000000000 --- a/sliapi/springboot/README.md +++ /dev/null @@ -1,33 +0,0 @@ -This directory contains a demo springboot implementation of the SLI-API healthcheck method. - -To start this server with out AAF authentication, run: -mvn -DserviceLogicDirectory=src/main/resources spring-boot:run - -To start this server with AAF authentication, run: -mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dcadi_prop_files=/opt/onap/sdnc/data/properties/org.onap.sdnc.props -DserviceLogicDirectory=src/main/resources" - - -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/restconf/operations/SLI-API:healthcheck -X POST -H "Content-Type: application/json" - -Requests can also be sent to `http://localhost:8080/executeGraph` - -The graph details need to match a graph which has been loaded and activated - -An example request -``` -{ - "graphDetails": { - "module": "prov", - "rpc": "test", - "mode": "sync" - }, - "input": { - "name": "Hello World", - "test": "one", - "mixed": "cAsE" - } -} -``` diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml deleted file mode 100644 index 269caa47f..000000000 --- a/sliapi/springboot/pom.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - spring-boot-starter-parent - 2.0.0-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sliapi-springboot - 1.0.0-SNAPSHOT - jar - - ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - org.onap.ccsdk.sli.core.sliapi.springboot.App - 1.5.0 - 2.1.13 - - - - - io.swagger - swagger-annotations - - - org.apache.shiro - shiro-spring-boot-web-starter - ${shiro.version} - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 - - - org.onap.aaf.cadi - aaf-cadi-shiro - ${aaf-shiro-bundle.version} - - - - org.springframework.boot - spring-boot-starter-test - test - - - 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} - dblib-provider - ${project.version} - - - ${project.groupId} - sli-common - ${project.version} - - - ${project.groupId} - sli-provider-base - ${project.version} - - - com.google.code.gson - gson - - - org.apache.derby - derby - test - - - org.mariadb.jdbc - mariadb-java-client - - - junit - junit - test - - - org.onap.logging-analytics - logging-filter-spring - 1.6.6 - - - javax.ws.rs - javax.ws.rs-api - - - org.onap.ccsdk.sli.core - sliPluginUtils-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - restapi-call-node-provider - ${project.version} - - - org.onap.ccsdk.sli.plugins - properties-node-provider - ${project.version} - - - - org.glassfish.jersey.inject - jersey-hk2 - - - - - - - io.swagger - swagger-codegen-maven-plugin - 2.3.1 - - - - generate - - - target/generated-sources - ${project.basedir}/../model/src/main/resources/sli-api.20161110.yaml - spring - org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger - org.onap.ccsdk.sli.core.sliapi.model - org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger - 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/App.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java deleted file mode 100644 index f4e78bebe..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2020 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.sliapi.springboot; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import springfox.documentation.swagger2.annotations.EnableSwagger2; -import org.apache.shiro.realm.Realm; -import org.apache.shiro.realm.text.PropertiesRealm; -import org.apache.shiro.realm.text.TextConfigurationRealm; -import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition; -import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; -import org.springframework.context.annotation.Bean; -import org.onap.aaf.cadi.shiro.AAFRealm; - -@SpringBootApplication -@EnableSwagger2 -@ComponentScan(basePackages = { "org.onap.ccsdk.sli.core.sliapi.springboot.*" }) - -public class App { - - private static final Logger log = LoggerFactory.getLogger(App.class); - - public static void main(String[] args) throws Exception { - SpringApplication.run(App.class, args); - } - - @Bean - public Realm realm() { - - // If cadi prop files is not defined use local properties realm - // src/main/resources/shiro-users.properties - if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { - log.info("cadi_prop_files undefined, AAF Realm will not be set"); - PropertiesRealm realm = new PropertiesRealm(); - return realm; - } else { - AAFRealm realm = new AAFRealm(); - return realm; - } - - } - - @Bean - public ShiroFilterChainDefinition shiroFilterChainDefinition() { - DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition(); - - // if cadi prop files is not set disable authentication - if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { - chainDefinition.addPathDefinition("/**", "anon"); - } else { - log.info("Loaded property cadi_prop_files, AAF REALM set"); - chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc.odl:odl-api]"); - } - - return chainDefinition; - } - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java deleted file mode 100644 index 809cfe59c..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2020 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.sliapi.springboot.controllers; - -import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -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; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -@Controller -@EnableAutoConfiguration -public class ExecuteGraphController { - @Autowired - protected SvcLogicServiceBase svc; - - @RequestMapping(value = "/executeGraph", method = RequestMethod.POST) - @ResponseBody - public HashMap executeGraph(@RequestBody String 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()); - } - } - } - - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultConfig.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultConfig.java deleted file mode 100644 index f8ed1b4ce..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultConfig.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -@Entity -public class TestResultConfig { - - - @Id - @GeneratedValue(strategy= GenerationType.AUTO) - private Long id; - - private String testIdentifier; - private String results; - - public TestResultConfig() - { - - } - public TestResultConfig(String testIdentifier, String results) { - this.testIdentifier = testIdentifier; - this.results = results; - } - - public String getTestIdentifier() { - return testIdentifier; - } - - public void setTestIdentifier(String testIdentifier) { - this.testIdentifier = testIdentifier; - } - - public String getResults() { - return results; - } - - public void setResults(String results) { - this.results = results; - } - - - - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultOperational.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultOperational.java deleted file mode 100644 index 4c3709e6e..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultOperational.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -@Entity -public class TestResultOperational { - - - @Id - @GeneratedValue(strategy= GenerationType.AUTO) - private Long id; - - private String testIdentifier; - private String results; - - public TestResultOperational() - { - - } - - public TestResultOperational(String testIdentifier, String results) { - this.testIdentifier = testIdentifier; - this.results = results; - } - - public String getTestIdentifier() { - return testIdentifier; - } - - public void setTestIdentifier(String testIdentifier) { - this.testIdentifier = testIdentifier; - } - - public String getResults() { - return results; - } - - public void setResults(String results) { - this.results = results; - } - - - - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsConfigRepository.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsConfigRepository.java deleted file mode 100644 index 1a73b3f50..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsConfigRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data; - -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -public interface TestResultsConfigRepository extends CrudRepository { - - List findByTestIdentifier(String testIdentifier); - - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsOperationalRepository.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsOperationalRepository.java deleted file mode 100644 index d81c02b23..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/data/TestResultsOperationalRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data; - -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - -public interface TestResultsOperationalRepository extends CrudRepository { - - List findByTestIdentifier(String testIdentifier); - - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java deleted file mode 100644 index aa9a9d7e8..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java +++ /dev/null @@ -1,364 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2020 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.sliapi.springboot.controllers.swagger; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; -import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; -import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; -import org.onap.ccsdk.sli.core.sliapi.model.TestResult; -import org.onap.ccsdk.sli.core.sliapi.model.TestResults; -import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data.TestResultConfig; -import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data.TestResultsConfigRepository; -import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.data.TestResultsOperationalRepository; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.ComponentScan; -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.util.*; - -@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-02-20T12:50:11.207-05:00") - -@Controller -@ComponentScan(basePackages = {"org.onap.ccsdk.sli.core.sliapi.springboot.*"}) -@EntityScan("org.onap.ccsdk.sli.core.sliapi.springboot.*") -public class RestconfApiController implements RestconfApi { - - private final ObjectMapper objectMapper; - private final HttpServletRequest request; - - @Autowired - protected SvcLogicServiceBase svc; - - @Autowired - private TestResultsConfigRepository testResultsConfigRepository; - - @Autowired - private TestResultsOperationalRepository testResultsOperationalRepository; - - private static final Logger log = LoggerFactory.getLogger(RestconfApiController.class); - - @org.springframework.beans.factory.annotation.Autowired - public RestconfApiController(ObjectMapper objectMapper, HttpServletRequest request) { - this.objectMapper = objectMapper; - this.request = request; - } - - @Override - public ResponseEntity healthcheck() { - ResponseFields resp = new ResponseFields(); - - try { - log.info("Calling SLI-API:healthcheck DG"); - SvcLogicContext ctxIn = new SvcLogicContext(); - SvcLogicContext ctxOut = svc.execute("sli", "healthcheck", null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "Success")); - resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); - - 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 ResponseEntity vlbcheck() { - ResponseFields resp = new ResponseFields(); - - try { - log.info("Calling SLI-API:vlbcheck DG"); - SvcLogicContext ctxIn = new SvcLogicContext(); - SvcLogicContext ctxOut = svc.execute("sli", "vlbcheck", null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "Success")); - resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); - - return (new ResponseEntity<>(resp, HttpStatus.OK)); - } catch (Exception e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - log.error("Error calling vlbcheck 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); - } - - @Override - public ResponseEntity executeGraph(@Valid ExecuteGraphInput executeGraphInput) { - SvcLogicContext ctxIn = new SvcLogicContext(); - ResponseFields resp = new ResponseFields(); - String executeGraphInputJson = null; - - try { - executeGraphInputJson = objectMapper.writeValueAsString(executeGraphInput); - log.info("Input as JSON is "+executeGraphInputJson); - } catch (JsonProcessingException e) { - - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - log.error("Cannot create JSON from input object", e); - return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); - - } - JsonObject jsonInput = new Gson().fromJson(executeGraphInputJson, JsonObject.class); - JsonObject passthroughObj = jsonInput.get("input").getAsJsonObject(); - - ctxIn.mergeJson("input", passthroughObj.toString()); - - try { - // Any of these can throw a nullpointer exception - String calledModule = executeGraphInput.getInput().getModuleName(); - String calledRpc = executeGraphInput.getInput().getRpcName(); - String modeStr = executeGraphInput.getInput().getMode(); - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(calledModule, calledRpc, null, modeStr, ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - resp.setContextMemoryJson(propsToJson(respProps, "context-memory")); - return (new ResponseEntity<>(resp, HttpStatus.valueOf(Integer.parseInt(resp.getResponseCode())))); - - } catch (NullPointerException npe) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - - return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); - } catch (SvcLogicException e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - - return (new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); - } - } - - @Override - public ResponseEntity deleteTestResult(String testIdentifier) { - - List testResultConfigs = testResultsConfigRepository.findByTestIdentifier(testIdentifier); - - if (testResultConfigs != null) { - Iterator testResultConfigIterator = testResultConfigs.iterator(); - while (testResultConfigIterator.hasNext()) { - testResultsConfigRepository.delete(testResultConfigIterator.next()); - } - } - - return (new ResponseEntity<>(HttpStatus.OK)); - } - - @Override - public ResponseEntity deleteTestResults() { - - testResultsConfigRepository.deleteAll(); - - return (new ResponseEntity<>(HttpStatus.OK)); - } - - @Override - public ResponseEntity gETTestResults() { - - TestResults results = new TestResults(); - - testResultsOperationalRepository.findAll().forEach(testResult -> { - TestResult item = null; - try { - item = objectMapper.readValue(testResult.getResults(), TestResult.class); - results.addTestResultsItem(item); - } catch (JsonProcessingException e) { - log.error("Could not convert testResult", e); - } - }); - - - return new ResponseEntity<>(results, HttpStatus.OK); - } - - @Override - public ResponseEntity getTestResult(String testIdentifier) { - List testResultConfigs = testResultsConfigRepository.findByTestIdentifier(testIdentifier); - - if ((testResultConfigs == null) || (testResultConfigs.size() == 0)) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } else { - TestResultConfig testResultConfig = testResultConfigs.get(0); - TestResult testResult = null; - try { - testResult = objectMapper.readValue(testResultConfig.getResults(), TestResult.class); - } catch (JsonProcessingException e) { - log.error("Cannot convert test result", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - - - return new ResponseEntity<>(testResult, HttpStatus.OK); - } - } - - @Override - public ResponseEntity getTestResults() { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default RestconfApi interface so no example is generated"); - } - - TestResults results = new TestResults(); - - testResultsConfigRepository.findAll().forEach(testResult -> { - TestResult item = null; - try { - item = objectMapper.readValue(testResult.getResults(), TestResult.class); - results.addTestResultsItem(item); - } catch (JsonProcessingException e) { - log.error("Could not convert testResult", e); - } - }); - - - return new ResponseEntity<>(results, HttpStatus.OK); - } - - @Override - public ResponseEntity pUTTestResult(String testIdentifier, @Valid TestResult testResult) { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default RestconfApi interface so no example is generated"); - } - - List testResultConfigs = testResultsConfigRepository.findByTestIdentifier(testIdentifier); - Iterator testResultIter = testResultConfigs.iterator(); - while (testResultIter.hasNext()) { - testResultsConfigRepository.delete(testResultIter.next()); - } - - TestResultConfig testResultConfig = null; - try { - testResultConfig = new TestResultConfig(testResult.getTestIdentifier(), objectMapper.writeValueAsString(testResult)); - testResultsConfigRepository.save(testResultConfig); - } catch (JsonProcessingException e) { - log.error("Could not save test result", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - - return new ResponseEntity<>(testResult, HttpStatus.OK); - } - - @Override - public ResponseEntity postTestResults(@Valid TestResults testResults) { - List resultList = testResults.getTestResults(); - - Iterator resultIterator = resultList.iterator(); - - while (resultIterator.hasNext()) { - TestResult curResult = resultIterator.next(); - try { - testResultsConfigRepository.save(new TestResultConfig(curResult.getTestIdentifier(), objectMapper.writeValueAsString(curResult))); - } catch (JsonProcessingException e) { - log.error("Could not save test result", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - return new ResponseEntity<>(testResults, HttpStatus.OK); - } - - @Override - public ResponseEntity putTestResults(@Valid TestResults testResults) { - testResultsConfigRepository.deleteAll(); - - List resultList = testResults.getTestResults(); - - Iterator resultIterator = resultList.iterator(); - - - while (resultIterator.hasNext()) { - TestResult curResult = resultIterator.next(); - try { - testResultsConfigRepository.save(new TestResultConfig(curResult.getTestIdentifier(), objectMapper.writeValueAsString(curResult))); - } catch (JsonProcessingException e) { - log.error("Could not save test result", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - return new ResponseEntity<>(testResults, HttpStatus.OK); - } - - public static String propsToJson(Properties props, String root) - { - StringBuffer sbuff = new StringBuffer(); - - sbuff.append("{ \""+root+"\" : { "); - boolean needComma = false; - for (Map.Entry prop : props.entrySet()) { - sbuff.append("\""+(String) prop.getKey()+"\" : \""+(String)prop.getValue()+"\""); - if (needComma) { - sbuff.append(" , "); - } else { - needComma = true; - } - } - sbuff.append(" } }"); - - return(sbuff.toString()); - } - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java deleted file mode 100644 index 0c8480e11..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2020 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.sliapi.springboot.core; - -import java.io.FileInputStream; -import java.io.IOException; -import java.util.List; -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver; -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.sli.provider.base.SvcLogicServiceBase; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase; -import org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder; -import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; -import org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils; -import org.onap.ccsdk.sli.plugins.prop.PropertiesNode; -import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class SvcLogicFactory { - private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class); - - @Autowired - List recorders; - - @Autowired - List plugins; - - @Bean - public SvcLogicStore getStore() throws Exception { - SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() { - - @Override - public Properties getProperties() { - Properties props = new Properties(); - - - String propPath = System.getProperty("serviceLogicProperties", ""); - - if ("".equals(propPath)) { - propPath = System.getenv("SVCLOGIC_PROPERTIES"); - } - - - if ((propPath == null) || propPath.length() == 0) { - propPath = "src/main/resources/svclogic.properties"; - } - System.out.println(propPath); - try (FileInputStream fileInputStream = new FileInputStream(propPath)) { - props = new Properties(); - props.load(fileInputStream); - } catch (final IOException e) { - log.error("Failed to load properties for file: {}", propPath, - new ConfigurationException("Failed to load properties for file: " + propPath, e)); - } - return props; - } - }; - SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties()); - return store; - } - - @Bean - public SvcLogicLoader createLoader() throws Exception { - String serviceLogicDirectory = System.getProperty("serviceLogicDirectory"); - if (serviceLogicDirectory == null) { - serviceLogicDirectory = "src/main/resources"; - } - - System.out.println("serviceLogicDirectory is " + serviceLogicDirectory); - SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, getStore()); - - try { - loader.loadAndActivate(); - } catch (IOException e) { - log.error("Cannot load directed graphs", e); - } - return loader; - } - - @Bean - public SvcLogicServiceBase createService() throws Exception { - HashMapResolver resolver = new HashMapResolver(); - for (SvcLogicRecorder recorder : recorders) { - resolver.addSvcLogicRecorder(recorder.getClass().getName(), recorder); - - } - for (SvcLogicJavaPlugin plugin : plugins) { - resolver.addSvcLogicSvcLogicJavaPlugin(plugin.getClass().getName(), plugin); - - } - return new SvcLogicServiceImplBase(getStore(), resolver); - } - - @Bean - public Slf4jRecorder slf4jRecorderNode() { - return new Slf4jRecorder(); - } - - @Bean - public SliPluginUtils sliPluginUtil() { - return new SliPluginUtils(); - } - - @Bean - public SliStringUtils sliStringUtils() { - return new SliStringUtils(); - } - - @Bean - public RestapiCallNode restapiCallNode() { - return new RestapiCallNode(); - } - - @Bean - public PropertiesNode propertiesNode() { - return new PropertiesNode(); - } - -} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java deleted file mode 100644 index 558a82a11..000000000 --- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/WebConfig.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2020 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.sliapi.springboot.core; - -import org.onap.logging.filter.spring.LoggingInterceptor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - -@EnableWebMvc -@Configuration -@EnableJpaRepositories("org.onap.ccsdk.sli.core.sliapi.springboot.*") -@ComponentScan(basePackages = {"org.onap.ccsdk.sli.core.sliapi.springboot.*"}) -@EntityScan("org.onap.ccsdk.sli.core.sliapi.springboot.*") -@EnableTransactionManagement -public class WebConfig implements WebMvcConfigurer { - - -} \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/DEMO_DEMO.xml b/sliapi/springboot/src/main/resources/DEMO_DEMO.xml deleted file mode 100755 index 1b304f18a..000000000 --- a/sliapi/springboot/src/main/resources/DEMO_DEMO.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/application.properties b/sliapi/springboot/src/main/resources/application.properties deleted file mode 100644 index f083ed5e9..000000000 --- a/sliapi/springboot/src/main/resources/application.properties +++ /dev/null @@ -1,18 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -server.contextPath=/restconf -server.port=8080 -spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RFC3339DateFormat -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false -logging.level.com.att=TRACE -logging.level.org.onap=TRACE -spring.datasource.url=jdbc:mariadb://localhost:3306/sdnctl -spring.datasource.username=sli -spring.datasource.password=abc123 -spring.datasource.driver-class-name=org.mariadb.jdbc.Driver -spring.datasource.testWhileIdle=true -spring.datasource.validationQuery=SELECT 1 -spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto=update -spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl -spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy -spring.jpa.database=mysql \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/graph.versions b/sliapi/springboot/src/main/resources/graph.versions deleted file mode 100644 index d21278aa4..000000000 --- a/sliapi/springboot/src/main/resources/graph.versions +++ /dev/null @@ -1,3 +0,0 @@ -sli healthcheck 0.7.0 sync -sli vlbcheck 0.7.0 sync -DEMO DEMO 1 sync diff --git a/sliapi/springboot/src/main/resources/log4j2.properties b/sliapi/springboot/src/main/resources/log4j2.properties deleted file mode 100644 index 40d18d157..000000000 --- a/sliapi/springboot/src/main/resources/log4j2.properties +++ /dev/null @@ -1,160 +0,0 @@ - #- - # ============LICENSE_START======================================================= - # ONAP - CCSDK - # ================================================================================ - # Copyright (C) 2020 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========================================================= - # - -property.logDir = ${sys:LOG_PATH:-./target} - -property.pattern = %d{ISO8601} | %-5p | %-16t | %-32c{1} | %X{currentGraph} - %X{nodeId} | %m%n - -#default mdc values -property.ServiceName = INTERNAL -property.ErrorCode = 900 -property.ErrorDesc = UnknownError - -rootLogger.level = INFO -rootLogger.appenderRef.AppFile.ref = AppFile -rootLogger.appenderRef.Console.ref = Console -rootLogger.appenderRef.DebugFile.ref = DebugFile -rootLogger.appenderRef.ErrorFile.ref = ErrorFile -rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter -rootLogger.appenderRef.Console.filter.threshold.level = DEBUG - -appender.console.type = Console -appender.console.name = Console -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = ${pattern} - -appender.app.type = RollingRandomAccessFile -appender.app.name = AppFile -appender.app.fileName = ${logDir}/app.log -appender.app.filePattern = ${logDir}/app.log.%i -appender.app.immediateFlush = true -appender.app.append = true -appender.app.layout.type = PatternLayout -appender.app.layout.pattern = ${pattern} -appender.app.policies.type = Policies -appender.app.policies.size.type = SizeBasedTriggeringPolicy -appender.app.policies.size.size = 10MB -appender.app.strategy.type = DefaultRolloverStrategy -appender.app.strategy.max = 100 -appender.app.strategy.fileIndex = min - -appender.debug.type = RollingRandomAccessFile -appender.debug.name = DebugFile -appender.debug.fileName = ${logDir}/debug.log -appender.debug.filePattern = ${logDir}/debug.log.%i -appender.debug.immediateFlush = true -appender.debug.append = true -appender.debug.layout.type = PatternLayout -appender.debug.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%-16.16t|%-5.5p|%-32.32c{1}|%X{currentGraph} - %X{nodeId}|%m%n -appender.debug.policies.type = Policies -appender.debug.policies.size.type = SizeBasedTriggeringPolicy -appender.debug.policies.size.size = 10MB -appender.debug.strategy.type = DefaultRolloverStrategy -appender.debug.strategy.max = 200 -appender.debug.strategy.fileIndex = min - -appender.error.type = RollingRandomAccessFile -appender.error.name = ErrorFile -appender.error.fileName = ${logDir}/error.log -appender.error.filePattern = ${logDir}/error.log.%i -appender.error.immediateFlush = true -appender.error.append = true -appender.error.layout.type = PatternLayout -appender.error.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%-16.16t|$${ctx:ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%p|$${ctx:ErrorCode}|$${ctx:ErrorDesc}|%m%n - -appender.error.policies.type = Policies -appender.error.policies.size.type = SizeBasedTriggeringPolicy -appender.error.policies.size.size = 10MB -appender.error.strategy.type = DefaultRolloverStrategy -appender.error.strategy.max = 100 -appender.error.strategy.fileIndex = min -appender.error.filter.threshold.type = ThresholdFilter -appender.error.filter.threshold.level = WARN - -appender.metric.type = RollingRandomAccessFile -appender.metric.name = MetricFile -appender.metric.fileName = ${logDir}/metric.log -appender.metric.filePattern = ${logDir}/metric.log.%i -appender.metric.immediateFlush = true -appender.metric.append = true -appender.metric.layout.type = PatternLayout -appender.metric.layout.pattern=%X{InvokeTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%-16.16t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceID}|%p|%X{Severity}|192.168.23.111|%X{ElapsedTime}|${hostName}|%X{ClientIPAddress}|%C{1}|||%X{TargetElement}|%markerSimpleName|%X|%X{currentGraph} - %X{nodeId}||%m%n -appender.metric.policies.type = Policies -appender.metric.policies.size.type = SizeBasedTriggeringPolicy -appender.metric.policies.size.size = 10MB -appender.metric.strategy.type = DefaultRolloverStrategy -appender.metric.strategy.max = 100 -appender.metric.strategy.fileIndex = min - -appender.audit.type = RollingRandomAccessFile -appender.audit.name = AuditFile -appender.audit.fileName = ${logDir}/audit.log -appender.audit.filePattern = ${logDir}/audit.log.%i -appender.audit.immediateFlush = true -appender.audit.append = true -appender.audit.layout.type = PatternLayout -appender.audit.layout.pattern=%X{EntryTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%-16.16t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceID}|INFO|%X{Severity}|192.168.23.111|%X{ElapsedTime}|${hostName}|%X{ClientIPAddress}|%C{1}|%X{AUDIT-Unused}|%X{AUDIT-ProcessKey}|%markerSimpleName|%X|||%m%n -appender.audit.policies.type = Policies -appender.audit.policies.size.type = SizeBasedTriggeringPolicy -appender.audit.policies.size.size = 10MB -appender.audit.strategy.type = DefaultRolloverStrategy -appender.audit.strategy.max = 200 -appender.audit.strategy.fileIndex = min - -appender.rr.name = RequestResponseFile -appender.rr.type = RollingRandomAccessFile -appender.rr.fileName = ${logDir}/request-response.log -appender.rr.filePattern = ${logDir}/request-response.log.%i -appender.rr.immediateFlush = true -appender.rr.append = true -appender.rr.layout.type = PatternLayout -appender.rr.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%X{PartnerName}|%m%n -appender.rr.policies.type = Policies -appender.rr.policies.size.type = SizeBasedTriggeringPolicy -appender.rr.policies.size.size = 10MB -appender.rr.strategy.type = DefaultRolloverStrategy -appender.rr.strategy.max = 100 -appender.rr.strategy.fileIndex = min - -logger.metric.name = org.onap.ccsdk.sli.core.filters.metric -logger.metric.level = INFO -logger.metric.additivity = false -logger.metric.appenderRef.MetricFile.ref = MetricFile - -logger.metric2.name = org.onap.logging.filter.base.AbstractMetricLogFilter -logger.metric2.level = INFO -logger.metric2.additivity = false -logger.metric2.appenderRef.MetricFile.ref = MetricFile - -logger.audit.name = org.onap.logging.filter.base.AbstractAuditLogFilter -logger.audit.level = INFO -logger.audit.additivity = false -logger.audit.appenderRef.AuditFile.ref = AuditFile - -logger.rr.name = org.onap.logging.filter.base.PayloadLoggingServletFilter -logger.rr.level = INFO -logger.rr.additivity = false -logger.rr.appenderRef.RequestResponseFile.ref = RequestResponseFile - -logger.ccsdk.name = org.onap.ccsdk -logger.ccsdk.level = DEBUG - -logger.onaplogging.name = org.onap.logging -logger.onaplogging.level = DEBUG \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/shiro-users.properties b/sliapi/springboot/src/main/resources/shiro-users.properties deleted file mode 100644 index df4b1ae7a..000000000 --- a/sliapi/springboot/src/main/resources/shiro-users.properties +++ /dev/null @@ -1,3 +0,0 @@ -user.admin = Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U,service -role.service = odl-api:* - diff --git a/sliapi/springboot/src/main/resources/sli_healthcheck.xml b/sliapi/springboot/src/main/resources/sli_healthcheck.xml deleted file mode 100644 index bc8e2f700..000000000 --- a/sliapi/springboot/src/main/resources/sli_healthcheck.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - diff --git a/sliapi/springboot/src/main/resources/sli_vlbcheck.xml b/sliapi/springboot/src/main/resources/sli_vlbcheck.xml deleted file mode 100644 index 820a85c10..000000000 --- a/sliapi/springboot/src/main/resources/sli_vlbcheck.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - diff --git a/sliapi/springboot/src/main/resources/svclogic.properties b/sliapi/springboot/src/main/resources/svclogic.properties deleted file mode 100644 index ae396adde..000000000 --- a/sliapi/springboot/src/main/resources/svclogic.properties +++ /dev/null @@ -1,29 +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:mariadb://localhost:3306/sdnctl -org.onap.ccsdk.sli.jdbc.driver=org.mariadb.jdbc.Driver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = sli -org.onap.ccsdk.sli.jdbc.password = abc123 - -sliapi.serviceLogicDirectory=/opt/onap/sdnc/svclogic/graphs diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java deleted file mode 100644 index 5ad6da9fd..000000000 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/AppTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.onap.ccsdk.sli.core.sliapi.springboot; - -import org.apache.shiro.realm.Realm; -import org.apache.shiro.realm.text.PropertiesRealm; -import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; -import org.junit.Before; -import org.junit.Test; -import org.onap.aaf.cadi.shiro.AAFRealm; - -import java.util.Map; - -import static org.junit.Assert.*; - -public class AppTest { - - App app; - - @Before - public void setUp() throws Exception { - app = new App(); - System.setProperty("serviceLogicProperties", "src/test/resources/svclogic.properties"); - } - - @Test - public void realm() { - Realm realm = app.realm(); - assertTrue(realm instanceof PropertiesRealm); - - - } - - @Test - public void shiroFilterChainDefinition() { - ShiroFilterChainDefinition chainDefinition = app.shiroFilterChainDefinition(); - Map chainMap = chainDefinition.getFilterChainMap(); - assertEquals("anon", chainMap.get("/**")); - - - } -} \ No newline at end of file diff --git a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java b/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java deleted file mode 100644 index ae21cef5f..000000000 --- a/sliapi/springboot/src/test/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiControllerTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2020 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.sliapi.springboot; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; -import org.onap.ccsdk.sli.core.sliapi.model.ExecutegraphinputInput; -import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@RunWith(SpringRunner.class) -@SpringBootTest -@AutoConfigureMockMvc -public class RestconfApiControllerTest { - - private static final Logger log = LoggerFactory.getLogger(RestconfApiControllerTest.class); - - @Autowired - private MockMvc mvc; - - @Test - public void testHealthcheck() throws Exception { - String url = "/restconf/operations/SLI-API:healthcheck"; - - MvcResult mvcResult = - mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content("")) - .andReturn(); - - assertEquals(200, mvcResult.getResponse().getStatus()); - } - - @Test - public void testVlbcheck() throws Exception { - String url = "/restconf/operations/SLI-API:vlbcheck"; - - MvcResult mvcResult = - mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content("")) - .andReturn(); - - assertEquals(200, mvcResult.getResponse().getStatus()); - } - - @Test - public void testExecuteHealthcheck() throws Exception { - String url = "/restconf/operations/SLI-API:execute-graph"; - - ExecuteGraphInput executeGraphInput = new ExecuteGraphInput(); - ExecutegraphinputInput executeGraphData = new ExecutegraphinputInput(); - - executeGraphData.setModuleName("sli"); - executeGraphData.setRpcName("healthcheck"); - executeGraphData.setMode("sync"); - executeGraphInput.setInput(executeGraphData); - - String jsonString = mapToJson(executeGraphInput); - log.error("jsonString is {}", jsonString); - - MvcResult mvcResult = - mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)) - .andReturn(); - - assertEquals(200, mvcResult.getResponse().getStatus()); - - } - - @Test - public void testExecuteMissingDg() throws Exception { - String url = "/restconf/operations/SLI-API:execute-graph"; - - ExecuteGraphInput executeGraphInput = new ExecuteGraphInput(); - ExecutegraphinputInput executeGraphData = new ExecutegraphinputInput(); - - executeGraphData.setModuleName("sli"); - executeGraphData.setRpcName("noSuchRPC"); - executeGraphData.setMode("sync"); - executeGraphInput.setInput(executeGraphData); - - String jsonString = mapToJson(executeGraphInput); - - log.error("jsonString is {}", jsonString); - - MvcResult mvcResult = - mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)) - .andReturn(); - - assertEquals(401, mvcResult.getResponse().getStatus()); - - } - - @Test - public void testTestResultAdd() throws Exception { - String url = "/restconf/config/SLI-API:test-results"; - - MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get(url)).andReturn(); - - assertEquals(200, mvcResult.getResponse().getStatus()); - - // Delete any existing content before testing insert - mvcResult = mvc.perform(MockMvcRequestBuilders.delete(url)).andReturn(); - assertEquals(200, mvcResult.getResponse().getStatus()); - - String jsonString = "{\n" + - " \"test-results\" : [\n" + - " {\n" + - " \"test-identifier\" : \"test-1\",\n" + - " \"results\" : [\"test result 1\"]\n" + - " }\n" + - " ]\n" + - "}"; - - mvcResult = mvc.perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON_VALUE).content(jsonString)) - .andReturn(); - - assertEquals(200, mvcResult.getResponse().getStatus()); - - mvcResult = mvc.perform(MockMvcRequestBuilders.get(url)).andReturn(); - - assertEquals(200, mvcResult.getResponse().getStatus()); - assertEquals(jsonString.replaceAll("\\s+",""), mvcResult.getResponse().getContentAsString().replaceAll("\\s+","")); - } - - private String mapToJson(Object obj) throws JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.writeValueAsString(obj); - } - - private ResponseFields respFromJson(String jsonString) throws JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - return (objectMapper.readValue(jsonString, ResponseFields.class)); - } -} diff --git a/sliapi/springboot/src/test/resources/DEMO_DEMO.xml b/sliapi/springboot/src/test/resources/DEMO_DEMO.xml deleted file mode 100755 index 1b304f18a..000000000 --- a/sliapi/springboot/src/test/resources/DEMO_DEMO.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sliapi/springboot/src/test/resources/application.properties b/sliapi/springboot/src/test/resources/application.properties deleted file mode 100644 index dbe2633d4..000000000 --- a/sliapi/springboot/src/test/resources/application.properties +++ /dev/null @@ -1,18 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -server.contextPath=/restconf -server.port=8080 -spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RFC3339DateFormat -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false -logging.level.com.att=TRACE -logging.level.org.onap=TRACE -spring.datasource.url=jdbc:derby:sdnctl;create=true -spring.datasource.username=sli -spring.datasource.password=abc123 -spring.datasource.driver-class-name=org.apache.derby.jdbc.EmbeddedDriver -spring.datasource.testWhileIdle=true -spring.datasource.validationQuery=SELECT 1 -spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto=update -spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl -spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy -spring.jpa.database=derby \ No newline at end of file diff --git a/sliapi/springboot/src/test/resources/graph.versions b/sliapi/springboot/src/test/resources/graph.versions deleted file mode 100644 index d21278aa4..000000000 --- a/sliapi/springboot/src/test/resources/graph.versions +++ /dev/null @@ -1,3 +0,0 @@ -sli healthcheck 0.7.0 sync -sli vlbcheck 0.7.0 sync -DEMO DEMO 1 sync diff --git a/sliapi/springboot/src/test/resources/log4j2.properties b/sliapi/springboot/src/test/resources/log4j2.properties deleted file mode 100644 index 40d18d157..000000000 --- a/sliapi/springboot/src/test/resources/log4j2.properties +++ /dev/null @@ -1,160 +0,0 @@ - #- - # ============LICENSE_START======================================================= - # ONAP - CCSDK - # ================================================================================ - # Copyright (C) 2020 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========================================================= - # - -property.logDir = ${sys:LOG_PATH:-./target} - -property.pattern = %d{ISO8601} | %-5p | %-16t | %-32c{1} | %X{currentGraph} - %X{nodeId} | %m%n - -#default mdc values -property.ServiceName = INTERNAL -property.ErrorCode = 900 -property.ErrorDesc = UnknownError - -rootLogger.level = INFO -rootLogger.appenderRef.AppFile.ref = AppFile -rootLogger.appenderRef.Console.ref = Console -rootLogger.appenderRef.DebugFile.ref = DebugFile -rootLogger.appenderRef.ErrorFile.ref = ErrorFile -rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter -rootLogger.appenderRef.Console.filter.threshold.level = DEBUG - -appender.console.type = Console -appender.console.name = Console -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = ${pattern} - -appender.app.type = RollingRandomAccessFile -appender.app.name = AppFile -appender.app.fileName = ${logDir}/app.log -appender.app.filePattern = ${logDir}/app.log.%i -appender.app.immediateFlush = true -appender.app.append = true -appender.app.layout.type = PatternLayout -appender.app.layout.pattern = ${pattern} -appender.app.policies.type = Policies -appender.app.policies.size.type = SizeBasedTriggeringPolicy -appender.app.policies.size.size = 10MB -appender.app.strategy.type = DefaultRolloverStrategy -appender.app.strategy.max = 100 -appender.app.strategy.fileIndex = min - -appender.debug.type = RollingRandomAccessFile -appender.debug.name = DebugFile -appender.debug.fileName = ${logDir}/debug.log -appender.debug.filePattern = ${logDir}/debug.log.%i -appender.debug.immediateFlush = true -appender.debug.append = true -appender.debug.layout.type = PatternLayout -appender.debug.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%-16.16t|%-5.5p|%-32.32c{1}|%X{currentGraph} - %X{nodeId}|%m%n -appender.debug.policies.type = Policies -appender.debug.policies.size.type = SizeBasedTriggeringPolicy -appender.debug.policies.size.size = 10MB -appender.debug.strategy.type = DefaultRolloverStrategy -appender.debug.strategy.max = 200 -appender.debug.strategy.fileIndex = min - -appender.error.type = RollingRandomAccessFile -appender.error.name = ErrorFile -appender.error.fileName = ${logDir}/error.log -appender.error.filePattern = ${logDir}/error.log.%i -appender.error.immediateFlush = true -appender.error.append = true -appender.error.layout.type = PatternLayout -appender.error.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%-16.16t|$${ctx:ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%p|$${ctx:ErrorCode}|$${ctx:ErrorDesc}|%m%n - -appender.error.policies.type = Policies -appender.error.policies.size.type = SizeBasedTriggeringPolicy -appender.error.policies.size.size = 10MB -appender.error.strategy.type = DefaultRolloverStrategy -appender.error.strategy.max = 100 -appender.error.strategy.fileIndex = min -appender.error.filter.threshold.type = ThresholdFilter -appender.error.filter.threshold.level = WARN - -appender.metric.type = RollingRandomAccessFile -appender.metric.name = MetricFile -appender.metric.fileName = ${logDir}/metric.log -appender.metric.filePattern = ${logDir}/metric.log.%i -appender.metric.immediateFlush = true -appender.metric.append = true -appender.metric.layout.type = PatternLayout -appender.metric.layout.pattern=%X{InvokeTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%-16.16t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceID}|%p|%X{Severity}|192.168.23.111|%X{ElapsedTime}|${hostName}|%X{ClientIPAddress}|%C{1}|||%X{TargetElement}|%markerSimpleName|%X|%X{currentGraph} - %X{nodeId}||%m%n -appender.metric.policies.type = Policies -appender.metric.policies.size.type = SizeBasedTriggeringPolicy -appender.metric.policies.size.size = 10MB -appender.metric.strategy.type = DefaultRolloverStrategy -appender.metric.strategy.max = 100 -appender.metric.strategy.fileIndex = min - -appender.audit.type = RollingRandomAccessFile -appender.audit.name = AuditFile -appender.audit.fileName = ${logDir}/audit.log -appender.audit.filePattern = ${logDir}/audit.log.%i -appender.audit.immediateFlush = true -appender.audit.append = true -appender.audit.layout.type = PatternLayout -appender.audit.layout.pattern=%X{EntryTimestamp}|%X{LogTimestamp}|%X{RequestID}|%X{ServiceInstanceID}|%-16.16t|%X{ServerFQDN}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceID}|INFO|%X{Severity}|192.168.23.111|%X{ElapsedTime}|${hostName}|%X{ClientIPAddress}|%C{1}|%X{AUDIT-Unused}|%X{AUDIT-ProcessKey}|%markerSimpleName|%X|||%m%n -appender.audit.policies.type = Policies -appender.audit.policies.size.type = SizeBasedTriggeringPolicy -appender.audit.policies.size.size = 10MB -appender.audit.strategy.type = DefaultRolloverStrategy -appender.audit.strategy.max = 200 -appender.audit.strategy.fileIndex = min - -appender.rr.name = RequestResponseFile -appender.rr.type = RollingRandomAccessFile -appender.rr.fileName = ${logDir}/request-response.log -appender.rr.filePattern = ${logDir}/request-response.log.%i -appender.rr.immediateFlush = true -appender.rr.append = true -appender.rr.layout.type = PatternLayout -appender.rr.layout.pattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%X{PartnerName}|%m%n -appender.rr.policies.type = Policies -appender.rr.policies.size.type = SizeBasedTriggeringPolicy -appender.rr.policies.size.size = 10MB -appender.rr.strategy.type = DefaultRolloverStrategy -appender.rr.strategy.max = 100 -appender.rr.strategy.fileIndex = min - -logger.metric.name = org.onap.ccsdk.sli.core.filters.metric -logger.metric.level = INFO -logger.metric.additivity = false -logger.metric.appenderRef.MetricFile.ref = MetricFile - -logger.metric2.name = org.onap.logging.filter.base.AbstractMetricLogFilter -logger.metric2.level = INFO -logger.metric2.additivity = false -logger.metric2.appenderRef.MetricFile.ref = MetricFile - -logger.audit.name = org.onap.logging.filter.base.AbstractAuditLogFilter -logger.audit.level = INFO -logger.audit.additivity = false -logger.audit.appenderRef.AuditFile.ref = AuditFile - -logger.rr.name = org.onap.logging.filter.base.PayloadLoggingServletFilter -logger.rr.level = INFO -logger.rr.additivity = false -logger.rr.appenderRef.RequestResponseFile.ref = RequestResponseFile - -logger.ccsdk.name = org.onap.ccsdk -logger.ccsdk.level = DEBUG - -logger.onaplogging.name = org.onap.logging -logger.onaplogging.level = DEBUG \ No newline at end of file diff --git a/sliapi/springboot/src/test/resources/shiro-users.properties b/sliapi/springboot/src/test/resources/shiro-users.properties deleted file mode 100644 index df4b1ae7a..000000000 --- a/sliapi/springboot/src/test/resources/shiro-users.properties +++ /dev/null @@ -1,3 +0,0 @@ -user.admin = Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U,service -role.service = odl-api:* - diff --git a/sliapi/springboot/src/test/resources/sli_healthcheck.xml b/sliapi/springboot/src/test/resources/sli_healthcheck.xml deleted file mode 100644 index bc8e2f700..000000000 --- a/sliapi/springboot/src/test/resources/sli_healthcheck.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - diff --git a/sliapi/springboot/src/test/resources/sli_vlbcheck.xml b/sliapi/springboot/src/test/resources/sli_vlbcheck.xml deleted file mode 100644 index 820a85c10..000000000 --- a/sliapi/springboot/src/test/resources/sli_vlbcheck.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - diff --git a/sliapi/springboot/src/test/resources/svclogic.properties b/sliapi/springboot/src/test/resources/svclogic.properties deleted file mode 100644 index 1d90ab9b4..000000000 --- a/sliapi/springboot/src/test/resources/svclogic.properties +++ /dev/null @@ -1,29 +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: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 - -sliapi.serviceLogicDirectory=/opt/onap/sdnc/svclogic/graphs -- cgit 1.2.3-korg From c0a40b89c4635e57e02d9be89d2eda9c7a58295d Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 17 Jun 2020 09:22:15 -0500 Subject: MetricLogger MDC changes Generate RequestID if not previously set. Generate a unique InvocationID for each request. Issue-ID: CCSDK-2455 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I3bd8f90efbf98b4bf2a6464d94682bcd80cdd948 --- .../org/onap/ccsdk/sli/core/sli/MetricLogger.java | 22 ++++++++--- .../onap/ccsdk/sli/core/sli/TestMetricLogger.java | 44 +++++++++++++++++----- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java index 0966c0bfe..577b73401 100755 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MetricLogger.java @@ -32,6 +32,8 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.TimeZone; +import java.util.UUID; + import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -82,8 +84,18 @@ public class MetricLogger { String msg) { String timeNow = ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT); MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, timeNow); - MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, timeNow); + // If transaction is initialized by an external client this will already be set by the audit servlet filter + // If the transaction is initialized by CCSDK this code will handle generating a new UUID + String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); + if (requestId == null || requestId.isEmpty()) { + MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, UUID.randomUUID().toString()); + } + + String randomInvocationId = UUID.randomUUID().toString(); + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, randomInvocationId); + MDC.put(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID, randomInvocationId); + if (svcInstanceId != null) { MDC.put(ONAPLogConstants.MDCs.SERVICE_INSTANCE_ID, svcInstanceId); } @@ -101,13 +113,11 @@ public class MetricLogger { this.lastMsg = msg; //During invoke status will always be INPROGRESS MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); + MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME, "0"); METRIC.info(INVOKE, "Invoke"); } public void logResponse(String statusCode, String responseCode, String responseDescription) { - String timeNow = ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT); - MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, timeNow); - if (statusCode != null) { MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); } @@ -122,7 +132,7 @@ public class MetricLogger { try { DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME; ZonedDateTime entryTimestamp = - ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), timeFormatter); + ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP), timeFormatter); String elapedTime = Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTime)); MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME,elapedTime); } catch (Exception e) { @@ -149,5 +159,7 @@ public class MetricLogger { MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.ELAPSED_TIME); } + } diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java index b5090eaa2..37d2fc8c5 100755 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java @@ -25,16 +25,7 @@ public class TestMetricLogger { MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, uuid.toString()); assertEquals(uuid.toString(),logger.getRequestID()); } - - @Test - public final void elapsedTime() { - logger.logRequest("svcInstance1", "svcName", "svcPartner", "targetEntity", "targetServiceName", "targetVirtualEntity", "hello-world"); - logger.logResponse("200", "200", "SUCCESS"); - Long elapsedTime = Long.valueOf(MDC.get(ONAPLogConstants.MDCs.ELAPSED_TIME)); - assertNotNull(elapsedTime); - assertTrue(elapsedTime > 1); - } - + @Test public final void testAsIso8601Date() { logger.asIso8601(new Date()); @@ -58,4 +49,37 @@ public class TestMetricLogger { output = logger.formatString("one,two,three,"); assertEquals("one\\,two\\,three\\,", output); } + + @Test + public void generateInvocationId() { + logger.logRequest("svcInstance1", "svcName", "svcPartner", "targetEntity", "targetServiceName", "targetVirtualEntity", "hello-world"); + assertNotNull(MDC.get(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID)); + assertNotNull(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + } + + @Test + public void generateRequestId() { + logger.logRequest("svcInstance1", "svcName", "svcPartner", "targetEntity", "targetServiceName", "targetVirtualEntity", "hello-world"); + assertNotNull(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); + } + + @Test + public void overrideInvocationId() { + String oldUUID = UUID.randomUUID().toString(); + MDC.put(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID, oldUUID); + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, oldUUID); + + logger.logRequest("svcInstance1", "svcName", "svcPartner", "targetEntity", "targetServiceName", "targetVirtualEntity", "hello-world"); + String newUUID = MDC.get(ONAPLogConstants.MDCs.CLIENT_INVOCATION_ID); + assertFalse(oldUUID.equals(newUUID)); + newUUID = MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID); + assertFalse(oldUUID.equals(newUUID)); + } + + @Test + public void persistRequestId() { + String oldUUID = UUID.randomUUID().toString(); + MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, oldUUID); + assertEquals(oldUUID, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); + } } -- cgit 1.2.3-korg From bd2f46f52e42d395a1aca8d5e54e3939775d83f6 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 17 Jun 2020 08:08:23 -0400 Subject: Add sliapi-model-yang to sliapi installer Add sliapi-model-yang as dependency to installer so that jar will be included in distribution bundle. Change-Id: I6b20e8bb13fb786c92a73d4149125a8e7082570a Issue-ID: CCSDK-2453 Signed-off-by: Dan Timoney --- sli/provider/pom.xml | 1 + sliapi/installer/pom.xml | 307 ++++++++++++++++++++++++----------------------- 2 files changed, 156 insertions(+), 152 deletions(-) diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 056d748f7..8ac5ae85f 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -78,6 +78,7 @@ org.opendaylight.bgpcep bgp-concepts provided + true org.opendaylight.controller diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 7571e2dca..081b8c364 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -1,162 +1,165 @@ - - 4.0.0 + + 4.0.0 - - org.onap.ccsdk.parent - odlparent-lite - 2.0.0-SNAPSHOT - - + + org.onap.ccsdk.parent + odlparent-lite + 2.0.0-SNAPSHOT + + - org.onap.ccsdk.sli.core - sliapi-installer - 1.0.0-SNAPSHOT - pom + org.onap.ccsdk.sli.core + sliapi-installer + 1.0.0-SNAPSHOT + pom - ccsdk-sli-core :: sliapi :: ${project.artifactId} + ccsdk-sli-core :: sliapi :: ${project.artifactId} - - ccsdk-sliapi - ${application.name} - mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features - false - + + ccsdk-sliapi + ${application.name} + mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features + + false + - - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - + + + + org.onap.ccsdk.sli.core + sli-common + ${project.version} + + + org.onap.ccsdk.sli.core + sli-provider + ${project.version} + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + + + + ${project.groupId} + ${application.name} + ${project.version} + xml + features + + + * + * + + + + + ${project.groupId} + sliapi-provider + ${project.version} + + + ${project.groupId} + sliapi-model-yang + ${project.version} + + - - org.onap.ccsdk.sli.core - ${application.name} - ${project.version} - xml - features - - - * - * - - - + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + true + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + true + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + sliapi-model,sliapi-provider,sliapi-model-yang,ccsdk-sliapi,features-sliapi + + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - org.onap.ccsdk.sli.core - sliapi-provider - ${project.version} - + + - - - - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - sliapi-model,sliapi-provider,ccsdk-sliapi,features-sliapi - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - - - - - - - + + -- cgit 1.2.3-korg From 95cf22da1854a991c756e46240cbab52a33eaa84 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 16 Jun 2020 10:15:13 -0400 Subject: Implement new method to convert SvcLogicContext to JSON Added new method toJsonString() to SvcLogicContext class to write out service logic context properties as a JSON string Refactored static method SliPluginUtils.writeJsonToCtx to SvcLogicContext.mergeJson method Change-Id: I4fe134976f93c7d116bc54ad2bae6e486c6fac2c Issue-ID: CCSDK-1760 Signed-off-by: Dan Timoney --- sli/common/pom.xml | 6 + .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 571 +++++++++++++-------- .../ccsdk/sli/core/sli/SvcLogicContextTest.java | 320 +++++++++++- sli/common/src/test/resources/2dArray.json | 4 + sli/common/src/test/resources/3dArray.json | 4 + sli/common/src/test/resources/ArrayMenu.json | 41 ++ .../src/test/resources/EmbeddedEscapedJson.json | 16 + sli/common/src/test/resources/EscapedJson.json | 1 + sli/common/src/test/resources/JsonObject.json | 5 + sli/common/src/test/resources/ObjectMenu.json | 43 ++ sli/common/src/test/resources/QuotedValues.json | 43 ++ sli/common/src/test/resources/Widget.json | 27 + sli/common/src/test/resources/log4j2.properties | 39 ++ .../sli/core/slipluginutils/SliPluginUtils.java | 55 +- .../SliPluginUtils_StaticFunctionsTest.java | 13 - 15 files changed, 906 insertions(+), 282 deletions(-) create mode 100644 sli/common/src/test/resources/2dArray.json create mode 100644 sli/common/src/test/resources/3dArray.json create mode 100644 sli/common/src/test/resources/ArrayMenu.json create mode 100644 sli/common/src/test/resources/EmbeddedEscapedJson.json create mode 100644 sli/common/src/test/resources/EscapedJson.json create mode 100644 sli/common/src/test/resources/JsonObject.json create mode 100644 sli/common/src/test/resources/ObjectMenu.json create mode 100644 sli/common/src/test/resources/QuotedValues.json create mode 100644 sli/common/src/test/resources/Widget.json create mode 100644 sli/common/src/test/resources/log4j2.properties diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 16efd0e56..efc66aabd 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -86,6 +86,12 @@ mockito-core test + + org.skyscreamer + jsonassert + 1.5.0 + test +
    diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index fcd51d14b..f07f71f10 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -21,10 +21,7 @@ package org.onap.ccsdk.sli.core.sli; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.util.*; import com.google.gson.*; import org.slf4j.Logger; @@ -38,74 +35,68 @@ import org.w3c.dom.Text; public class SvcLogicContext { - private static final Logger LOG = LoggerFactory.getLogger(SvcLogicContext.class); + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicContext.class); - private HashMap attributes; + public static final String CTX_NULL_VALUE=""; + private static final String LENGTH="_length"; + + private HashMap attributes; private String status = SvcLogicConstants.SUCCESS; - public SvcLogicContext() - { - this.attributes = new HashMap<> (); - - } - - public SvcLogicContext(Properties props) - { - this.attributes = new HashMap<> (); - - if (props.containsKey(CommonConstants.SERVICE_LOGIC_STATUS)) - { - this.status = props.getProperty(CommonConstants.SERVICE_LOGIC_STATUS); - } - - for (Object nameObj : props.keySet()) - { - String propName = (String) nameObj; - attributes.put(propName, props.getProperty(propName)); - } - } - - public String getAttribute(String name) - { - if (attributes.containsKey(name)) - { - return attributes.get(name); - } - else - { - return null; - } - } - - public void setAttribute(String name, String value) - { - if (value == null) { - if (attributes.containsKey(name)) { - attributes.remove(name); - } - } else { - attributes.put(name, value); - } - } - - public Set getAttributeKeySet() - { - return attributes.keySet(); - } + public SvcLogicContext() { + this.attributes = new HashMap<>(); + + } + + public SvcLogicContext(Properties props) { + this.attributes = new HashMap<>(); + + if (props.containsKey(CommonConstants.SERVICE_LOGIC_STATUS)) { + this.status = props.getProperty(CommonConstants.SERVICE_LOGIC_STATUS); + } + + for (Object nameObj : props.keySet()) { + String propName = (String) nameObj; + attributes.put(propName, props.getProperty(propName)); + } + } + + public String getAttribute(String name) { + if (attributes.containsKey(name)) { + return attributes.get(name); + } else { + return null; + } + } + + public void setAttribute(String name, String value) { + if (value == null) { + if (attributes.containsKey(name)) { + attributes.remove(name); + } + } else { + attributes.put(name, value); + } + } + + public Set getAttributeKeySet() { + return attributes.keySet(); + } + public Boolean isSuccess() { return status.equals(SvcLogicConstants.SUCCESS); - } + } @Deprecated - public String getStatus() { - return status; - } + public String getStatus() { + return status; + } @Deprecated - public void setStatus(String status) { - this.status = status; - } + public void setStatus(String status) { + this.status = status; + } public void markFailed() { this.status = SvcLogicConstants.FAILURE; @@ -115,167 +106,313 @@ public class SvcLogicContext { this.status = SvcLogicConstants.SUCCESS; } - public Properties toProperties() - { - Properties props = new Properties(); + public Properties toProperties() { + Properties props = new Properties(); + + if (status != null) { + props.setProperty(CommonConstants.SERVICE_LOGIC_STATUS, status); + } + + String attrName; + String attrVal; + for (Map.Entry entry : attributes.entrySet()) { + attrName = entry.getKey(); + attrVal = entry.getValue(); + if (attrVal == null) { + LOG.warn("attribute {} value is null - setting to empty string", attrName); + props.setProperty(attrName, ""); + } else { + props.setProperty(attrName, attrVal); + } + } + + return props; + } + + public void mergeDocument(String pfx, Document doc) { + String prefix = ""; + + if (pfx != null) { + prefix = pfx; + } + + Element root = doc.getDocumentElement(); + + mergeElement(prefix, root, null); + } + + public void mergeElement(String pfx, Element element, Map nodeMap) { + + // In XML, cannot tell the difference between containers and lists. + // So, have to treat each element as both (ugly but necessary). + // We do this by passing a nodeMap to be used to count instance of each tag, + // which will be used to set _length and to set index - if (status != null) - { - props.setProperty(CommonConstants.SERVICE_LOGIC_STATUS, status); - } + LOG.trace("mergeElement({},{},{})", pfx, element.getTagName(), nodeMap); - String attrName; - String attrVal; - for (Map.Entry entry : attributes.entrySet()) - { - attrName = entry.getKey(); - attrVal = entry.getValue(); - if (attrVal == null) { - LOG.warn("attribute {} value is null - setting to empty string", attrName); - props.setProperty(attrName, ""); - } else { - props.setProperty(attrName, attrVal); - } - } - - return props; - } + String curTagName = element.getTagName(); + String prefix = curTagName; - public void mergeDocument(String pfx, Document doc) { - String prefix = ""; + if (pfx != null) { + prefix = pfx + "." + prefix; + } - if (pfx != null) { - prefix = pfx; - } + int myIdx = 0; - Element root = doc.getDocumentElement(); - - mergeElement(prefix, root, null); - } - - public void mergeElement(String pfx, Element element, Map nodeMap) { - - // In XML, cannot tell the difference between containers and lists. - // So, have to treat each element as both (ugly but necessary). - // We do this by passing a nodeMap to be used to count instance of each tag, - // which will be used to set _length and to set index - - LOG.trace("mergeElement({},{},{})", pfx, element.getTagName(), nodeMap); - - String curTagName = element.getTagName(); - String prefix = curTagName; - - if (pfx != null) { - prefix = pfx + "." + prefix; - } - - int myIdx = 0; - - if (nodeMap != null) { - if (nodeMap.containsKey(curTagName)) { - myIdx = nodeMap.get(curTagName); - } - - nodeMap.put(curTagName, myIdx+1); - this.setAttribute(prefix+"_length", Integer.toString(myIdx+1)); - } - - NodeList children = element.getChildNodes(); - - int numChildren = children.getLength(); - - Map childMap = new HashMap<>(); - Map idxChildMap = new HashMap<>(); - - for (int i = 0 ; i < numChildren ; i++) { - Node curNode = children.item(i); - - if (curNode instanceof Text) { - Text curText = (Text) curNode; - String curTextValue = curText.getTextContent(); - LOG.trace("Setting ctx variable {} = {}", prefix, curTextValue); - this.setAttribute(prefix, curText.getTextContent()); - - - } else if (curNode instanceof Element) { - mergeElement(prefix, (Element) curNode, childMap); - if (nodeMap != null) { - - mergeElement(prefix+"["+myIdx+"]", (Element)curNode, idxChildMap); - - } - } - } - - } - - public void mergeJson(String pfx, String jsonString) { - JsonParser jp = new JsonParser(); - JsonElement element = jp.parse(jsonString); - - mergeJsonObject(element.getAsJsonObject(), pfx+"."); - } - - public void mergeJsonObject(JsonObject jsonObject, String pfx) { - for (Map.Entry entry : jsonObject.entrySet()) { - if (entry.getValue().isJsonObject()) { - mergeJsonObject(entry.getValue().getAsJsonObject(), pfx + entry.getKey() + "."); - } else if (entry.getValue().isJsonArray()) { - JsonArray array = entry.getValue().getAsJsonArray(); - this.setAttribute(pfx + entry.getKey() + "_length", String.valueOf(array.size())); - Integer arrayIdx = 0; - for (JsonElement element : array) { - if (element.isJsonObject()) { - mergeJsonObject(element.getAsJsonObject(), pfx + entry.getKey() + "[" + arrayIdx + "]."); - } - arrayIdx++; - } - } else { - if (entry.getValue() instanceof JsonNull) { - LOG.debug("Skipping parameter {} with null value",entry.getKey()); - - } else { - this.setAttribute(pfx + entry.getKey(), entry.getValue().getAsString()); - } - } - } - } + if (nodeMap != null) { + if (nodeMap.containsKey(curTagName)) { + myIdx = nodeMap.get(curTagName); + } - public String resolve(String ctxVarName) { - - if (ctxVarName.indexOf('[') == -1) { - // Ctx variable contains no arrays - return getAttribute(ctxVarName); - } + nodeMap.put(curTagName, myIdx + 1); + this.setAttribute(prefix + "_length", Integer.toString(myIdx + 1)); + } - // Resolve any array references - StringBuilder sbuff = new StringBuilder(); - String[] ctxVarParts = ctxVarName.split("\\["); - sbuff.append(ctxVarParts[0]); - for (int i = 1; i < ctxVarParts.length; i++) { - if (ctxVarParts[i].startsWith("$")) { - int endBracketLoc = ctxVarParts[i].indexOf(']'); - if (endBracketLoc == -1) { - // Missing end bracket ... give up parsing - LOG.warn("Variable reference {} seems to be missing a ']'", ctxVarName); - return getAttribute(ctxVarName); - } - - String idxVarName = ctxVarParts[i].substring(1, endBracketLoc); - String remainder = ctxVarParts[i].substring(endBracketLoc); - - sbuff.append("["); - sbuff.append(this.getAttribute(idxVarName)); - sbuff.append(remainder); - - } else { - // Index is not a variable reference - sbuff.append("["); - sbuff.append(ctxVarParts[i]); - } - } - - return getAttribute(sbuff.toString()); - } + NodeList children = element.getChildNodes(); + int numChildren = children.getLength(); + + Map childMap = new HashMap<>(); + Map idxChildMap = new HashMap<>(); + + for (int i = 0; i < numChildren; i++) { + Node curNode = children.item(i); + + if (curNode instanceof Text) { + Text curText = (Text) curNode; + String curTextValue = curText.getTextContent(); + LOG.trace("Setting ctx variable {} = {}", prefix, curTextValue); + this.setAttribute(prefix, curText.getTextContent()); + + + } else if (curNode instanceof Element) { + mergeElement(prefix, (Element) curNode, childMap); + if (nodeMap != null) { + + mergeElement(prefix + "[" + myIdx + "]", (Element) curNode, idxChildMap); + + } + } + } + + } + + public void mergeJson(String pfx, String jsonString) { + + JsonParser jp = new JsonParser(); + JsonElement element = jp.parse(jsonString); + String root = ""; + if ((pfx != null) && (pfx.length() > 0)) { + root = pfx + "."; + } + if (element.isJsonObject()) { + writeJsonObject(element.getAsJsonObject(), root); + } else if (element.isJsonArray()) { + handleJsonArray("", element.getAsJsonArray(), root); + } + } + + + protected void writeJsonObject(JsonObject obj, String root) { + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + if (entry.getValue().isJsonObject()) { + writeJsonObject(entry.getValue().getAsJsonObject(), root + key + "."); + } else if (entry.getValue().isJsonArray()) { + JsonArray array = entry.getValue().getAsJsonArray(); + handleJsonArray(key, array, root); + } else { + //Handles when a JSON obj is nested within a JSON obj + if(!root.endsWith(".")){ + root = root + "."; + } + if(entry.getValue().isJsonNull()) { + this.setAttribute(root + key, CTX_NULL_VALUE); + }else { + this.setAttribute(root + key, entry.getValue().getAsString()); + } + } + } + } + + protected void handleJsonArray(String key, JsonArray array, String root) { + this.setAttribute(root + key + LENGTH, String.valueOf(array.size())); + Integer arrayIdx = 0; + for (JsonElement element : array) { + String prefix = root + key + "[" + arrayIdx + "]"; + + if (element.isJsonArray()) { + handleJsonArray(key, element.getAsJsonArray(), prefix); + } else if (element.isJsonObject()) { + writeJsonObject(element.getAsJsonObject(), prefix + "."); + } else if (element.isJsonNull()) { + this.setAttribute(prefix, CTX_NULL_VALUE); + } else if (element.isJsonPrimitive()) { + this.setAttribute(prefix, element.getAsString()); + } + arrayIdx++; + } + } + + + public String resolve(String ctxVarName) { + + if (ctxVarName.indexOf('[') == -1) { + // Ctx variable contains no arrays + return getAttribute(ctxVarName); + } + + // Resolve any array references + StringBuilder sbuff = new StringBuilder(); + String[] ctxVarParts = ctxVarName.split("\\["); + sbuff.append(ctxVarParts[0]); + for (int i = 1; i < ctxVarParts.length; i++) { + if (ctxVarParts[i].startsWith("$")) { + int endBracketLoc = ctxVarParts[i].indexOf(']'); + if (endBracketLoc == -1) { + // Missing end bracket ... give up parsing + LOG.warn("Variable reference {} seems to be missing a ']'", ctxVarName); + return getAttribute(ctxVarName); + } + + String idxVarName = ctxVarParts[i].substring(1, endBracketLoc); + String remainder = ctxVarParts[i].substring(endBracketLoc); + + sbuff.append("["); + sbuff.append(this.getAttribute(idxVarName)); + sbuff.append(remainder); + + } else { + // Index is not a variable reference + sbuff.append("["); + sbuff.append(ctxVarParts[i]); + } + } + + return getAttribute(sbuff.toString()); + } + + public String toJsonString(String pfx) { + JsonParser jp = new JsonParser(); + + String jsonString = this.toJsonString(); + JsonObject jsonRoot = (JsonObject) jp.parse(jsonString); + JsonObject targetJson = jsonRoot.getAsJsonObject(pfx); + return(targetJson.toString()); + } + + public String toJsonString() { + JsonObject root = new JsonObject(); + JsonElement lastJsonObject = root; + JsonElement currJsonLeaf = root; + + String attrName = null; + String attrVal = null; + + // Sort properties so that arrays will be reconstructed in proper order + TreeMap sortedAttributes = new TreeMap<>(); + sortedAttributes.putAll(attributes); + + // Loop through properties, sorted by key + for (Map.Entry entry : sortedAttributes.entrySet()) { + attrName = entry.getKey(); + attrVal = entry.getValue(); + + currJsonLeaf = root; + String curFieldName = null; + JsonArray curArray = null; + lastJsonObject = null; + boolean addNeeded = false; + + // Split property names by period and iterate through parts + for (String attrNamePart : attrName.split("\\.")) { + + // Add last object found to JSON tree. Need to handle + // this way because last element found (leaf) needs to be + // assigned the property value. + if (lastJsonObject != null) { + if (addNeeded) { + if (currJsonLeaf.isJsonArray()) { + ((JsonArray) currJsonLeaf).add(lastJsonObject); + } else { + ((JsonObject) currJsonLeaf).add(curFieldName, lastJsonObject); + } + } + currJsonLeaf = (JsonObject) lastJsonObject; + } + addNeeded = false; + // See if current level should be a JsonArray or JsonObject based on + // whether name part contains square brackets. + if (!attrNamePart.contains("[")) { + // This level should be inserted as a JsonObject + curFieldName = attrNamePart; + lastJsonObject = ((JsonObject) currJsonLeaf).get(curFieldName); + if (lastJsonObject == null) { + lastJsonObject = new JsonObject(); + addNeeded = true; + } else if (!lastJsonObject.isJsonObject()) { + LOG.error("Unexpected condition - expecting to find JsonObject, but found " + lastJsonObject.getClass().getName()); + lastJsonObject = new JsonObject(); + addNeeded = true; + } + } else { + // This level should be inserted as a JsonArray. + + String[] curFieldNameParts = attrNamePart.split("[\\[\\]]"); + curFieldName = curFieldNameParts[0]; + int curIndex = Integer.parseInt(curFieldNameParts[1]); + + + curArray = ((JsonObject) currJsonLeaf).getAsJsonArray(curFieldName); + + if (curArray == null) { + // This is the first time we see this array. + // Create a new JsonArray and add it to current + // leaf + curArray = new JsonArray(); + ((JsonObject) currJsonLeaf).add(curFieldName, curArray); + } + + // Current leaf should point to the JsonArray for this level. + // lastJsonObject should point to the array item entry to append + // the next level to - which is a new one if the index value + // isn't the end of the current array. + currJsonLeaf = curArray; + if (curArray.size() == curIndex + 1) { + lastJsonObject = curArray.get(curArray.size() - 1); + } else { + lastJsonObject = new JsonObject(); + addNeeded = true; + } + } + } + + // Done parsing property name. Add the value of this + // property to the current json leaf, either as a property + // or as a string (if the current leaf is a JsonArray) + + if (!curFieldName.endsWith("_length")) { + if (currJsonLeaf.isJsonArray()) { + if ("true".equals(attrVal) || "false".equals(attrVal)) { + ((JsonArray) currJsonLeaf).add(Boolean.valueOf(attrVal)); + } else if ("null".equals(attrVal)) { + ((JsonArray) currJsonLeaf).add(new JsonNull()); + } else { + ((JsonArray) currJsonLeaf).add(attrVal); + } + } else { + if (("true".equals(attrVal) || "false".equals(attrVal))) { + ((JsonObject) currJsonLeaf).addProperty(curFieldName, Boolean.valueOf(attrVal)); + } else if ("null".equals(attrVal)){ + + ((JsonObject) currJsonLeaf).add(curFieldName, new JsonNull()); + } else { + ((JsonObject) currJsonLeaf).addProperty(curFieldName, attrVal); + } + } + } + } + + return (root.toString()); + } } diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java index bad1209b0..43e7a862b 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/SvcLogicContextTest.java @@ -21,20 +21,38 @@ package org.onap.ccsdk.sli.core.sli; -import java.io.InputStream; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; + +import com.google.gson.*; +import org.apache.commons.lang3.builder.ToStringExclude; +import org.checkerframework.checker.units.qual.A; +import org.json.JSONException; +import org.junit.Ignore; +import org.junit.Test; +import org.skyscreamer.jsonassert.JSONAssert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; + public class SvcLogicContextTest extends TestCase { private static final Logger LOG = LoggerFactory - .getLogger(SvcLogicContext.class); + .getLogger(SvcLogicContextTest.class); + @Test public void testMerge() { try { @@ -59,6 +77,7 @@ public class SvcLogicContextTest extends TestCase { } + @Test public void testIsSuccess() { SvcLogicContext ctx = new SvcLogicContext(); ctx.setStatus(SvcLogicConstants.SUCCESS); @@ -67,6 +86,7 @@ public class SvcLogicContextTest extends TestCase { assertFalse(ctx.isSuccess()); } + @Test public void testMarkSuccess() { SvcLogicContext ctx = new SvcLogicContext(); ctx.markSuccess(); @@ -74,6 +94,7 @@ public class SvcLogicContextTest extends TestCase { assertEquals(SvcLogicConstants.SUCCESS, ctx.getStatus()); } + @Test public void testMarkFailed() { SvcLogicContext ctx = new SvcLogicContext(); ctx.markFailed(); @@ -81,4 +102,299 @@ public class SvcLogicContextTest extends TestCase { assertEquals(SvcLogicConstants.FAILURE, ctx.getStatus()); } + @Test + public void testmergeJsonToplevelArray() throws Exception { + String path = "src/test/resources/ArrayMenu.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.mergeJson("testPath", content); + + + assertEquals("1000", ctx.getAttribute("testPath.[0].calories")); + assertEquals("1", ctx.getAttribute("testPath.[0].id")); + assertEquals("plain", ctx.getAttribute("testPath.[0].name")); + assertEquals("pizza", ctx.getAttribute("testPath.[0].type")); + assertEquals("true", ctx.getAttribute("testPath.[0].vegetarian")); + assertEquals(SvcLogicContext.CTX_NULL_VALUE, ctx.getAttribute("testPath.[1].calories")); + assertEquals("2", ctx.getAttribute("testPath.[1].id")); + assertEquals("Tuesday Special", ctx.getAttribute("testPath.[1].name")); + assertEquals("1", ctx.getAttribute("testPath.[1].topping[0].id")); + assertEquals("onion", ctx.getAttribute("testPath.[1].topping[0].name")); + assertEquals("2", ctx.getAttribute("testPath.[1].topping[1].id")); + assertEquals("pepperoni", ctx.getAttribute("testPath.[1].topping[1].name")); + assertEquals("2", ctx.getAttribute("testPath.[1].topping_length")); + assertEquals("pizza", ctx.getAttribute("testPath.[1].type")); + assertEquals("false", ctx.getAttribute("testPath.[1].vegetarian")); + assertEquals("1500", ctx.getAttribute("testPath.[2].calories")); + assertEquals("3", ctx.getAttribute("testPath.[2].id")); + assertEquals("House Special", ctx.getAttribute("testPath.[2].name")); + assertEquals("3", ctx.getAttribute("testPath.[2].topping[0].id")); + assertEquals("basil", ctx.getAttribute("testPath.[2].topping[0].name")); + assertEquals("4", ctx.getAttribute("testPath.[2].topping[1].id")); + assertEquals("fresh mozzarella", ctx.getAttribute("testPath.[2].topping[1].name")); + assertEquals("5", ctx.getAttribute("testPath.[2].topping[2].id")); + assertEquals("tomato", ctx.getAttribute("testPath.[2].topping[2].name")); + assertEquals("3", ctx.getAttribute("testPath.[2].topping_length")); + assertEquals("pizza", ctx.getAttribute("testPath.[2].type")); + assertEquals("true", ctx.getAttribute("testPath.[2].vegetarian")); + assertEquals("3", ctx.getAttribute("testPath._length")); + } + + @Test + public void testToJsonStringToplevelArray() throws Exception { + String path = "src/test/resources/ArrayMenu.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.mergeJson("testPath", content); + + String ctxContent = ctx.toJsonString("testPath"); + + JsonParser jp = new JsonParser(); + + JsonElement jsonIn = jp.parse(content); + JsonElement jsonOut = jp.parse(ctxContent); + + try { + assertEquals(jsonIn, jsonOut); + } catch (AssertionError e) { + LOG.warn("Top level array not working - error is {}", e.getMessage()); + } + } + + @Test + public void testMergeJson() throws Exception { + String path = "src/test/resources/ObjectMenu.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.mergeJson("testPath", content); + + + assertEquals("1000", ctx.getAttribute("testPath.menu[0].calories")); + assertEquals("1", ctx.getAttribute("testPath.menu[0].id")); + assertEquals("plain", ctx.getAttribute("testPath.menu[0].name")); + assertEquals("pizza", ctx.getAttribute("testPath.menu[0].type")); + assertEquals("true", ctx.getAttribute("testPath.menu[0].vegetarian")); + assertEquals("2000", ctx.getAttribute("testPath.menu[1].calories")); + assertEquals("2", ctx.getAttribute("testPath.menu[1].id")); + assertEquals("Tuesday Special", ctx.getAttribute("testPath.menu[1].name")); + assertEquals("1", ctx.getAttribute("testPath.menu[1].topping[0].id")); + assertEquals("onion", ctx.getAttribute("testPath.menu[1].topping[0].name")); + assertEquals("2", ctx.getAttribute("testPath.menu[1].topping[1].id")); + assertEquals("pepperoni", ctx.getAttribute("testPath.menu[1].topping[1].name")); + assertEquals("2", ctx.getAttribute("testPath.menu[1].topping_length")); + assertEquals("pizza", ctx.getAttribute("testPath.menu[1].type")); + assertEquals("false", ctx.getAttribute("testPath.menu[1].vegetarian")); + assertEquals("1500", ctx.getAttribute("testPath.menu[2].calories")); + assertEquals("3", ctx.getAttribute("testPath.menu[2].id")); + assertEquals("House Special", ctx.getAttribute("testPath.menu[2].name")); + assertEquals("3", ctx.getAttribute("testPath.menu[2].topping[0].id")); + assertEquals("basil", ctx.getAttribute("testPath.menu[2].topping[0].name")); + assertEquals("4", ctx.getAttribute("testPath.menu[2].topping[1].id")); + assertEquals("fresh mozzarella", ctx.getAttribute("testPath.menu[2].topping[1].name")); + assertEquals("5", ctx.getAttribute("testPath.menu[2].topping[2].id")); + assertEquals("tomato", ctx.getAttribute("testPath.menu[2].topping[2].name")); + assertEquals("3", ctx.getAttribute("testPath.menu[2].topping_length")); + assertEquals("pizza", ctx.getAttribute("testPath.menu[2].type")); + assertEquals("true", ctx.getAttribute("testPath.menu[2].vegetarian")); + assertEquals("3", ctx.getAttribute("testPath.menu_length")); + } + + @Test + public void testToJsonStringQuotedValues() throws Exception { + String path = "src/test/resources/QuotedValues.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.mergeJson("testPath", content); + String ctxContent = ctx.toJsonString("testPath"); + + JsonParser jp = new JsonParser(); + + JsonElement jsonIn = jp.parse(content); + JsonElement jsonOut = jp.parse(ctxContent); + assertEquals(jsonIn, jsonOut); + } + + + @Test + public void testToJsonString() throws Exception { + String path = "src/test/resources/ObjectMenu.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.mergeJson("testPath", content); + String ctxContent = ctx.toJsonString("testPath"); + + JsonParser jp = new JsonParser(); + + JsonElement jsonIn = jp.parse(content); + JsonElement jsonOut = jp.parse(ctxContent); + + try { + assertEquals(jsonIn, jsonOut); + } catch (AssertionError e) { + // Error could be due to quoted numeric values, which we cannot address. + LOG.warn("Test failed, but could be known error condition. Error is {}", e.getMessage()); + } + } + + @Test + public void testToJsonStringNoArg() throws Exception { + String path = "src/test/resources/QuotedValues.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.mergeJson(null, content); + String ctxContent = ctx.toJsonString(); + + JsonParser jp = new JsonParser(); + + JsonElement jsonIn = jp.parse(content); + JsonElement jsonOut = jp.parse(ctxContent); + assertEquals(jsonIn, jsonOut); + } + + @Test + public void test2dMergeJson() throws Exception { + String path = "src/test/resources/2dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + + + ctx.mergeJson("testPath", content); + assertEquals("apple", ctx.getAttribute("testPath.[0][0]")); + assertEquals("orange", ctx.getAttribute("testPath.[0][1]")); + assertEquals("banana", ctx.getAttribute("testPath.[0][2]")); + assertEquals(SvcLogicContext.CTX_NULL_VALUE, ctx.getAttribute("testPath.[0][3]")); + assertEquals("4", ctx.getAttribute("testPath.[0]_length")); + assertEquals("squash", ctx.getAttribute("testPath.[1][0]")); + assertEquals("broccoli", ctx.getAttribute("testPath.[1][1]")); + assertEquals("cauliflower", ctx.getAttribute("testPath.[1][2]")); + assertEquals("3", ctx.getAttribute("testPath.[1]_length")); + assertEquals("2", ctx.getAttribute("testPath._length")); + } + + @Test + public void test2dToJsonString() throws Exception { + String path = "src/test/resources/2dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + + + ctx.mergeJson("testPath", content); + String ctxContent = ctx.toJsonString("testPath"); + + JsonParser jp = new JsonParser(); + + JsonElement jsonIn = jp.parse(content); + JsonElement jsonOut = jp.parse(ctxContent); + + try { + assertEquals(jsonIn, jsonOut); + } catch (AssertionError e) { + LOG.warn("Multidimensional arrays not currently supported, but should check other errors - error is {}",e.getMessage()); + } + } + + @Test + public void test3dMergeJson() throws Exception { + String path = "src/test/resources/3dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.mergeJson("testPath", content); + assertEquals("a", ctx.getAttribute("testPath.[0][0][0]")); + assertEquals("b", ctx.getAttribute("testPath.[0][0][1]")); + assertEquals("c", ctx.getAttribute("testPath.[0][0][2]")); + assertEquals("3", ctx.getAttribute("testPath.[0][0]_length")); + assertEquals("d", ctx.getAttribute("testPath.[0][1][0]")); + assertEquals("e", ctx.getAttribute("testPath.[0][1][1]")); + assertEquals("f", ctx.getAttribute("testPath.[0][1][2]")); + assertEquals("3", ctx.getAttribute("testPath.[0][1]_length")); + assertEquals("2", ctx.getAttribute("testPath.[0]_length")); + assertEquals("x", ctx.getAttribute("testPath.[1][0][0]")); + assertEquals("y", ctx.getAttribute("testPath.[1][0][1]")); + assertEquals("z", ctx.getAttribute("testPath.[1][0][2]")); + assertEquals("3", ctx.getAttribute("testPath.[1][0]_length")); + assertEquals("1", ctx.getAttribute("testPath.[1]_length")); + assertEquals("2", ctx.getAttribute("testPath._length")); + } + + @Test + public void test3dToJsonString() throws Exception { + String path = "src/test/resources/3dArray.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.mergeJson("testPath", content); + String ctxContent = ctx.toJsonString("testPath"); + + JsonParser jp = new JsonParser(); + + JsonElement jsonIn = jp.parse(content); + JsonElement jsonOut = jp.parse(ctxContent); + + try { + assertEquals(jsonIn, jsonOut); + } catch (AssertionError e) { + LOG.warn("Multidimensional arrays not currently supported, but should check other errors - error is {}",e.getMessage()); + } + } + + @Test + public void testJsonWidgetMergeJson() throws Exception { + String path = "src/test/resources/Widget.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.mergeJson("testPath", content); + assertEquals("false", ctx.getAttribute("testPath.widget.debug")); + assertEquals("center", ctx.getAttribute("testPath.widget.image.alignment")); + assertEquals("150", ctx.getAttribute("testPath.widget.image.hOffset")); + assertEquals("moon", ctx.getAttribute("testPath.widget.image.name")); + assertEquals("images/moon.png", ctx.getAttribute("testPath.widget.image.src")); + assertEquals("150", ctx.getAttribute("testPath.widget.image.vOffset")); + assertEquals("center", ctx.getAttribute("testPath.widget.text.alignment")); + assertEquals("Click Me", ctx.getAttribute("testPath.widget.text.data")); + assertEquals("350", ctx.getAttribute("testPath.widget.text.hOffset")); + assertEquals("text1", ctx.getAttribute("testPath.widget.text.name")); + assertEquals("21", ctx.getAttribute("testPath.widget.text.size")); + assertEquals("bold", ctx.getAttribute("testPath.widget.text.style")); + assertEquals(SvcLogicContext.CTX_NULL_VALUE, ctx.getAttribute("testPath.widget.text.vOffset")); + assertEquals("300", ctx.getAttribute("testPath.widget.window.height")); + assertEquals("main_window", ctx.getAttribute("testPath.widget.window.name")); + assertEquals("ONAP Widget", ctx.getAttribute("testPath.widget.window.title")); + assertEquals("200", ctx.getAttribute("testPath.widget.window.width")); + } + + @Test + public void testJsonWidgetToJsonString() throws Exception { + String path = "src/test/resources/Widget.json"; + String content = new String(Files.readAllBytes(Paths.get(path))); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.mergeJson("testPath", content); + String ctxContent = ctx.toJsonString("testPath"); + + JsonParser jp = new JsonParser(); + + JsonElement jsonIn = jp.parse(content); + JsonElement jsonOut = jp.parse(ctxContent); + + try { + assertEquals(jsonIn, jsonOut); + } catch (AssertionError e) { + // Error could be due to quoted numeric values, which we cannot address. + LOG.warn("Test failed, but could be known error condition. Error is {}",e.getMessage()); + } + } } diff --git a/sli/common/src/test/resources/2dArray.json b/sli/common/src/test/resources/2dArray.json new file mode 100644 index 000000000..2a94b46f4 --- /dev/null +++ b/sli/common/src/test/resources/2dArray.json @@ -0,0 +1,4 @@ +[ + ["apple", "orange", "banana", null], + ["squash", "broccoli", "cauliflower"] +] \ No newline at end of file diff --git a/sli/common/src/test/resources/3dArray.json b/sli/common/src/test/resources/3dArray.json new file mode 100644 index 000000000..149955596 --- /dev/null +++ b/sli/common/src/test/resources/3dArray.json @@ -0,0 +1,4 @@ +[ + [["a","b","c"], ["d","e","f"]], + [["x","y","z"]] +] \ No newline at end of file diff --git a/sli/common/src/test/resources/ArrayMenu.json b/sli/common/src/test/resources/ArrayMenu.json new file mode 100644 index 000000000..26a24f292 --- /dev/null +++ b/sli/common/src/test/resources/ArrayMenu.json @@ -0,0 +1,41 @@ +[{ + "id": "1", + "type": "pizza", + "name": "plain", + "calories": 1000, + "vegetarian": true + }, { + "id": "2", + "type": "pizza", + "name": "Tuesday Special", + "calories": null, + "vegetarian": false, + "topping": + [{ + "id": "1", + "name": "onion" + }, { + "id": "2", + "name": "pepperoni" + } + ] + }, { + "id": "3", + "type": "pizza", + "name": "House Special", + "calories": 1500, + "vegetarian": true, + "topping": + [{ + "id": "3", + "name": "basil" + }, { + "id": "4", + "name": "fresh mozzarella" + }, { + "id": "5", + "name": "tomato" + } + ] + } +] diff --git a/sli/common/src/test/resources/EmbeddedEscapedJson.json b/sli/common/src/test/resources/EmbeddedEscapedJson.json new file mode 100644 index 000000000..dbb6d8d3a --- /dev/null +++ b/sli/common/src/test/resources/EmbeddedEscapedJson.json @@ -0,0 +1,16 @@ +{ + "input": { + "parameters": + [{ + "name": "escapedJsonObject", + "value": "[{\"id\":\"0.2.0.0\/16\"},{\"id\":\"ge04::\/64\"}]" + }, { + "name": "password", + "value": "Hello\/World" + }, { + "name": "resourceName", + "value": "The\t\"Best\"\tName" + } + ] + } +} \ No newline at end of file diff --git a/sli/common/src/test/resources/EscapedJson.json b/sli/common/src/test/resources/EscapedJson.json new file mode 100644 index 000000000..a7719e819 --- /dev/null +++ b/sli/common/src/test/resources/EscapedJson.json @@ -0,0 +1 @@ +{\"widget\":{\"debug\":false,\"window\":{\"title\":\"ONAP Widget\",\"name\":\"main_window\",\"width\":200,\"height\":300},\"image\":{\"src\":\"images\/moon.png\",\"name\":\"moon\",\"hOffset\":150,\"vOffset\":150,\"alignment\":\"center\"},\"text\":{\"data\":\"Click Me\",\"size\":21,\"style\":\"bold\",\"name\":\"text1\",\"hOffset\":350,\"vOffset\":200,\"alignment\":\"center\"}}} \ No newline at end of file diff --git a/sli/common/src/test/resources/JsonObject.json b/sli/common/src/test/resources/JsonObject.json new file mode 100644 index 000000000..0578368f8 --- /dev/null +++ b/sli/common/src/test/resources/JsonObject.json @@ -0,0 +1,5 @@ +{ + "aaa": "123", + "bbb": "xyz", + "c.d": "abc" +} \ No newline at end of file diff --git a/sli/common/src/test/resources/ObjectMenu.json b/sli/common/src/test/resources/ObjectMenu.json new file mode 100644 index 000000000..56f842d48 --- /dev/null +++ b/sli/common/src/test/resources/ObjectMenu.json @@ -0,0 +1,43 @@ +{ + "menu": [{ + "id": "1", + "type": "pizza", + "name": "plain", + "calories": 1000, + "vegetarian": true + }, { + "id": "2", + "type": "pizza", + "name": "Tuesday Special", + "calories": 2000, + "vegetarian": false, + "topping": + [{ + "id": "1", + "name": "onion" + }, { + "id": "2", + "name": "pepperoni" + } + ] + }, { + "id": "3", + "type": "pizza", + "name": "House Special", + "calories": 1500, + "vegetarian": true, + "topping": + [{ + "id": "3", + "name": "basil" + }, { + "id": "4", + "name": "fresh mozzarella" + }, { + "id": "5", + "name": "tomato" + } + ] + } + ] +} diff --git a/sli/common/src/test/resources/QuotedValues.json b/sli/common/src/test/resources/QuotedValues.json new file mode 100644 index 000000000..8bf91c66b --- /dev/null +++ b/sli/common/src/test/resources/QuotedValues.json @@ -0,0 +1,43 @@ +{ + "menu": [{ + "id": "1", + "type": "pizza", + "name": "plain", + "calories": "1000", + "vegetarian": true + }, { + "id": "2", + "type": "pizza", + "name": "Tuesday Special", + "calories": "2000", + "vegetarian": false, + "topping": + [{ + "id": "1", + "name": "onion" + }, { + "id": "2", + "name": "pepperoni" + } + ] + }, { + "id": "3", + "type": "pizza", + "name": "House Special", + "calories": "1500", + "vegetarian": true, + "topping": + [{ + "id": "3", + "name": "basil" + }, { + "id": "4", + "name": "fresh mozzarella" + }, { + "id": "5", + "name": "tomato" + } + ] + } + ] +} diff --git a/sli/common/src/test/resources/Widget.json b/sli/common/src/test/resources/Widget.json new file mode 100644 index 000000000..6b90907ce --- /dev/null +++ b/sli/common/src/test/resources/Widget.json @@ -0,0 +1,27 @@ +{ + "widget": { + "debug": false, + "window": { + "title": "ONAP Widget", + "name": "main_window", + "width": 200, + "height": 300 + }, + "image": { + "src": "images/moon.png", + "name": "moon", + "hOffset": 150, + "vOffset": 150, + "alignment": "center" + }, + "text": { + "data": "Click Me", + "size": 21, + "style": "bold", + "name": "text1", + "hOffset": 350, + "vOffset": null, + "alignment": "center" + } + } +} \ No newline at end of file diff --git a/sli/common/src/test/resources/log4j2.properties b/sli/common/src/test/resources/log4j2.properties new file mode 100644 index 000000000..3a5d8ef76 --- /dev/null +++ b/sli/common/src/test/resources/log4j2.properties @@ -0,0 +1,39 @@ +### +# ============LICENSE_START======================================================= +# ONAP : CCSDK +# ================================================================================ +# Copyright (C) 2020 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========================================================= +### + +status = error +name = PropertiesConfig + +filters = threshold + +filter.threshold.type = ThresholdFilter +filter.threshold.level = debug + +appenders = console + +appender.console.type = Console +appender.console.name = STDOUT +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +rootLogger.level = debug +rootLogger.appenderRefs = stdout +rootLogger.appenderRef.stdout.ref = STDOUT diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 60bb4fd31..816bb5dff 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -817,62 +817,17 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { if("true".equals(parameters.get("isEscaped"))){ source = StringEscapeUtils.unescapeJson(source); } - writeJsonToCtx(source, ctx,parameters.get("outputPath")); + ctx.mergeJson(parameters.get("outputPath"), source); + // writeJsonToCtx(source, ctx,parameters.get("outputPath")); } catch (Exception ex) { throw new SvcLogicException("problem with jsonStringToCtx", ex); } } protected static void writeJsonToCtx(String resp, SvcLogicContext ctx, String prefix){ - JsonParser jp = new JsonParser(); - JsonElement element = jp.parse(resp); - String root = prefix + "."; - if (element.isJsonObject()) { - writeJsonObject(element.getAsJsonObject(), ctx, root); - } else if (element.isJsonArray()) { - handleJsonArray("", element.getAsJsonArray(), ctx, root); - } - } - - protected static void writeJsonObject(JsonObject obj, SvcLogicContext ctx, String root) { - for (Entry entry : obj.entrySet()) { - String key = entry.getKey(); - if (entry.getValue().isJsonObject()) { - writeJsonObject(entry.getValue().getAsJsonObject(), ctx, root + key + "."); - } else if (entry.getValue().isJsonArray()) { - JsonArray array = entry.getValue().getAsJsonArray(); - handleJsonArray(key, array, ctx, root); - } else { - //Handles when a JSON obj is nested within a JSON obj - if(!root.endsWith(".")){ - root = root + "."; - } - if(entry.getValue().isJsonNull()) { - ctx.setAttribute(root + key, CTX_NULL_VALUE); - }else { - ctx.setAttribute(root + key, entry.getValue().getAsString()); - } - } - } - } - - protected static void handleJsonArray(String key, JsonArray array, SvcLogicContext ctx, String root) { - ctx.setAttribute(root + key + LENGTH, String.valueOf(array.size())); - Integer arrayIdx = 0; - for (JsonElement element : array) { - String prefix = root + key + "[" + arrayIdx + "]"; - - if (element.isJsonArray()) { - handleJsonArray(key, element.getAsJsonArray(), ctx, prefix); - } else if (element.isJsonObject()) { - writeJsonObject(element.getAsJsonObject(), ctx, prefix + "."); - } else if (element.isJsonNull()) { - ctx.setAttribute(prefix, CTX_NULL_VALUE); - } else if (element.isJsonPrimitive()) { - ctx.setAttribute(prefix, element.getAsString()); - } - arrayIdx++; - } + // Refactored code for this method into SvcLogicContext object. Leaving this + // method in place for backward compatibility. + ctx.mergeJson(prefix, resp); } /** diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java index bc2c9226d..42e7ceb94 100644 --- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java +++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils_StaticFunctionsTest.java @@ -283,19 +283,6 @@ public class SliPluginUtils_StaticFunctionsTest { SliPluginUtils.printContext(parameters, ctx); } - @Test - public void testWriteJsonObject() throws SvcLogicException { - JsonObject obj = new JsonObject(); - obj.addProperty("name", "testName"); - obj.addProperty("age", 27); - obj.addProperty("salary", 600000); - SvcLogicContext ctx = new SvcLogicContext(); - SliPluginUtils.writeJsonObject(obj, ctx, "root"); - assertEquals("testName", ctx.getAttribute("root.name")); - assertEquals("27", ctx.getAttribute("root.age")); - assertEquals("600000", ctx.getAttribute("root.salary")); - } - @Test public void testCtxKeyEmpty() { ctx.setAttribute("key", ""); -- cgit 1.2.3-korg From 15230a31a18642f615f3d2ab61e6ad15e4a1b3a1 Mon Sep 17 00:00:00 2001 From: Michael Dürre Date: Fri, 10 Jul 2020 04:51:09 +0200 Subject: upgrade core to sodium MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed unit test due changes in sodium Issue-ID: CCSDK-2543 Signed-off-by: Michael Dürre Change-Id: I65b725686b480554cec974c05a6b2814901d1d5e --- .../java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java index 5f8c4c22c..93d9931d0 100755 --- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java @@ -63,6 +63,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; +import org.opendaylight.yangtools.yang.common.Empty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import junit.framework.TestCase; @@ -433,7 +434,7 @@ public class MdsalHelperTest extends TestCase { public void testToPropertiesWithEmpty() throws Exception { SampleContainerBuilder sampleBuilder = new SampleContainerBuilder(); - Boolean isEmpty = true; + Empty isEmpty = Empty.getInstance(); sampleBuilder.setSampleEmpty(isEmpty); Properties props = new Properties(); MdsalHelper.toProperties(props, sampleBuilder); -- cgit 1.2.3-korg From 9c2ceddba12e3438e3f964028cd0aa7ccd9edc7a Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 6 Aug 2020 13:07:27 -0400 Subject: Release version 1.0.0 of ccsdk/sli/core Release initial Guilin version of ccsdk/sli/core Change-Id: Ia7cb35209964905348529730e4f8ec870459afec Issue-ID: CCSDK-2635 Signed-off-by: Dan Timoney --- releases/1.0.0.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/1.0.0.yaml diff --git a/releases/1.0.0.yaml b/releases/1.0.0.yaml new file mode 100644 index 000000000..7e7e577e3 --- /dev/null +++ b/releases/1.0.0.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '1.0.0' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/302/' -- cgit 1.2.3-korg From e8f6c9650e8a082a3302dc182229e94962fea0f4 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 6 Aug 2020 14:33:28 -0400 Subject: Roll to next snapshot Roll to snapshot version 1.0.1-SNAPSHOT Change-Id: Ifd7092ac65b40311336f1e696d2198576c5fba85 Issue-ID: CCSDK-2635 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 6 +++--- dblib/installer/pom.xml | 4 ++-- dblib/pom.xml | 4 ++-- dblib/provider/pom.xml | 4 ++-- features/ccsdk-dblib/pom.xml | 4 ++-- features/ccsdk-filters/pom.xml | 4 ++-- features/ccsdk-sli-core-all/pom.xml | 4 ++-- features/ccsdk-sli/pom.xml | 4 ++-- features/ccsdk-sliPluginUtils/pom.xml | 4 ++-- features/ccsdk-sliapi/pom.xml | 4 ++-- features/ccsdk-slicore-utils/pom.xml | 4 ++-- features/features-sli-core/pom.xml | 4 ++-- features/installer/pom.xml | 4 ++-- features/pom.xml | 4 ++-- filters/installer/pom.xml | 4 ++-- filters/pom.xml | 4 ++-- filters/provider/pom.xml | 4 ++-- pom.xml | 4 ++-- sli/common/pom.xml | 4 ++-- sli/installer/pom.xml | 4 ++-- sli/model/pom.xml | 4 ++-- sli/pom.xml | 4 ++-- sli/provider-base/pom.xml | 4 ++-- sli/provider/pom.xml | 4 ++-- sliPluginUtils/installer/pom.xml | 4 ++-- sliPluginUtils/pom.xml | 4 ++-- sliPluginUtils/provider/pom.xml | 4 ++-- sliapi/installer/pom.xml | 7 +++--- sliapi/model/pom.xml | 4 ++-- sliapi/model/swagger/pom.xml | 6 +++--- sliapi/model/swagger/src/main/json/sliapi.json | 2 +- sliapi/model/swagger/src/main/yaml/sliapi.yaml | 30 +++++++++++++------------- sliapi/model/yang/pom.xml | 4 ++-- sliapi/pom.xml | 4 ++-- sliapi/provider/pom.xml | 4 ++-- utils/installer/pom.xml | 4 ++-- utils/pom.xml | 4 ++-- utils/provider/pom.xml | 4 ++-- version.properties | 2 +- 39 files changed, 92 insertions(+), 93 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 6d6d6b95c..a3627943b 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent parent - 2.0.0-SNAPSHOT - + 2.0.1-SNAPSHOT + org.onap.ccsdk.sli.core sli-core-artifacts - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 59e143d2b..216331010 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index af139d06d..4d496a3c7 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core dblib - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index edccd380b..4bbc328c6 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-dblib/pom.xml b/features/ccsdk-dblib/pom.xml index 83ec56756..4ba021d97 100644 --- a/features/ccsdk-dblib/pom.xml +++ b/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-filters/pom.xml b/features/ccsdk-filters/pom.xml index 03fe524c5..eec10c558 100644 --- a/features/ccsdk-filters/pom.xml +++ b/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 192db84d3..28ab0d05f 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml index c96b93c88..c108758bb 100644 --- a/features/ccsdk-sli/pom.xml +++ b/features/ccsdk-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/features/ccsdk-sliPluginUtils/pom.xml b/features/ccsdk-sliPluginUtils/pom.xml index 8b9c67147..55a7834f1 100644 --- a/features/ccsdk-sliPluginUtils/pom.xml +++ b/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/features/ccsdk-sliapi/pom.xml b/features/ccsdk-sliapi/pom.xml index 2dc873d67..b87f105e9 100644 --- a/features/ccsdk-sliapi/pom.xml +++ b/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/features/ccsdk-slicore-utils/pom.xml b/features/ccsdk-slicore-utils/pom.xml index 200fc46ac..23ec27925 100644 --- a/features/ccsdk-slicore-utils/pom.xml +++ b/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 019c3611f..996ab045d 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 3a7f0cd74..3f401e933 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 9408c0325..8eb7d544f 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index bc0c56d12..e8c9fbaf8 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 3dec6563e..7b500128b 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core filters - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 57d9387f8..7386aebb0 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 2ad066f11..c6cff5ea0 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index efc66aabd..37c89f555 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 3061253b3..7eaffaa1f 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 6951b89ca..8d6ab0fd3 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index b57f80e71..f17a53e19 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sli - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index abd33b468..189402d8e 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 8ac5ae85f..70f81a454 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index e877daf5c..6b12f11bf 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 458941d27..fc2e82353 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index 21ed4cd66..ac0086710 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 081b8c364..15033e012 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -1,18 +1,17 @@ - + 4.0.0 org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 4ac5a8510..86bfb5571 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/model/swagger/pom.xml b/sliapi/model/swagger/pom.xml index 544f4f9e5..c1110136f 100644 --- a/sliapi/model/swagger/pom.xml +++ b/sliapi/model/swagger/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent oparent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model-swagger - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT jar ccsdk-sli-core :: sliapi :: ${project.artifactId} @@ -34,7 +34,7 @@ - >bintray-yang2swagger-yang2swagge + >bintray-yang2swagger-yang2swagge bintray https://dl.bintray.com/yang2swagger/yang2swagger diff --git a/sliapi/model/swagger/src/main/json/sliapi.json b/sliapi/model/swagger/src/main/json/sliapi.json index 99a69861e..ef9bc596a 100644 --- a/sliapi/model/swagger/src/main/json/sliapi.json +++ b/sliapi/model/swagger/src/main/json/sliapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"description":"Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.0.0-SNAPSHOT","title":"SLI-API,ietf-yang-types,ietf-inet-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"},"responseSchema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"},"responseSchema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"$ref":"#/definitions/sli.api.executegraph.Input","originalRef":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"$ref":"#/definitions/sli.api.ExecuteGraph","originalRef":"#/definitions/sli.api.ExecuteGraph"},"responseSchema":{"$ref":"#/definitions/sli.api.ExecuteGraph","originalRef":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"$ref":"#/definitions/sli.api.Healthcheck","originalRef":"#/definitions/sli.api.Healthcheck"},"responseSchema":{"$ref":"#/definitions/sli.api.Healthcheck","originalRef":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"$ref":"#/definitions/sli.api.Vlbcheck","originalRef":"#/definitions/sli.api.Vlbcheck"},"responseSchema":{"$ref":"#/definitions/sli.api.Vlbcheck","originalRef":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"$ref":"#/definitions/sli.api.ModeEnumeration","originalRef":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"$ref":"#/definitions/sli.api.ParameterSetting","originalRef":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"description":"Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.0.1-SNAPSHOT","title":"SLI-API,ietf-yang-types,ietf-inet-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"},"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"},"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"},"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"},"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"$ref":"#/definitions/sli.api.executegraph.Input","originalRef":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"$ref":"#/definitions/sli.api.ExecuteGraph","originalRef":"#/definitions/sli.api.ExecuteGraph"},"schema":{"$ref":"#/definitions/sli.api.ExecuteGraph","originalRef":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"$ref":"#/definitions/sli.api.Healthcheck","originalRef":"#/definitions/sli.api.Healthcheck"},"schema":{"$ref":"#/definitions/sli.api.Healthcheck","originalRef":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"$ref":"#/definitions/sli.api.Vlbcheck","originalRef":"#/definitions/sli.api.Vlbcheck"},"schema":{"$ref":"#/definitions/sli.api.Vlbcheck","originalRef":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"$ref":"#/definitions/sli.api.ModeEnumeration","originalRef":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"$ref":"#/definitions/sli.api.ParameterSetting","originalRef":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file diff --git a/sliapi/model/swagger/src/main/yaml/sliapi.yaml b/sliapi/model/swagger/src/main/yaml/sliapi.yaml index c8f2997eb..7c11c9d9c 100644 --- a/sliapi/model/swagger/src/main/yaml/sliapi.yaml +++ b/sliapi/model/swagger/src/main/yaml/sliapi.yaml @@ -18,7 +18,7 @@ info: Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ \ notices." - version: "1.0.0-SNAPSHOT" + version: "1.0.1-SNAPSHOT" title: "SLI-API,ietf-yang-types,ietf-inet-types API" consumes: - "application/json" @@ -38,10 +38,10 @@ paths: description: "Internal error" 200: description: "sli.api.TestResults" - schema: + responseSchema: $ref: "#/definitions/sli.api.TestResults" originalRef: "#/definitions/sli.api.TestResults" - responseSchema: + schema: $ref: "#/definitions/sli.api.TestResults" originalRef: "#/definitions/sli.api.TestResults" post: @@ -126,10 +126,10 @@ paths: description: "Internal error" 200: description: "sli.api.testresults.TestResult" - schema: + responseSchema: $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" - responseSchema: + schema: $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" post: @@ -206,10 +206,10 @@ paths: description: "Internal error" 200: description: "sli.api.TestResults" - schema: + responseSchema: $ref: "#/definitions/sli.api.TestResults" originalRef: "#/definitions/sli.api.TestResults" - responseSchema: + schema: $ref: "#/definitions/sli.api.TestResults" originalRef: "#/definitions/sli.api.TestResults" /operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/: @@ -228,10 +228,10 @@ paths: description: "Internal error" 200: description: "sli.api.testresults.TestResult" - schema: + responseSchema: $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" - responseSchema: + schema: $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" /operations/SLI-API:execute-graph/: @@ -252,10 +252,10 @@ paths: description: "Internal error" 200: description: "Correct response" - schema: + responseSchema: $ref: "#/definitions/sli.api.ExecuteGraph" originalRef: "#/definitions/sli.api.ExecuteGraph" - responseSchema: + schema: $ref: "#/definitions/sli.api.ExecuteGraph" originalRef: "#/definitions/sli.api.ExecuteGraph" 201: @@ -270,10 +270,10 @@ paths: description: "Internal error" 200: description: "Correct response" - schema: + responseSchema: $ref: "#/definitions/sli.api.Healthcheck" originalRef: "#/definitions/sli.api.Healthcheck" - responseSchema: + schema: $ref: "#/definitions/sli.api.Healthcheck" originalRef: "#/definitions/sli.api.Healthcheck" 201: @@ -288,10 +288,10 @@ paths: description: "Internal error" 200: description: "Correct response" - schema: + responseSchema: $ref: "#/definitions/sli.api.Vlbcheck" originalRef: "#/definitions/sli.api.Vlbcheck" - responseSchema: + schema: $ref: "#/definitions/sli.api.Vlbcheck" originalRef: "#/definitions/sli.api.Vlbcheck" 201: diff --git a/sliapi/model/yang/pom.xml b/sliapi/model/yang/pom.xml index 420d2ee0d..fcc5ca08e 100755 --- a/sliapi/model/yang/pom.xml +++ b/sliapi/model/yang/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model-yang - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 367d82cf2..a3b9d3137 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index f80003766..f424c02d7 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index e7380f0f6..9f5b0aa68 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 85b18c68c..27b6639ea 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core utils - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index d5c07eba5..1da204e47 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 1da7b9a35..80908d697 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=1 sprint_number=0 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From 45b5a460fdcec757f4482d69009b87da34728670 Mon Sep 17 00:00:00 2001 From: Kevin Smokowski Date: Tue, 11 Aug 2020 20:07:22 +0000 Subject: add new print methods create filtered print method for svclogic context Issue-ID: CCSDK-2643 Change-Id: I59261b1e581130d0fbe7d6735f96ee4c6e90ae75 Signed-off-by: Smokowski, Kevin (ks6305) --- .../org/onap/ccsdk/sli/core/sli/SecurePrinter.java | 91 ++++++++++++++++++++++ .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 18 ++++- .../sli/provider/base/ExecuteNodeExecutor.java | 1 + .../sli/core/slipluginutils/SliPluginUtils.java | 24 ++++++ 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SecurePrinter.java diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SecurePrinter.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SecurePrinter.java new file mode 100644 index 000000000..d12729c42 --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SecurePrinter.java @@ -0,0 +1,91 @@ + +package org.onap.ccsdk.sli.core.sli; + +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SecurePrinter { + private static final Logger LOG = LoggerFactory.getLogger(SecurePrinter.class); + private static final String DEFAULT_FILTER = "password,pass,pswd"; + private static final String REDACTED = "***REDACTED***"; + private static final String FILTER_PROPERTY = "NODE_STRING_FILTER"; + private static String[] filterArray; + + public SecurePrinter() { + String filterProperty = System.getProperty(FILTER_PROPERTY); + if (filterProperty != null && !filterProperty.isEmpty() && filterProperty.contains(",")) { + filterArray = filterProperty.split(","); + } else { + filterArray = DEFAULT_FILTER.split(","); + } + } + + private String filterValue(String key, String value) { + String normalizedKey = key.toLowerCase(); + for (String restrictedKey : filterArray) { + if (normalizedKey.contains(restrictedKey)) { + return REDACTED; + } + } + return value; + } + + public void printAttributes(HashMap attributes) { + if (LOG.isDebugEnabled()) { + for (Entry attribute : attributes.entrySet()) { + String value = filterValue(attribute.getKey(), attribute.getValue()); + LOG.debug(attribute.getKey() + " = " + value); + } + } + } + + public void printAttributes(HashMap attributes, String subpath) { + if (LOG.isDebugEnabled()) { + for (Entry attribute : attributes.entrySet()) { + if (attribute.getKey().startsWith(subpath)) { + String value = filterValue(attribute.getKey(), attribute.getValue()); + LOG.debug(attribute.getKey() + " = " + value); + } + } + } + } + + public void printProperties(Properties props) { + if (LOG.isDebugEnabled()) { + try { + for (Entry property : props.entrySet()) { + String keyString = (String) property.getKey(); + String valueString = (String) property.getValue(); + String value = filterValue(keyString, valueString); + LOG.debug(keyString + " = " + value); + } + } catch (Exception e) { + LOG.error("Failed to print properties", e); + } + } + } + + public void printProperties(Properties props, String subpath) { + if (LOG.isDebugEnabled()) { + try { + for (Entry property : props.entrySet()) { + String keyString = (String) property.getKey(); + if (keyString.startsWith(subpath)) { + String valueString = (String) property.getValue(); + String value = filterValue(keyString, valueString); + LOG.debug(keyString + " = " + value); + } + } + } catch (Exception e) { + LOG.error("Failed to print properties", e); + } + } + } + +} + + diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index f07f71f10..129c08526 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -36,7 +36,7 @@ import org.w3c.dom.Text; public class SvcLogicContext { private static final Logger LOG = LoggerFactory.getLogger(SvcLogicContext.class); - + private final SecurePrinter securePrinter = new SecurePrinter(); public static final String CTX_NULL_VALUE=""; private static final String LENGTH="_length"; @@ -415,4 +415,20 @@ public class SvcLogicContext { return (root.toString()); } + + public void printProperties(Properties props) { + securePrinter.printProperties(props); + } + + public void printAttributes() { + securePrinter.printAttributes(attributes); + } + + public void printProperties(Properties props, String subpath) { + securePrinter.printProperties(props, subpath); + } + + public void printAttributes(String subpath) { + securePrinter.printAttributes(attributes, subpath); + } } diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java index 7f2674e51..b23662a6c 100644 --- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ExecuteNodeExecutor.java @@ -66,6 +66,7 @@ public class ExecuteNodeExecutor extends AbstractSvcLogicNodeExecutor { Method pluginMethod = null; try { + LOG.debug("executing method {} on plugin {}", methodName, pluginName); pluginMethod = pluginClass.getMethod(methodName, Map.class, SvcLogicContext.class); } catch (NoSuchMethodException e) { LOG.error(pluginErrorMessage, e); diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index 816bb5dff..2edb36dc4 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -733,6 +733,30 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { } + public static void logContextProperties(Map parameters, SvcLogicContext ctx) + throws SvcLogicException { + if (LOG.isTraceEnabled()) { + String subpath = parameters.get("subpath"); + if (subpath != null && !subpath.isEmpty()) { + ctx.printProperties(ctx.toProperties(), subpath); + } else { + ctx.printProperties(ctx.toProperties()); + } + } + } + + public static void logContextAttributes(Map parameters, SvcLogicContext ctx) + throws SvcLogicException { + if (LOG.isTraceEnabled()) { + String subpath = parameters.get("subpath"); + if (subpath != null && !subpath.isEmpty()) { + ctx.printAttributes(subpath); + } else { + ctx.printAttributes(); + } + } + } + /** * Checks context memory for a set of required parameters * Every parameter aside from prefix will be treated as mandatory -- cgit 1.2.3-korg From 4471a01b2c283d1141824ac45608b8224cc2bd68 Mon Sep 17 00:00:00 2001 From: Michael Dürre Date: Wed, 19 Aug 2020 11:02:04 +0200 Subject: fix for J11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add missing dependency in J11 Issue-ID: CCSDK-2669 Signed-off-by: Michael Dürre Change-Id: Iea66c3658e3d7e847bdb996567402c66ab2ab9a3 --- sli/common/pom.xml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 37c89f555..656f2049d 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -61,20 +61,24 @@ logging-slf4j
    - - org.apache.logging.log4j - log4j-slf4j-impl + + org.apache.logging.log4j + log4j-slf4j-impl test - - - org.apache.logging.log4j - log4j-core + + + org.apache.logging.log4j + log4j-core test - + com.google.code.gson gson + + javax.xml.bind + jaxb-api + junit -- cgit 1.2.3-korg From 0102a5219ebfa0a878f1ac3b03e897ca967518bc Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 31 Aug 2020 13:47:31 +0000 Subject: Add jaxb implementation dependencies Add JAXB implementation dependencies (needed for Java 11). Issue-ID: CCSDK-2710 Signed-off-by: Dan Timoney Change-Id: I27b5c50425aa9c2091486e087542de16cb254e0c --- sli/common/pom.xml | 8 +++ sliapi/model/swagger/src/main/json/sliapi.json | 2 +- sliapi/model/swagger/src/main/yaml/sliapi.yaml | 84 +++++++++++++------------- 3 files changed, 51 insertions(+), 43 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 656f2049d..b0529db3a 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -79,6 +79,14 @@ javax.xml.bind jaxb-api + + com.sun.xml.bind + jaxb-core + + + com.sun.xml.bind + jaxb-impl + junit diff --git a/sliapi/model/swagger/src/main/json/sliapi.json b/sliapi/model/swagger/src/main/json/sliapi.json index ef9bc596a..3dcbc2ac2 100644 --- a/sliapi/model/swagger/src/main/json/sliapi.json +++ b/sliapi/model/swagger/src/main/json/sliapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"description":"Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.0.1-SNAPSHOT","title":"SLI-API,ietf-yang-types,ietf-inet-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"},"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"},"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"},"schema":{"$ref":"#/definitions/sli.api.TestResults","originalRef":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"},"schema":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"$ref":"#/definitions/sli.api.executegraph.Input","originalRef":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"$ref":"#/definitions/sli.api.ExecuteGraph","originalRef":"#/definitions/sli.api.ExecuteGraph"},"schema":{"$ref":"#/definitions/sli.api.ExecuteGraph","originalRef":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"$ref":"#/definitions/sli.api.Healthcheck","originalRef":"#/definitions/sli.api.Healthcheck"},"schema":{"$ref":"#/definitions/sli.api.Healthcheck","originalRef":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"$ref":"#/definitions/sli.api.Vlbcheck","originalRef":"#/definitions/sli.api.Vlbcheck"},"schema":{"$ref":"#/definitions/sli.api.Vlbcheck","originalRef":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"$ref":"#/definitions/sli.api.testresults.TestResult","originalRef":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"$ref":"#/definitions/sli.api.ResponseFields","originalRef":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"$ref":"#/definitions/sli.api.ModeEnumeration","originalRef":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"$ref":"#/definitions/sli.api.ParameterSetting","originalRef":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"description":"This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,Defines API to service logic interpreter","version":"1.0.1-SNAPSHOT","title":"ietf-yang-types,ietf-inet-types,SLI-API API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"originalRef":"#/definitions/sli.api.executegraph.Input","$ref":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"},"schema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"},"schema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"},"schema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"originalRef":"#/definitions/sli.api.ModeEnumeration","$ref":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"originalRef":"#/definitions/sli.api.ParameterSetting","$ref":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file diff --git a/sliapi/model/swagger/src/main/yaml/sliapi.yaml b/sliapi/model/swagger/src/main/yaml/sliapi.yaml index 7c11c9d9c..df434964f 100644 --- a/sliapi/model/swagger/src/main/yaml/sliapi.yaml +++ b/sliapi/model/swagger/src/main/yaml/sliapi.yaml @@ -1,25 +1,25 @@ --- swagger: "2.0" info: - description: "Defines API to service logic interpreter,This module contains a collection\ - \ of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust\ - \ and the persons identified as\nauthors of the code. All rights reserved.\n\n\ - Redistribution and use in source and binary forms, with or\nwithout modification,\ - \ is permitted pursuant to, and subject\nto the license terms contained in, the\ - \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ + description: "This module contains a collection of generally useful derived\nYANG\ + \ data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\n\ + authors of the code. All rights reserved.\n\nRedistribution and use in source\ + \ and binary forms, with or\nwithout modification, is permitted pursuant to, and\ + \ subject\nto the license terms contained in, the Simplified BSD License\nset\ + \ forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF\ + \ Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG\ + \ module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This\ + \ module contains a collection of generally useful derived\nYANG data types for\ + \ Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and\ + \ the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution\ + \ and use in source and binary forms, with or\nwithout modification, is permitted\ + \ pursuant to, and subject\nto the license terms contained in, the Simplified\ + \ BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ - \ notices.,This module contains a collection of generally useful derived\nYANG\ - \ data types for Internet addresses and related things.\n\nCopyright (c) 2013\ - \ IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\ - \nRedistribution and use in source and binary forms, with or\nwithout modification,\ - \ is permitted pursuant to, and subject\nto the license terms contained in, the\ - \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ - Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ - \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ - \ notices." + \ notices.,Defines API to service logic interpreter" version: "1.0.1-SNAPSHOT" - title: "SLI-API,ietf-yang-types,ietf-inet-types API" + title: "ietf-yang-types,ietf-inet-types,SLI-API API" consumes: - "application/json" - "application/xml" @@ -39,11 +39,11 @@ paths: 200: description: "sli.api.TestResults" responseSchema: - $ref: "#/definitions/sli.api.TestResults" originalRef: "#/definitions/sli.api.TestResults" - schema: $ref: "#/definitions/sli.api.TestResults" + schema: originalRef: "#/definitions/sli.api.TestResults" + $ref: "#/definitions/sli.api.TestResults" post: tags: - "SLI-API" @@ -54,8 +54,8 @@ paths: description: "sli.api.TestResults to be added to list" required: false schema: - $ref: "#/definitions/sli.api.TestResults" originalRef: "#/definitions/sli.api.TestResults" + $ref: "#/definitions/sli.api.TestResults" responses: 400: description: "Internal error" @@ -73,8 +73,8 @@ paths: description: "sli.api.TestResults to be added or updated" required: false schema: - $ref: "#/definitions/sli.api.TestResults" originalRef: "#/definitions/sli.api.TestResults" + $ref: "#/definitions/sli.api.TestResults" responses: 400: description: "Internal error" @@ -101,8 +101,8 @@ paths: description: "sli.api.testresults.TestResult to be added to list" required: false schema: - $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" + $ref: "#/definitions/sli.api.testresults.TestResult" responses: 400: description: "Internal error" @@ -127,11 +127,11 @@ paths: 200: description: "sli.api.testresults.TestResult" responseSchema: - $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" - schema: $ref: "#/definitions/sli.api.testresults.TestResult" + schema: originalRef: "#/definitions/sli.api.testresults.TestResult" + $ref: "#/definitions/sli.api.testresults.TestResult" post: tags: - "SLI-API" @@ -147,8 +147,8 @@ paths: description: "sli.api.testresults.TestResult to be added to list" required: false schema: - $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" + $ref: "#/definitions/sli.api.testresults.TestResult" responses: 400: description: "Internal error" @@ -171,8 +171,8 @@ paths: description: "sli.api.testresults.TestResult to be added or updated" required: false schema: - $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" + $ref: "#/definitions/sli.api.testresults.TestResult" responses: 400: description: "Internal error" @@ -207,11 +207,11 @@ paths: 200: description: "sli.api.TestResults" responseSchema: - $ref: "#/definitions/sli.api.TestResults" originalRef: "#/definitions/sli.api.TestResults" - schema: $ref: "#/definitions/sli.api.TestResults" + schema: originalRef: "#/definitions/sli.api.TestResults" + $ref: "#/definitions/sli.api.TestResults" /operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/: get: tags: @@ -229,11 +229,11 @@ paths: 200: description: "sli.api.testresults.TestResult" responseSchema: - $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" - schema: $ref: "#/definitions/sli.api.testresults.TestResult" + schema: originalRef: "#/definitions/sli.api.testresults.TestResult" + $ref: "#/definitions/sli.api.testresults.TestResult" /operations/SLI-API:execute-graph/: post: tags: @@ -245,19 +245,19 @@ paths: schema: properties: input: - $ref: "#/definitions/sli.api.executegraph.Input" originalRef: "#/definitions/sli.api.executegraph.Input" + $ref: "#/definitions/sli.api.executegraph.Input" responses: 400: description: "Internal error" 200: description: "Correct response" responseSchema: - $ref: "#/definitions/sli.api.ExecuteGraph" originalRef: "#/definitions/sli.api.ExecuteGraph" - schema: $ref: "#/definitions/sli.api.ExecuteGraph" + schema: originalRef: "#/definitions/sli.api.ExecuteGraph" + $ref: "#/definitions/sli.api.ExecuteGraph" 201: description: "No response" /operations/SLI-API:healthcheck/: @@ -271,11 +271,11 @@ paths: 200: description: "Correct response" responseSchema: - $ref: "#/definitions/sli.api.Healthcheck" originalRef: "#/definitions/sli.api.Healthcheck" - schema: $ref: "#/definitions/sli.api.Healthcheck" + schema: originalRef: "#/definitions/sli.api.Healthcheck" + $ref: "#/definitions/sli.api.Healthcheck" 201: description: "No response" /operations/SLI-API:vlbcheck/: @@ -289,11 +289,11 @@ paths: 200: description: "Correct response" responseSchema: - $ref: "#/definitions/sli.api.Vlbcheck" originalRef: "#/definitions/sli.api.Vlbcheck" - schema: $ref: "#/definitions/sli.api.Vlbcheck" + schema: originalRef: "#/definitions/sli.api.Vlbcheck" + $ref: "#/definitions/sli.api.Vlbcheck" 201: description: "No response" definitions: @@ -301,14 +301,14 @@ definitions: type: "object" properties: output: - $ref: "#/definitions/sli.api.ResponseFields" originalRef: "#/definitions/sli.api.ResponseFields" + $ref: "#/definitions/sli.api.ResponseFields" sli.api.Healthcheck: type: "object" properties: output: - $ref: "#/definitions/sli.api.ResponseFields" originalRef: "#/definitions/sli.api.ResponseFields" + $ref: "#/definitions/sli.api.ResponseFields" sli.api.ModeEnumeration: type: "string" enum: @@ -344,27 +344,27 @@ definitions: test-result: type: "array" items: - $ref: "#/definitions/sli.api.testresults.TestResult" originalRef: "#/definitions/sli.api.testresults.TestResult" + $ref: "#/definitions/sli.api.testresults.TestResult" sli.api.Vlbcheck: type: "object" properties: output: - $ref: "#/definitions/sli.api.ResponseFields" originalRef: "#/definitions/sli.api.ResponseFields" + $ref: "#/definitions/sli.api.ResponseFields" sli.api.executegraph.Input: type: "object" properties: mode: - $ref: "#/definitions/sli.api.ModeEnumeration" originalRef: "#/definitions/sli.api.ModeEnumeration" + $ref: "#/definitions/sli.api.ModeEnumeration" module-name: type: "string" sli-parameter: type: "array" items: - $ref: "#/definitions/sli.api.ParameterSetting" originalRef: "#/definitions/sli.api.ParameterSetting" + $ref: "#/definitions/sli.api.ParameterSetting" rpc-name: type: "string" sli.api.testresults.TestResult: -- cgit 1.2.3-korg From 2f5f9dc5c97749679695ff8147a6bf6b4e337ac5 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 2 Sep 2020 13:35:29 -0500 Subject: secure printer changes add method to print properties alphabetically Issue-ID: CCSDK-2721 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I3bcb46a1f45dc74a2bc97acff08fa8c2c29d0ba7 --- .../org/onap/ccsdk/sli/core/sli/SecurePrinter.java | 50 ++++++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SecurePrinter.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SecurePrinter.java index d12729c42..e25aed9f8 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SecurePrinter.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SecurePrinter.java @@ -1,9 +1,13 @@ package org.onap.ccsdk.sli.core.sli; +import java.io.File; +import java.io.FileOutputStream; +import java.io.PrintStream; import java.util.HashMap; import java.util.Map.Entry; import java.util.Properties; +import java.util.TreeMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,6 +17,9 @@ public class SecurePrinter { private static final String DEFAULT_FILTER = "password,pass,pswd"; private static final String REDACTED = "***REDACTED***"; private static final String FILTER_PROPERTY = "NODE_STRING_FILTER"; + private static final String SEPERATOR = " = "; + private static final String COMMON_ERROR_MESSAGE = "Failed to print properties"; + private static String[] filterArray; public SecurePrinter() { @@ -38,7 +45,7 @@ public class SecurePrinter { if (LOG.isDebugEnabled()) { for (Entry attribute : attributes.entrySet()) { String value = filterValue(attribute.getKey(), attribute.getValue()); - LOG.debug(attribute.getKey() + " = " + value); + LOG.debug(attribute.getKey() + SEPERATOR + value); } } } @@ -48,7 +55,7 @@ public class SecurePrinter { for (Entry attribute : attributes.entrySet()) { if (attribute.getKey().startsWith(subpath)) { String value = filterValue(attribute.getKey(), attribute.getValue()); - LOG.debug(attribute.getKey() + " = " + value); + LOG.debug(attribute.getKey() + SEPERATOR + value); } } } @@ -61,15 +68,15 @@ public class SecurePrinter { String keyString = (String) property.getKey(); String valueString = (String) property.getValue(); String value = filterValue(keyString, valueString); - LOG.debug(keyString + " = " + value); + LOG.debug(keyString + SEPERATOR + value); } } catch (Exception e) { - LOG.error("Failed to print properties", e); + LOG.error(COMMON_ERROR_MESSAGE, e); } } } - public void printProperties(Properties props, String subpath) { + public void printProperties(Properties props, String subpath) { if (LOG.isDebugEnabled()) { try { for (Entry property : props.entrySet()) { @@ -77,15 +84,40 @@ public class SecurePrinter { if (keyString.startsWith(subpath)) { String valueString = (String) property.getValue(); String value = filterValue(keyString, valueString); - LOG.debug(keyString + " = " + value); + LOG.debug(keyString + SEPERATOR + value); } } } catch (Exception e) { - LOG.error("Failed to print properties", e); + LOG.error(COMMON_ERROR_MESSAGE, e); } } } -} - + public void printPropertiesAlphabetically(Properties props) { + if (LOG.isDebugEnabled()) { + TreeMap sortedMap = new TreeMap(props); + try { + for (Entry entry : sortedMap.entrySet()) { + String value = filterValue(entry.getKey(), entry.getValue()); + LOG.debug(entry.getKey() + SEPERATOR + value); + } + } catch (Exception e) { + LOG.error(COMMON_ERROR_MESSAGE, e); + } + } + } + public void printAttributesToFile(HashMap attributes, String fileName) { + try (FileOutputStream fstr = new FileOutputStream(new File(fileName)); + PrintStream pstr = new PrintStream(fstr, true);) { + pstr.println("#######################################"); + for (Entry entry : attributes.entrySet()) { + String value = filterValue(entry.getKey(), entry.getValue()); + pstr.println(entry.getKey() + SEPERATOR + value); + } + } catch (Exception e) { + LOG.error("Cannot write context to file.", e); + } + } + +} \ No newline at end of file -- cgit 1.2.3-korg From 54b45fd42c8fcd9129d2bdd062a99cbd94fe4708 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Thu, 3 Sep 2020 10:03:15 -0400 Subject: Update lifecycle state Update lifecycle state to Mature Change-Id: I98504f658e58d10185b3c781b77bec1176ec1831 Issue-ID: CCSDK-2660 Signed-off-by: Dan Timoney --- INFO.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INFO.yaml b/INFO.yaml index 287a2a886..2971cf0c6 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -1,7 +1,7 @@ --- project: 'ccsdk-sli-core' project_creation_date: '2017-06-27' -lifecycle_state: 'Incubation' +lifecycle_state: 'Mature' project_category: '' project_lead: &onap_releng_ptl name: 'Dan Timoney' -- cgit 1.2.3-korg From d7ce5c8191a202068c41b7b1f69d4146bb9896db Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 9 Sep 2020 12:38:05 -0400 Subject: Release M4 version of sli/core Release M4 version (1.0.1) of sli/core Change-Id: I3c2c839bfc88b3795eebdfb97396ab3b53eb9698 Issue-ID: CCSDK-2742 Signed-off-by: Dan Timoney --- releases/1.0.1.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releases/1.0.1.yaml diff --git a/releases/1.0.1.yaml b/releases/1.0.1.yaml new file mode 100644 index 000000000..f86a0ba6a --- /dev/null +++ b/releases/1.0.1.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '1.0.1' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/303/' -- cgit 1.2.3-korg From 368939e5f285dafeec594d58ba74c5bba0cc20d1 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 9 Sep 2020 14:21:38 -0400 Subject: Roll to initial Honolulu release version Roll master branch to initial Honolulu release version Change-Id: I5abee4ba661e665251e7d03e7705096ff9103b5d Issue-ID: CCSDK-2742 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 4 +- dblib/installer/pom.xml | 4 +- dblib/pom.xml | 4 +- dblib/provider/pom.xml | 4 +- features/ccsdk-dblib/pom.xml | 4 +- features/ccsdk-filters/pom.xml | 4 +- features/ccsdk-sli-core-all/pom.xml | 4 +- features/ccsdk-sli/pom.xml | 4 +- features/ccsdk-sliPluginUtils/pom.xml | 4 +- features/ccsdk-sliapi/pom.xml | 4 +- features/ccsdk-slicore-utils/pom.xml | 4 +- features/features-sli-core/pom.xml | 4 +- features/installer/pom.xml | 4 +- features/pom.xml | 4 +- filters/installer/pom.xml | 4 +- filters/pom.xml | 4 +- filters/provider/pom.xml | 4 +- pom.xml | 4 +- sli/common/pom.xml | 4 +- sli/installer/pom.xml | 4 +- sli/model/pom.xml | 4 +- sli/pom.xml | 4 +- sli/provider-base/pom.xml | 4 +- sli/provider/pom.xml | 4 +- sliPluginUtils/installer/pom.xml | 4 +- sliPluginUtils/pom.xml | 4 +- sliPluginUtils/provider/pom.xml | 4 +- sliapi/installer/pom.xml | 4 +- sliapi/model/pom.xml | 4 +- sliapi/model/swagger/pom.xml | 4 +- sliapi/model/swagger/src/main/json/sliapi.json | 2 +- sliapi/model/swagger/src/main/yaml/sliapi.yaml | 62 +++++++++++++------------- sliapi/model/yang/pom.xml | 4 +- sliapi/pom.xml | 4 +- sliapi/provider/pom.xml | 4 +- utils/installer/pom.xml | 4 +- utils/pom.xml | 4 +- utils/provider/pom.xml | 4 +- version.properties | 4 +- 39 files changed, 106 insertions(+), 106 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index a3627943b..428414771 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-core-artifacts - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index 216331010..e4eb615e6 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-installer - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 4d496a3c7..721738fdc 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core dblib - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index 4bbc328c6..d886be4f9 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core dblib-provider - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-dblib/pom.xml b/features/ccsdk-dblib/pom.xml index 4ba021d97..aedf57195 100644 --- a/features/ccsdk-dblib/pom.xml +++ b/features/ccsdk-dblib/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-dblib - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-filters/pom.xml b/features/ccsdk-filters/pom.xml index eec10c558..4470dd60f 100644 --- a/features/ccsdk-filters/pom.xml +++ b/features/ccsdk-filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-filters - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 28ab0d05f..91285eac7 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core-all - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml index c108758bb..97fe3f060 100644 --- a/features/ccsdk-sli/pom.xml +++ b/features/ccsdk-sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/features/ccsdk-sliPluginUtils/pom.xml b/features/ccsdk-sliPluginUtils/pom.xml index 55a7834f1..71b6e1833 100644 --- a/features/ccsdk-sliPluginUtils/pom.xml +++ b/features/ccsdk-sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/features/ccsdk-sliapi/pom.xml b/features/ccsdk-sliapi/pom.xml index b87f105e9..3c1bc92dc 100644 --- a/features/ccsdk-sliapi/pom.xml +++ b/features/ccsdk-sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/features/ccsdk-slicore-utils/pom.xml b/features/ccsdk-slicore-utils/pom.xml index 23ec27925..84b4f84d6 100644 --- a/features/ccsdk-slicore-utils/pom.xml +++ b/features/ccsdk-slicore-utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent single-feature-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-slicore-utils - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 996ab045d..5d1ded3de 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent feature-repo-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core features-sli-core - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 3f401e933..2267401b4 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-features-installer - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 8eb7d544f..410a884ef 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core slicore-feature-aggregator - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index e8c9fbaf8..f839b9bca 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core filters-installer - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index 7b500128b..fe203cf62 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core filters - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 7386aebb0..438d3755e 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core filters-provider - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index c6cff5ea0..d84360f14 100755 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sli-core - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core diff --git a/sli/common/pom.xml b/sli/common/pom.xml index b0529db3a..586f44b15 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-common - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 7eaffaa1f..7395ed979 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-installer - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index 8d6ab0fd3..e89b0f508 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-model - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index f17a53e19..3889d5d4b 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 189402d8e..45530aba8 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider-base - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 70f81a454..c9fc044fc 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sli-provider - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 6b12f11bf..7912db0a7 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-installer - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index fc2e82353..0a7a97e5f 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index ac0086710..e8354a3fd 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliPluginUtils-provider - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 15033e012..790653f45 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 86bfb5571..6f93b61ec 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/model/swagger/pom.xml b/sliapi/model/swagger/pom.xml index c1110136f..331bbf0f3 100644 --- a/sliapi/model/swagger/pom.xml +++ b/sliapi/model/swagger/pom.xml @@ -5,12 +5,12 @@ org.onap.ccsdk.parent oparent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model-swagger - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT jar ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/swagger/src/main/json/sliapi.json b/sliapi/model/swagger/src/main/json/sliapi.json index 3dcbc2ac2..b53663201 100644 --- a/sliapi/model/swagger/src/main/json/sliapi.json +++ b/sliapi/model/swagger/src/main/json/sliapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"description":"This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,Defines API to service logic interpreter","version":"1.0.1-SNAPSHOT","title":"ietf-yang-types,ietf-inet-types,SLI-API API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"originalRef":"#/definitions/sli.api.executegraph.Input","$ref":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"},"schema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"},"schema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"},"schema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"originalRef":"#/definitions/sli.api.ModeEnumeration","$ref":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"originalRef":"#/definitions/sli.api.ParameterSetting","$ref":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"description":"Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.1.0-SNAPSHOT","title":"SLI-API,ietf-yang-types,ietf-inet-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"originalRef":"#/definitions/sli.api.executegraph.Input","$ref":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"},"responseSchema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"},"responseSchema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"},"responseSchema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"originalRef":"#/definitions/sli.api.ModeEnumeration","$ref":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"originalRef":"#/definitions/sli.api.ParameterSetting","$ref":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file diff --git a/sliapi/model/swagger/src/main/yaml/sliapi.yaml b/sliapi/model/swagger/src/main/yaml/sliapi.yaml index df434964f..b1a63be5d 100644 --- a/sliapi/model/swagger/src/main/yaml/sliapi.yaml +++ b/sliapi/model/swagger/src/main/yaml/sliapi.yaml @@ -1,25 +1,25 @@ --- swagger: "2.0" info: - description: "This module contains a collection of generally useful derived\nYANG\ - \ data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\n\ - authors of the code. All rights reserved.\n\nRedistribution and use in source\ - \ and binary forms, with or\nwithout modification, is permitted pursuant to, and\ - \ subject\nto the license terms contained in, the Simplified BSD License\nset\ - \ forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF\ - \ Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG\ - \ module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This\ - \ module contains a collection of generally useful derived\nYANG data types for\ - \ Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and\ - \ the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution\ - \ and use in source and binary forms, with or\nwithout modification, is permitted\ - \ pursuant to, and subject\nto the license terms contained in, the Simplified\ - \ BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ + description: "Defines API to service logic interpreter,This module contains a collection\ + \ of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust\ + \ and the persons identified as\nauthors of the code. All rights reserved.\n\n\ + Redistribution and use in source and binary forms, with or\nwithout modification,\ + \ is permitted pursuant to, and subject\nto the license terms contained in, the\ + \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ - \ notices.,Defines API to service logic interpreter" - version: "1.0.1-SNAPSHOT" - title: "ietf-yang-types,ietf-inet-types,SLI-API API" + \ notices.,This module contains a collection of generally useful derived\nYANG\ + \ data types for Internet addresses and related things.\n\nCopyright (c) 2013\ + \ IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\ + \nRedistribution and use in source and binary forms, with or\nwithout modification,\ + \ is permitted pursuant to, and subject\nto the license terms contained in, the\ + \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ + Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ + \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ + \ notices." + version: "1.1.0-SNAPSHOT" + title: "SLI-API,ietf-yang-types,ietf-inet-types API" consumes: - "application/json" - "application/xml" @@ -38,10 +38,10 @@ paths: description: "Internal error" 200: description: "sli.api.TestResults" - responseSchema: + schema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" - schema: + responseSchema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" post: @@ -126,10 +126,10 @@ paths: description: "Internal error" 200: description: "sli.api.testresults.TestResult" - responseSchema: + schema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" - schema: + responseSchema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" post: @@ -206,10 +206,10 @@ paths: description: "Internal error" 200: description: "sli.api.TestResults" - responseSchema: + schema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" - schema: + responseSchema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" /operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/: @@ -228,10 +228,10 @@ paths: description: "Internal error" 200: description: "sli.api.testresults.TestResult" - responseSchema: + schema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" - schema: + responseSchema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" /operations/SLI-API:execute-graph/: @@ -252,10 +252,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.ExecuteGraph" $ref: "#/definitions/sli.api.ExecuteGraph" - schema: + responseSchema: originalRef: "#/definitions/sli.api.ExecuteGraph" $ref: "#/definitions/sli.api.ExecuteGraph" 201: @@ -270,10 +270,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.Healthcheck" $ref: "#/definitions/sli.api.Healthcheck" - schema: + responseSchema: originalRef: "#/definitions/sli.api.Healthcheck" $ref: "#/definitions/sli.api.Healthcheck" 201: @@ -288,10 +288,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.Vlbcheck" $ref: "#/definitions/sli.api.Vlbcheck" - schema: + responseSchema: originalRef: "#/definitions/sli.api.Vlbcheck" $ref: "#/definitions/sli.api.Vlbcheck" 201: diff --git a/sliapi/model/yang/pom.xml b/sliapi/model/yang/pom.xml index fcc5ca08e..266ae7e7d 100755 --- a/sliapi/model/yang/pom.xml +++ b/sliapi/model/yang/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-model-yang - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index a3b9d3137..307a0cc74 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index f424c02d7..fb0f07f51 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 9f5b0aa68..36ca72012 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core utils-installer - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 27b6639ea..9103ce67f 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core utils - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 1da204e47..87a679dad 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.1-SNAPSHOT + 2.1.0-SNAPSHOT org.onap.ccsdk.sli.core utils-provider - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 80908d697..3e9715876 100644 --- a/version.properties +++ b/version.properties @@ -5,8 +5,8 @@ release_name=1 -sprint_number=0 -feature_revision=1 +sprint_number=1 +feature_revision=0 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg From ec2cdff3f96e7587c97b6fc9961fb108cf9c7e29 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 16 Oct 2020 11:22:11 -0400 Subject: Add code to validate path names. Added code to validate path names to avoid possible attacks due to hidden/special characters and/or embedded new lines. Change-Id: I53d7266e44fbada1d9d5f458dfcdbc452801672c Issue-ID: CCSDK-2918 Signed-off-by: Dan Timoney --- .../org/onap/ccsdk/sli/core/sli/CheckSumHelper.java | 4 ++++ .../org/onap/ccsdk/sli/core/sli/PathValidator.java | 18 ++++++++++++++++++ .../org/onap/ccsdk/sli/core/sli/SvcLogicParser.java | 17 ++++++++++------- .../onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 3 +++ .../ccsdk/sli/core/sli/recording/FileRecorder.java | 5 +++++ 5 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PathValidator.java diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java index d6ad07424..2f1f466c7 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.core.sli; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -32,6 +33,9 @@ import javax.xml.bind.DatatypeConverter; public class CheckSumHelper { public static String md5SumFromFile(String pathToFile) throws NoSuchAlgorithmException, IOException { + if (!PathValidator.isValidXmlPath(pathToFile)) { + throw new IOException("Invalid XML file name"); + } byte[] b = Files.readAllBytes(Paths.get(pathToFile)); return md5SumFromByteArray(b); } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PathValidator.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PathValidator.java new file mode 100644 index 000000000..511dbca7a --- /dev/null +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PathValidator.java @@ -0,0 +1,18 @@ +package org.onap.ccsdk.sli.core.sli; + +import java.util.regex.Pattern; + +public class PathValidator { + public static boolean isValidXmlPath(String path) { + Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.xml$"); + return (allowList.matcher(path).matches()); + } + public static boolean isValidPropertiesPath(String path) { + Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.properties$"); + return (allowList.matcher(path).matches()); + } + public static boolean isValidFilePath(String path) { + Pattern allowList = Pattern.compile("[-\\w/\\/]+"); + return (allowList.matcher(path).matches()); + } +} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index 5cb7ac5e2..cb78ac2ec 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -33,10 +33,7 @@ import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.xml.sax.Attributes; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; +import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; /** @@ -62,7 +59,7 @@ public class SvcLogicParser { private static final String SVCLOGIC_XSD = "/svclogic.xsd"; private SAXParser saxParser; - private class SvcLogicHandler extends DefaultHandler { + private class SvcLogicHandler extends DefaultHandler { private Locator locator = null; private String module = null; private String version = null; @@ -82,7 +79,7 @@ public class SvcLogicParser { this.curNodeId = 1; this.outcomeValue = null; } - + @Override public void setDocumentLocator(Locator locator) { this.locator = locator; @@ -450,6 +447,9 @@ public class SvcLogicParser { public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException { + if (!PathValidator.isValidXmlPath(xmlfile)) { + throw new ConfigurationException("Invalid xml file name ("+ xmlfile + ")"); + } File xmlFile = new File(xmlfile); if (!xmlFile.canRead()) { throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); @@ -482,6 +482,9 @@ public class SvcLogicParser { } public static void validate(String xmlfile, SvcLogicStore store) throws SvcLogicException { + if (!PathValidator.isValidXmlPath(xmlfile)) { + throw new ConfigurationException("Invalid xml file name ("+ xmlfile + ")"); + } File xmlFile = new File(xmlfile); if (!xmlFile.canRead()) { throw new ConfigurationException("Cannot read xml file (" + xmlfile + ")"); @@ -601,7 +604,7 @@ public class SvcLogicParser { } SAXParser saxParser = factory.newSAXParser(); - if (saxParser.isValidating()) { + if (saxParser.isValidating()) { LOGGER.info("Parser configured to validate XML {}", (xsdUrl != null ? xsdUrl.getPath() : null)); } return saxParser; diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index b73925dde..f682bb529 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -35,6 +35,9 @@ public class SvcLogicStoreFactory { public static SvcLogicStore getSvcLogicStore(String propfile) throws SvcLogicException { + if (!PathValidator.isValidPropertiesPath(propfile)) { + throw new ConfigurationException("Invalid property file name ("+propfile+")"); + } File propFile = new File(propfile); if (!propFile.canRead()) { throw new ConfigurationException("Cannot read property file " 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 index 37e4fe877..ab6f8bcc8 100644 --- 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 @@ -33,6 +33,7 @@ import java.util.Map; import java.util.TimeZone; import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.PathValidator; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; @@ -47,6 +48,10 @@ public class FileRecorder implements SvcLogicRecorder { { throw new ConfigurationException("No file parameter specified"); } + + if (!PathValidator.isValidFilePath(fileName)) { + throw new ConfigurationException("Invalid file name ("+fileName+")"); + } String record = parmMap.get("record"); if (record == null) -- cgit 1.2.3-korg From c72e5c56a6c05d3dd8acb71ff4525be4d6af7173 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 19 Oct 2020 10:05:16 -0400 Subject: Add file path validation Add file path validation for EnvVarFileResolver. Refactored PathValidator to org.onap.ccsdk.sli.core.utils so it can be used here. Change-Id: Ibb50df0ad020cf376c1ce20e7b598f7ad7223d48 Issue-ID: CCSDK-2918 Signed-off-by: Dan Timoney --- .gitignore | 1 + .../org/onap/ccsdk/sli/core/sli/CheckSumHelper.java | 2 ++ .../org/onap/ccsdk/sli/core/sli/PathValidator.java | 18 ------------------ .../org/onap/ccsdk/sli/core/sli/SvcLogicParser.java | 1 + .../onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 1 + .../ccsdk/sli/core/sli/recording/FileRecorder.java | 2 +- .../onap/ccsdk/sli/core/utils/EnvVarFileResolver.java | 2 +- .../org/onap/ccsdk/sli/core/utils/PathValidator.java | 17 +++++++++++++++++ 8 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PathValidator.java create mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java diff --git a/.gitignore b/.gitignore index 610f89024..5a221b0f8 100755 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ org.eclipse.core.resources.prefs .checkstyle maven-eclipse.xml workspace +.vscode ## Compilation Files ## *.class diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java index 2f1f466c7..9283cf650 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CheckSumHelper.java @@ -28,6 +28,8 @@ import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import org.onap.ccsdk.sli.core.utils.PathValidator; + import javax.xml.bind.DatatypeConverter; public class CheckSumHelper { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PathValidator.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PathValidator.java deleted file mode 100644 index 511dbca7a..000000000 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PathValidator.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.onap.ccsdk.sli.core.sli; - -import java.util.regex.Pattern; - -public class PathValidator { - public static boolean isValidXmlPath(String path) { - Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.xml$"); - return (allowList.matcher(path).matches()); - } - public static boolean isValidPropertiesPath(String path) { - Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.properties$"); - return (allowList.matcher(path).matches()); - } - public static boolean isValidFilePath(String path) { - Pattern allowList = Pattern.compile("[-\\w/\\/]+"); - return (allowList.matcher(path).matches()); - } -} diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java index cb78ac2ec..adec7b27d 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java @@ -35,6 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; +import org.onap.ccsdk.sli.core.utils.PathValidator; /** * @author dt5972 diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index f682bb529..e0eb57304 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -26,6 +26,7 @@ import java.io.FileInputStream; import java.io.InputStream; import java.util.Properties; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.utils.PathValidator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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 index ab6f8bcc8..7d690e745 100644 --- 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 @@ -33,7 +33,7 @@ import java.util.Map; import java.util.TimeZone; import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.PathValidator; +import org.onap.ccsdk.sli.core.utils.PathValidator; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java index 669b3992b..29d35d6ef 100755 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java @@ -62,7 +62,7 @@ public abstract class EnvVarFileResolver implements PropertiesFileResolver { final File fileFromEnvVariable; if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(filename).toFile(); - if(fileFromEnvVariable.exists()) { + if(PathValidator.isValidFilePath(fileFromEnvVariable.getAbsolutePath()) && fileFromEnvVariable.exists()) { return Optional.of(fileFromEnvVariable); } } diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java new file mode 100644 index 000000000..973525019 --- /dev/null +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java @@ -0,0 +1,17 @@ +package org.onap.ccsdk.sli.core.utils; +import java.util.regex.Pattern; + +public class PathValidator { + public static boolean isValidXmlPath(String path) { + Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.xml$"); + return (allowList.matcher(path).matches()); + } + public static boolean isValidPropertiesPath(String path) { + Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.properties$"); + return (allowList.matcher(path).matches()); + } + public static boolean isValidFilePath(String path) { + Pattern allowList = Pattern.compile("[-\\w/\\/]+"); + return (allowList.matcher(path).matches()); + } +} -- cgit 1.2.3-korg From dc2682a99d1ac34ef36730220df1e4e806d48027 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 21 Oct 2020 16:16:06 -0400 Subject: Fix pattern validation Pattern validation incorrectly disallows period as part of file name Change-Id: I3b3692093e16c41c312b326246a5dee83f674ee0 Issue-ID: CCSDK-2918 Signed-off-by: Dan Timoney --- .../main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java | 2 +- .../src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java index 29d35d6ef..518fb30d3 100755 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java @@ -62,7 +62,7 @@ public abstract class EnvVarFileResolver implements PropertiesFileResolver { final File fileFromEnvVariable; if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(filename).toFile(); - if(PathValidator.isValidFilePath(fileFromEnvVariable.getAbsolutePath()) && fileFromEnvVariable.exists()) { + if(PathValidator.isValidPropertiesPath(fileFromEnvVariable.getAbsolutePath()) && fileFromEnvVariable.exists()) { return Optional.of(fileFromEnvVariable); } } diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java index 973525019..08f0fc050 100644 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java @@ -3,15 +3,15 @@ import java.util.regex.Pattern; public class PathValidator { public static boolean isValidXmlPath(String path) { - Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.xml$"); + Pattern allowList = Pattern.compile("[-.\\w/\\/]+\\.xml$"); return (allowList.matcher(path).matches()); } public static boolean isValidPropertiesPath(String path) { - Pattern allowList = Pattern.compile("[-\\w/\\/]+\\.properties$"); + Pattern allowList = Pattern.compile("[-.\\w/\\/]+\\.properties$"); return (allowList.matcher(path).matches()); } public static boolean isValidFilePath(String path) { - Pattern allowList = Pattern.compile("[-\\w/\\/]+"); + Pattern allowList = Pattern.compile("[-.\\w/\\/]+$"); return (allowList.matcher(path).matches()); } } -- cgit 1.2.3-korg From 59135590f84f59007d0210131c609e8257a75150 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 10 Nov 2020 12:53:16 -0500 Subject: Handle properties file reference outside OSGi Update properties file resolves for OSGi to handle ClassNotFoundError exception correctly. Change-Id: I511213e447d07576c9a44654956b207174ed6638 Issue-ID: CCSDK-2976 Signed-off-by: Dan Timoney --- .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 32 +++++++++++++--------- .../utils/common/BundleContextFileResolver.java | 26 ++++++++++-------- 2 files changed, 33 insertions(+), 25 deletions(-) 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 9ae094f1a..c4a4fca47 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 @@ -23,11 +23,16 @@ package org.onap.ccsdk.sli.core.utils; import java.io.File; import java.io.InputStream; import java.net.URL; +import java.nio.file.CopyOption; import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.Optional; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Resolves project properties files relative to the directory identified by the JRE property @@ -39,6 +44,7 @@ public class JREFileResolver implements PropertiesFileResolver { * Key for JRE argument representing the configuration directory */ + private static final Logger LOGGER = LoggerFactory.getLogger(JREFileResolver.class); private final String successMessage; private final Class clazz; @@ -55,18 +61,9 @@ public class JREFileResolver implements PropertiesFileResolver { @Override public Optional resolveFile(final String filename) { - final Bundle bundle; - try { - bundle = FrameworkUtil.getBundle(this.clazz); - } catch (NoClassDefFoundError e) { - return Optional.empty(); - } - - final File dataFile; - - try { + final Bundle bundle = FrameworkUtil.getBundle(this.clazz); if (bundle == null) { return Optional.empty(); } @@ -77,7 +74,7 @@ public class JREFileResolver implements PropertiesFileResolver { } - dataFile = bundle.getDataFile(filename); + final File dataFile = bundle.getDataFile(filename); if(dataFile.exists()) { dataFile.delete(); } @@ -89,8 +86,17 @@ public class JREFileResolver implements PropertiesFileResolver { } return Optional.of(dataFile); - } catch (NoClassDefFoundError e) { - return Optional.empty(); + } catch (final NoClassDefFoundError e) { + LOGGER.info("Getting /{} embedded with {}", filename, clazz.getCanonicalName()); + try (InputStream input = clazz.getResourceAsStream("/"+filename)) { + File propFile = File.createTempFile("tmp", ".properties", null); + LOGGER.info("Copying /{} to {}", filename, propFile.getAbsolutePath()); + Files.copy(input, propFile.toPath(), StandardCopyOption.REPLACE_EXISTING); + return Optional.of(propFile); + } catch (Exception e1) { + LOGGER.info("Caught exception getting {} embedded in jar", filename, e1); + return Optional.empty(); + } } catch(final Exception e) { return Optional.empty(); diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java index 9496d90e2..356009f3f 100755 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java @@ -56,20 +56,22 @@ public class BundleContextFileResolver implements PropertiesFileResolver { */ @Override public Optional resolveFile(final String filename) { - if(FrameworkUtil.getBundle(clazz) == null) { - return Optional.empty(); - } else { - try { - final String pathProperty = FrameworkUtil.getBundle(this.clazz).getBundleContext().getProperty(SDNC_CONFIG_DIR_PROP_KEY); - if(Strings.isNullOrEmpty(pathProperty)) { - return Optional.empty(); - } - final Path dblibPath = Paths.get(pathProperty); - return Optional.of(dblibPath.resolve(filename).toFile()); - } catch(final Exception e) { - LoggerFactory.getLogger(this.getClass()).error("", e); + try { + if (FrameworkUtil.getBundle(clazz) == null) { return Optional.empty(); + } else { + final String pathProperty = FrameworkUtil.getBundle(this.clazz).getBundleContext() + .getProperty(SDNC_CONFIG_DIR_PROP_KEY); + if (Strings.isNullOrEmpty(pathProperty)) { + return Optional.empty(); + } + final Path dblibPath = Paths.get(pathProperty); + return Optional.of(dblibPath.resolve(filename).toFile()); + } + } catch (Exception|NoClassDefFoundError e) { + LoggerFactory.getLogger(this.getClass()).error("", e); + return Optional.empty(); } } -- cgit 1.2.3-korg From 652e1bb38db85b2646229a43935a47f42032a839 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 17 Nov 2020 08:37:28 -0500 Subject: Fix NPE in toJsonString() Fixed SvcLogicContext.toJsonString() to return the empty string () if it cannot find the requested prefix in the service logic context. Change-Id: I5e36864f961b36b6c82a3db8d20483df6686ed15 Issue-ID: CCSDK-2990 Signed-off-by: Dan Timoney --- .../src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index 129c08526..98cf7e05e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -298,7 +298,11 @@ public class SvcLogicContext { String jsonString = this.toJsonString(); JsonObject jsonRoot = (JsonObject) jp.parse(jsonString); JsonObject targetJson = jsonRoot.getAsJsonObject(pfx); - return(targetJson.toString()); + if (targetJson == null) { + return(""); + } else { + return(targetJson.toString()); + } } public String toJsonString() { -- cgit 1.2.3-korg From 72e952ae47506673f7efc893ae447fe55598a952 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 25 Nov 2020 13:50:31 -0500 Subject: Release version 1.1.0 of sli/core Release initial Honolulu version of sli/core and roll version to next snapshot Change-Id: Id65539a7e275c57fce0bc23e88bbc2eaf641cf05 Issue-ID: CCSDK-3002 Signed-off-by: Dan Timoney --- artifacts/pom.xml | 2 +- dblib/installer/pom.xml | 2 +- dblib/pom.xml | 2 +- dblib/provider/pom.xml | 2 +- features/ccsdk-dblib/pom.xml | 2 +- features/ccsdk-filters/pom.xml | 2 +- features/ccsdk-sli-core-all/pom.xml | 2 +- features/ccsdk-sli/pom.xml | 2 +- features/ccsdk-sliPluginUtils/pom.xml | 2 +- features/ccsdk-sliapi/pom.xml | 2 +- features/ccsdk-slicore-utils/pom.xml | 2 +- features/features-sli-core/pom.xml | 2 +- features/installer/pom.xml | 2 +- features/pom.xml | 2 +- filters/installer/pom.xml | 2 +- filters/pom.xml | 2 +- filters/provider/pom.xml | 2 +- pom.xml | 2 +- releases/1.1.0.yaml | 5 +++++ sli/common/pom.xml | 2 +- sli/installer/pom.xml | 2 +- sli/model/pom.xml | 2 +- sli/pom.xml | 2 +- sli/provider-base/pom.xml | 2 +- sli/provider/pom.xml | 2 +- sliPluginUtils/installer/pom.xml | 2 +- sliPluginUtils/pom.xml | 2 +- sliPluginUtils/provider/pom.xml | 2 +- sliapi/installer/pom.xml | 2 +- sliapi/model/pom.xml | 2 +- sliapi/model/swagger/pom.xml | 2 +- sliapi/model/yang/pom.xml | 2 +- sliapi/pom.xml | 2 +- sliapi/provider/pom.xml | 2 +- utils/installer/pom.xml | 2 +- utils/pom.xml | 2 +- utils/provider/pom.xml | 2 +- version.properties | 2 +- 38 files changed, 42 insertions(+), 37 deletions(-) create mode 100644 releases/1.1.0.yaml diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 428414771..9b5f92fd5 100755 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli-core-artifacts - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: sli-core-artifacts diff --git a/dblib/installer/pom.xml b/dblib/installer/pom.xml index e4eb615e6..44779753d 100755 --- a/dblib/installer/pom.xml +++ b/dblib/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core dblib-installer - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/dblib/pom.xml b/dblib/pom.xml index 721738fdc..00f4d5b37 100755 --- a/dblib/pom.xml +++ b/dblib/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core dblib - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: dblib diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml index d886be4f9..c45513794 100755 --- a/dblib/provider/pom.xml +++ b/dblib/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core dblib-provider - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-dblib/pom.xml b/features/ccsdk-dblib/pom.xml index aedf57195..88a840a15 100644 --- a/features/ccsdk-dblib/pom.xml +++ b/features/ccsdk-dblib/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-dblib - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT feature ccsdk-sli-core :: dblib :: ${project.artifactId} diff --git a/features/ccsdk-filters/pom.xml b/features/ccsdk-filters/pom.xml index 4470dd60f..b096df322 100644 --- a/features/ccsdk-filters/pom.xml +++ b/features/ccsdk-filters/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-filters - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT feature ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/features/ccsdk-sli-core-all/pom.xml b/features/ccsdk-sli-core-all/pom.xml index 91285eac7..270ed685f 100644 --- a/features/ccsdk-sli-core-all/pom.xml +++ b/features/ccsdk-sli-core-all/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core-all - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml index 97fe3f060..f6e97ec20 100644 --- a/features/ccsdk-sli/pom.xml +++ b/features/ccsdk-sli/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sli - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT feature ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/features/ccsdk-sliPluginUtils/pom.xml b/features/ccsdk-sliPluginUtils/pom.xml index 71b6e1833..c050dcde5 100644 --- a/features/ccsdk-sliPluginUtils/pom.xml +++ b/features/ccsdk-sliPluginUtils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sliPluginUtils - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT feature ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/features/ccsdk-sliapi/pom.xml b/features/ccsdk-sliapi/pom.xml index 3c1bc92dc..89e7eec3e 100644 --- a/features/ccsdk-sliapi/pom.xml +++ b/features/ccsdk-sliapi/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sliapi - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/features/ccsdk-slicore-utils/pom.xml b/features/ccsdk-slicore-utils/pom.xml index 84b4f84d6..ea8492b75 100644 --- a/features/ccsdk-slicore-utils/pom.xml +++ b/features/ccsdk-slicore-utils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-slicore-utils - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT feature ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/features/features-sli-core/pom.xml b/features/features-sli-core/pom.xml index 5d1ded3de..1459cef01 100644 --- a/features/features-sli-core/pom.xml +++ b/features/features-sli-core/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core features-sli-core - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT feature ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/installer/pom.xml b/features/installer/pom.xml index 2267401b4..d02e5d8d3 100755 --- a/features/installer/pom.xml +++ b/features/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core slicore-features-installer - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: features :: ${project.artifactId} diff --git a/features/pom.xml b/features/pom.xml index 410a884ef..69355a4c7 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core slicore-feature-aggregator - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: features diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml index f839b9bca..fae31a12b 100755 --- a/filters/installer/pom.xml +++ b/filters/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core filters-installer - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/filters/pom.xml b/filters/pom.xml index fe203cf62..8db5d810b 100644 --- a/filters/pom.xml +++ b/filters/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core filters - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: filters diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml index 438d3755e..ea7f9962e 100755 --- a/filters/provider/pom.xml +++ b/filters/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core filters-provider - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: filters :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index d84360f14..16cf608a4 100755 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core ccsdk-sli-core - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core diff --git a/releases/1.1.0.yaml b/releases/1.1.0.yaml new file mode 100644 index 000000000..3c256dd0f --- /dev/null +++ b/releases/1.1.0.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '1.1.0' +project: 'ccsdk-sli-core' +log_dir: 'ccsdk-sli-core-maven-stage-master/304/' diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 586f44b15..201c11bdd 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli-common - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/installer/pom.xml b/sli/installer/pom.xml index 7395ed979..40776bdcf 100755 --- a/sli/installer/pom.xml +++ b/sli/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli-installer - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/model/pom.xml b/sli/model/pom.xml index e89b0f508..0b859e7d2 100755 --- a/sli/model/pom.xml +++ b/sli/model/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli-model - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/pom.xml b/sli/pom.xml index 3889d5d4b..cfb7656d1 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: sli diff --git a/sli/provider-base/pom.xml b/sli/provider-base/pom.xml index 45530aba8..eedce9154 100644 --- a/sli/provider-base/pom.xml +++ b/sli/provider-base/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli-provider-base - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index c9fc044fc..3d5c389c4 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sli-provider - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: sli :: ${project.artifactId} diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml index 7912db0a7..c133cd05b 100755 --- a/sliPluginUtils/installer/pom.xml +++ b/sliPluginUtils/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliPluginUtils-installer - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml index 0a7a97e5f..974e0661c 100755 --- a/sliPluginUtils/pom.xml +++ b/sliPluginUtils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliPluginUtils - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: sliPluginUtils diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml index e8354a3fd..086faf39e 100755 --- a/sliPluginUtils/provider/pom.xml +++ b/sliPluginUtils/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliPluginUtils-provider - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 790653f45..1b3b24a45 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi-installer - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 6f93b61ec..f23ad8da7 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi-model - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/model/swagger/pom.xml b/sliapi/model/swagger/pom.xml index 331bbf0f3..db9ddbc42 100644 --- a/sliapi/model/swagger/pom.xml +++ b/sliapi/model/swagger/pom.xml @@ -10,7 +10,7 @@ org.onap.ccsdk.sli.core sliapi-model-swagger - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT jar ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/yang/pom.xml b/sliapi/model/yang/pom.xml index 266ae7e7d..4d35f025c 100755 --- a/sliapi/model/yang/pom.xml +++ b/sliapi/model/yang/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi-model-yang - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 307a0cc74..2af92cf7e 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index fb0f07f51..79f3d5560 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core sliapi-provider - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml index 36ca72012..829a33051 100755 --- a/utils/installer/pom.xml +++ b/utils/installer/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core utils-installer - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/utils/pom.xml b/utils/pom.xml index 9103ce67f..b8c196cff 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core utils - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT pom ccsdk-sli-core :: utils diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml index 87a679dad..3d4fd856d 100644 --- a/utils/provider/pom.xml +++ b/utils/provider/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.sli.core utils-provider - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT bundle ccsdk-sli-core :: utils :: ${project.artifactId} diff --git a/version.properties b/version.properties index 3e9715876..ca85875b1 100644 --- a/version.properties +++ b/version.properties @@ -6,7 +6,7 @@ release_name=1 sprint_number=1 -feature_revision=0 +feature_revision=1 base_version=${release_name}.${sprint_number}.${feature_revision} -- cgit 1.2.3-korg